mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 03:12:22 +00:00
Refactoring virDomainVideoDriverDefParseXML() to use XPath
Signed-off-by: Kristina Hanicova <khanicov@redhat.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
bcce7f2e3a
commit
fc7e1b2f03
@ -14313,34 +14313,24 @@ virDomainVideoResolutionDefParseXML(xmlNodePtr node)
|
||||
|
||||
static virDomainVideoDriverDef *
|
||||
virDomainVideoDriverDefParseXML(xmlNodePtr node,
|
||||
xmlXPathContextPtr ctxt G_GNUC_UNUSED)
|
||||
xmlXPathContextPtr ctxt)
|
||||
{
|
||||
xmlNodePtr cur;
|
||||
virDomainVideoDriverDef *def;
|
||||
int val;
|
||||
g_autofree char *vgaconf = NULL;
|
||||
unsigned int val;
|
||||
xmlNodePtr driver = NULL;
|
||||
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
||||
|
||||
cur = node->children;
|
||||
while (cur != NULL) {
|
||||
if (cur->type == XML_ELEMENT_NODE) {
|
||||
if (!vgaconf &&
|
||||
virXMLNodeNameEqual(cur, "driver")) {
|
||||
vgaconf = virXMLPropString(cur, "vgaconf");
|
||||
}
|
||||
}
|
||||
cur = cur->next;
|
||||
}
|
||||
ctxt->node = node;
|
||||
|
||||
if (!vgaconf)
|
||||
if (!(driver = virXPathNode("./driver", ctxt)))
|
||||
return NULL;
|
||||
|
||||
if (virXMLPropEnum(driver, "vgaconf",
|
||||
virDomainVideoVGAConfTypeFromString,
|
||||
VIR_XML_PROP_NONZERO, &val) < 0)
|
||||
return NULL;
|
||||
|
||||
def = g_new0(virDomainVideoDriverDef, 1);
|
||||
|
||||
if ((val = virDomainVideoVGAConfTypeFromString(vgaconf)) <= 0) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("unknown vgaconf value '%s'"), vgaconf);
|
||||
return def;
|
||||
}
|
||||
def->vgaconf = val;
|
||||
|
||||
return def;
|
||||
|
@ -1665,7 +1665,7 @@ struct _virDomainVideoResolutionDef {
|
||||
};
|
||||
|
||||
struct _virDomainVideoDriverDef {
|
||||
virDomainVideoVGAConf vgaconf;
|
||||
virDomainVideoVGAConf vgaconf;
|
||||
char *vhost_user_binary;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user