From 1ac56a403876fa109385ef6281c525335a613b34 Mon Sep 17 00:00:00 2001 From: arches Date: Thu, 27 Dec 2018 17:25:48 +0200 Subject: [PATCH] Skip checking of target_dev for vhostuser Nova skips detaching of ovs dpdk interfaces thinking that it's already detached because get_interface_by_cfg() return no inteface. This is due to _set_config_VIFVHostUser() not setting target_dev in configuration while LibvirtConfigGuestInterface sets target_dev if tag "target" is found in the interface. As target_dev is not a valid value for vhostuser interface, it will not be checked for vhostuser type. Change-Id: Iaf185b98c236df47e44cda0732ee0aed1fd6323d Closes-Bug: #1807340 (cherry picked from commit a19c38a6ab13cdf2509a1f9f9d39c7f0a70ba121) --- nova/tests/unit/virt/libvirt/test_guest.py | 28 ++++++++++++++++++++++ nova/virt/libvirt/guest.py | 5 +++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/nova/tests/unit/virt/libvirt/test_guest.py b/nova/tests/unit/virt/libvirt/test_guest.py index 4943b2dfa79d..2fb0adb707e1 100644 --- a/nova/tests/unit/virt/libvirt/test_guest.py +++ b/nova/tests/unit/virt/libvirt/test_guest.py @@ -547,6 +547,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 35d059c37271..ac1a35846cc4 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