[PATCHv2 2/3] conf: introduce 'poll_us' attribute for domain interface

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

 



From: Sahid Orentino Ferdjaoui <sahid.ferdjaoui@xxxxxxxxxx>

In this commit we introduce 'poll_us' attribute which will be passed
then to the QEMU command line to enable support of busy polling. This
commit also take into account that attribute to generate the XML.

Signed-off-by: Sahid Orentino Ferdjaoui <sahid.ferdjaoui@xxxxxxxxxx>
---

 Addressed comments:
 - Moved the RNG and doc from patch3 to that one
 - Added an xml2xml test
 - Renamed var pollus to poll_us

 docs/formatdomain.html.in                          | 12 +++++++-
 docs/schemas/domaincommon.rng                      |  5 ++++
 src/conf/domain_conf.c                             | 16 +++++++++++
 src/conf/domain_conf.h                             |  1 +
 .../qemuxml2argv-net-virtio-poll-us.xml            | 23 +++++++++++++++
 .../qemuxml2xmlout-net-virtio-poll-us.xml          | 33 ++++++++++++++++++++++
 tests/qemuxml2xmltest.c                            |  1 +
 7 files changed, 90 insertions(+), 1 deletion(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-virtio-poll-us.xml
 create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-net-virtio-poll-us.xml

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index c12efcf..c0516e3 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -5071,7 +5071,7 @@ qemu-kvm -net nic,model=? /dev/null
     &lt;source network='default'/&gt;
     &lt;target dev='vnet1'/&gt;
     &lt;model type='virtio'/&gt;
-    <b>&lt;driver name='vhost' txmode='iothread' ioeventfd='on' event_idx='off' queues='5' rx_queue_size='256'&gt;
+    <b>&lt;driver name='vhost' txmode='iothread' ioeventfd='on' event_idx='off' queues='5' rx_queue_size='256' poll_us='50'&gt;
       &lt;host csum='off' gso='off' tso4='off' tso6='off' ecn='off' ufo='off' mrg_rxbuf='off'/&gt;
       &lt;guest csum='off' tso4='off' tso6='off' ecn='off' ufo='off'/&gt;
     &lt;/driver&gt;
@@ -5201,6 +5201,16 @@ qemu-kvm -net nic,model=? /dev/null
         <b>In general you should leave this option alone, unless you
         are very certain you know what you are doing.</b>
       </dd>
+      <dd>
+        The optional <code>poll_us</code> attribute configure the
+        maximum number of microseconds that could be spent on busy
+        polling. It improves the performance, but requires more
+        CPU. This option is only available with vhost backend driver.
+        <span class="since">Since 2.7.0 (QEMU and KVM only)</span><br/><br/>
+
+        <b>In general you should leave this option alone, unless you
+        are very certain you know what you are doing.</b>
+      </dd>
       <dt>virtio options</dt>
       <dd>
         For virtio interfaces,
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index fc1a40f..0cd2dc0 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2723,6 +2723,11 @@
               <optional>
                 <ref name="event_idx"/>
               </optional>
+              <optional>
+                <attribute name='poll_us'>
+                  <ref name='positiveInteger'/>
+                </attribute>
+              </optional>
             </group>
           </choice>
           <ref name="virtioOptions"/>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 3feeccb..51735dc 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9920,6 +9920,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
     char *event_idx = NULL;
     char *queues = NULL;
     char *rx_queue_size = NULL;
+    char *poll_us = NULL;
     char *str = NULL;
     char *filter = NULL;
     char *internal = NULL;
@@ -10093,6 +10094,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
                 event_idx = virXMLPropString(cur, "event_idx");
                 queues = virXMLPropString(cur, "queues");
                 rx_queue_size = virXMLPropString(cur, "rx_queue_size");
+                poll_us = virXMLPropString(cur, "poll_us");
             } else if (xmlStrEqual(cur->name, BAD_CAST "filterref")) {
                 if (filter) {
                     virReportError(VIR_ERR_XML_ERROR, "%s",
@@ -10490,6 +10492,17 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
             }
             def->driver.virtio.rx_queue_size = q;
         }
+        if (poll_us) {
+            unsigned int us;
+            if (virStrToLong_uip(poll_us, NULL, 10, &us) < 0) {
+                virReportError(VIR_ERR_XML_DETAIL,
+                               _("'poll_us' attribute must be positive: %s"),
+                               poll_us);
+                goto error;
+            }
+            if (us > 1)
+                def->driver.virtio.poll_us = us;
+        }
         if ((str = virXPathString("string(./driver/host/@csum)", ctxt))) {
             if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
@@ -10687,6 +10700,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
     VIR_FREE(event_idx);
     VIR_FREE(queues);
     VIR_FREE(rx_queue_size);
+    VIR_FREE(poll_us);
     VIR_FREE(str);
     VIR_FREE(filter);
     VIR_FREE(type);
@@ -22558,6 +22572,8 @@ virDomainVirtioNetDriverFormat(char **outstr,
     if (def->driver.virtio.rx_queue_size)
         virBufferAsprintf(&buf, " rx_queue_size='%u'",
                           def->driver.virtio.rx_queue_size);
+    if (def->driver.virtio.poll_us)
+        virBufferAsprintf(&buf, " poll_us='%u'", def->driver.virtio.poll_us);
 
     virDomainVirtioOptionsFormat(&buf, def->virtio);
 
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index af15ee8..ae3616b 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -969,6 +969,7 @@ struct _virDomainNetDef {
             virTristateSwitch event_idx;
             unsigned int queues; /* Multiqueue virtio-net */
             unsigned int rx_queue_size;
+            unsigned int poll_us; /* busy polling for tap */
             struct {
                 virTristateSwitch csum;
                 virTristateSwitch gso;
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-poll-us.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-poll-us.xml
new file mode 100644
index 0000000..46ef7d6
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-poll-us.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/qemuxml2xmloutdata/qemuxml2xmlout-net-virtio-poll-us.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-virtio-poll-us.xml
new file mode 100644
index 0000000..7f81d15
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-virtio-poll-us.xml
@@ -0,0 +1,33 @@
+<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>
+    <controller type='usb' index='0'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+    </controller>
+    <controller type='pci' index='0' model='pci-root'/>
+    <interface type='ethernet'>
+      <mac address='52:54:00:23:bc:ba'/>
+      <model type='virtio'/>
+      <driver name='vhost' poll_us='50'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+    </interface>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <memballoon model='virtio'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+    </memballoon>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 5e4b1d1..7abba30 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -538,6 +538,7 @@ mymain(void)
     DO_TEST("net-eth-hostip", NONE);
     DO_TEST("net-virtio-network-portgroup", NONE);
     DO_TEST("net-virtio-rxqueuesize", NONE);
+    DO_TEST("net-virtio-poll-us", NONE);
     DO_TEST("net-hostdev", NONE);
     DO_TEST("net-hostdev-vfio", NONE);
     DO_TEST("net-midonet", NONE);
-- 
2.9.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux