The virDomainHubDefParseXML() 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 | 17 ++++------------- src/conf/domain_conf.h | 14 +++++++------- 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 44ab79c1f0..52a34cd131 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11934,23 +11934,14 @@ virDomainHubDefParseXML(virDomainXMLOption *xmlopt, unsigned int flags) { virDomainHubDef *def; - g_autofree char *type = NULL; def = g_new0(virDomainHubDef, 1); - type = virXMLPropString(node, "type"); - - if (!type) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("missing hub device type")); + if (virXMLPropEnum(node, "type", + virDomainHubTypeFromString, + VIR_XML_PROP_REQUIRED, + &def->type) < 0) goto error; - } - - if ((def->type = virDomainHubTypeFromString(type)) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown hub device type '%s'"), type); - goto error; - } if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &def->info, flags) < 0) goto error; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index b3d51565e3..cad19a3d5d 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1381,8 +1381,14 @@ struct _virDomainSmartcardDef { virDomainDeviceInfo info; }; +typedef enum { + VIR_DOMAIN_HUB_TYPE_USB, + + VIR_DOMAIN_HUB_TYPE_LAST +} virDomainHubType; + struct _virDomainHubDef { - int type; + virDomainHubType type; virDomainDeviceInfo info; }; @@ -1881,12 +1887,6 @@ typedef enum { VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST } virDomainGraphicsListenType; -typedef enum { - VIR_DOMAIN_HUB_TYPE_USB, - - VIR_DOMAIN_HUB_TYPE_LAST -} virDomainHubType; - struct _virDomainGraphicsListenDef { virDomainGraphicsListenType type; char *address; -- 2.35.1