diff --git a/nova/tests/unit/virt/libvirt/test_designer.py b/nova/tests/unit/virt/libvirt/test_designer.py index bb5b8e9f72..14a896eb17 100644 --- a/nova/tests/unit/virt/libvirt/test_designer.py +++ b/nova/tests/unit/virt/libvirt/test_designer.py @@ -207,6 +207,19 @@ class DesignerTestCase(test.NoDBTestCase): self.assertEqual(512, conf.vhost_rx_queue_size) self.assertIsNone(conf.vhost_tx_queue_size) + def test_set_vif_host_backend_vhostuser_config_tapname(self): + conf = config.LibvirtConfigGuestInterface() + designer.set_vif_host_backend_vhostuser_config(conf, 'fake-mode', + 'fake-path', None, None, + 'fake-tap') + self.assertEqual('vhostuser', conf.net_type) + self.assertEqual('unix', conf.vhostuser_type) + self.assertEqual('fake-mode', conf.vhostuser_mode) + self.assertEqual('fake-path', conf.vhostuser_path) + self.assertIsNone(conf.vhost_rx_queue_size) + self.assertIsNone(conf.vhost_tx_queue_size) + self.assertEqual('fake-tap', conf.target_dev) + def test_set_vif_mtu_config(self): conf = config.LibvirtConfigGuestInterface() designer.set_vif_mtu_config(conf, 9000) diff --git a/nova/tests/unit/virt/libvirt/test_vif.py b/nova/tests/unit/virt/libvirt/test_vif.py index 1bfc532da6..b77d704bab 100644 --- a/nova/tests/unit/virt/libvirt/test_vif.py +++ b/nova/tests/unit/virt/libvirt/test_vif.py @@ -556,6 +556,12 @@ class LibvirtVifTestCase(test.NoDBTestCase): pci_slot_want = vif['profile']['pci_slot'] self.assertEqual(pci_slot, pci_slot_want) + def _assertQueueSizeEquals(self, node, rx_want, tx_want): + rx_queue_size = node.find("driver").get("rx_queue_size") + tx_queue_size = node.find("driver").get("tx_queue_size") + self.assertEqual(rx_queue_size, rx_want) + self.assertEqual(tx_queue_size, tx_want) + def _assertXmlEqual(self, expectedXmlstr, actualXmlstr): if not isinstance(actualXmlstr, six.string_types): actualXmlstr = etree.tostring(actualXmlstr, encoding='unicode', @@ -1296,24 +1302,8 @@ class LibvirtVifTestCase(test.NoDBTestCase): self.flags(tx_queue_size=1024, group='libvirt') d = vif.LibvirtGenericVIFDriver() xml = self._get_instance_xml(d, self.vif_vhostuser) - self._assertXmlEqual(""" - - fake-uuid - fake-name - 102400 - 4 - - None - - - - - - - - - - """, xml) + node = self._get_node(xml) + self._assertQueueSizeEquals(node, "512", "1024") def test_vhostuser_driver_no_path(self): d = vif.LibvirtGenericVIFDriver() @@ -1554,6 +1544,7 @@ class LibvirtVifTestCase(test.NoDBTestCase): + """ self._test_config_os_vif(os_vif_type, vif_type, expected_xml) @@ -1591,6 +1582,7 @@ class LibvirtVifTestCase(test.NoDBTestCase): + """ self._test_config_os_vif(os_vif_type, vif_type, expected_xml) diff --git a/nova/virt/libvirt/designer.py b/nova/virt/libvirt/designer.py index c18d104e6b..3677ed5280 100644 --- a/nova/virt/libvirt/designer.py +++ b/nova/virt/libvirt/designer.py @@ -133,7 +133,7 @@ def set_vif_host_backend_direct_config(conf, devname, mode="passthrough"): def set_vif_host_backend_vhostuser_config(conf, mode, path, rx_queue_size, - tx_queue_size): + tx_queue_size, tapname=None): """Populate a LibvirtConfigGuestInterface instance with host backend details for vhostuser socket. @@ -147,6 +147,8 @@ def set_vif_host_backend_vhostuser_config(conf, mode, path, rx_queue_size, conf.vhost_rx_queue_size = rx_queue_size if tx_queue_size: conf.vhost_tx_queue_size = tx_queue_size + if tapname: + conf.target_dev = tapname def set_vif_mtu_config(conf, mtu): diff --git a/nova/virt/libvirt/vif.py b/nova/virt/libvirt/vif.py index 52ec500bf5..505c0d51f3 100644 --- a/nova/virt/libvirt/vif.py +++ b/nova/virt/libvirt/vif.py @@ -462,7 +462,7 @@ class LibvirtGenericVIFDriver(object): designer.set_vif_host_backend_vhostuser_config( conf, vif.mode, vif.path, CONF.libvirt.rx_queue_size, - CONF.libvirt.tx_queue_size) + CONF.libvirt.tx_queue_size, vif.vif_name) def _set_config_VIFHostDevice(self, instance, vif, conf): if vif.dev_type == osv_fields.VIFHostDeviceDevType.ETHERNET: