The virDomainBackupDefParse() 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/backup_conf.c | 16 ++++++---------- src/conf/backup_conf.h | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/conf/backup_conf.c b/src/conf/backup_conf.c index 2a7fa95e0c..11d533a905 100644 --- a/src/conf/backup_conf.c +++ b/src/conf/backup_conf.c @@ -201,22 +201,18 @@ virDomainBackupDefParse(xmlXPathContextPtr ctxt, g_autoptr(virDomainBackupDef) def = NULL; g_autofree xmlNodePtr *nodes = NULL; xmlNodePtr node = NULL; - g_autofree char *mode = NULL; bool push; size_t i; int n; def = g_new0(virDomainBackupDef, 1); - def->type = VIR_DOMAIN_BACKUP_TYPE_PUSH; - - if ((mode = virXMLPropString(ctxt->node, "mode"))) { - if ((def->type = virDomainBackupTypeFromString(mode)) <= 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown backup mode '%s'"), mode); - return NULL; - } - } + if (virXMLPropEnumDefault(ctxt->node, "mode", + virDomainBackupTypeFromString, + VIR_XML_PROP_NONZERO, + &def->type, + VIR_DOMAIN_BACKUP_TYPE_PUSH) < 0) + return NULL; push = def->type == VIR_DOMAIN_BACKUP_TYPE_PUSH; diff --git a/src/conf/backup_conf.h b/src/conf/backup_conf.h index dc66b75892..413488e123 100644 --- a/src/conf/backup_conf.h +++ b/src/conf/backup_conf.h @@ -76,7 +76,7 @@ struct _virDomainBackupDiskDef { typedef struct _virDomainBackupDef virDomainBackupDef; struct _virDomainBackupDef { /* Public XML. */ - int type; /* virDomainBackupType */ + virDomainBackupType type; char *incremental; virStorageNetHostDef *server; /* only when type == PULL */ virTristateBool tls; /* use TLS for NBD */ -- 2.35.1