mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 12:35:17 +00:00
qemu: use automatic cleanup for virCommand
Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
eff68d3637
commit
d9fdc65a51
@ -6315,7 +6315,7 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
|
|||||||
{
|
{
|
||||||
virQEMUDriver *driver = conn->privateData;
|
virQEMUDriver *driver = conn->privateData;
|
||||||
virDomainObj *vm = NULL;
|
virDomainObj *vm = NULL;
|
||||||
virCommand *cmd = NULL;
|
g_autoptr(virCommand) cmd = NULL;
|
||||||
char *ret = NULL;
|
char *ret = NULL;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
@ -6375,7 +6375,6 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
|
|||||||
ret = virCommandToString(cmd, false);
|
ret = virCommandToString(cmd, false);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virCommandFree(cmd);
|
|
||||||
virObjectUnref(vm);
|
virObjectUnref(vm);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -320,7 +320,7 @@ qemuCreateInBridgePortWithHelper(virQEMUDriverConfig *cfg,
|
|||||||
int *tapfd,
|
int *tapfd,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
virCommand *cmd;
|
g_autoptr(virCommand) cmd = NULL;
|
||||||
char *errbuf = NULL, *cmdstr = NULL;
|
char *errbuf = NULL, *cmdstr = NULL;
|
||||||
int pair[2] = { -1, -1 };
|
int pair[2] = { -1, -1 };
|
||||||
|
|
||||||
@ -387,7 +387,6 @@ qemuCreateInBridgePortWithHelper(virQEMUDriverConfig *cfg,
|
|||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(cmdstr);
|
VIR_FREE(cmdstr);
|
||||||
VIR_FREE(errbuf);
|
VIR_FREE(errbuf);
|
||||||
virCommandFree(cmd);
|
|
||||||
VIR_FORCE_CLOSE(pair[0]);
|
VIR_FORCE_CLOSE(pair[0]);
|
||||||
return *tapfd < 0 ? -1 : 0;
|
return *tapfd < 0 ? -1 : 0;
|
||||||
}
|
}
|
||||||
|
@ -793,7 +793,7 @@ static void
|
|||||||
qemuTPMEmulatorStop(const char *swtpmStateDir,
|
qemuTPMEmulatorStop(const char *swtpmStateDir,
|
||||||
const char *shortName)
|
const char *shortName)
|
||||||
{
|
{
|
||||||
virCommand *cmd;
|
g_autoptr(virCommand) cmd = NULL;
|
||||||
g_autofree char *pathname = NULL;
|
g_autofree char *pathname = NULL;
|
||||||
g_autofree char *errbuf = NULL;
|
g_autofree char *errbuf = NULL;
|
||||||
g_autofree char *swtpm_ioctl = virTPMGetSwtpmIoctl();
|
g_autofree char *swtpm_ioctl = virTPMGetSwtpmIoctl();
|
||||||
@ -817,8 +817,6 @@ qemuTPMEmulatorStop(const char *swtpmStateDir,
|
|||||||
|
|
||||||
ignore_value(virCommandRun(cmd, NULL));
|
ignore_value(virCommandRun(cmd, NULL));
|
||||||
|
|
||||||
virCommandFree(cmd);
|
|
||||||
|
|
||||||
/* clean up the socket */
|
/* clean up the socket */
|
||||||
unlink(pathname);
|
unlink(pathname);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user