render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
7a3408
From 77f59c5205af71af094a1a87b2502a8e286369ef Mon Sep 17 00:00:00 2001
7a3408
Message-Id: <77f59c5205af71af094a1a87b2502a8e286369ef@dist-git>
7a3408
From: Martin Kletzander <mkletzan@redhat.com>
7a3408
Date: Thu, 3 Sep 2015 15:55:43 +0200
7a3408
Subject: [PATCH] conf: Add ioeventfd option for controllers
7a3408
7a3408
https://bugzilla.redhat.com/show_bug.cgi?id=1150484
7a3408
7a3408
This will be used with a virtio-scsi controller later on.
7a3408
7a3408
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7a3408
(cherry picked from commit 35eecddee3fd822285a4ac619ac972f3714e8edc)
7a3408
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7a3408
7a3408
 Conflicts:
7a3408
	src/conf/domain_conf.c -- controller (sub)models
7a3408
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7a3408
---
7a3408
 docs/formatdomain.html.in                          |  8 ++++++
7a3408
 docs/schemas/domaincommon.rng                      |  3 +++
7a3408
 src/conf/domain_conf.c                             | 20 +++++++++++++--
7a3408
 src/conf/domain_conf.h                             |  1 +
7a3408
 .../qemuxml2argv-disk-virtio-scsi-ioeventfd.xml    | 29 ++++++++++++++++++++++
7a3408
 tests/qemuxml2xmltest.c                            |  1 +
7a3408
 6 files changed, 60 insertions(+), 2 deletions(-)
7a3408
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-ioeventfd.xml
7a3408
7a3408
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
7a3408
index cb11b1f..0bf5845 100644
7a3408
--- a/docs/formatdomain.html.in
7a3408
+++ b/docs/formatdomain.html.in
7a3408
@@ -3000,6 +3000,14 @@
7a3408
         a sector is 512 bytes.
7a3408
         Since 1.2.7 (QEMU and KVM only)
7a3408
       
7a3408
+      
ioeventfd
7a3408
+      
7a3408
+        The optional ioeventfd attribute specifies
7a3408
+        whether the controller should use
7a3408
+        
7a3408
+        I/O asynchronous handling or not.  Accepted values are
7a3408
+        "on" and "off". Since 1.2.18
7a3408
+      
7a3408
     
7a3408
     

7a3408
       USB companion controllers have an optional
7a3408
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
7a3408
index 1120003..1739015 100644
7a3408
--- a/docs/schemas/domaincommon.rng
7a3408
+++ b/docs/schemas/domaincommon.rng
7a3408
@@ -1790,6 +1790,9 @@
7a3408
                 <ref name="unsignedInt"/>
7a3408
               </attribute>
7a3408
             </optional>
7a3408
+            <optional>
7a3408
+              <ref name="ioeventfd"/>
7a3408
+            </optional>
7a3408
           </element>
7a3408
         </optional>
7a3408
       </interleave>
7a3408
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
7a3408
index b4503c3..15d3a5e 100644
7a3408
--- a/src/conf/domain_conf.c
7a3408
+++ b/src/conf/domain_conf.c
7a3408
@@ -7734,6 +7734,7 @@ virDomainControllerDefParseXML(xmlNodePtr node,
7a3408
     char *queues = NULL;
7a3408
     char *cmd_per_lun = NULL;
7a3408
     char *max_sectors = NULL;
7a3408
+    char *ioeventfd = NULL;
7a3408
     xmlNodePtr saved = ctxt->node;
7a3408
     int rc;
7a3408
 
7a3408
@@ -7779,6 +7780,7 @@ virDomainControllerDefParseXML(xmlNodePtr node,
7a3408
                 queues = virXMLPropString(cur, "queues");
7a3408
                 cmd_per_lun = virXMLPropString(cur, "cmd_per_lun");
7a3408
                 max_sectors = virXMLPropString(cur, "max_sectors");
7a3408
+                ioeventfd = virXMLPropString(cur, "ioeventfd");
7a3408
             }
7a3408
         }
7a3408
         cur = cur->next;
7a3408
@@ -7802,6 +7804,13 @@ virDomainControllerDefParseXML(xmlNodePtr node,
7a3408
         goto error;
7a3408
     }
7a3408
 
7a3408
+    if (ioeventfd &&
7a3408
+        (def->ioeventfd = virTristateSwitchTypeFromString(ioeventfd)) < 0) {
7a3408
+        virReportError(VIR_ERR_XML_ERROR,
7a3408
+                       _("Malformed 'ioeventfd' value %s'"), max_sectors);
7a3408
+        goto error;
7a3408
+    }
7a3408
+
7a3408
     if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_USB &&
7a3408
         def->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE) {
7a3408
         VIR_DEBUG("Ignoring device address for none model usb controller");
7a3408
@@ -7915,6 +7924,7 @@ virDomainControllerDefParseXML(xmlNodePtr node,
7a3408
     VIR_FREE(queues);
7a3408
     VIR_FREE(cmd_per_lun);
7a3408
     VIR_FREE(max_sectors);
7a3408
+    VIR_FREE(ioeventfd);
7a3408
 
7a3408
     return def;
7a3408
 
7a3408
@@ -18980,12 +18990,13 @@ virDomainControllerDefFormat(virBufferPtr buf,
7a3408
         break;
7a3408
     }
7a3408
 
7a3408
-    if (def->queues || def->cmd_per_lun || def->max_sectors ||
7a3408
+    if (def->queues || def->cmd_per_lun || def->max_sectors || def->ioeventfd ||
7a3408
         virDomainDeviceInfoNeedsFormat(&def->info, flags) || pcihole64) {
7a3408
         virBufferAddLit(buf, ">\n");
7a3408
         virBufferAdjustIndent(buf, 2);
7a3408
 
7a3408
-        if (def->queues || def->cmd_per_lun || def->max_sectors) {
7a3408
+        if (def->queues || def->cmd_per_lun ||
7a3408
+            def->max_sectors || def->ioeventfd) {
7a3408
             virBufferAddLit(buf, "
7a3408
             if (def->queues)
7a3408
                 virBufferAsprintf(buf, " queues='%u'", def->queues);
7a3408
@@ -18995,6 +19006,11 @@ virDomainControllerDefFormat(virBufferPtr buf,
7a3408
 
7a3408
             if (def->max_sectors)
7a3408
                 virBufferAsprintf(buf, " max_sectors='%u'", def->max_sectors);
7a3408
+
7a3408
+            if (def->ioeventfd) {
7a3408
+                virBufferAsprintf(buf, " ioeventfd='%s'",
7a3408
+                                  virTristateSwitchTypeToString(def->ioeventfd));
7a3408
+            }
7a3408
             virBufferAddLit(buf, "/>\n");
7a3408
         }
7a3408
 
7a3408
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
7a3408
index ed0ccba..3040ddc 100644
7a3408
--- a/src/conf/domain_conf.h
7a3408
+++ b/src/conf/domain_conf.h
7a3408
@@ -807,6 +807,7 @@ struct _virDomainControllerDef {
7a3408
     unsigned int queues;
7a3408
     unsigned int cmd_per_lun;
7a3408
     unsigned int max_sectors;
7a3408
+    int ioeventfd; /* enum virTristateSwitch */
7a3408
     union {
7a3408
         virDomainVirtioSerialOpts vioserial;
7a3408
         virDomainPCIControllerOpts pciopts;
7a3408
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-ioeventfd.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-ioeventfd.xml
7a3408
new file mode 100644
7a3408
index 0000000..f4487eb
7a3408
--- /dev/null
7a3408
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-ioeventfd.xml
7a3408
@@ -0,0 +1,29 @@
7a3408
+<domain type='qemu'>
7a3408
+  <name>QEMUGuest1</name>
7a3408
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
7a3408
+  <memory unit='KiB'>219136</memory>
7a3408
+  <currentMemory unit='KiB'>219136</currentMemory>
7a3408
+  <vcpu placement='static'>8</vcpu>
7a3408
+  <os>
7a3408
+    <type arch='i686' machine='pc'>hvm</type>
7a3408
+    <boot dev='hd'/>
7a3408
+  </os>
7a3408
+  <clock offset='utc'/>
7a3408
+  <on_poweroff>destroy</on_poweroff>
7a3408
+  <on_reboot>restart</on_reboot>
7a3408
+  <on_crash>destroy</on_crash>
7a3408
+  <devices>
7a3408
+    <emulator>/usr/bin/qemu</emulator>
7a3408
+    <disk type='block' device='disk'>
7a3408
+      <source dev='/dev/HostVG/QEMUGuest1'/>
7a3408
+      <target dev='sdb' bus='scsi'/>
7a3408
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
7a3408
+    </disk>
7a3408
+    <controller type='usb' index='0'/>
7a3408
+    <controller type='scsi' index='0' model='virtio-scsi'>
7a3408
+      <driver ioeventfd='on'/>
7a3408
+    </controller>
7a3408
+    <controller type='pci' index='0' model='pci-root'/>
7a3408
+    <memballoon model='virtio'/>
7a3408
+  </devices>
7a3408
+</domain>
7a3408
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
7a3408
index 09806b2..5f88c5d 100644
7a3408
--- a/tests/qemuxml2xmltest.c
7a3408
+++ b/tests/qemuxml2xmltest.c
7a3408
@@ -421,6 +421,7 @@ mymain(void)
7a3408
     DO_TEST("disk-virtio-scsi-num_queues");
7a3408
     DO_TEST("disk-virtio-scsi-cmd_per_lun");
7a3408
     DO_TEST("disk-virtio-scsi-max_sectors");
7a3408
+    DO_TEST("disk-virtio-scsi-ioeventfd");
7a3408
     DO_TEST("disk-scsi-megasas");
7a3408
     DO_TEST_DIFFERENT("disk-mirror-old");
7a3408
     DO_TEST_FULL("disk-mirror", false, WHEN_ACTIVE);
7a3408
-- 
7a3408
2.5.1
7a3408