Convert the field and adjust the XML parser to use
virXMLPropEnum().
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/conf/domain_conf.c | 13 ++++---------
src/conf/domain_conf.h | 2 +-
src/qemu/qemu_domain_address.c | 2 +-
3 files changed, 6 insertions(+), 11 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 95a71b204f..3b24d0218d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -12116,21 +12116,16 @@ virDomainRNGDefParseXML(virDomainXMLOption *xmlopt,
VIR_XPATH_NODE_AUTORESTORE(ctxt)
int nbackends;
g_autofree xmlNodePtr *backends = NULL;
- g_autofree char *model = NULL;
g_autofree char *backend = NULL;
g_autofree char *type = NULL;
def = g_new0(virDomainRNGDef, 1);
- if (!(model = virXMLPropString(node, "model"))) {
- virReportError(VIR_ERR_XML_ERROR, "%s", _("missing RNG device
model"));
+ if (virXMLPropEnum(node, "model",
+ virDomainRNGModelTypeFromString,
+ VIR_XML_PROP_REQUIRED,
+ &def->model) < 0)
goto error;
- }
-
- if ((def->model = virDomainRNGModelTypeFromString(model)) < 0) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown RNG model
'%1$s'"), model);
- goto error;
- }
ctxt->node = node;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 9dadda2d1d..f56c04ce36 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2609,7 +2609,7 @@ typedef enum {
} virDomainRNGBackend;
struct _virDomainRNGDef {
- int model;
+ virDomainRNGModel model;
int backend;
unsigned int rate; /* bytes per period */
unsigned int period; /* milliseconds */
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index 2e58930eec..0ed70e5b86 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -912,7 +912,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDef *dev,
break;
case VIR_DOMAIN_DEVICE_RNG:
- switch ((virDomainRNGModel) dev->data.rng->model) {
+ switch (dev->data.rng->model) {
case VIR_DOMAIN_RNG_MODEL_VIRTIO_TRANSITIONAL:
/* Transitional devices only work in conventional PCI slots */
return pciFlags;
--
2.41.0