Use the appropriate type for the variable and refactor the XML parser to
parse it correctly using virXMLPropEnum.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/conf/domain_conf.c | 8 ++------
src/conf/domain_conf.h | 2 +-
2 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index fd933fefc8..da0e7700ff 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9345,13 +9345,9 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt,
}
VIR_FREE(tmp);
- if ((tmp = virXMLPropString(node, "model")) &&
- (def->model = virDomainDiskModelTypeFromString(tmp)) < 0) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("unknown disk model '%s'"), tmp);
+ if (virXMLPropEnum(node, "model", virDomainDiskModelTypeFromString,
+ VIR_XML_PROP_OPTIONAL, &def->model) < 0)
return NULL;
- }
- VIR_FREE(tmp);
snapshot = virXMLPropString(node, "snapshot");
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 1b62af6d63..a83d5b337f 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -584,7 +584,7 @@ struct _virDomainDiskDef {
int detect_zeroes; /* enum virDomainDiskDetectZeroes */
char *domain_name; /* backend domain name */
unsigned int queues;
- int model; /* enum virDomainDiskModel */
+ virDomainDiskModel model;
virDomainVirtioOptions *virtio;
bool diskElementAuth;
--
2.30.2