[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCHv2 3/3] This patch finalizes support of 'poll_us' attribute as an option of the NIC driver-specific element, the commit also takes care of hotplug.



From: Sahid Orentino Ferdjaoui <sahid ferdjaoui redhat com>

<devices>
  <interface type='ethernet'>
    <mac address='52:54:00:23:bc:ba'/>
      <model type='virtio'/>
    <driver name="vhost" poll_us='50'/>
  </interface>
</devices>

That option is supported for all networks which are using a tap
device.

To be used the backend should be specificly set to use vhost.

Signed-off-by: Sahid Orentino Ferdjaoui <sahid ferdjaoui redhat com>
---

 Addressed comments:
 - Added comment to explain why we should explicitly
   set the driver name.

 src/qemu/qemu_command.c                            | 28 ++++++++++++++++++++++
 src/qemu/qemu_hotplug.c                            | 12 ++++++++++
 .../qemuxml2argv-net-virtio-netdev-pollus-fail.xml | 23 ++++++++++++++++++
 ...xml2argv-net-virtio-netdev-pollus-qemu-fail.xml | 23 ++++++++++++++++++
 .../qemuxml2argv-net-virtio-netdev-pollus.args     | 25 +++++++++++++++++++
 .../qemuxml2argv-net-virtio-netdev-pollus.xml      | 23 ++++++++++++++++++
 tests/qemuxml2argvtest.c                           |  9 +++++++
 7 files changed, 143 insertions(+)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-virtio-netdev-pollus-fail.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-virtio-netdev-pollus-qemu-fail.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-virtio-netdev-pollus.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-virtio-netdev-pollus.xml

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 6ac26af..1fc2a88 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3899,6 +3899,9 @@ qemuBuildHostNetStr(virDomainNetDefPtr net,
         }
         if (net->tune.sndbuf_specified)
             virBufferAsprintf(&buf, "sndbuf=%lu,", net->tune.sndbuf);
+        if (net->driver.virtio.poll_us)
+            virBufferAsprintf(&buf, "poll-us=%u,",
+                              net->driver.virtio.poll_us);
     }
 
     virObjectUnref(cfg);
@@ -8330,6 +8333,31 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver,
         return -1;
     }
 
+    if (net->driver.virtio.poll_us > 0) {
+        if (net->driver.virtio.name != VIR_DOMAIN_NET_BACKEND_TYPE_VHOST) {
+            /* virtio.name is set only if driver is specificly
+             * indicated. Since 'poll_us' option is only available for
+             * vhost-net we don't want libvirt to fallback to QEMU if
+             * not available. That's why we request users to set the
+             * driver. */
+            virReportError(
+                VIR_ERR_CONFIG_UNSUPPORTED,
+                _("Busy polling (poll_us) is only supported with vhost "
+                  "backend driver"));
+            return -1;
+        }
+        /* Nothing besides TAP devices supports busy polling. */
+        if (!(actualType == VIR_DOMAIN_NET_TYPE_NETWORK ||
+              actualType == VIR_DOMAIN_NET_TYPE_BRIDGE ||
+              actualType == VIR_DOMAIN_NET_TYPE_DIRECT ||
+              actualType == VIR_DOMAIN_NET_TYPE_ETHERNET)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("Busy polling is not supported for: %s"),
+                           virDomainNetTypeToString(actualType));
+            return -1;
+        }
+    }
+
     /* and only TAP devices support nwfilter rules */
     if (net->filter &&
         !(actualType == VIR_DOMAIN_NET_TYPE_NETWORK ||
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 4bc4972..78f61e7 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1015,6 +1015,18 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
         return -1;
     }
 
+    /* and nothing besides TAP devices supports busy polling. */
+    if (net->driver.virtio.poll_us > 0 &&
+        !(actualType == VIR_DOMAIN_NET_TYPE_NETWORK ||
+          actualType == VIR_DOMAIN_NET_TYPE_BRIDGE ||
+          actualType == VIR_DOMAIN_NET_TYPE_DIRECT ||
+          actualType == VIR_DOMAIN_NET_TYPE_ETHERNET)) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                       _("Busy polling is not supported for: %s"),
+                       virDomainNetTypeToString(actualType));
+        return -1;
+    }
+
     /* and only TAP devices support nwfilter rules */
     if (net->filter &&
         !(actualType == VIR_DOMAIN_NET_TYPE_NETWORK ||
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-netdev-pollus-fail.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-netdev-pollus-fail.xml
new file mode 100644
index 0000000..3b664b9
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-netdev-pollus-fail.xml
@@ -0,0 +1,23 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-i686</emulator>
+    <interface type='ethernet'>
+      <mac address='52:54:00:23:bc:ba'/>
+      <model type='virtio'/>
+      <driver poll_us='50'/>
+    </interface>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-netdev-pollus-qemu-fail.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-netdev-pollus-qemu-fail.xml
new file mode 100644
index 0000000..18999c3
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-netdev-pollus-qemu-fail.xml
@@ -0,0 +1,23 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-i686</emulator>
+    <interface type='ethernet'>
+      <mac address='52:54:00:23:bc:ba'/>
+      <model type='virtio'/>
+      <driver name="qemu" poll_us='50'/>
+    </interface>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-netdev-pollus.args b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-netdev-pollus.args
new file mode 100644
index 0000000..15e26fb
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-netdev-pollus.args
@@ -0,0 +1,25 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-i686 \
+-name QEMUGuest1 \
+-S \
+-M pc \
+-m 214 \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-nographic \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
+server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=readline \
+-no-acpi \
+-boot c \
+-usb \
+-netdev tap,fd=3,id=hostnet0,poll-us=50 \
+-device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:23:bc:ba,bus=pci.0,\
+addr=0x3 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-netdev-pollus.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-netdev-pollus.xml
new file mode 100644
index 0000000..46ef7d6
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-netdev-pollus.xml
@@ -0,0 +1,23 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-i686</emulator>
+    <interface type='ethernet'>
+      <mac address='52:54:00:23:bc:ba'/>
+      <model type='virtio'/>
+      <driver name="vhost" poll_us='50'/>
+    </interface>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index b95ea46..8311d9a 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1156,6 +1156,15 @@ mymain(void)
             QEMU_CAPS_NODEFCONFIG);
     DO_TEST("net-virtio-netdev",
             QEMU_CAPS_NETDEV, QEMU_CAPS_NODEFCONFIG);
+    DO_TEST("net-virtio-netdev-pollus",
+            QEMU_CAPS_NETDEV,
+            QEMU_CAPS_NETDEV_POLL_US);
+    DO_TEST_FAILURE("net-virtio-netdev-pollus-fail",
+                    QEMU_CAPS_NETDEV,
+                    QEMU_CAPS_NETDEV_POLL_US);
+    DO_TEST_FAILURE("net-virtio-netdev-pollus-qemu-fail",
+                    QEMU_CAPS_NETDEV,
+                    QEMU_CAPS_NETDEV_POLL_US);
     DO_TEST("net-virtio-s390",
             QEMU_CAPS_VIRTIO_S390);
     DO_TEST("net-virtio-ccw",
-- 
2.9.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]