From 77c638c3c780e2b094f9f31525693e6c2b383ff5 Mon Sep 17 00:00:00 2001 From: Andrea Bolognani Date: Thu, 24 Mar 2022 20:15:54 +0100 Subject: [PATCH] conf: Restore error checking in VideoAccelDefParseXML() 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 Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5140f71dda..98df54e78c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -14025,23 +14025,31 @@ virDomainVideoAccelDefParseXML(xmlNodePtr node) { g_autofree virDomainVideoAccelDef *def = NULL; g_autofree char *rendernode = NULL; + virTristateBool accel3d; + virTristateBool accel2d; rendernode = virXMLPropString(node, "rendernode"); + if (virXMLPropTristateBool(node, "accel3d", + VIR_XML_PROP_NONE, &accel3d) < 0) + return NULL; + if (virXMLPropTristateBool(node, "accel2d", + 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 (virXMLPropTristateBool(node, "accel3d", - VIR_XML_PROP_NONE, - &def->accel3d) < 0) - return NULL; - - if (virXMLPropTristateBool(node, "accel2d", - VIR_XML_PROP_NONE, - &def->accel2d) < 0) - return NULL; - if (rendernode) def->rendernode = virFileSanitizePath(rendernode); + def->accel3d = accel3d; + def->accel2d = accel2d; return g_steal_pointer(&def); }