[PATCH 7/9] conf: Restore error checking in VideoAccelDefParseXML()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The check that ensures that at least one property among accel3d,
accel2d and rendernode has been provided by the user had been
lost during the conversion to virXMLPropTristateBool().

Fixes: 0fe2d8dd335054fae38b46bbbac58a4662e1a1d0
Signed-off-by: Andrea Bolognani <abologna@xxxxxxxxxx>
---
 src/conf/domain_conf.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 68191f42bd..bd98317f4d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -14019,23 +14019,31 @@ virDomainVideoAccelDefParseXML(xmlNodePtr node)
 {
     g_autofree virDomainVideoAccelDef *def = NULL;
     g_autofree char *rendernode = NULL;
+    virTristateBool accel3d;
+    virTristateBool accel2d;
 
     rendernode = virXMLPropString(node, "rendernode");
-
-    def = g_new0(virDomainVideoAccelDef, 1);
-
     if (virXMLPropTristateBool(node, "accel3d",
-                               VIR_XML_PROP_NONE,
-                               &def->accel3d) < 0)
+                               VIR_XML_PROP_NONE, &accel3d) < 0)
         return NULL;
-
     if (virXMLPropTristateBool(node, "accel2d",
-                               VIR_XML_PROP_NONE,
-                               &def->accel2d) < 0)
+                               VIR_XML_PROP_NONE, &accel2d) < 0)
         return NULL;
 
+    if (!rendernode &&
+        accel3d == VIR_TRISTATE_BOOL_ABSENT &&
+        accel2d == VIR_TRISTATE_BOOL_ABSENT) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                _("missing values for acceleration"));
+        return NULL;
+    }
+
+    def = g_new0(virDomainVideoAccelDef, 1);
+
     if (rendernode)
         def->rendernode = virFileSanitizePath(rendernode);
+    def->accel3d = accel3d;
+    def->accel2d = accel2d;
 
     return g_steal_pointer(&def);
 }
-- 
2.35.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux