The virDomainDiskSourcePoolDefParse() function uses old style of parsing XML (virXMLPropString + str2enum conversion). Use virXMLPropEnumDefault() which encapsulates those steps. Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> --- src/conf/domain_conf.c | 12 ++++-------- src/conf/storage_source_conf.h | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index cb4b43ea23..3bbc5f2214 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8157,7 +8157,6 @@ virDomainDiskSourcePoolDefParse(xmlNodePtr node, { virStorageSourcePoolDef *source; int ret = -1; - g_autofree char *mode = NULL; *srcpool = NULL; @@ -8165,7 +8164,6 @@ virDomainDiskSourcePoolDefParse(xmlNodePtr node, source->pool = virXMLPropString(node, "pool"); source->volume = virXMLPropString(node, "volume"); - mode = virXMLPropString(node, "mode"); /* CD-ROM and Floppy allows no source */ if (!source->pool && !source->volume) { @@ -8180,13 +8178,11 @@ virDomainDiskSourcePoolDefParse(xmlNodePtr node, goto cleanup; } - if (mode && - (source->mode = virStorageSourcePoolModeTypeFromString(mode)) <= 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown source mode '%s' for volume type disk"), - mode); + if (virXMLPropEnum(node, "mode", + virStorageSourcePoolModeTypeFromString, + VIR_XML_PROP_NONZERO, + &source->mode) < 0) goto cleanup; - } *srcpool = g_steal_pointer(&source); ret = 0; diff --git a/src/conf/storage_source_conf.h b/src/conf/storage_source_conf.h index 3afad96bdb..b99a952702 100644 --- a/src/conf/storage_source_conf.h +++ b/src/conf/storage_source_conf.h @@ -200,7 +200,7 @@ struct _virStorageSourcePoolDef { int voltype; /* virStorageVolType, internal only */ int pooltype; /* virStoragePoolType from storage_conf.h, internal only */ virStorageType actualtype; /* internal only */ - int mode; /* virStorageSourcePoolMode, currently makes sense only for iscsi pool */ + virStorageSourcePoolMode mode; /* currently makes sense only for iscsi pool */ }; -- 2.35.1