mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 12:35:17 +00:00
Fix more OOM handling bugs
* src/qemu_conf.c: Fix leak of values upon OOM * src/xend_internal.c: Fix missing check for OOM failure * tests/qemuargv2xmltest.c, tests/qemuxml2argvtest.c: Free stateDir upon exit to avoid leak
This commit is contained in:
parent
755915ea4b
commit
cbe63e529d
@ -1848,6 +1848,8 @@ int qemudBuildCommandLine(virConnectPtr conn,
|
||||
continue;
|
||||
}
|
||||
|
||||
ADD_ARG_SPACE;
|
||||
|
||||
if (idx < 0) {
|
||||
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
|
||||
_("unsupported disk type '%s'"), disk->dst);
|
||||
@ -1905,7 +1907,10 @@ int qemudBuildCommandLine(virConnectPtr conn,
|
||||
|
||||
optstr = virBufferContentAndReset(&opt);
|
||||
|
||||
ADD_ARG_LIT("-drive");
|
||||
if ((qargv[qargc++] = strdup("-drive")) == NULL) {
|
||||
VIR_FREE(optstr);
|
||||
goto no_memory;
|
||||
}
|
||||
ADD_ARG(optstr);
|
||||
}
|
||||
} else {
|
||||
@ -1961,6 +1966,7 @@ int qemudBuildCommandLine(virConnectPtr conn,
|
||||
|
||||
net->vlan = i;
|
||||
|
||||
ADD_ARG_SPACE;
|
||||
if ((qemuCmdFlags & QEMUD_CMD_FLAG_NET_NAME) &&
|
||||
qemuAssignNetNames(def, net) < 0)
|
||||
goto no_memory;
|
||||
@ -1968,9 +1974,14 @@ int qemudBuildCommandLine(virConnectPtr conn,
|
||||
if (qemuBuildNicStr(conn, net, NULL, ',', net->vlan, &nic) < 0)
|
||||
goto error;
|
||||
|
||||
ADD_ARG_LIT("-net");
|
||||
if ((qargv[qargc++] = strdup("-net")) == NULL) {
|
||||
VIR_FREE(nic);
|
||||
goto no_memory;
|
||||
}
|
||||
ADD_ARG(nic);
|
||||
|
||||
|
||||
ADD_ARG_SPACE;
|
||||
if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK ||
|
||||
net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) {
|
||||
int tapfd = qemudNetworkIfaceConnect(conn, driver, net, qemuCmdFlags);
|
||||
@ -1994,7 +2005,10 @@ int qemudBuildCommandLine(virConnectPtr conn,
|
||||
goto error;
|
||||
}
|
||||
|
||||
ADD_ARG_LIT("-net");
|
||||
if ((qargv[qargc++] = strdup("-net")) == NULL) {
|
||||
VIR_FREE(host);
|
||||
goto no_memory;
|
||||
}
|
||||
ADD_ARG(host);
|
||||
|
||||
VIR_FREE(tapfd_name);
|
||||
@ -2362,6 +2376,7 @@ static int qemuStringToArgvEnv(const char *args,
|
||||
goto no_memory;
|
||||
for (i = 0 ; i < envend ; i++) {
|
||||
progenv[i] = arglist[i];
|
||||
arglist[i] = NULL;
|
||||
}
|
||||
progenv[i] = NULL;
|
||||
}
|
||||
|
@ -5226,6 +5226,9 @@ xenDaemonFormatSxprChr(virConnectPtr conn,
|
||||
break;
|
||||
}
|
||||
|
||||
if (virBufferError(buf))
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -5549,6 +5552,9 @@ xenDaemonFormatSxprSound(virConnectPtr conn,
|
||||
virBufferVSprintf(buf, "%s%s", i ? "," : "", str);
|
||||
}
|
||||
|
||||
if (virBufferError(buf))
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -223,6 +223,7 @@ mymain(int argc, char **argv)
|
||||
DO_TEST_FULL("restore-v2", QEMUD_CMD_FLAG_MIGRATE_QEMU_EXEC, "exec:cat");
|
||||
DO_TEST_FULL("migrate", QEMUD_CMD_FLAG_MIGRATE_QEMU_TCP, "tcp:10.0.0.1:5000");
|
||||
|
||||
free(driver.stateDir);
|
||||
virCapabilitiesFree(driver.caps);
|
||||
|
||||
return(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
|
@ -280,6 +280,7 @@ mymain(int argc, char **argv)
|
||||
DO_TEST_FULL("restore-v2", QEMUD_CMD_FLAG_MIGRATE_QEMU_EXEC, "exec:cat");
|
||||
DO_TEST_FULL("migrate", QEMUD_CMD_FLAG_MIGRATE_QEMU_TCP, "tcp:10.0.0.1:5000");
|
||||
|
||||
free(driver.stateDir);
|
||||
virCapabilitiesFree(driver.caps);
|
||||
|
||||
return(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
|
Loading…
x
Reference in New Issue
Block a user