Convert the field and adjust the XML parsers to use
virXMLPropEnum().
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/conf/domain_conf.c | 15 ++++-----------
src/conf/domain_conf.h | 2 +-
src/qemu/qemu_domain_address.c | 2 +-
src/qemu/qemu_validate.c | 2 +-
4 files changed, 7 insertions(+), 14 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 47c4170f29..5c1712cb46 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -12065,21 +12065,14 @@ virDomainWatchdogDefParseXML(virDomainXMLOption *xmlopt,
unsigned int flags)
{
virDomainWatchdogDef *def;
- g_autofree char *model = NULL;
g_autofree char *action = NULL;
def = g_new0(virDomainWatchdogDef, 1);
- model = virXMLPropString(node, "model");
- if (model == NULL) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("watchdog must contain model name"));
- goto error;
- }
- def->model = virDomainWatchdogModelTypeFromString(model);
- if (def->model < 0) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("unknown watchdog model '%1$s'"), model);
+ if (virXMLPropEnum(node, "model",
+ virDomainWatchdogModelTypeFromString,
+ VIR_XML_PROP_REQUIRED,
+ &def->model) < 0) {
goto error;
}
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index c9b9fbabd3..e7c663b0e9 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1759,7 +1759,7 @@ typedef enum {
} virDomainWatchdogAction;
struct _virDomainWatchdogDef {
- int model;
+ virDomainWatchdogModel model;
int action;
virDomainDeviceInfo info;
};
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index 0ed70e5b86..099778b2a8 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -927,7 +927,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDef *dev,
case VIR_DOMAIN_DEVICE_WATCHDOG:
/* only one model connects using PCI */
- switch ((virDomainWatchdogModel) dev->data.watchdog->model) {
+ switch (dev->data.watchdog->model) {
case VIR_DOMAIN_WATCHDOG_MODEL_I6300ESB:
return pciFlags;
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index fc61c489e9..27fd5b9a99 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -2251,7 +2251,7 @@ qemuValidateDomainWatchdogDef(const virDomainWatchdogDef *dev,
return -1;
}
- switch ((virDomainWatchdogModel) dev->model) {
+ switch (dev->model) {
case VIR_DOMAIN_WATCHDOG_MODEL_I6300ESB:
if (dev->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
dev->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
--
2.41.0