Changing a host architecture or a CPU is not as easy as assigning a new value to the appropriate element in virCaps since there is a relation between the CPU and host architecture (we don't really want to test anything on an AArch64 host with core2duo CPU). This patch introduces qemuTestSetHostArch and qemuTestSetHostCPU helpers which will make sure the host architecture matches the host CPU. Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx> --- Notes: Version 2: - cpuPower8 separated into a new patch - switched to qemuTestSetHostCPU() in testQemuCapsInit() tests/testutilsqemu.c | 37 ++++++++++++++++++++++++++++++++----- tests/testutilsqemu.h | 7 +++++-- 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index 11dd20e..b569e0d 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -334,7 +334,7 @@ virCapsPtr testQemuCapsInit(void) !(cpuHaswell = virCPUDefCopy(&cpuHaswellData))) goto cleanup; - caps->host.cpu = cpuDefault; + qemuTestSetHostCPU(caps, NULL); caps->host.nnumaCell_max = 4; @@ -440,15 +440,42 @@ virCapsPtr testQemuCapsInit(void) cleanup: virCapabilitiesFreeMachines(machines, nmachines); - if (caps->host.cpu != cpuDefault) - virCPUDefFree(cpuDefault); - if (caps->host.cpu != cpuHaswell) - virCPUDefFree(cpuHaswell); + caps->host.cpu = NULL; + virCPUDefFree(cpuDefault); + virCPUDefFree(cpuHaswell); virObjectUnref(caps); return NULL; } +void +qemuTestSetHostArch(virCapsPtr caps, + virArch arch) +{ + if (arch == VIR_ARCH_NONE) + arch = VIR_ARCH_X86_64; + caps->host.arch = arch; + qemuTestSetHostCPU(caps, NULL); +} + + +void +qemuTestSetHostCPU(virCapsPtr caps, + virCPUDefPtr cpu) +{ + virArch arch = caps->host.arch; + + if (!cpu) { + if (ARCH_IS_X86(arch)) + cpu = cpuDefault; + } + + if (cpu) + caps->host.arch = cpu->arch; + caps->host.cpu = cpu; +} + + virQEMUCapsPtr qemuTestParseCapabilities(const char *capsFile) { diff --git a/tests/testutilsqemu.h b/tests/testutilsqemu.h index f2b71e9..7c678c9 100644 --- a/tests/testutilsqemu.h +++ b/tests/testutilsqemu.h @@ -19,8 +19,11 @@ virQEMUCapsPtr qemuTestParseCapabilities(const char *capsFile); extern virCPUDefPtr cpuDefault; extern virCPUDefPtr cpuHaswell; -void testQemuCapsSetCPU(virCapsPtr caps, - virCPUDefPtr hostCPU); + +void qemuTestSetHostArch(virCapsPtr caps, + virArch arch); +void qemuTestSetHostCPU(virCapsPtr caps, + virCPUDefPtr cpu); int qemuTestDriverInit(virQEMUDriver *driver); void qemuTestDriverFree(virQEMUDriver *driver); -- 2.10.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list