virDomainGraphicsDefParseXMLSDL: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Tim Wiederhake 2021-04-23 17:39:14 +02:00 committed by Peter Krempa
parent 3c3c55be66
commit 7ae08ef3a2

View File

@ -12813,42 +12813,23 @@ virDomainGraphicsDefParseXMLSDL(virDomainGraphicsDef *def,
xmlXPathContextPtr ctxt) xmlXPathContextPtr ctxt)
{ {
VIR_XPATH_NODE_AUTORESTORE(ctxt) VIR_XPATH_NODE_AUTORESTORE(ctxt)
int enableVal;
xmlNodePtr glNode; xmlNodePtr glNode;
g_autofree char *fullscreen = virXMLPropString(node, "fullscreen"); virTristateBool fullscreen = VIR_TRISTATE_BOOL_NO;
g_autofree char *enable = NULL;
ctxt->node = node; ctxt->node = node;
if (fullscreen != NULL) { if (virXMLPropTristateBool(node, "fullscreen", VIR_XML_PROP_NONE,
if (virStringParseYesNo(fullscreen, &def->data.sdl.fullscreen) < 0) { &fullscreen) < 0)
virReportError(VIR_ERR_INTERNAL_ERROR, return -1;
_("unknown fullscreen value '%s'"), fullscreen);
return -1;
}
} else {
def->data.sdl.fullscreen = false;
}
def->data.sdl.fullscreen = fullscreen == VIR_TRISTATE_BOOL_YES;
def->data.sdl.xauth = virXMLPropString(node, "xauth"); def->data.sdl.xauth = virXMLPropString(node, "xauth");
def->data.sdl.display = virXMLPropString(node, "display"); def->data.sdl.display = virXMLPropString(node, "display");
glNode = virXPathNode("./gl", ctxt); if ((glNode = virXPathNode("./gl", ctxt))) {
if (glNode) { if (virXMLPropTristateBool(glNode, "enable", VIR_XML_PROP_REQUIRED,
enable = virXMLPropString(glNode, "enable"); &def->data.sdl.gl) < 0)
if (!enable) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("sdl gl element missing enable"));
return -1; return -1;
}
enableVal = virTristateBoolTypeFromString(enable);
if (enableVal < 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown enable value '%s'"), enable);
return -1;
}
def->data.sdl.gl = enableVal;
} }
return 0; return 0;