libvirt: fix wrong driver name for vhostuser interface
This is currently ignored for (qemu/vhost) option when we have a vif_type of vhostuser, which means we're setting "vhost". libvirt is doing bad job at accepting this value. The fix is setting the driver name to None when vif is vhostuser. Signed-off-by: Sahid Orentino Ferdjaoui <sahid.ferdjaoui@redhat.com> Change-Id: Ic6f1260378e233634a9e5b53f82d7f59461a474f
This commit is contained in:
parent
c6db1fc78a
commit
8ea168d641
@ -1933,6 +1933,32 @@ class LibvirtConfigGuestInterfaceTest(LibvirtConfigBaseTest):
|
||||
obj2.parse_str(xml)
|
||||
self.assertXmlEqual(xml, obj2.to_xml())
|
||||
|
||||
def test_config_vhostuser_ensure_driver_never_set(self):
|
||||
obj = config.LibvirtConfigGuestInterface()
|
||||
# Even if 'driver_name' attribute is set we should never set
|
||||
# it in the domain XML for vhostuser interface.
|
||||
obj.driver_name = "vhost-user"
|
||||
|
||||
obj.net_type = "vhostuser"
|
||||
obj.vhostuser_type = "unix"
|
||||
obj.vhostuser_mode = "server"
|
||||
obj.mac_addr = "DE:AD:BE:EF:CA:FE"
|
||||
obj.vhostuser_path = "/vhost-user/test.sock"
|
||||
obj.model = "virtio"
|
||||
xml = obj.to_xml()
|
||||
self.assertXmlEqual(xml, """
|
||||
<interface type="vhostuser">
|
||||
<mac address="DE:AD:BE:EF:CA:FE"/>
|
||||
<model type="virtio"/>
|
||||
<source type="unix" mode="server" path="/vhost-user/test.sock"/>
|
||||
</interface>""")
|
||||
|
||||
# parse the xml from the first object into a new object and make sure
|
||||
# they are the same
|
||||
obj2 = config.LibvirtConfigGuestInterface()
|
||||
obj2.parse_str(xml)
|
||||
self.assertXmlEqual(xml, obj2.to_xml())
|
||||
|
||||
def test_config_interface_address(self):
|
||||
xml = """
|
||||
<interface type='network'>
|
||||
|
@ -672,7 +672,7 @@ class LibvirtVifTestCase(test.NoDBTestCase):
|
||||
d._set_config_VIFVHostUser(self.instance, self.os_vif_vhostuser,
|
||||
conf, hostimpl)
|
||||
self.assertEqual(4, conf.vhost_queues)
|
||||
self.assertEqual('vhost', conf.driver_name)
|
||||
self.assertIsNone(conf.driver_name)
|
||||
has_min_version.assert_called_once_with(MIN_LIBVIRT_VHOSTUSER_MQ)
|
||||
|
||||
has_min_version.return_value = False
|
||||
|
@ -1339,11 +1339,21 @@ class LibvirtConfigGuestInterface(LibvirtConfigGuestDevice):
|
||||
if self.model:
|
||||
dev.append(etree.Element("model", type=self.model))
|
||||
|
||||
drv_elem = None
|
||||
if self.driver_name:
|
||||
drv_elem = etree.Element("driver", name=self.driver_name)
|
||||
if self.net_type == "vhostuser":
|
||||
# For vhostuser interface we should not set the driver
|
||||
# name.
|
||||
drv_elem = etree.Element("driver")
|
||||
if drv_elem is not None:
|
||||
if self.vhost_queues is not None:
|
||||
drv_elem.set('queues', str(self.vhost_queues))
|
||||
dev.append(drv_elem)
|
||||
|
||||
if drv_elem.get('name') or drv_elem.get('queues'):
|
||||
# Append the driver element into the dom only if name
|
||||
# or queues attributes are set.
|
||||
dev.append(drv_elem)
|
||||
|
||||
if self.net_type == "ethernet":
|
||||
if self.script is not None:
|
||||
|
@ -431,13 +431,18 @@ class LibvirtGenericVIFDriver(object):
|
||||
conf = self.get_base_config(instance, vif['address'], image_meta,
|
||||
inst_type, virt_type, vif['vnic_type'],
|
||||
host)
|
||||
# TODO(sahid): We should never configure a driver backend for
|
||||
# vhostuser interface. Specifically override driver to use
|
||||
# None. This can be removed when get_base_config will be fixed
|
||||
# and rewrite to set the correct backend.
|
||||
conf.driver_name = None
|
||||
|
||||
mode, sock_path = self._get_vhostuser_settings(vif)
|
||||
designer.set_vif_host_backend_vhostuser_config(conf, mode, sock_path)
|
||||
# (vladikr) Not setting up driver and queues for vhostuser
|
||||
# as queues are not supported in Libvirt until version 1.2.17
|
||||
if not host.has_min_version(MIN_LIBVIRT_VHOSTUSER_MQ):
|
||||
LOG.debug('Queues are not a vhostuser supported feature.')
|
||||
conf.driver_name = None
|
||||
conf.vhost_queues = None
|
||||
|
||||
return conf
|
||||
@ -474,11 +479,16 @@ class LibvirtGenericVIFDriver(object):
|
||||
self._set_config_VIFPortProfile(instance, vif, conf)
|
||||
|
||||
def _set_config_VIFVHostUser(self, instance, vif, conf, host=None):
|
||||
# TODO(sahid): We should never configure a driver backend for
|
||||
# vhostuser interface. Specifically override driver to use
|
||||
# None. This can be removed when get_base_config will be fixed
|
||||
# and rewrite to set the correct backend.
|
||||
conf.driver_name = None
|
||||
|
||||
designer.set_vif_host_backend_vhostuser_config(
|
||||
conf, vif.mode, vif.path)
|
||||
if not host.has_min_version(MIN_LIBVIRT_VHOSTUSER_MQ):
|
||||
LOG.debug('Queues are not a vhostuser supported feature.')
|
||||
conf.driver_name = None
|
||||
conf.vhost_queues = None
|
||||
|
||||
def _set_config_VIFHostDevice(self, instance, vif, conf, host=None):
|
||||
|
Loading…
x
Reference in New Issue
Block a user