[PATCH v2 2/5] domain_conf: Change virDomainDiskDef 'rawio' to use virTristateBool

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

 



Adjust disk definition for 'rawio' to use the TristateBool logic

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/conf/domain_conf.c  | 16 ++++------------
 src/conf/domain_conf.h  |  3 +--
 src/qemu/qemu_domain.c  |  5 +++--
 src/qemu/qemu_process.c |  2 +-
 4 files changed, 9 insertions(+), 17 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 3ccec1c..c240c83 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5954,12 +5954,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
     }
 
     if (rawio) {
-        def->rawio_specified = true;
-        if (STREQ(rawio, "yes")) {
-            def->rawio = 1;
-        } else if (STREQ(rawio, "no")) {
-            def->rawio = 0;
-        } else {
+        if ((def->rawio = virTristateBoolTypeFromString(rawio)) <= 0) {
             virReportError(VIR_ERR_XML_ERROR,
                            _("unknown disk rawio setting '%s'"),
                            rawio);
@@ -15828,12 +15823,9 @@ virDomainDiskDefFormat(virBufferPtr buf,
     virBufferAsprintf(buf,
                       "<disk type='%s' device='%s'",
                       type, device);
-    if (def->rawio_specified) {
-        if (def->rawio == 1) {
-            virBufferAddLit(buf, " rawio='yes'");
-        } else if (def->rawio == 0) {
-            virBufferAddLit(buf, " rawio='no'");
-        }
+    if (def->rawio) {
+        virBufferAsprintf(buf, " rawio='%s'",
+                          virTristateBoolTypeToString(def->rawio));
     }
 
     if (def->sgio)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 640a4c5..afd9943 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -663,8 +663,7 @@ struct _virDomainDiskDef {
     int startupPolicy; /* enum virDomainStartupPolicy */
     bool transient;
     virDomainDeviceInfo info;
-    bool rawio_specified;
-    int rawio; /* no = 0, yes = 1 */
+    int rawio; /* enum virTristateBool */
     int sgio; /* enum virDomainDeviceSGIO */
     int discard; /* enum virDomainDiskDiscard */
     unsigned int iothread; /* unused = 0, > 0 specific thread # */
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 5859ba7..075406e 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1945,8 +1945,9 @@ void qemuDomainObjCheckDiskTaint(virQEMUDriverPtr driver,
         cfg->allowDiskFormatProbing)
         qemuDomainObjTaint(driver, obj, VIR_DOMAIN_TAINT_DISK_PROBING, logFD);
 
-    if (disk->rawio == 1)
-        qemuDomainObjTaint(driver, obj, VIR_DOMAIN_TAINT_HIGH_PRIVILEGES, logFD);
+    if (disk->rawio == VIR_TRISTATE_BOOL_YES)
+        qemuDomainObjTaint(driver, obj, VIR_DOMAIN_TAINT_HIGH_PRIVILEGES,
+                           logFD);
 
     virObjectUnref(cfg);
 }
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index eecef12..43cf396 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4357,7 +4357,7 @@ int qemuProcessStart(virConnectPtr conn,
         virDomainDeviceDef dev;
         virDomainDiskDefPtr disk = vm->def->disks[i];
 
-        if (vm->def->disks[i]->rawio == 1) {
+        if (vm->def->disks[i]->rawio == VIR_TRISTATE_BOOL_YES) {
 #ifdef CAP_SYS_RAWIO
             virCommandAllowCap(cmd, CAP_SYS_RAWIO);
 #else
-- 
1.9.3

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