[PATCH 19/25] conf: domain: Convert virDomainDiskDef's 'rawio' to virTristateBool

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

 



Use the appropriate type for the variable and refactor the XML parser to
parse it correctly using virXMLPropEnum.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/conf/domain_conf.c | 14 +++-----------
 src/conf/domain_conf.h |  2 +-
 2 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 5e27ca6265..6641a7a78b 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9314,7 +9314,6 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt,
     bool source = false;
     g_autofree char *tmp = NULL;
     g_autofree char *snapshot = NULL;
-    g_autofree char *rawio = NULL;
     g_autofree char *sgio = NULL;
     g_autofree char *target = NULL;
     g_autofree char *bus = NULL;
@@ -9357,7 +9356,9 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt,

     snapshot = virXMLPropString(node, "snapshot");

-    rawio = virXMLPropString(node, "rawio");
+    if (virXMLPropTristateBool(node, "rawio", VIR_XML_PROP_OPTIONAL, &def->rawio) < 0)
+        return NULL;
+
     sgio = virXMLPropString(node, "sgio");

     for (cur = node->children; cur != NULL; cur = cur->next) {
@@ -9473,15 +9474,6 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt,
         }
     }

-    if (rawio) {
-        if ((def->rawio = virTristateBoolTypeFromString(rawio)) <= 0) {
-            virReportError(VIR_ERR_XML_ERROR,
-                           _("unknown disk rawio setting '%s'"),
-                           rawio);
-            return NULL;
-        }
-    }
-
     if (sgio) {
         if ((def->sgio = virDomainDeviceSGIOTypeFromString(sgio)) <= 0) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 878ba4c961..b3a91c0a4c 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -577,7 +577,7 @@ struct _virDomainDiskDef {
     virDomainStartupPolicy startupPolicy;
     bool transient;
     virDomainDeviceInfo info;
-    int rawio; /* enum virTristateBool */
+    virTristateBool rawio;
     int sgio; /* enum virDomainDeviceSGIO */
     int discard; /* enum virDomainDiskDiscard */
     unsigned int iothread; /* unused = 0, > 0 specific thread # */
-- 
2.30.2




[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