]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: report errors when parsing video acceleration
authorJonathon Jongsma <jjongsma@redhat.com>
Thu, 14 Nov 2019 21:59:16 +0000 (15:59 -0600)
committerCole Robinson <crobinso@redhat.com>
Fri, 15 Nov 2019 18:30:56 +0000 (13:30 -0500)
Since this function is now only called when an 'acceleration' element is
present in the xml, any failure to parse the element will be considered
an error.

Previously, we detected some types of errors, but we would only log an
error (virReportError()), but still return a partially-specified accel
object to the caller. This patch returns NULL for all parsing errors and
reports that error back up to the caller.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
src/conf/domain_conf.c

index b0599c7318dd172f99358e4c0f989f55dc2e3c7b..c0f20c928f8d5bfde5ac7c917a3a7cfdc2a0f0c6 100644 (file)
@@ -15269,8 +15269,11 @@ virDomainVideoAccelDefParseXML(xmlNodePtr node)
     accel2d = virXMLPropString(node, "accel2d");
     rendernode = virXMLPropString(node, "rendernode");
 
-    if (!accel3d && !accel2d && !rendernode)
+    if (!accel3d && !accel2d && !rendernode) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("missing values for acceleration"));
         return NULL;
+    }
 
     def = g_new0(virDomainVideoAccelDef, 1);
 
@@ -15278,7 +15281,7 @@ virDomainVideoAccelDefParseXML(xmlNodePtr node)
         if ((val = virTristateBoolTypeFromString(accel3d)) <= 0) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                            _("unknown accel3d value '%s'"), accel3d);
-            goto cleanup;
+            return NULL;
         }
         def->accel3d = val;
     }
@@ -15287,7 +15290,7 @@ virDomainVideoAccelDefParseXML(xmlNodePtr node)
         if ((val = virTristateBoolTypeFromString(accel2d)) <= 0) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                            _("unknown accel2d value '%s'"), accel2d);
-            goto cleanup;
+            return NULL;
         }
         def->accel2d = val;
     }
@@ -15295,7 +15298,6 @@ virDomainVideoAccelDefParseXML(xmlNodePtr node)
     if (rendernode)
         def->rendernode = virFileSanitizePath(rendernode);
 
- cleanup:
     return g_steal_pointer(&def);
 }
 
@@ -15414,8 +15416,10 @@ virDomainVideoDefParseXML(virDomainXMLOptionPtr xmlopt,
                 while (child != NULL) {
                     if (child->type == XML_ELEMENT_NODE) {
                         if (def->accel == NULL &&
-                            virXMLNodeNameEqual(child, "acceleration"))
-                            def->accel = virDomainVideoAccelDefParseXML(child);
+                            virXMLNodeNameEqual(child, "acceleration")) {
+                            if ((def->accel = virDomainVideoAccelDefParseXML(child)) == NULL)
+                                goto error;
+                        }
                         if (def->res == NULL &&
                             virXMLNodeNameEqual(child, "resolution")) {
                             if ((def->res = virDomainVideoResolutionDefParseXML(child)) == NULL)