mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 05:17:59 +03:00
qemuBuildNumaArgStr: Simplify @nodeBackends
Instead of array of pointers to individual buffers it can be array of buffers directly. This also fixes the following memleak: ==22516== 96 bytes in 4 blocks are definitely lost in loss record 166 of 195 ==22516== at 0x4C2EF26: calloc (vg_replace_malloc.c:711) ==22516== by 0x5D2C7D5: virAlloc (viralloc.c:144) ==22516== by 0x56FAABD: qemuBuildNumaArgStr (qemu_command.c:7543) ==22516== by 0x5701835: qemuBuildCommandLine (qemu_command.c:10112) ==22516== by 0x575D794: qemuProcessCreatePretendCmd (qemu_process.c:6568) ==22516== by 0x113338: testCompareXMLToArgv (qemuxml2argvtest.c:549) ==22516== by 0x138CA3: virTestRun (testutils.c:180) ==22516== by 0x136CD1: mymain (qemuxml2argvtest.c:2825) ==22516== by 0x13AD58: virTestMain (testutils.c:1118) ==22516== by 0x137351: main (qemuxml2argvtest.c:2874) Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
d0498881a0
commit
7d34949b07
@ -7478,7 +7478,7 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg,
|
||||
virQEMUCapsPtr qemuCaps = priv->qemuCaps;
|
||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
||||
char *cpumask = NULL, *tmpmask = NULL, *next = NULL;
|
||||
virBufferPtr *nodeBackends = NULL;
|
||||
virBufferPtr nodeBackends = NULL;
|
||||
bool needBackend = false;
|
||||
int rc;
|
||||
int ret = -1;
|
||||
@ -7540,11 +7540,8 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg,
|
||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_RAM) ||
|
||||
virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_FILE)) {
|
||||
|
||||
if (VIR_ALLOC(nodeBackends[i]) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if ((rc = qemuBuildMemoryCellBackendStr(def, cfg, i, priv,
|
||||
nodeBackends[i])) < 0)
|
||||
&nodeBackends[i])) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (rc == 0)
|
||||
@ -7578,7 +7575,7 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg,
|
||||
|
||||
if (needBackend) {
|
||||
virCommandAddArg(cmd, "-object");
|
||||
virCommandAddArgBuffer(cmd, nodeBackends[i]);
|
||||
virCommandAddArgBuffer(cmd, &nodeBackends[i]);
|
||||
}
|
||||
|
||||
virCommandAddArg(cmd, "-numa");
|
||||
@ -7642,7 +7639,7 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg,
|
||||
|
||||
if (nodeBackends) {
|
||||
for (i = 0; i < ncells; i++)
|
||||
virBufferFreeAndReset(nodeBackends[i]);
|
||||
virBufferFreeAndReset(&nodeBackends[i]);
|
||||
|
||||
VIR_FREE(nodeBackends);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user