This function exists because of 5276ec712a44b36. But it is
missing initial check just like virQEMUCapsInitHostCPUModel()
has.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_capabilities.c | 4 ++++
src/qemu/qemu_capspriv.h | 1 +
tests/qemuxml2argvtest.c | 6 ++++--
3 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 26969ed3dc..949c32ddd2 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2846,10 +2846,14 @@ virQEMUCapsNewHostCPUModel(void)
void
virQEMUCapsFreeHostCPUModel(virQEMUCapsPtr qemuCaps,
+ virArch hostArch,
virDomainVirtType type)
{
virQEMUCapsHostCPUDataPtr cpuData = virQEMUCapsGetHostCPUData(qemuCaps, type);
+ if (!virQEMUCapsGuestIsNative(hostArch, qemuCaps->arch))
+ return;
+
virQEMUCapsHostCPUDataClearModels(cpuData);
}
diff --git a/src/qemu/qemu_capspriv.h b/src/qemu/qemu_capspriv.h
index fea039ef3a..989d183c6c 100644
--- a/src/qemu/qemu_capspriv.h
+++ b/src/qemu/qemu_capspriv.h
@@ -58,6 +58,7 @@ virQEMUCapsSetArch(virQEMUCapsPtr qemuCaps,
void
virQEMUCapsFreeHostCPUModel(virQEMUCapsPtr qemuCaps,
+ virArch hostArch,
virDomainVirtType type);
void
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 14a994523f..4984028d38 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -388,8 +388,10 @@ testUpdateQEMUCaps(const struct testInfo *info,
if (testAddCPUModels(info->qemuCaps, info->skipLegacyCPUs) < 0)
goto cleanup;
- virQEMUCapsFreeHostCPUModel(info->qemuCaps, VIR_DOMAIN_VIRT_KVM);
- virQEMUCapsFreeHostCPUModel(info->qemuCaps, VIR_DOMAIN_VIRT_QEMU);
+ virQEMUCapsFreeHostCPUModel(info->qemuCaps, caps->host.arch,
+ VIR_DOMAIN_VIRT_KVM);
+ virQEMUCapsFreeHostCPUModel(info->qemuCaps, caps->host.arch,
+ VIR_DOMAIN_VIRT_QEMU);
virQEMUCapsInitHostCPUModel(info->qemuCaps, caps->host.arch,
VIR_DOMAIN_VIRT_KVM);
--
2.16.4