mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
qemu: Fix name-space handling
The XML parser for the qemu specific extensions expects the qemu name-space to be bound to the 'qemu' prefix. This is too strict, since the name of the name-space-prefix is only meant as an internal lookup key. Only the associated URI is relevant. <domain>... <qemu:commandline xmlns:qemu="http://libvirt.org/schemas/domain/qemu/1.0"> ...</qemu:commandline> </domain> <domain xmlns:ns0="http://libvirt.org/schemas/domain/qemu/1.0">... <ns0:commandline> ...</ns0:commandline> </domain> <domain xmlns:qemu="http://libvirt.org/schemas/domain/qemu/1.0"> <qemu:commandline xmlns:qemu="urn:foo"> ...</qemu:commandline> </domain> Remove the test for checking the name-space binding on the top-level <domain> element. Registering the name-space with XPath is enough. Signed-off-by: Philipp Hahn <hahn@univention.de>
This commit is contained in:
parent
8f3d1669da
commit
d1249910b8
@ -484,31 +484,20 @@ qemuDomainDefNamespaceFree(void *nsdata)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuDomainDefNamespaceParse(xmlDocPtr xml,
|
qemuDomainDefNamespaceParse(xmlDocPtr xml ATTRIBUTE_UNUSED,
|
||||||
xmlNodePtr root,
|
xmlNodePtr root ATTRIBUTE_UNUSED,
|
||||||
xmlXPathContextPtr ctxt,
|
xmlXPathContextPtr ctxt,
|
||||||
void **data)
|
void **data)
|
||||||
{
|
{
|
||||||
qemuDomainCmdlineDefPtr cmd = NULL;
|
qemuDomainCmdlineDefPtr cmd = NULL;
|
||||||
xmlNsPtr ns;
|
bool uses_qemu_ns = false;
|
||||||
xmlNodePtr *nodes = NULL;
|
xmlNodePtr *nodes = NULL;
|
||||||
int n, i;
|
int n, i;
|
||||||
|
|
||||||
ns = xmlSearchNs(xml, root, BAD_CAST "qemu");
|
if (xmlXPathRegisterNs(ctxt, BAD_CAST "qemu", BAD_CAST QEMU_NAMESPACE_HREF) < 0) {
|
||||||
if (!ns)
|
|
||||||
/* this is fine; it just means there was no qemu namespace listed */
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (STRNEQ((const char *)ns->href, QEMU_NAMESPACE_HREF)) {
|
|
||||||
qemuReportError(VIR_ERR_INTERNAL_ERROR,
|
qemuReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Found namespace '%s' doesn't match expected '%s'"),
|
_("Failed to register xml namespace '%s'"),
|
||||||
ns->href, QEMU_NAMESPACE_HREF);
|
QEMU_NAMESPACE_HREF);
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (xmlXPathRegisterNs(ctxt, ns->prefix, ns->href) < 0) {
|
|
||||||
qemuReportError(VIR_ERR_INTERNAL_ERROR,
|
|
||||||
_("Failed to register xml namespace '%s'"), ns->href);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -521,6 +510,7 @@ qemuDomainDefNamespaceParse(xmlDocPtr xml,
|
|||||||
n = virXPathNodeSet("./qemu:commandline/qemu:arg", ctxt, &nodes);
|
n = virXPathNodeSet("./qemu:commandline/qemu:arg", ctxt, &nodes);
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
uses_qemu_ns |= n > 0;
|
||||||
|
|
||||||
if (n && VIR_ALLOC_N(cmd->args, n) < 0)
|
if (n && VIR_ALLOC_N(cmd->args, n) < 0)
|
||||||
goto no_memory;
|
goto no_memory;
|
||||||
@ -541,6 +531,7 @@ qemuDomainDefNamespaceParse(xmlDocPtr xml,
|
|||||||
n = virXPathNodeSet("./qemu:commandline/qemu:env", ctxt, &nodes);
|
n = virXPathNodeSet("./qemu:commandline/qemu:env", ctxt, &nodes);
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
uses_qemu_ns |= n > 0;
|
||||||
|
|
||||||
if (n && VIR_ALLOC_N(cmd->env_name, n) < 0)
|
if (n && VIR_ALLOC_N(cmd->env_name, n) < 0)
|
||||||
goto no_memory;
|
goto no_memory;
|
||||||
@ -582,7 +573,10 @@ qemuDomainDefNamespaceParse(xmlDocPtr xml,
|
|||||||
|
|
||||||
VIR_FREE(nodes);
|
VIR_FREE(nodes);
|
||||||
|
|
||||||
*data = cmd;
|
if (uses_qemu_ns)
|
||||||
|
*data = cmd;
|
||||||
|
else
|
||||||
|
VIR_FREE(cmd);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user