[PATCH 2/6] unpriv_sgio: Parse and format the new XML

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

 



Setting "unpriv_sgio" to "yes" to enable the unprivleged SG_IO,
and "no" to disable it. Later patch will do the actual setting.
---
 src/conf/domain_conf.c                             |   33 ++++++++++---------
 src/conf/domain_conf.h                             |   15 ++++-----
 ...l2argv-disk-scsi-lun-passthrough-upriv-sgio.xml |   32 +++++++++++++++++++
 tests/qemuxml2xmltest.c                            |    1 +
 4 files changed, 57 insertions(+), 24 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-lun-passthrough-upriv-sgio.xml

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index e57dbd0..b25229a 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -236,7 +236,7 @@ VIR_ENUM_IMPL(virDomainDiskIo, VIR_DOMAIN_DISK_IO_LAST,
               "default",
               "native",
               "threads")
-VIR_ENUM_IMPL(virDomainDiskSGIO, VIR_DOMAIN_DISK_SGIO_LAST,
+VIR_ENUM_IMPL(virDomainDiskUnprivSGIO, VIR_DOMAIN_DISK_UNPRIV_SGIO_LAST,
               "default",
               "yes",
               "no")
@@ -3519,7 +3519,7 @@ virDomainDiskDefParseXML(virCapsPtr caps,
     char *device = NULL;
     char *snapshot = NULL;
     char *rawio = NULL;
-    char *sgio = NULL;
+    char *unpriv_sgio = NULL;
     char *driverName = NULL;
     char *driverType = NULL;
     char *source = NULL;
@@ -3581,7 +3581,7 @@ virDomainDiskDefParseXML(virCapsPtr caps,
     snapshot = virXMLPropString(node, "snapshot");
 
     rawio = virXMLPropString(node, "rawio");
-    sgio = virXMLPropString(node, "sgio");
+    unpriv_sgio = virXMLPropString(node, "unpriv_sgio");
 
     cur = node->children;
     while (cur != NULL) {
@@ -3972,13 +3972,13 @@ virDomainDiskDefParseXML(virCapsPtr caps,
         def->snapshot = VIR_DOMAIN_SNAPSHOT_LOCATION_NONE;
     }
 
-    if (rawio && sgio) {
+    if (rawio && unpriv_sgio) {
         virReportError(VIR_ERR_XML_ERROR, "%s",
-                       _("rawio and sgio are exclusive"));
+                       _("rawio and unpriv_sgio are exclusive"));
         goto error;
     }
 
-    if ((rawio || sgio) &&
+    if ((rawio || unpriv_sgio) &&
         (def->device != VIR_DOMAIN_DISK_DEVICE_LUN)) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                        _("rawio can be used only with device='lun'"));
@@ -3999,17 +3999,18 @@ virDomainDiskDefParseXML(virCapsPtr caps,
         }
     }
 
-    if (sgio) {
-        int sgioVal = 0;
+    if (unpriv_sgio) {
+        int unpriv_sgio_val = 0;
 
-        if ((sgioVal = virDomainDiskSGIOTypeFromString(sgio)) < 0) {
+        if ((unpriv_sgio_val =
+             virDomainDiskUnprivSGIOTypeFromString(unpriv_sgio)) < 0) {
             virReportError(VIR_ERR_XML_ERROR,
-                           _("unknown disk sgio setting '%s'"),
-                           sgio);
+                           _("unknown disk unpriv_sgio setting '%s'"),
+                           unpriv_sgio);
             goto error;
         }
 
-        def->sgio = sgioVal;
+        def->unpriv_sgio = unpriv_sgio_val;
     }
 
     if (bus) {
@@ -4246,7 +4247,7 @@ cleanup:
     VIR_FREE(type);
     VIR_FREE(snapshot);
     VIR_FREE(rawio);
-    VIR_FREE(sgio);
+    VIR_FREE(unpriv_sgio);
     VIR_FREE(target);
     VIR_FREE(source);
     VIR_FREE(tray);
@@ -11924,9 +11925,9 @@ virDomainDiskDefFormat(virBufferPtr buf,
             virBufferAddLit(buf, " rawio='no'");
         }
     }
-    if (def->sgio)
-        virBufferAsprintf(buf, "   sgio='%s'",
-                          virDomainDiskSGIOTypeToString(def->sgio));
+    if (def->unpriv_sgio)
+        virBufferAsprintf(buf, " unpriv_sgio='%s'",
+                          virDomainDiskUnprivSGIOTypeToString(def->unpriv_sgio));
     if (def->snapshot &&
         !(def->snapshot == VIR_DOMAIN_SNAPSHOT_LOCATION_NONE && def->readonly))
         virBufferAsprintf(buf, " snapshot='%s'",
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 9e1a9bb..105fb7d 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -496,12 +496,12 @@ enum  virDomainDiskIo {
     VIR_DOMAIN_DISK_IO_LAST
 };
 
-enum virDomainDiskSGIO {
-    VIR_DOMAIN_DISK_SGIO_DEFAULT = 0,
-    VIR_DOMAIN_DISK_SGIO_YES,
-    VIR_DOMAIN_DISK_SGIO_NO,
+enum virDomainDiskUnprivSGIO {
+    VIR_DOMAIN_DISK_UNPRIV_SGIO_DEFAULT = 0,
+    VIR_DOMAIN_DISK_UNPRIV_SGIO_YES,
+    VIR_DOMAIN_DISK_UNPRIV_SGIO_NO,
 
-    VIR_DOMAIN_DISK_SGIO_LAST
+    VIR_DOMAIN_DISK_UNPRIV_SGIO_LAST
 };
 
 enum virDomainIoEventFd {
@@ -615,8 +615,7 @@ struct _virDomainDiskDef {
     virStorageEncryptionPtr encryption;
     bool rawio_specified;
     int rawio; /* no = 0, yes = 1 */
-    int sgio;  /* no = 0, yes = 1 */
-    int old_sgio; /* To record the old unpriv_sgio value, internally */
+    int unpriv_sgio;  /* no = 0, yes = 1 */
 
     size_t nseclabels;
     virSecurityDeviceLabelDefPtr *seclabels;
@@ -2207,7 +2206,7 @@ VIR_ENUM_DECL(virDomainDiskCache)
 VIR_ENUM_DECL(virDomainDiskErrorPolicy)
 VIR_ENUM_DECL(virDomainDiskProtocol)
 VIR_ENUM_DECL(virDomainDiskIo)
-VIR_ENUM_DECL(virDomainDiskSGIO)
+VIR_ENUM_DECL(virDomainDiskUnprivSGIO)
 VIR_ENUM_DECL(virDomainDiskSecretType)
 VIR_ENUM_DECL(virDomainDiskTray)
 VIR_ENUM_DECL(virDomainIoEventFd)
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-lun-passthrough-upriv-sgio.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-lun-passthrough-upriv-sgio.xml
new file mode 100644
index 0000000..d8f9d12
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-lun-passthrough-upriv-sgio.xml
@@ -0,0 +1,32 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219136</memory>
+  <currentMemory unit='KiB'>219136</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</emulator>
+    <disk type='block' device='lun' unpriv_sgio='yes'>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda' bus='scsi'/>
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+    </disk>
+    <disk type='block' device='lun' unpriv_sgio='no'>
+      <source dev='/dev/HostVG/QEMUGuest2'/>
+      <target dev='hda' bus='scsi'/>
+      <address type='drive' controller='0' bus='0' target='1' unit='1'/>
+    </disk>
+    <controller type='scsi' index='0' model='virtio-scsi'/>
+    <controller type='scsi' index='1' model='lsilogic'/>
+    <controller type='usb' index='0'/>
+    <memballoon model='virtio'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 1d366f1..9cb4d88 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -238,6 +238,7 @@ mymain(void)
     DO_TEST("seclabel-static");
     DO_TEST("seclabel-none");
     DO_TEST("numad-static-vcpu-no-numatune");
+    DO_TEST("disk-scsi-lun-passthrough-upriv-sgio");
 
     /* These tests generate different XML */
     DO_TEST_DIFFERENT("balloon-device-auto");
-- 
1.7.7.6

--
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]