c480ed
From 3ddc4c63f770fa6e2b2e37915c3f70598aa59d97 Mon Sep 17 00:00:00 2001
c480ed
Message-Id: <3ddc4c63f770fa6e2b2e37915c3f70598aa59d97@dist-git>
c480ed
From: Jiri Denemark <jdenemar@redhat.com>
c480ed
Date: Fri, 21 Jun 2019 09:25:50 +0200
c480ed
Subject: [PATCH] qemuxml2argvtest: Add test for CPU features translation
c480ed
MIME-Version: 1.0
c480ed
Content-Type: text/plain; charset=UTF-8
c480ed
Content-Transfer-Encoding: 8bit
c480ed
c480ed
This should cover all CPU features for which QEMU prefers spelling that
c480ed
differs from the one used by libvirt.
c480ed
c480ed
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c480ed
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c480ed
(cherry picked from commit 24aa210d90770a6ea2313ebf2047c0a802932dca)
c480ed
c480ed
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
c480ed
c480ed
Conflicts:
c480ed
	tests/qemuxml2argvdata/cpu-translation.x86_64-latest.args
c480ed
            - old command line
c480ed
            - downstream patch to add rtm=on and hle=on for Haswell
c480ed
c480ed
	tests/qemuxml2argvdata/cpu-translation.x86_64-4.0.0.args
c480ed
            - dropped as there are no 4.0.0 capabilities downstream
c480ed
c480ed
	tests/qemuxml2argvtest.c
c480ed
            - dropped cpu-translation test with QEMU 4.0.0
c480ed
c480ed
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c480ed
Message-Id: <6ce0d74bdf9a66c0908fd8162902b1f75870189b.1561068591.git.jdenemar@redhat.com>
c480ed
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c480ed
---
c480ed
 .../cpu-translation.x86_64-latest.args        | 33 ++++++++++++++++++
c480ed
 tests/qemuxml2argvdata/cpu-translation.xml    | 34 +++++++++++++++++++
c480ed
 tests/qemuxml2argvtest.c                      |  1 +
c480ed
 3 files changed, 68 insertions(+)
c480ed
 create mode 100644 tests/qemuxml2argvdata/cpu-translation.x86_64-latest.args
c480ed
 create mode 100644 tests/qemuxml2argvdata/cpu-translation.xml
c480ed
c480ed
diff --git a/tests/qemuxml2argvdata/cpu-translation.x86_64-latest.args b/tests/qemuxml2argvdata/cpu-translation.x86_64-latest.args
c480ed
new file mode 100644
c480ed
index 0000000000..898b987086
c480ed
--- /dev/null
c480ed
+++ b/tests/qemuxml2argvdata/cpu-translation.x86_64-latest.args
c480ed
@@ -0,0 +1,33 @@
c480ed
+LC_ALL=C \
c480ed
+PATH=/bin \
c480ed
+HOME=/home/test \
c480ed
+USER=test \
c480ed
+LOGNAME=test \
c480ed
+QEMU_AUDIO_DRV=none \
c480ed
+/usr/bin/qemu-system-x86_64 \
c480ed
+-name guest=QEMUGuest1,debug-threads=on \
c480ed
+-S \
c480ed
+-object secret,id=masterKey0,format=raw,\
c480ed
+file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
c480ed
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
c480ed
+-cpu Haswell,pclmuldq=on,ds_cpl=on,tsc_adjust=on,fxsr_opt=on,lahf_lm=on,\
c480ed
+cmp_legacy=on,nodeid_msr=on,perfctr_core=on,perfctr_nb=on,rtm=on,hle=on,\
c480ed
+kvm_pv_eoi=on,kvm_pv_unhalt=on \
c480ed
+-m 214 \
c480ed
+-realtime mlock=off \
c480ed
+-smp 1,sockets=1,cores=1,threads=1 \
c480ed
+-uuid c7a5fdbd-fade-9455-926a-d65c16db1809 \
c480ed
+-display none \
c480ed
+-no-user-config \
c480ed
+-nodefaults \
c480ed
+-chardev socket,id=charmonitor,fd=1729,server,nowait \
c480ed
+-mon chardev=charmonitor,id=monitor,mode=control \
c480ed
+-rtc base=utc \
c480ed
+-no-shutdown \
c480ed
+-no-acpi \
c480ed
+-boot strict=on \
c480ed
+-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
c480ed
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \
c480ed
+-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
c480ed
+resourcecontrol=deny \
c480ed
+-msg timestamp=on
c480ed
diff --git a/tests/qemuxml2argvdata/cpu-translation.xml b/tests/qemuxml2argvdata/cpu-translation.xml
c480ed
new file mode 100644
c480ed
index 0000000000..4054f3d3be
c480ed
--- /dev/null
c480ed
+++ b/tests/qemuxml2argvdata/cpu-translation.xml
c480ed
@@ -0,0 +1,34 @@
c480ed
+<domain type='qemu'>
c480ed
+  <name>QEMUGuest1</name>
c480ed
+  <uuid>c7a5fdbd-fade-9455-926a-d65c16db1809</uuid>
c480ed
+  <memory unit='KiB'>219100</memory>
c480ed
+  <currentMemory unit='KiB'>219100</currentMemory>
c480ed
+  <vcpu placement='static'>1</vcpu>
c480ed
+  <os>
c480ed
+    <type arch='x86_64' machine='pc'>hvm</type>
c480ed
+    <boot dev='network'/>
c480ed
+  </os>
c480ed
+  <features>
c480ed
+    <apic eoi='on'/>
c480ed
+    <pvspinlock state='on'/>
c480ed
+  </features>
c480ed
+  <cpu mode='custom'>
c480ed
+    <model fallback='forbid'>Haswell</model>
c480ed
+    <feature name='pclmuldq' policy='require'/>
c480ed
+    <feature name='ds_cpl' policy='require'/>
c480ed
+    <feature name='tsc_adjust' policy='require'/>
c480ed
+    <feature name='fxsr_opt' policy='require'/>
c480ed
+    <feature name='lahf_lm' policy='require'/>
c480ed
+    <feature name='cmp_legacy' policy='require'/>
c480ed
+    <feature name='nodeid_msr' policy='require'/>
c480ed
+    <feature name='perfctr_core' policy='require'/>
c480ed
+    <feature name='perfctr_nb' policy='require'/>
c480ed
+  </cpu>
c480ed
+  <clock offset='utc'/>
c480ed
+  <on_poweroff>destroy</on_poweroff>
c480ed
+  <on_reboot>restart</on_reboot>
c480ed
+  <on_crash>destroy</on_crash>
c480ed
+  <devices>
c480ed
+      <emulator>/usr/bin/qemu-system-x86_64</emulator>
c480ed
+  </devices>
c480ed
+</domain>
c480ed
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
c480ed
index 9de0cbf7e9..03d6a60736 100644
c480ed
--- a/tests/qemuxml2argvtest.c
c480ed
+++ b/tests/qemuxml2argvtest.c
c480ed
@@ -1741,6 +1741,7 @@ mymain(void)
c480ed
     DO_TEST("cpu-Haswell-noTSX", QEMU_CAPS_KVM);
c480ed
     DO_TEST("cpu-host-model-cmt", NONE);
c480ed
     DO_TEST("cpu-tsc-frequency", QEMU_CAPS_KVM);
c480ed
+    DO_TEST_CAPS_LATEST("cpu-translation");
c480ed
     qemuTestSetHostCPU(driver.caps, NULL);
c480ed
 
c480ed
     DO_TEST("encrypted-disk", QEMU_CAPS_QCOW2_LUKS, QEMU_CAPS_OBJECT_SECRET);
c480ed
-- 
c480ed
2.22.0
c480ed