From 3feb7797cfe7ac9cfd05fbc5d008527b1a88c06a Mon Sep 17 00:00:00 2001 Message-Id: <3feb7797cfe7ac9cfd05fbc5d008527b1a88c06a@dist-git> From: Jiri Denemark Date: Wed, 17 May 2017 16:39:16 +0200 Subject: [PATCH] cpu_ppc64: Add support for host-model on POWER9 Signed-off-by: Jiri Denemark (cherry picked from commit 5c8c2d1633f3d2500e49132296793fc267648d2b) https://bugzilla.redhat.com/show_bug.cgi?id=1450770 Signed-off-by: Jiri Denemark --- src/cpu/cpu_ppc64.c | 8 ++++---- .../qemuxml2argv-pseries-cpu-compat-power9.args | 24 ++++++++++++++++++++++ .../qemuxml2argv-pseries-cpu-compat-power9.xml | 21 +++++++++++++++++++ tests/qemuxml2argvtest.c | 7 +++++++ tests/testutilsqemu.c | 13 +++++++++++- tests/testutilsqemu.h | 1 + 6 files changed, 69 insertions(+), 5 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat-power9.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat-power9.xml diff --git a/src/cpu/cpu_ppc64.c b/src/cpu/cpu_ppc64.c index f64592b558..bf08599049 100644 --- a/src/cpu/cpu_ppc64.c +++ b/src/cpu/cpu_ppc64.c @@ -92,22 +92,22 @@ ppc64CheckCompatibilityMode(const char *host_model, if (!compat_mode) return VIR_CPU_COMPARE_IDENTICAL; - /* Valid host CPUs: POWER6, POWER7, POWER8 */ + /* Valid host CPUs: POWER6, POWER7, POWER8, POWER9 */ if (!STRPREFIX(host_model, "POWER") || !(tmp = (char *) host_model + strlen("POWER")) || virStrToLong_i(tmp, NULL, 10, &host) < 0 || - host < 6 || host > 8) { + host < 6 || host > 9) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Host CPU does not support compatibility modes")); goto out; } - /* Valid compatibility modes: power6, power7, power8 */ + /* Valid compatibility modes: power6, power7, power8, power9 */ if (!STRPREFIX(compat_mode, "power") || !(tmp = (char *) compat_mode + strlen("power")) || virStrToLong_i(tmp, NULL, 10, &compat) < 0 || - compat < 6 || compat > 8) { + compat < 6 || compat > 9) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Unknown compatibility mode %s"), compat_mode); diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat-power9.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat-power9.args new file mode 100644 index 0000000000..af93d63dc9 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat-power9.args @@ -0,0 +1,24 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-ppc64 \ +-name QEMUGuest1 \ +-S \ +-M pseries \ +-cpu host,compat=power9 \ +-m 256 \ +-smp 4,sockets=4,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-nographic \ +-nodefconfig \ +-nodefaults \ +-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\ +server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=readline \ +-boot c \ +-usb \ +-chardev pty,id=charserial0 \ +-device spapr-vty,chardev=charserial0,reg=0x30000000 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat-power9.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat-power9.xml new file mode 100644 index 0000000000..30ab5c2679 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat-power9.xml @@ -0,0 +1,21 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 4 + + hvm + + + power9 + + + + /usr/bin/qemu-system-ppc64 + +
+ + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 5ca27f105d..6ac24c9bb0 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1688,6 +1688,13 @@ mymain(void) QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG); DO_TEST("pseries-cpu-le", QEMU_CAPS_KVM, QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG); + DO_TEST_FAILURE("pseries-cpu-compat-power9", QEMU_CAPS_KVM); + + qemuTestSetHostCPU(driver.caps, cpuPower9); + DO_TEST("pseries-cpu-compat-power9", + QEMU_CAPS_KVM, QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG); + qemuTestSetHostCPU(driver.caps, NULL); + qemuTestSetHostArch(driver.caps, VIR_ARCH_NONE); DO_TEST("pseries-panic-missing", diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index 4cc482dfb0..fe2941efbf 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -17,6 +17,7 @@ virCPUDefPtr cpuDefault; virCPUDefPtr cpuHaswell; virCPUDefPtr cpuPower8; +virCPUDefPtr cpuPower9; static virCPUFeatureDef cpuDefaultFeatures[] = { { (char *) "ds", -1 }, @@ -94,6 +95,15 @@ static virCPUDef cpuPower8Data = { .threads = 8, }; +static virCPUDef cpuPower9Data = { + .type = VIR_CPU_TYPE_HOST, + .arch = VIR_ARCH_PPC64, + .model = (char *) "POWER9", + .sockets = 1, + .cores = 16, + .threads = 1, +}; + static virCapsGuestMachinePtr *testQemuAllocMachines(int *nmachines) { virCapsGuestMachinePtr *machines; @@ -334,7 +344,8 @@ virCapsPtr testQemuCapsInit(void) if (!(cpuDefault = virCPUDefCopy(&cpuDefaultData)) || !(cpuHaswell = virCPUDefCopy(&cpuHaswellData)) || - !(cpuPower8 = virCPUDefCopy(&cpuPower8Data))) + !(cpuPower8 = virCPUDefCopy(&cpuPower8Data)) || + !(cpuPower9 = virCPUDefCopy(&cpuPower9Data))) goto cleanup; qemuTestSetHostCPU(caps, NULL); diff --git a/tests/testutilsqemu.h b/tests/testutilsqemu.h index 047a64d1ac..781b435cc2 100644 --- a/tests/testutilsqemu.h +++ b/tests/testutilsqemu.h @@ -21,6 +21,7 @@ virQEMUCapsPtr qemuTestParseCapabilities(virCapsPtr caps, extern virCPUDefPtr cpuDefault; extern virCPUDefPtr cpuHaswell; extern virCPUDefPtr cpuPower8; +extern virCPUDefPtr cpuPower9; void qemuTestSetHostArch(virCapsPtr caps, virArch arch); -- 2.13.1