[PATCH 20/25] conf: domain: Convert virDomainDiskDef's 'sgio' to virDomainDeviceSGIO

[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 | 13 +++----------
 src/conf/domain_conf.h |  2 +-
 2 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 6641a7a78b..fd933fefc8 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 *sgio = NULL;
     g_autofree char *target = NULL;
     g_autofree char *bus = NULL;
     g_autofree char *serial = NULL;
@@ -9359,7 +9358,9 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt,
     if (virXMLPropTristateBool(node, "rawio", VIR_XML_PROP_OPTIONAL, &def->rawio) < 0)
         return NULL;

-    sgio = virXMLPropString(node, "sgio");
+    if (virXMLPropEnum(node, "sgio", virDomainDeviceSGIOTypeFromString,
+                       VIR_XML_PROP_OPTIONAL | VIR_XML_PROP_NONZERO, &def->sgio) < 0)
+        return NULL;

     for (cur = node->children; cur != NULL; cur = cur->next) {
         if (cur->type != XML_ELEMENT_NODE)
@@ -9474,14 +9475,6 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt,
         }
     }

-    if (sgio) {
-        if ((def->sgio = virDomainDeviceSGIOTypeFromString(sgio)) <= 0) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                           _("unknown disk sgio mode '%s'"), sgio);
-            return NULL;
-        }
-    }
-
     if (bus) {
         if ((def->bus = virDomainDiskBusTypeFromString(bus)) <= 0) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index b3a91c0a4c..1b62af6d63 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -578,7 +578,7 @@ struct _virDomainDiskDef {
     bool transient;
     virDomainDeviceInfo info;
     virTristateBool rawio;
-    int sgio; /* enum virDomainDeviceSGIO */
+    virDomainDeviceSGIO sgio;
     int discard; /* enum virDomainDiskDiscard */
     unsigned int iothread; /* unused = 0, > 0 specific thread # */
     int detect_zeroes; /* enum virDomainDiskDetectZeroes */
-- 
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