The virDomainPanicDefParseXML() function uses old style of parsing XML (virXMLPropString + str2enum conversion). Use virXMLPropEnumDefault() which encapsulates those steps.
Signed-off-by: Michal Privoznik <mpriv...@redhat.com> --- src/conf/domain_conf.c | 11 ++++------- src/conf/domain_conf.h | 2 +- src/qemu/qemu_command.c | 2 +- src/qemu/qemu_validate.c | 2 +- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 4044515bdc..85aae73873 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11788,7 +11788,6 @@ virDomainPanicDefParseXML(virDomainXMLOption *xmlopt, unsigned int flags) { virDomainPanicDef *panic; - g_autofree char *model = NULL; panic = g_new0(virDomainPanicDef, 1); @@ -11796,13 +11795,11 @@ virDomainPanicDefParseXML(virDomainXMLOption *xmlopt, &panic->info, flags) < 0) goto error; - model = virXMLPropString(node, "model"); - if (model != NULL && - (panic->model = virDomainPanicModelTypeFromString(model)) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown panic model '%s'"), model); + if (virXMLPropEnum(node, "model", + virDomainPanicModelTypeFromString, + VIR_XML_PROP_NONE, + &panic->model) < 0) goto error; - } return panic; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 13ffdbfe88..3abc1dba36 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2619,7 +2619,7 @@ typedef enum { } virDomainPanicModel; struct _virDomainPanicDef { - int model; /* virDomainPanicModel */ + virDomainPanicModel model; virDomainDeviceInfo info; }; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 6f716c63a0..d3d69fed4f 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9995,7 +9995,7 @@ qemuBuildPanicCommandLine(virCommand *cmd, size_t i; for (i = 0; i < def->npanics; i++) { - switch ((virDomainPanicModel) def->panics[i]->model) { + switch (def->panics[i]->model) { case VIR_DOMAIN_PANIC_MODEL_ISA: { g_autoptr(virJSONValue) props = NULL; diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 8842e2f837..3a82a2adfa 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -927,7 +927,7 @@ qemuValidateDomainDefPanic(const virDomainDef *def, size_t i; for (i = 0; i < def->npanics; i++) { - switch ((virDomainPanicModel) def->panics[i]->model) { + switch (def->panics[i]->model) { case VIR_DOMAIN_PANIC_MODEL_S390: /* For s390 guests, the hardware provides the same * functionality as the pvpanic device. The address -- 2.35.1