Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
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 f64592b55..bf0859904 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 000000000..af93d63dc
--- /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 000000000..30ab5c267
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-cpu-compat-power9.xml
@@ -0,0 +1,21 @@
+<domain type='kvm'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>4</vcpu>
+ <os>
+ <type arch='ppc64' machine='pseries'>hvm</type>
+ </os>
+ <cpu mode='host-model'>
+ <model>power9</model>
+ </cpu>
+ <clock offset='utc'/>
+ <devices>
+ <emulator>/usr/bin/qemu-system-ppc64</emulator>
+ <console type='pty'>
+ <address type="spapr-vio"/>
+ </console>
+ <memballoon model="none"/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 426959857..669caa0e4 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1673,6 +1673,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 709e291bd..ee4853841 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,
+};
+
typedef enum {
TEST_UTILS_QEMU_BIN_I686,
TEST_UTILS_QEMU_BIN_X86_64,
@@ -467,7 +477,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 3393f5eb7..05e5651ae 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.0