Signed-off-by: Tim Wiederhake <twied...@redhat.com>
---
 src/conf/domain_conf.c | 25 +++++--------------------
 1 file changed, 5 insertions(+), 20 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 50ddb293ed..867a83a605 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -13173,20 +13173,14 @@ virDomainSoundDefParseXML(virDomainXMLOption *xmlopt,
 {
     virDomainSoundDef *def;
     VIR_XPATH_NODE_AUTORESTORE(ctxt)
-    g_autofree char *model = NULL;
-    int modelval;
     xmlNodePtr audioNode;
 
     def = g_new0(virDomainSoundDef, 1);
     ctxt->node = node;
 
-    model = virXMLPropString(node, "model");
-    if ((modelval = virDomainSoundModelTypeFromString(model)) < 0) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                       _("unknown sound model '%s'"), model);
+    if (virXMLPropEnum(node, "model", virDomainSoundModelTypeFromString,
+                       VIR_XML_PROP_REQUIRED, &def->model) < 0)
         goto error;
-    }
-    def->model = modelval;
 
     if (virDomainSoundModelSupportsCodecs(def)) {
         int ncodecs;
@@ -13215,19 +13209,10 @@ virDomainSoundDefParseXML(virDomainXMLOption *xmlopt,
 
     audioNode = virXPathNode("./audio", ctxt);
     if (audioNode) {
-        g_autofree char *tmp = NULL;
-        tmp = virXMLPropString(audioNode, "id");
-        if (!tmp) {
-            virReportError(VIR_ERR_XML_ERROR, "%s",
-                           _("missing audio 'id' attribute"));
-            goto error;
-        }
-        if (virStrToLong_ui(tmp, NULL, 10, &def->audioId) < 0 ||
-            def->audioId == 0) {
-            virReportError(VIR_ERR_XML_ERROR,
-                           _("Invalid audio 'id' value '%s'"), tmp);
+        if (virXMLPropUInt(audioNode, "id", 10,
+                           VIR_XML_PROP_REQUIRED | VIR_XML_PROP_NONZERO,
+                           &def->audioId) < 0)
             goto error;
-        }
     }
 
     if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &def->info, flags) < 0)
-- 
2.26.3

Reply via email to