mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
testUpdateQEMUCaps: Don't leak host cpuData
When preparing qemuCaps for test cases the following is happening: qemuTestParseCapabilitiesArch() is called, which calls virQEMUCapsLoadCache() which in turn calls virQEMUCapsInitHostCPUModel() which sets qemuCaps->kvmCPU and qemuCaps->tcgCPU. But then the code tries to update the capabilities: testCompareXMLToArgv() calls testUpdateQEMUCaps() which calls virQEMUCapsInitHostCPUModel() again overwriting previously allocated memory. The solution is to free host cpuData in testUpdateQEMUCaps(). Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
cc9c75f562
commit
5276ec712a
@ -1516,12 +1516,19 @@ virQEMUCapsHostCPUDataCopy(virQEMUCapsHostCPUDataPtr dst,
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
virQEMUCapsHostCPUDataClear(virQEMUCapsHostCPUDataPtr cpuData)
|
virQEMUCapsHostCPUDataClearModels(virQEMUCapsHostCPUDataPtr cpuData)
|
||||||
{
|
{
|
||||||
qemuMonitorCPUModelInfoFree(cpuData->info);
|
|
||||||
virCPUDefFree(cpuData->reported);
|
virCPUDefFree(cpuData->reported);
|
||||||
virCPUDefFree(cpuData->migratable);
|
virCPUDefFree(cpuData->migratable);
|
||||||
virCPUDefFree(cpuData->full);
|
virCPUDefFree(cpuData->full);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
virQEMUCapsHostCPUDataClear(virQEMUCapsHostCPUDataPtr cpuData)
|
||||||
|
{
|
||||||
|
qemuMonitorCPUModelInfoFree(cpuData->info);
|
||||||
|
virQEMUCapsHostCPUDataClearModels(cpuData);
|
||||||
|
|
||||||
memset(cpuData, 0, sizeof(*cpuData));
|
memset(cpuData, 0, sizeof(*cpuData));
|
||||||
}
|
}
|
||||||
@ -2834,6 +2841,16 @@ virQEMUCapsNewHostCPUModel(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
virQEMUCapsFreeHostCPUModel(virQEMUCapsPtr qemuCaps,
|
||||||
|
virDomainVirtType type)
|
||||||
|
{
|
||||||
|
virQEMUCapsHostCPUDataPtr cpuData = virQEMUCapsGetHostCPUData(qemuCaps, type);
|
||||||
|
|
||||||
|
virQEMUCapsHostCPUDataClearModels(cpuData);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
virQEMUCapsInitHostCPUModel(virQEMUCapsPtr qemuCaps,
|
virQEMUCapsInitHostCPUModel(virQEMUCapsPtr qemuCaps,
|
||||||
virArch hostArch,
|
virArch hostArch,
|
||||||
|
@ -56,6 +56,10 @@ void
|
|||||||
virQEMUCapsSetArch(virQEMUCapsPtr qemuCaps,
|
virQEMUCapsSetArch(virQEMUCapsPtr qemuCaps,
|
||||||
virArch arch);
|
virArch arch);
|
||||||
|
|
||||||
|
void
|
||||||
|
virQEMUCapsFreeHostCPUModel(virQEMUCapsPtr qemuCaps,
|
||||||
|
virDomainVirtType type);
|
||||||
|
|
||||||
void
|
void
|
||||||
virQEMUCapsInitHostCPUModel(virQEMUCapsPtr qemuCaps,
|
virQEMUCapsInitHostCPUModel(virQEMUCapsPtr qemuCaps,
|
||||||
virArch hostArch,
|
virArch hostArch,
|
||||||
|
@ -388,6 +388,9 @@ testUpdateQEMUCaps(const struct testInfo *info,
|
|||||||
if (testAddCPUModels(info->qemuCaps, info->skipLegacyCPUs) < 0)
|
if (testAddCPUModels(info->qemuCaps, info->skipLegacyCPUs) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
virQEMUCapsFreeHostCPUModel(info->qemuCaps, VIR_DOMAIN_VIRT_KVM);
|
||||||
|
virQEMUCapsFreeHostCPUModel(info->qemuCaps, VIR_DOMAIN_VIRT_QEMU);
|
||||||
|
|
||||||
virQEMUCapsInitHostCPUModel(info->qemuCaps, caps->host.arch,
|
virQEMUCapsInitHostCPUModel(info->qemuCaps, caps->host.arch,
|
||||||
VIR_DOMAIN_VIRT_KVM);
|
VIR_DOMAIN_VIRT_KVM);
|
||||||
virQEMUCapsInitHostCPUModel(info->qemuCaps, caps->host.arch,
|
virQEMUCapsInitHostCPUModel(info->qemuCaps, caps->host.arch,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user