Merge "Fix virsh domifstat to get vhostuser vif statistics"

This commit is contained in:
Zuul
2020-10-31 06:31:40 +00:00
committed by Gerrit Code Review
4 changed files with 27 additions and 20 deletions
@@ -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)
+10 -18
View File
@@ -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("""
<domain type="qemu">
<uuid>fake-uuid</uuid>
<name>fake-name</name>
<memory>102400</memory>
<vcpu>4</vcpu>
<os>
<type>None</type>
</os>
<devices>
<interface type="vhostuser">
<mac address="ca:fe:de:ad:be:ef"/>
<model type="virtio"/>
<driver rx_queue_size="512" tx_queue_size="1024"/>
<source mode="client" path="/tmp/vif-xxx-yyy-zzz" type="unix"/>
</interface>
</devices>
</domain>""", 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):
<model type="virtio"/>
<source mode="client"
path="/var/run/openvswitch/vhudc065497-3c" type="unix"/>
<target dev="vhudc065497-3c"/>
</interface>"""
self._test_config_os_vif(os_vif_type, vif_type, expected_xml)
@@ -1591,6 +1582,7 @@ class LibvirtVifTestCase(test.NoDBTestCase):
<model type="virtio"/>
<source mode="client"
path="/var/run/openvswitch/vhudc065497-3c" type="unix"/>
<target dev="nicdc065497-3c"/>
</interface>"""
self._test_config_os_vif(os_vif_type, vif_type, expected_xml)
+3 -1
View File
@@ -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):
+1 -1
View File
@@ -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: