From: Peter Krempa Date: Fri, 16 Apr 2021 08:46:00 +0000 (+0200) Subject: conf: domain: Convert virDomainDiskDef's 'sgio' to virDomainDeviceSGIO X-Git-Tag: v7.3.0-rc1~151 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e3434446c5fb53f8bab4bc1cb6c81a2a694036dc;p=thirdparty%2Flibvirt.git conf: domain: Convert virDomainDiskDef's 'sgio' to virDomainDeviceSGIO Use the appropriate type for the variable and refactor the XML parser to parse it correctly using virXMLPropEnum. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- 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 */