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 a19c38a6ab)
This commit is contained in:
arches 2018-12-27 17:25:48 +02:00 committed by Matt Riedemann
parent 6e1120ae30
commit 1ac56a4038
2 changed files with 32 additions and 1 deletions

View File

@ -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 = """<domain>
<devices>
<interface type="vhostuser">
<mac address='fa:16:3e:55:3e:e4'/>
<source type='unix' path='/var/run/openvswitch/vhued80c655-4e'
mode='server'/>
<target dev='vhued80c655-4e'/>
<model type='virtio'/>
<alias name='net0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03'
function='0x0'/>
</interface>
</devices>
</domain>"""
cfg = vconfig.LibvirtConfigGuestInterface()
cfg.parse_str("""<interface type="vhostuser">
<mac address='fa:16:3e:55:3e:e4'/>
<model type="virtio"/>
<source type='unix' path='/var/run/openvswitch/vhued80c655-4e'
mode='server'/>
<alias name='net0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>""")
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

View File

@ -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