conf: domain: Convert virDomainDiskDef's 'rawio' to virTristateBool

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>
This commit is contained in:
Peter Krempa 2021-04-16 10:46:00 +02:00
parent 35efc9b535
commit 56a190068d
2 changed files with 4 additions and 12 deletions

View 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,

View 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 # */