diff --git a/nova/tests/unit/virt/libvirt/test_guest.py b/nova/tests/unit/virt/libvirt/test_guest.py index 418092eee236..58cce0bd1580 100644 --- a/nova/tests/unit/virt/libvirt/test_guest.py +++ b/nova/tests/unit/virt/libvirt/test_guest.py @@ -549,6 +549,34 @@ class GuestTestCase(test.NoDBTestCase): self.guest.get_interface_by_cfg(cfg)) self.assertIsNone(self.guest.get_interface_by_cfg(None)) + def test_get_interface_by_cfg_vhostuser(self): + self.domain.XMLDesc.return_value = """ + + + + + + + +
+ + +""" + cfg = vconfig.LibvirtConfigGuestInterface() + cfg.parse_str(""" + + + + +
+ """) + self.assertIsNotNone( + self.guest.get_interface_by_cfg(cfg)) + self.assertIsNone(self.guest.get_interface_by_cfg(None)) + def test_get_info(self): self.domain.info.return_value = (1, 2, 3, 4, 5) self.domain.ID.return_value = 6 diff --git a/nova/virt/libvirt/guest.py b/nova/virt/libvirt/guest.py index b4ea4a4ef27f..3d242e7eb1dc 100644 --- a/nova/virt/libvirt/guest.py +++ b/nova/virt/libvirt/guest.py @@ -241,10 +241,13 @@ class Guest(object): # NOTE(leehom) LibvirtConfigGuestInterface get from domain and # LibvirtConfigGuestInterface generated by # nova.virt.libvirt.vif.get_config must be identical. + # NOTE(arches) Skip checking target_dev for vhostuser + # vif type; target_dev is not a valid value for vhostuser. if (interface.mac_addr == cfg.mac_addr and interface.net_type == cfg.net_type and interface.source_dev == cfg.source_dev and - interface.target_dev == cfg.target_dev and + (cfg.net_type == 'vhostuser' or + interface.target_dev == cfg.target_dev) and interface.vhostuser_path == cfg.vhostuser_path): return interface