>From 5846f6fbb787b2c3dfbe25d456502c4501f329a8 Mon Sep 17 00:00:00 2001
From: Boris Fiuczynski <fiuczy@linux.ibm.com>
Date: Mon, 18 Nov 2019 17:41:02 +0100
Subject: [PATCH] qemuxml2*test: Add test cases for not setting default CPU
 models on s390

Adding tests for QEMU v2.7.0 which was the last version without CPU model
support on s390 to ensure the default CPU model is not automatically added.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
---
 ...lt-cpu-kvm-ccw-virtio-2.7.s390x-2.7.0.args | 29 +++++++++++++++++++
 .../s390-default-cpu-kvm-ccw-virtio-2.7.xml   | 16 ++++++++++
 tests/qemuxml2argvtest.c                      |  1 +
 ...ult-cpu-kvm-ccw-virtio-2.7.s390x-2.7.0.xml | 23 +++++++++++++++
 tests/qemuxml2xmltest.c                       |  1 +
 5 files changed, 70 insertions(+)
 create mode 100644 tests/qemuxml2argvdata/s390-default-cpu-kvm-ccw-virtio-2.7.s390x-2.7.0.args
 create mode 100644 tests/qemuxml2argvdata/s390-default-cpu-kvm-ccw-virtio-2.7.xml
 create mode 100644 tests/qemuxml2xmloutdata/s390-default-cpu-kvm-ccw-virtio-2.7.s390x-2.7.0.xml

diff --git a/tests/qemuxml2argvdata/s390-default-cpu-kvm-ccw-virtio-2.7.s390x-2.7.0.args b/tests/qemuxml2argvdata/s390-default-cpu-kvm-ccw-virtio-2.7.s390x-2.7.0.args
new file mode 100644
index 0000000000..431de90bcc
--- /dev/null
+++ b/tests/qemuxml2argvdata/s390-default-cpu-kvm-ccw-virtio-2.7.s390x-2.7.0.args
@@ -0,0 +1,29 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/tmp/lib/domain--1-test \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/tmp/lib/domain--1-test/.local/share \
+XDG_CACHE_HOME=/tmp/lib/domain--1-test/.cache \
+XDG_CONFIG_HOME=/tmp/lib/domain--1-test/.config \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-s390x \
+-name guest=test,debug-threads=on \
+-S \
+-object secret,id=masterKey0,format=raw,\
+file=/tmp/lib/domain--1-test/master-key.aes \
+-machine s390-ccw-virtio-2.7,accel=kvm,usb=off,dump-guest-core=off \
+-m 256 \
+-realtime mlock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid 9aa4b45c-b9dd-45ef-91fe-862b27b4231f \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-test/monitor.sock,server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-boot strict=on \
+-device virtio-balloon-ccw,id=balloon0,devno=fe.0.0000 \
+-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/s390-default-cpu-kvm-ccw-virtio-2.7.xml b/tests/qemuxml2argvdata/s390-default-cpu-kvm-ccw-virtio-2.7.xml
new file mode 100644
index 0000000000..5051c861ee
--- /dev/null
+++ b/tests/qemuxml2argvdata/s390-default-cpu-kvm-ccw-virtio-2.7.xml
@@ -0,0 +1,16 @@
+<domain type='kvm'>
+  <name>test</name>
+  <uuid>9aa4b45c-b9dd-45ef-91fe-862b27b4231f</uuid>
+  <memory>262144</memory>
+  <currentMemory>262144</currentMemory>
+  <os>
+    <type arch='s390x' machine='s390-ccw-virtio'>hvm</type>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-s390x</emulator>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index e3e2bc5e63..753c588f95 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -3031,6 +3031,7 @@ mymain(void)
     DO_TEST_CAPS_ARCH_LATEST("ppc64-default-cpu-tcg-pseries-3.1", "ppc64");
     DO_TEST_CAPS_ARCH_LATEST("ppc64-default-cpu-kvm-pseries-4.2", "ppc64");
     DO_TEST_CAPS_ARCH_LATEST("ppc64-default-cpu-tcg-pseries-4.2", "ppc64");
+    DO_TEST_CAPS_ARCH_VER("s390-default-cpu-kvm-ccw-virtio-2.7", "s390x", "2.7.0");
     DO_TEST_CAPS_ARCH_LATEST("s390-default-cpu-kvm-ccw-virtio-4.2", "s390x");
     DO_TEST_CAPS_ARCH_LATEST("s390-default-cpu-tcg-ccw-virtio-4.2", "s390x");
     DO_TEST_CAPS_ARCH_LATEST("x86_64-default-cpu-kvm-pc-4.2", "x86_64");
diff --git a/tests/qemuxml2xmloutdata/s390-default-cpu-kvm-ccw-virtio-2.7.s390x-2.7.0.xml b/tests/qemuxml2xmloutdata/s390-default-cpu-kvm-ccw-virtio-2.7.s390x-2.7.0.xml
new file mode 100644
index 0000000000..9ae5356bf3
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/s390-default-cpu-kvm-ccw-virtio-2.7.s390x-2.7.0.xml
@@ -0,0 +1,23 @@
+<domain type='kvm'>
+  <name>test</name>
+  <uuid>9aa4b45c-b9dd-45ef-91fe-862b27b4231f</uuid>
+  <memory unit='KiB'>262144</memory>
+  <currentMemory unit='KiB'>262144</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='s390x' machine='s390-ccw-virtio-2.7'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-s390x</emulator>
+    <controller type='pci' index='0' model='pci-root'/>
+    <memballoon model='virtio'>
+      <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0000'/>
+    </memballoon>
+    <panic model='s390'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 64a6971740..9bf1969047 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -1349,6 +1349,7 @@ mymain(void)
     DO_TEST_CAPS_ARCH_LATEST("ppc64-default-cpu-tcg-pseries-3.1", "ppc64");
     DO_TEST_CAPS_ARCH_LATEST("ppc64-default-cpu-kvm-pseries-4.2", "ppc64");
     DO_TEST_CAPS_ARCH_LATEST("ppc64-default-cpu-tcg-pseries-4.2", "ppc64");
+    DO_TEST_CAPS_ARCH_VER("s390-default-cpu-kvm-ccw-virtio-2.7", "s390x", "2.7.0");
     DO_TEST_CAPS_ARCH_LATEST("s390-default-cpu-kvm-ccw-virtio-4.2", "s390x");
     DO_TEST_CAPS_ARCH_LATEST("s390-default-cpu-tcg-ccw-virtio-4.2", "s390x");
     DO_TEST_CAPS_ARCH_LATEST("x86_64-default-cpu-kvm-pc-4.2", "x86_64");
-- 
2.21.0

