[PATCH 17/21] qemuxml2(xml|argv)test: Test real state of things with 'x86-kvm-32-on-64'

Peter Krempa posted 21 patches 4 years, 1 month ago
[PATCH 17/21] qemuxml2(xml|argv)test: Test real state of things with 'x86-kvm-32-on-64'
Posted by Peter Krempa 4 years, 1 month ago
As demonstrated by the qemuxml2xmltest DO_TEST_CAPS_LATEST data based on
the 'x86-kvm-32-on-64' test case the post parse CPU selection code which
fills in the CPU into the definition does not have exactly the same
logic as we used to have when the cpu model was picked when formatting
the commandline.

Change the qemuxml2argv test to use DO_TEST_CAPS_LATEST too as it
doesn't really make sense to test this on fake data.

This possibly shows that there's a regression/change in behaviour which
happened when the CPU code was changed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 ...gs => x86-kvm-32-on-64.x86_64-latest.args} | 14 +++++-----
 tests/qemuxml2argvtest.c                      |  2 +-
 .../x86-kvm-32-on-64.x86_64-latest.xml        | 27 +++++++++++++++++++
 tests/qemuxml2xmltest.c                       |  2 ++
 4 files changed, 38 insertions(+), 7 deletions(-)
 rename tests/qemuxml2argvdata/{x86-kvm-32-on-64.args => x86-kvm-32-on-64.x86_64-latest.args} (53%)
 create mode 100644 tests/qemuxml2xmloutdata/x86-kvm-32-on-64.x86_64-latest.xml

diff --git a/tests/qemuxml2argvdata/x86-kvm-32-on-64.args b/tests/qemuxml2argvdata/x86-kvm-32-on-64.x86_64-latest.args
similarity index 53%
rename from tests/qemuxml2argvdata/x86-kvm-32-on-64.args
rename to tests/qemuxml2argvdata/x86-kvm-32-on-64.x86_64-latest.args
index fdfd506495..fe326b6943 100644
--- a/tests/qemuxml2argvdata/x86-kvm-32-on-64.args
+++ b/tests/qemuxml2argvdata/x86-kvm-32-on-64.x86_64-latest.args
@@ -6,25 +6,27 @@ LOGNAME=test \
 XDG_DATA_HOME=/tmp/lib/domain--1-kvm/.local/share \
 XDG_CACHE_HOME=/tmp/lib/domain--1-kvm/.cache \
 XDG_CONFIG_HOME=/tmp/lib/domain--1-kvm/.config \
-QEMU_AUDIO_DRV=none \
 /usr/bin/qemu-system-x86_64 \
 -name guest=kvm,debug-threads=on \
 -S \
--object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-kvm/master-key.aes \
--machine pc,usb=off,dump-guest-core=off \
+-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tmp/lib/domain--1-kvm/master-key.aes"}' \
+-machine pc-i440fx-6.2,usb=off,dump-guest-core=off,memory-backend=pc.ram \
 -accel kvm \
--cpu qemu32 \
+-cpu qemu64 \
 -m 4096 \
--realtime mlock=off \
+-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":4294967296}' \
+-overcommit mem-lock=off \
 -smp 1,sockets=1,cores=1,threads=1 \
 -uuid d091ea82-29e6-2e34-3005-f02617b36e87 \
 -display none \
 -no-user-config \
 -nodefaults \
--chardev socket,id=charmonitor,path=/tmp/lib/domain--1-kvm/monitor.sock,server=on,wait=off \
+-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \
 -mon chardev=charmonitor,id=monitor,mode=control \
 -rtc base=utc \
 -no-shutdown \
 -no-acpi \
 -boot strict=on \
+-audiodev '{"id":"audio1","driver":"none"}' \
+-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
 -msg timestamp=on
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 127f050058..46df0e935e 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1127,7 +1127,7 @@ mymain(void)
             QEMU_CAPS_MACHINE_VMPORT_OPT);
     DO_TEST_NOCAPS("default-kvm-host-arch");
     DO_TEST_NOCAPS("default-qemu-host-arch");
-    DO_TEST_NOCAPS("x86-kvm-32-on-64");
+    DO_TEST_CAPS_LATEST("x86-kvm-32-on-64");
     DO_TEST_NOCAPS("boot-cdrom");
     DO_TEST_NOCAPS("boot-network");
     DO_TEST_NOCAPS("boot-floppy");
diff --git a/tests/qemuxml2xmloutdata/x86-kvm-32-on-64.x86_64-latest.xml b/tests/qemuxml2xmloutdata/x86-kvm-32-on-64.x86_64-latest.xml
new file mode 100644
index 0000000000..b51fb18788
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/x86-kvm-32-on-64.x86_64-latest.xml
@@ -0,0 +1,27 @@
+<domain type='kvm'>
+  <name>kvm</name>
+  <uuid>d091ea82-29e6-2e34-3005-f02617b36e87</uuid>
+  <memory unit='KiB'>4194304</memory>
+  <currentMemory unit='KiB'>4194304</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='i686' machine='pc-i440fx-6.2'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <cpu mode='custom' match='exact' check='none'>
+    <model fallback='forbid'>qemu64</model>
+  </cpu>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-x86_64</emulator>
+    <controller type='usb' index='0' model='none'/>
+    <controller type='pci' index='0' model='pci-root'/>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <audio id='1' type='none'/>
+    <memballoon model='none'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 4ea1ee5e0f..6c4e39ad5f 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -1332,6 +1332,8 @@ mymain(void)
     DO_TEST("riscv64-virt-pci",
             QEMU_CAPS_OBJECT_GPEX);

+    DO_TEST_CAPS_LATEST("x86-kvm-32-on-64");
+
     DO_TEST_CAPS_LATEST("virtio-transitional");
     DO_TEST_CAPS_LATEST("virtio-non-transitional");

-- 
2.31.1

Re: [PATCH 17/21] qemuxml2(xml|argv)test: Test real state of things with 'x86-kvm-32-on-64'
Posted by Ján Tomko 4 years, 1 month ago
On a Thursday in 2022, Peter Krempa wrote:
>As demonstrated by the qemuxml2xmltest DO_TEST_CAPS_LATEST data based on
>the 'x86-kvm-32-on-64' test case the post parse CPU selection code which
>fills in the CPU into the definition does not have exactly the same
>logic as we used to have when the cpu model was picked when formatting
>the commandline.
>
>Change the qemuxml2argv test to use DO_TEST_CAPS_LATEST too as it
>doesn't really make sense to test this on fake data.
>

Consider also adding a versioned test with QEMU 4.1.0 data which executes the
code path in qemuBuildCpuCommandLine that hardcodes qemu32 for i686
guests.

Ever since
commit 5e939cea896fb3373a6f68f86e325c657429ed3d
     qemu: Store default CPU in domain XML
we fill the default model in post-parse.

The qemuDomainDefSetDefaultCPU function is probably missing:

if (def->os.arch == VIR_ARCH_I686)
     virStringReplace(model, "64", "32");

>This possibly shows that there's a regression/change in behaviour which
>happened when the CPU code was changed.
>
>Signed-off-by: Peter Krempa <pkrempa@redhat.com>
>---
> ...gs => x86-kvm-32-on-64.x86_64-latest.args} | 14 +++++-----
> tests/qemuxml2argvtest.c                      |  2 +-
> .../x86-kvm-32-on-64.x86_64-latest.xml        | 27 +++++++++++++++++++
> tests/qemuxml2xmltest.c                       |  2 ++
> 4 files changed, 38 insertions(+), 7 deletions(-)
> rename tests/qemuxml2argvdata/{x86-kvm-32-on-64.args => x86-kvm-32-on-64.x86_64-latest.args} (53%)
> create mode 100644 tests/qemuxml2xmloutdata/x86-kvm-32-on-64.x86_64-latest.xml
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano