render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
9119d9
From 5cb75e163743eddefdc5ea8cc63763918b8da51a Mon Sep 17 00:00:00 2001
9119d9
Message-Id: <5cb75e163743eddefdc5ea8cc63763918b8da51a@dist-git>
9119d9
From: John Ferlan <jferlan@redhat.com>
9119d9
Date: Fri, 26 Sep 2014 11:27:12 +0200
9119d9
Subject: [PATCH] hostdev: Add "rawio" attribute to _virDomainHostdevSubsysSCSI
9119d9
9119d9
https://bugzilla.redhat.com/show_bug.cgi?id=1103739
9119d9
9119d9
Add the 'rawio' attribute to match _virDomainDiskDef and process the
9119d9
hostdev XML similarly to the disk XML for a lun which supports/requires rawio
9119d9
9119d9
(cherry picked from commit 58abf1bb36ee89e9de39ab09995006fd1d461665)
9119d9
9119d9
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9119d9
---
9119d9
 docs/formatdomain.html.in                          | 12 ++++++--
9119d9
 docs/schemas/domaincommon.rng                      | 12 ++++++--
9119d9
 src/conf/domain_conf.c                             | 24 +++++++++++++++
9119d9
 src/conf/domain_conf.h                             |  1 +
9119d9
 .../qemuxml2argv-hostdev-scsi-rawio.xml            | 35 ++++++++++++++++++++++
9119d9
 tests/qemuxml2xmltest.c                            |  1 +
9119d9
 6 files changed, 79 insertions(+), 6 deletions(-)
9119d9
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-rawio.xml
9119d9
9119d9
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
9119d9
index 830bfa2..ee00eca 100644
9119d9
--- a/docs/formatdomain.html.in
9119d9
+++ b/docs/formatdomain.html.in
9119d9
@@ -1815,7 +1815,7 @@
9119d9
           
rawio attribute
9119d9
           since 0.9.10
9119d9
             
9119d9
-            Indicates whether the disk is needs rawio capability; valid
9119d9
+            Indicates whether the disk needs rawio capability. Valid
9119d9
             settings are "yes" or "no" (default is "no"). If any one disk
9119d9
             in a domain has rawio='yes', rawio capability will be enabled
9119d9
             for all disks in the domain (because, in the case of QEMU, this
9119d9
@@ -2925,7 +2925,7 @@
9119d9
 
9119d9
   ...
9119d9
   <devices>
9119d9
-    <hostdev mode='subsystem' type='scsi'>
9119d9
+    <hostdev mode='subsystem' type='scsi' sgio='filtered' rawio='yes'>
9119d9
       <source>
9119d9
         <adapter name='scsi_host0'/>
9119d9
         <address type='scsi' bus='0' target='0' unit='0'/>
9119d9
@@ -2984,7 +2984,13 @@
9119d9
             (since 1.0.6) attribute indicates
9119d9
             whether the kernel will filter unprivileged SG_IO commands for
9119d9
             the disk, valid settings are "filtered" or "unfiltered".
9119d9
-            The default is "filtered".
9119d9
+            The default is "filtered". The optional rawio
9119d9
+            (since 1.2.9) attribute indicates
9119d9
+            whether the lun needs the rawio capability. Valid settings are
9119d9
+            "yes" or "no". See the rawio description within the
9119d9
+            disk section.
9119d9
+            If a disk lun in the domain already has the rawio capability,
9119d9
+            then this setting not required.
9119d9
           
9119d9
         
9119d9
       
9119d9
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
9119d9
index ccfb511..e561486 100644
9119d9
--- a/docs/schemas/domaincommon.rng
9119d9
+++ b/docs/schemas/domaincommon.rng
9119d9
@@ -1252,9 +1252,7 @@
9119d9
             </choice>
9119d9
           </attribute>
9119d9
           <optional>
9119d9
-            <attribute name="rawio">
9119d9
-              <ref name="virYesNo"/>
9119d9
-            </attribute>
9119d9
+            <ref name="rawIO"/>
9119d9
           </optional>
9119d9
           <optional>
9119d9
             <attribute name="sgio">
9119d9
@@ -3641,6 +3639,9 @@
9119d9
         </choice>
9119d9
       </attribute>
9119d9
     </optional>
9119d9
+    <optional>
9119d9
+      <ref name="rawIO"/>
9119d9
+    </optional>
9119d9
     <element name="source">
9119d9
       <choice>
9119d9
         <group>  
9119d9
@@ -5001,4 +5002,9 @@
9119d9
       </optional>
9119d9
     </element>
9119d9
   </define>
9119d9
+  <define name="rawIO">
9119d9
+    <attribute name="rawio">
9119d9
+      <ref name="virYesNo"/>
9119d9
+    </attribute>
9119d9
+  </define>
9119d9
 </grammar>
9119d9
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
9119d9
index 4e80467..40626b8 100644
9119d9
--- a/src/conf/domain_conf.c
9119d9
+++ b/src/conf/domain_conf.c
9119d9
@@ -4501,6 +4501,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node,
9119d9
     xmlNodePtr sourcenode;
9119d9
     char *managed = NULL;
9119d9
     char *sgio = NULL;
9119d9
+    char *rawio = NULL;
9119d9
     char *backendStr = NULL;
9119d9
     int backend;
9119d9
     int ret = -1;
9119d9
@@ -4518,6 +4519,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node,
9119d9
     }
9119d9
 
9119d9
     sgio = virXMLPropString(node, "sgio");
9119d9
+    rawio = virXMLPropString(node, "rawio");
9119d9
 
9119d9
     /* @type is passed in from the caller rather than read from the
9119d9
      * xml document, because it is specified in different places for
9119d9
@@ -4569,6 +4571,21 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node,
9119d9
         }
9119d9
     }
9119d9
 
9119d9
+    if (rawio) {
9119d9
+        if (def->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI) {
9119d9
+            virReportError(VIR_ERR_XML_ERROR, "%s",
9119d9
+                           _("rawio is only supported for scsi host device"));
9119d9
+            goto error;
9119d9
+        }
9119d9
+
9119d9
+        if ((scsisrc->rawio = virTristateBoolTypeFromString(rawio)) <= 0) {
9119d9
+            virReportError(VIR_ERR_XML_ERROR,
9119d9
+                           _("unknown hostdev rawio setting '%s'"),
9119d9
+                           rawio);
9119d9
+            goto error;
9119d9
+        }
9119d9
+    }
9119d9
+
9119d9
     switch (def->source.subsys.type) {
9119d9
     case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI:
9119d9
         if (virDomainHostdevSubsysPCIDefParseXML(sourcenode, def, flags) < 0)
9119d9
@@ -4608,6 +4625,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node,
9119d9
  error:
9119d9
     VIR_FREE(managed);
9119d9
     VIR_FREE(sgio);
9119d9
+    VIR_FREE(rawio);
9119d9
     VIR_FREE(backendStr);
9119d9
     return ret;
9119d9
 }
9119d9
@@ -17975,6 +17993,12 @@ virDomainHostdevDefFormat(virBufferPtr buf,
9119d9
             scsisrc->sgio)
9119d9
             virBufferAsprintf(buf, " sgio='%s'",
9119d9
                               virDomainDeviceSGIOTypeToString(scsisrc->sgio));
9119d9
+
9119d9
+        if (def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI &&
9119d9
+            scsisrc->rawio) {
9119d9
+            virBufferAsprintf(buf, " rawio='%s'",
9119d9
+                              virTristateBoolTypeToString(scsisrc->rawio));
9119d9
+        }
9119d9
     }
9119d9
     virBufferAddLit(buf, ">\n");
9119d9
     virBufferAdjustIndent(buf, 2);
9119d9
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
9119d9
index 39f1948..b981020 100644
9119d9
--- a/src/conf/domain_conf.h
9119d9
+++ b/src/conf/domain_conf.h
9119d9
@@ -439,6 +439,7 @@ typedef virDomainHostdevSubsysSCSI *virDomainHostdevSubsysSCSIPtr;
9119d9
 struct _virDomainHostdevSubsysSCSI {
9119d9
     int protocol; /* enum virDomainHostdevSCSIProtocolType */
9119d9
     int sgio; /* enum virDomainDeviceSGIO */
9119d9
+    int rawio; /* enum virTristateBool */
9119d9
     union {
9119d9
         virDomainHostdevSubsysSCSIHost host;
9119d9
         virDomainHostdevSubsysSCSIiSCSI iscsi;
9119d9
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-rawio.xml b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-rawio.xml
9119d9
new file mode 100644
9119d9
index 0000000..69fdde3
9119d9
--- /dev/null
9119d9
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-rawio.xml
9119d9
@@ -0,0 +1,35 @@
9119d9
+<domain type='qemu'>
9119d9
+  <name>QEMUGuest2</name>
9119d9
+  <uuid>c7a5fdbd-edaf-9466-926a-d65c16db1809</uuid>
9119d9
+  <memory unit='KiB'>219100</memory>
9119d9
+  <currentMemory unit='KiB'>219100</currentMemory>
9119d9
+  <vcpu placement='static'>1</vcpu>
9119d9
+  <os>
9119d9
+    <type arch='i686' machine='pc'>hvm</type>
9119d9
+    <boot dev='hd'/>
9119d9
+  </os>
9119d9
+  <clock offset='utc'/>
9119d9
+  <on_poweroff>destroy</on_poweroff>
9119d9
+  <on_reboot>restart</on_reboot>
9119d9
+  <on_crash>destroy</on_crash>
9119d9
+  <devices>
9119d9
+    <emulator>/usr/bin/qemu</emulator>
9119d9
+    <disk type='block' device='disk'>
9119d9
+      <source dev='/dev/HostVG/QEMUGuest2'/>
9119d9
+      <target dev='hda' bus='ide'/>
9119d9
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
9119d9
+    </disk>
9119d9
+    <controller type='scsi' index='0' model='virtio-scsi'/>
9119d9
+    <controller type='usb' index='0'/>
9119d9
+    <controller type='ide' index='0'/>
9119d9
+    <controller type='pci' index='0' model='pci-root'/>
9119d9
+    <hostdev mode='subsystem' type='scsi' managed='yes' sgio='unfiltered' rawio='yes'>
9119d9
+      <source>
9119d9
+        <adapter name='scsi_host0'/>
9119d9
+        <address bus='0' target='0' unit='0'/>
9119d9
+      </source>
9119d9
+      <address type='drive' controller='0' bus='0' target='4' unit='8'/>
9119d9
+    </hostdev>
9119d9
+    <memballoon model='virtio'/>
9119d9
+  </devices>
9119d9
+</domain>
9119d9
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
9119d9
index ee05212..6e71cb2 100644
9119d9
--- a/tests/qemuxml2xmltest.c
9119d9
+++ b/tests/qemuxml2xmltest.c
9119d9
@@ -369,6 +369,7 @@ mymain(void)
9119d9
     DO_TEST("disk-copy_on_read");
9119d9
     DO_TEST("hostdev-scsi-shareable");
9119d9
     DO_TEST("hostdev-scsi-sgio");
9119d9
+    DO_TEST("hostdev-scsi-rawio");
9119d9
 
9119d9
     DO_TEST_DIFFERENT("hostdev-scsi-autogen-address");
9119d9
 
9119d9
-- 
9119d9
2.1.1
9119d9