mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
qemuConnectDomainXMLToNative: Refactor cleanup
Automatically free the 'vm' temporary domain object and remove the 'cleanup' label and 'ret' helper variable. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
343920794d
commit
d810ae2fae
@ -6337,30 +6337,29 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
|
|||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
virQEMUDriver *driver = conn->privateData;
|
virQEMUDriver *driver = conn->privateData;
|
||||||
virDomainObj *vm = NULL;
|
g_autoptr(virDomainObj) vm = NULL;
|
||||||
g_autoptr(virCommand) cmd = NULL;
|
g_autoptr(virCommand) cmd = NULL;
|
||||||
unsigned int commandlineflags = QEMU_BUILD_COMMAND_LINE_CPUS_RUNNING;
|
unsigned int commandlineflags = QEMU_BUILD_COMMAND_LINE_CPUS_RUNNING;
|
||||||
char *ret = NULL;
|
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
virCheckFlags(0, NULL);
|
virCheckFlags(0, NULL);
|
||||||
|
|
||||||
if (virConnectDomainXMLToNativeEnsureACL(conn) < 0)
|
if (virConnectDomainXMLToNativeEnsureACL(conn) < 0)
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
if (STRNEQ(format, QEMU_CONFIG_FORMAT_ARGV)) {
|
if (STRNEQ(format, QEMU_CONFIG_FORMAT_ARGV)) {
|
||||||
virReportError(VIR_ERR_INVALID_ARG,
|
virReportError(VIR_ERR_INVALID_ARG,
|
||||||
_("unsupported config type %s"), format);
|
_("unsupported config type %s"), format);
|
||||||
goto cleanup;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(vm = virDomainObjNew(driver->xmlopt)))
|
if (!(vm = virDomainObjNew(driver->xmlopt)))
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
if (!(vm->def = virDomainDefParseString(xmlData, driver->xmlopt, NULL,
|
if (!(vm->def = virDomainDefParseString(xmlData, driver->xmlopt, NULL,
|
||||||
VIR_DOMAIN_DEF_PARSE_INACTIVE |
|
VIR_DOMAIN_DEF_PARSE_INACTIVE |
|
||||||
VIR_DOMAIN_DEF_PARSE_ABI_UPDATE)))
|
VIR_DOMAIN_DEF_PARSE_ABI_UPDATE)))
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
/* Since we're just exporting args, we can't do bridge/network/direct
|
/* Since we're just exporting args, we can't do bridge/network/direct
|
||||||
* setups, since libvirt will normally create TAP/macvtap devices
|
* setups, since libvirt will normally create TAP/macvtap devices
|
||||||
@ -6372,7 +6371,7 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
|
|||||||
virDomainNetDef *newNet = virDomainNetDefNew(driver->xmlopt);
|
virDomainNetDef *newNet = virDomainNetDefNew(driver->xmlopt);
|
||||||
|
|
||||||
if (!newNet)
|
if (!newNet)
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
newNet->type = VIR_DOMAIN_NET_TYPE_ETHERNET;
|
newNet->type = VIR_DOMAIN_NET_TYPE_ETHERNET;
|
||||||
newNet->info.bootIndex = net->info.bootIndex;
|
newNet->info.bootIndex = net->info.bootIndex;
|
||||||
@ -6387,21 +6386,17 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
|
|||||||
|
|
||||||
if (qemuProcessCreatePretendCmdPrepare(driver, vm, NULL,
|
if (qemuProcessCreatePretendCmdPrepare(driver, vm, NULL,
|
||||||
VIR_QEMU_PROCESS_START_COLD) < 0)
|
VIR_QEMU_PROCESS_START_COLD) < 0)
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
if (qemuConnectDomainXMLToNativePrepareHost(vm) < 0)
|
if (qemuConnectDomainXMLToNativePrepareHost(vm) < 0)
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
if (!(cmd = qemuProcessCreatePretendCmdBuild(driver, vm, NULL,
|
if (!(cmd = qemuProcessCreatePretendCmdBuild(driver, vm, NULL,
|
||||||
qemuCheckFips(vm),
|
qemuCheckFips(vm),
|
||||||
commandlineflags)))
|
commandlineflags)))
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
ret = virCommandToString(cmd, false);
|
return virCommandToString(cmd, false);
|
||||||
|
|
||||||
cleanup:
|
|
||||||
virObjectUnref(vm);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user