1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-25 01:34:11 +03:00

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:
Peter Krempa 2019-06-17 16:10:12 +02:00
parent a858b77754
commit 8b0a389d2b

View File

@ -3201,8 +3201,8 @@ qemuDomainDefNamespaceParse(xmlDocPtr xml ATTRIBUTE_UNUSED,
xmlXPathContextPtr ctxt,
void **data)
{
qemuDomainXmlNsDefPtr cmd = NULL;
bool uses_qemu_ns = false;
qemuDomainXmlNsDefPtr nsdata = NULL;
int ret = -1;
if (xmlXPathRegisterNs(ctxt, BAD_CAST "qemu", BAD_CAST QEMU_NAMESPACE_HREF) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@ -3211,26 +3211,21 @@ qemuDomainDefNamespaceParse(xmlDocPtr xml ATTRIBUTE_UNUSED,
return -1;
}
if (VIR_ALLOC(cmd) < 0)
if (VIR_ALLOC(nsdata) < 0)
return -1;
if (qemuDomainDefNamespaceParseCommandlineArgs(cmd, ctxt) < 0 ||
qemuDomainDefNamespaceParseCommandlineEnv(cmd, ctxt) < 0)
goto error;
if (qemuDomainDefNamespaceParseCommandlineArgs(nsdata, ctxt) < 0 ||
qemuDomainDefNamespaceParseCommandlineEnv(nsdata, ctxt) < 0)
goto cleanup;
if (cmd->num_args > 0 || cmd->num_env > 0)
uses_qemu_ns = true;
if (nsdata->num_args > 0 || nsdata->num_env > 0)
VIR_STEAL_PTR(*data, nsdata);
if (uses_qemu_ns)
*data = cmd;
else
VIR_FREE(cmd);
ret = 0;
return 0;
error:
qemuDomainDefNamespaceFree(cmd);
return -1;
cleanup:
qemuDomainDefNamespaceFree(nsdata);
return ret;
}
static int