]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: domain: Convert virDomainDiskDef's 'rawio' to virTristateBool
authorPeter Krempa <pkrempa@redhat.com>
Fri, 16 Apr 2021 08:46:00 +0000 (10:46 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 19 Apr 2021 12:44:00 +0000 (14:44 +0200)
Use the appropriate type for the variable and refactor the XML parser to
parse it correctly using virXMLPropEnum.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/conf/domain_conf.c
src/conf/domain_conf.h

index 5e27ca6265e3e5ccf05301d53e4ba77025bbd355..6641a7a78bebb6433ebaa11c999db76806e4fc69 100644 (file)
@@ -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,
index 878ba4c961e025e74bcc83c08d26a45835100be2..b3a91c0a4c8263658e0132bf171dea0ae1ee61c0 100644 (file)
@@ -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 # */