mirror of https://gitee.com/openkylin/libvirt.git
qemu: Refactor qemuDomainDefNamespaceParse
Rename 'cmd' to 'nsdef' and improve the control flow. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
a858b77754
commit
8b0a389d2b
|
@ -3201,8 +3201,8 @@ qemuDomainDefNamespaceParse(xmlDocPtr xml ATTRIBUTE_UNUSED,
|
||||||
xmlXPathContextPtr ctxt,
|
xmlXPathContextPtr ctxt,
|
||||||
void **data)
|
void **data)
|
||||||
{
|
{
|
||||||
qemuDomainXmlNsDefPtr cmd = NULL;
|
qemuDomainXmlNsDefPtr nsdata = NULL;
|
||||||
bool uses_qemu_ns = false;
|
int ret = -1;
|
||||||
|
|
||||||
if (xmlXPathRegisterNs(ctxt, BAD_CAST "qemu", BAD_CAST QEMU_NAMESPACE_HREF) < 0) {
|
if (xmlXPathRegisterNs(ctxt, BAD_CAST "qemu", BAD_CAST QEMU_NAMESPACE_HREF) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
@ -3211,26 +3211,21 @@ qemuDomainDefNamespaceParse(xmlDocPtr xml ATTRIBUTE_UNUSED,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC(cmd) < 0)
|
if (VIR_ALLOC(nsdata) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (qemuDomainDefNamespaceParseCommandlineArgs(cmd, ctxt) < 0 ||
|
if (qemuDomainDefNamespaceParseCommandlineArgs(nsdata, ctxt) < 0 ||
|
||||||
qemuDomainDefNamespaceParseCommandlineEnv(cmd, ctxt) < 0)
|
qemuDomainDefNamespaceParseCommandlineEnv(nsdata, ctxt) < 0)
|
||||||
goto error;
|
goto cleanup;
|
||||||
|
|
||||||
if (cmd->num_args > 0 || cmd->num_env > 0)
|
if (nsdata->num_args > 0 || nsdata->num_env > 0)
|
||||||
uses_qemu_ns = true;
|
VIR_STEAL_PTR(*data, nsdata);
|
||||||
|
|
||||||
if (uses_qemu_ns)
|
ret = 0;
|
||||||
*data = cmd;
|
|
||||||
else
|
|
||||||
VIR_FREE(cmd);
|
|
||||||
|
|
||||||
return 0;
|
cleanup:
|
||||||
|
qemuDomainDefNamespaceFree(nsdata);
|
||||||
error:
|
return ret;
|
||||||
qemuDomainDefNamespaceFree(cmd);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
Loading…
Reference in New Issue