The virDomainHubDefParseXML() function uses old style of parsing
XML (virXMLPropString + str2enum conversion). Use
virXMLPropEnumDefault() which encapsulates those steps.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
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 0cb8de8b1f..26acc56dc3 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -11901,23 +11901,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 836f518f9c..5c85d3e334 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1365,8 +1365,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;
};
@@ -1871,12 +1877,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