When starting a domain without a CPU model specified in the domain XML,
QEMU will choose a default one. Which is fine unless the domain gets
migrated to another host because libvirt doesn't perform any CPU ABI
checks and the virtual CPU provided by QEMU on the destination host can
differ from the one on the source host.
With QEMU 4.2.0 we can probe for the default CPU model used by QEMU for
a particular machine type and store it in the domain XML. This way the
chosen CPU model is more visible to users and libvirt will make sure
the guest will see the exact same CPU after migration.
Architecture specific notes
- aarch64: We only set the default CPU for TCG domains as KVM requires
-cpu host to work.
- ppc64: (to be checked with QEMU developers) Default CPU data reported
by QEMU is unusable for KVM. QEMU would effectively use -cpu host by
default and it even rewrites typename of the current host CPU model to
host-powerpc64-cpu. The default CPU type reported by query-machines is
still power*-powerpc64-cpu, which may not even exist due to the
changed typename. For example, on a Power8 host, power8 CPU model is
of host-powerpc64-cpu type (according to query-cpu-definitions), while
the default CPU type name for pseries-3.1 machine type is reported as
power8_v2.0-powerpc64-cpu. What's even worse, pseries-4.2 says the
default CPU type is power9_v2.0-powerpc64-cpu, which cannot be started
on older host at all. So again, we only set the default CPU for TCG
domains.
- s390x: (to be checked with QEMU developers) The default CPU is said to
be "qemu", which works fine for TCG domains, but it doesn't work on
KVM because QEMU complains that some features requested in the CPU
model are not available.
- x86_64: The default CPU model (qemu64) is not runnable on any host
with KVM, but in contrast to s390x QEMU just disables unavailable
features and starts happily.
https://bugzilla.redhat.com/show_bug.cgi?id=1598151
https://bugzilla.redhat.com/show_bug.cgi?id=1598162
---
Notes:
This patch should not be merged yet as we need to confirm what to do
on s390x and ppc64 architectures.
Version 2:
- new test cases
src/qemu/qemu_domain.c | 56 +++++++++++++++++++
...fault-cpu-tcg-virt-4.2.aarch64-latest.args | 1 +
.../disk-cache.x86_64-latest.args | 1 +
.../disk-cdrom-network.x86_64-latest.args | 1 +
.../disk-cdrom-tray.x86_64-latest.args | 1 +
.../disk-copy_on_read.x86_64-latest.args | 1 +
.../disk-detect-zeroes.x86_64-latest.args | 1 +
.../disk-floppy-q35-2_11.x86_64-latest.args | 1 +
.../disk-floppy-q35-2_9.x86_64-latest.args | 1 +
.../os-firmware-bios.x86_64-latest.args | 1 +
...os-firmware-efi-secboot.x86_64-latest.args | 1 +
.../os-firmware-efi.x86_64-latest.args | 1 +
...ault-cpu-tcg-pseries-2.7.ppc64-latest.args | 1 +
...ault-cpu-tcg-pseries-3.1.ppc64-latest.args | 1 +
...ault-cpu-tcg-pseries-4.2.ppc64-latest.args | 1 +
...t-cpu-tcg-ccw-virtio-4.2.s390x-latest.args | 1 +
.../tpm-emulator-tpm2-enc.x86_64-latest.args | 1 +
.../tpm-emulator-tpm2.x86_64-latest.args | 1 +
.../tpm-emulator.x86_64-latest.args | 1 +
.../tseg-explicit-size.x86_64-latest.args | 1 +
.../vhost-vsock-auto.x86_64-latest.args | 1 +
.../vhost-vsock.x86_64-latest.args | 1 +
...-default-cpu-kvm-pc-4.2.x86_64-latest.args | 1 +
...default-cpu-kvm-q35-4.2.x86_64-latest.args | 1 +
...-default-cpu-tcg-pc-4.2.x86_64-latest.args | 1 +
...default-cpu-tcg-q35-4.2.x86_64-latest.args | 1 +
...efault-cpu-tcg-virt-4.2.aarch64-latest.xml | 3 +
.../os-firmware-bios.x86_64-latest.xml | 3 +
.../os-firmware-efi-secboot.x86_64-latest.xml | 3 +
.../os-firmware-efi.x86_64-latest.xml | 3 +
...fault-cpu-tcg-pseries-2.7.ppc64-latest.xml | 3 +
...fault-cpu-tcg-pseries-3.1.ppc64-latest.xml | 3 +
...fault-cpu-tcg-pseries-4.2.ppc64-latest.xml | 3 +
...lt-cpu-tcg-ccw-virtio-4.2.s390x-latest.xml | 3 +
.../tpm-emulator-tpm2-enc.x86_64-latest.xml | 3 +
.../tpm-emulator-tpm2.x86_64-latest.xml | 3 +
.../tpm-emulator.x86_64-latest.xml | 3 +
.../tpm-passthrough-crb.x86_64-latest.xml | 3 +
.../tpm-passthrough.x86_64-latest.xml | 3 +
...4-default-cpu-kvm-pc-4.2.x86_64-latest.xml | 3 +
...-default-cpu-kvm-q35-4.2.x86_64-latest.xml | 3 +
...4-default-cpu-tcg-pc-4.2.x86_64-latest.xml | 3 +
...-default-cpu-tcg-q35-4.2.x86_64-latest.xml | 3 +
43 files changed, 132 insertions(+)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 9dcba4ef38..438f003186 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -4470,6 +4470,59 @@ qemuDomainDefVcpusPostParse(virDomainDefPtr def)
}
+static int
+qemuDomainDefSetDefaultCPU(virDomainDefPtr def,
+ virQEMUCapsPtr qemuCaps)
+{
+ VIR_AUTOPTR(virCPUDef) newCPU = NULL;
+ virCPUDefPtr cpu = def->cpu;
+ const char *model;
+
+ if (cpu &&
+ (cpu->mode != VIR_CPU_MODE_CUSTOM ||
+ cpu->model))
+ return 0;
+
+ /* Default CPU model info from QEMU is usable for TCG only on non-Intel
+ * architectures. */
+ if (!ARCH_IS_X86(def->os.arch) && def->virtType !=
VIR_DOMAIN_VIRT_QEMU)
+ return 0;
+
+ model = virQEMUCapsGetMachineDefaultCPU(qemuCaps, def->os.machine,
def->virtType);
+ if (!model) {
+ VIR_DEBUG("Unknown default CPU model for domain '%s'",
def->name);
+ return 0;
+ }
+
+ VIR_DEBUG("Setting default CPU model for domain '%s' to %s",
+ def->name, model);
+
+ if (!cpu) {
+ if (VIR_ALLOC(newCPU) < 0)
+ return -1;
+ cpu = newCPU;
+ }
+
+ /* We need to turn off all CPU checks when the domain is started because
+ * the default CPU (e.g., qemu64) may not be runnable on any host. QEMU
+ * will just disable the unavailable features and we will update the CPU
+ * definition accordingly and set check to FULL when starting the domain. */
+ cpu->type = VIR_CPU_TYPE_GUEST;
+ cpu->mode = VIR_CPU_MODE_CUSTOM;
+ cpu->match = VIR_CPU_MATCH_EXACT;
+ cpu->check = VIR_CPU_CHECK_NONE;
+ cpu->fallback = VIR_CPU_FALLBACK_FORBID;
+
+ if (VIR_STRDUP(cpu->model, model) < 0)
+ return -1;
+
+ if (newCPU)
+ VIR_STEAL_PTR(def->cpu, newCPU);
+
+ return 0;
+}
+
+
static int
qemuDomainDefCPUPostParse(virDomainDefPtr def)
{
@@ -4644,6 +4697,9 @@ qemuDomainDefPostParse(virDomainDefPtr def,
if (qemuCanonicalizeMachine(def, qemuCaps) < 0)
return -1;
+ if (qemuDomainDefSetDefaultCPU(def, qemuCaps) < 0)
+ return -1;
+
qemuDomainDefEnableDefaultFeatures(def, qemuCaps);
if (qemuDomainRecheckInternalPaths(def, cfg, parseFlags) < 0)
diff --git a/tests/qemuxml2argvdata/aarch64-default-cpu-tcg-virt-4.2.aarch64-latest.args
b/tests/qemuxml2argvdata/aarch64-default-cpu-tcg-virt-4.2.aarch64-latest.args
index 5ecbe1fdd6..5305c23464 100644
--- a/tests/qemuxml2argvdata/aarch64-default-cpu-tcg-virt-4.2.aarch64-latest.args
+++ b/tests/qemuxml2argvdata/aarch64-default-cpu-tcg-virt-4.2.aarch64-latest.args
@@ -13,6 +13,7 @@ QEMU_AUDIO_DRV=none \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-guest/master-key.aes \
-machine virt-4.2,accel=tcg,usb=off,dump-guest-core=off,gic-version=2 \
+-cpu cortex-a15 \
-m 4096 \
-overcommit mem-lock=off \
-smp 1,sockets=1,cores=1,threads=1 \
diff --git a/tests/qemuxml2argvdata/disk-cache.x86_64-latest.args
b/tests/qemuxml2argvdata/disk-cache.x86_64-latest.args
index 7ea6d5b4d5..01d3b9d490 100644
--- a/tests/qemuxml2argvdata/disk-cache.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/disk-cache.x86_64-latest.args
@@ -13,6 +13,7 @@ QEMU_AUDIO_DRV=none \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
-machine pc-i440fx-2.6,accel=tcg,usb=off,dump-guest-core=off \
+-cpu qemu64 \
-m 214 \
-overcommit mem-lock=off \
-smp 1,sockets=1,cores=1,threads=1 \
diff --git a/tests/qemuxml2argvdata/disk-cdrom-network.x86_64-latest.args
b/tests/qemuxml2argvdata/disk-cdrom-network.x86_64-latest.args
index cf711c0a3f..e0d2eb049d 100644
--- a/tests/qemuxml2argvdata/disk-cdrom-network.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/disk-cdrom-network.x86_64-latest.args
@@ -13,6 +13,7 @@ QEMU_AUDIO_DRV=none \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
-machine pc-1.2,accel=kvm,usb=off,dump-guest-core=off \
+-cpu qemu64 \
-m 1024 \
-overcommit mem-lock=off \
-smp 1,sockets=1,cores=1,threads=1 \
diff --git a/tests/qemuxml2argvdata/disk-cdrom-tray.x86_64-latest.args
b/tests/qemuxml2argvdata/disk-cdrom-tray.x86_64-latest.args
index ad17416851..21542db4c2 100644
--- a/tests/qemuxml2argvdata/disk-cdrom-tray.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/disk-cdrom-tray.x86_64-latest.args
@@ -13,6 +13,7 @@ QEMU_AUDIO_DRV=none \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-test/master-key.aes \
-machine pc-0.13,accel=tcg,usb=off,dump-guest-core=off \
+-cpu qemu64 \
-m 1024 \
-overcommit mem-lock=off \
-smp 1,sockets=1,cores=1,threads=1 \
diff --git a/tests/qemuxml2argvdata/disk-copy_on_read.x86_64-latest.args
b/tests/qemuxml2argvdata/disk-copy_on_read.x86_64-latest.args
index 1f1d37c957..8552f9f00e 100644
--- a/tests/qemuxml2argvdata/disk-copy_on_read.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/disk-copy_on_read.x86_64-latest.args
@@ -13,6 +13,7 @@ QEMU_AUDIO_DRV=none \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-test/master-key.aes \
-machine pc-0.13,accel=tcg,usb=off,dump-guest-core=off \
+-cpu qemu64 \
-m 1024 \
-overcommit mem-lock=off \
-smp 1,sockets=1,cores=1,threads=1 \
diff --git a/tests/qemuxml2argvdata/disk-detect-zeroes.x86_64-latest.args
b/tests/qemuxml2argvdata/disk-detect-zeroes.x86_64-latest.args
index b48c0f8d43..2a01647e50 100644
--- a/tests/qemuxml2argvdata/disk-detect-zeroes.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/disk-detect-zeroes.x86_64-latest.args
@@ -13,6 +13,7 @@ QEMU_AUDIO_DRV=none \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-test/master-key.aes \
-machine pc-0.13,accel=tcg,usb=off,dump-guest-core=off \
+-cpu qemu64 \
-m 1024 \
-overcommit mem-lock=off \
-smp 1,sockets=1,cores=1,threads=1 \
diff --git a/tests/qemuxml2argvdata/disk-floppy-q35-2_11.x86_64-latest.args
b/tests/qemuxml2argvdata/disk-floppy-q35-2_11.x86_64-latest.args
index 02e2b1e76c..fadd5a6d7e 100644
--- a/tests/qemuxml2argvdata/disk-floppy-q35-2_11.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/disk-floppy-q35-2_11.x86_64-latest.args
@@ -13,6 +13,7 @@ QEMU_AUDIO_DRV=none \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
-machine pc-q35-2.11,accel=tcg,usb=off,dump-guest-core=off \
+-cpu qemu64 \
-m 214 \
-overcommit mem-lock=off \
-smp 1,sockets=1,cores=1,threads=1 \
diff --git a/tests/qemuxml2argvdata/disk-floppy-q35-2_9.x86_64-latest.args
b/tests/qemuxml2argvdata/disk-floppy-q35-2_9.x86_64-latest.args
index a158e8e3d3..4c932a7365 100644
--- a/tests/qemuxml2argvdata/disk-floppy-q35-2_9.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/disk-floppy-q35-2_9.x86_64-latest.args
@@ -13,6 +13,7 @@ QEMU_AUDIO_DRV=none \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
-machine pc-q35-2.9,accel=tcg,usb=off,dump-guest-core=off \
+-cpu qemu64 \
-m 214 \
-overcommit mem-lock=off \
-smp 1,sockets=1,cores=1,threads=1 \
diff --git a/tests/qemuxml2argvdata/os-firmware-bios.x86_64-latest.args
b/tests/qemuxml2argvdata/os-firmware-bios.x86_64-latest.args
index 7d6108ec24..4391c6eda2 100644
--- a/tests/qemuxml2argvdata/os-firmware-bios.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/os-firmware-bios.x86_64-latest.args
@@ -13,6 +13,7 @@ QEMU_AUDIO_DRV=none \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-fedora/master-key.aes \
-machine pc-q35-4.0,accel=kvm,usb=off,dump-guest-core=off \
+-cpu qemu64 \
-bios /usr/share/seabios/bios-256k.bin \
-m 8 \
-overcommit mem-lock=off \
diff --git a/tests/qemuxml2argvdata/os-firmware-efi-secboot.x86_64-latest.args
b/tests/qemuxml2argvdata/os-firmware-efi-secboot.x86_64-latest.args
index d8f356ea07..4de135beb8 100644
--- a/tests/qemuxml2argvdata/os-firmware-efi-secboot.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/os-firmware-efi-secboot.x86_64-latest.args
@@ -13,6 +13,7 @@ QEMU_AUDIO_DRV=none \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-fedora/master-key.aes \
-machine pc-q35-4.0,accel=kvm,usb=off,smm=on,dump-guest-core=off \
+-cpu qemu64 \
-global driver=cfi.pflash01,property=secure,value=on \
-drive file=/usr/share/OVMF/OVMF_CODE.secboot.fd,if=pflash,format=raw,unit=0,\
readonly=on \
diff --git a/tests/qemuxml2argvdata/os-firmware-efi.x86_64-latest.args
b/tests/qemuxml2argvdata/os-firmware-efi.x86_64-latest.args
index e4dda734b0..7eba20e443 100644
--- a/tests/qemuxml2argvdata/os-firmware-efi.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/os-firmware-efi.x86_64-latest.args
@@ -13,6 +13,7 @@ QEMU_AUDIO_DRV=none \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-fedora/master-key.aes \
-machine pc-q35-4.0,accel=kvm,usb=off,smm=on,dump-guest-core=off \
+-cpu qemu64 \
-drive file=/usr/share/OVMF/OVMF_CODE.secboot.fd,if=pflash,format=raw,unit=0,\
readonly=on \
-drive file=/var/lib/libvirt/qemu/nvram/fedora_VARS.fd,if=pflash,format=raw,\
diff --git a/tests/qemuxml2argvdata/ppc64-default-cpu-tcg-pseries-2.7.ppc64-latest.args
b/tests/qemuxml2argvdata/ppc64-default-cpu-tcg-pseries-2.7.ppc64-latest.args
index c97fa531ae..06946dcbd9 100644
--- a/tests/qemuxml2argvdata/ppc64-default-cpu-tcg-pseries-2.7.ppc64-latest.args
+++ b/tests/qemuxml2argvdata/ppc64-default-cpu-tcg-pseries-2.7.ppc64-latest.args
@@ -13,6 +13,7 @@ QEMU_AUDIO_DRV=none \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-guest/master-key.aes \
-machine pseries-2.7,accel=tcg,usb=off,dump-guest-core=off \
+-cpu POWER7 \
-m 4096 \
-overcommit mem-lock=off \
-smp 4,sockets=4,cores=1,threads=1 \
diff --git a/tests/qemuxml2argvdata/ppc64-default-cpu-tcg-pseries-3.1.ppc64-latest.args
b/tests/qemuxml2argvdata/ppc64-default-cpu-tcg-pseries-3.1.ppc64-latest.args
index fbad53b0fb..6090a1bbad 100644
--- a/tests/qemuxml2argvdata/ppc64-default-cpu-tcg-pseries-3.1.ppc64-latest.args
+++ b/tests/qemuxml2argvdata/ppc64-default-cpu-tcg-pseries-3.1.ppc64-latest.args
@@ -13,6 +13,7 @@ QEMU_AUDIO_DRV=none \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-guest/master-key.aes \
-machine pseries-3.1,accel=tcg,usb=off,dump-guest-core=off \
+-cpu POWER8 \
-m 4096 \
-overcommit mem-lock=off \
-smp 4,sockets=4,cores=1,threads=1 \
diff --git a/tests/qemuxml2argvdata/ppc64-default-cpu-tcg-pseries-4.2.ppc64-latest.args
b/tests/qemuxml2argvdata/ppc64-default-cpu-tcg-pseries-4.2.ppc64-latest.args
index 4222d4d4aa..7804a7b220 100644
--- a/tests/qemuxml2argvdata/ppc64-default-cpu-tcg-pseries-4.2.ppc64-latest.args
+++ b/tests/qemuxml2argvdata/ppc64-default-cpu-tcg-pseries-4.2.ppc64-latest.args
@@ -13,6 +13,7 @@ QEMU_AUDIO_DRV=none \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-guest/master-key.aes \
-machine pseries-4.2,accel=tcg,usb=off,dump-guest-core=off \
+-cpu POWER9 \
-m 4096 \
-overcommit mem-lock=off \
-smp 4,sockets=4,cores=1,threads=1 \
diff --git a/tests/qemuxml2argvdata/s390-default-cpu-tcg-ccw-virtio-4.2.s390x-latest.args
b/tests/qemuxml2argvdata/s390-default-cpu-tcg-ccw-virtio-4.2.s390x-latest.args
index 3d31148613..c7bd0c3840 100644
--- a/tests/qemuxml2argvdata/s390-default-cpu-tcg-ccw-virtio-4.2.s390x-latest.args
+++ b/tests/qemuxml2argvdata/s390-default-cpu-tcg-ccw-virtio-4.2.s390x-latest.args
@@ -13,6 +13,7 @@ QEMU_AUDIO_DRV=none \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-test/master-key.aes \
-machine s390-ccw-virtio-4.2,accel=tcg,usb=off,dump-guest-core=off \
+-cpu qemu \
-m 256 \
-overcommit mem-lock=off \
-smp 1,sockets=1,cores=1,threads=1 \
diff --git a/tests/qemuxml2argvdata/tpm-emulator-tpm2-enc.x86_64-latest.args
b/tests/qemuxml2argvdata/tpm-emulator-tpm2-enc.x86_64-latest.args
index 3c8dc8e483..2455e14cfe 100644
--- a/tests/qemuxml2argvdata/tpm-emulator-tpm2-enc.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/tpm-emulator-tpm2-enc.x86_64-latest.args
@@ -13,6 +13,7 @@ QEMU_AUDIO_DRV=none \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-TPM-VM/master-key.aes \
-machine pc-i440fx-2.12,accel=tcg,usb=off,dump-guest-core=off \
+-cpu qemu64 \
-m 2048 \
-overcommit mem-lock=off \
-smp 1,sockets=1,cores=1,threads=1 \
diff --git a/tests/qemuxml2argvdata/tpm-emulator-tpm2.x86_64-latest.args
b/tests/qemuxml2argvdata/tpm-emulator-tpm2.x86_64-latest.args
index 3c8dc8e483..2455e14cfe 100644
--- a/tests/qemuxml2argvdata/tpm-emulator-tpm2.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/tpm-emulator-tpm2.x86_64-latest.args
@@ -13,6 +13,7 @@ QEMU_AUDIO_DRV=none \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-TPM-VM/master-key.aes \
-machine pc-i440fx-2.12,accel=tcg,usb=off,dump-guest-core=off \
+-cpu qemu64 \
-m 2048 \
-overcommit mem-lock=off \
-smp 1,sockets=1,cores=1,threads=1 \
diff --git a/tests/qemuxml2argvdata/tpm-emulator.x86_64-latest.args
b/tests/qemuxml2argvdata/tpm-emulator.x86_64-latest.args
index 3c8dc8e483..2455e14cfe 100644
--- a/tests/qemuxml2argvdata/tpm-emulator.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/tpm-emulator.x86_64-latest.args
@@ -13,6 +13,7 @@ QEMU_AUDIO_DRV=none \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-TPM-VM/master-key.aes \
-machine pc-i440fx-2.12,accel=tcg,usb=off,dump-guest-core=off \
+-cpu qemu64 \
-m 2048 \
-overcommit mem-lock=off \
-smp 1,sockets=1,cores=1,threads=1 \
diff --git a/tests/qemuxml2argvdata/tseg-explicit-size.x86_64-latest.args
b/tests/qemuxml2argvdata/tseg-explicit-size.x86_64-latest.args
index 2fece310e7..53dab283cc 100644
--- a/tests/qemuxml2argvdata/tseg-explicit-size.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/tseg-explicit-size.x86_64-latest.args
@@ -14,6 +14,7 @@ QEMU_AUDIO_DRV=none \
file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
-machine pc-q35-2.10,accel=tcg,usb=off,smm=on,dump-guest-core=off \
-global mch.extended-tseg-mbytes=48 \
+-cpu qemu64 \
-m 214 \
-overcommit mem-lock=off \
-smp 1,sockets=1,cores=1,threads=1 \
diff --git a/tests/qemuxml2argvdata/vhost-vsock-auto.x86_64-latest.args
b/tests/qemuxml2argvdata/vhost-vsock-auto.x86_64-latest.args
index b5d3ff2204..e083b872c5 100644
--- a/tests/qemuxml2argvdata/vhost-vsock-auto.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/vhost-vsock-auto.x86_64-latest.args
@@ -13,6 +13,7 @@ QEMU_AUDIO_DRV=none \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-test/master-key.aes \
-machine pc-i440fx-2.9,accel=tcg,usb=off,dump-guest-core=off \
+-cpu qemu64 \
-m 1024 \
-overcommit mem-lock=off \
-smp 1,sockets=1,cores=1,threads=1 \
diff --git a/tests/qemuxml2argvdata/vhost-vsock.x86_64-latest.args
b/tests/qemuxml2argvdata/vhost-vsock.x86_64-latest.args
index 76df9d2d4d..1b0ffee6e8 100644
--- a/tests/qemuxml2argvdata/vhost-vsock.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/vhost-vsock.x86_64-latest.args
@@ -13,6 +13,7 @@ QEMU_AUDIO_DRV=none \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-test/master-key.aes \
-machine pc-0.13,accel=tcg,usb=off,dump-guest-core=off \
+-cpu qemu64 \
-m 1024 \
-overcommit mem-lock=off \
-smp 1,sockets=1,cores=1,threads=1 \
diff --git a/tests/qemuxml2argvdata/x86_64-default-cpu-kvm-pc-4.2.x86_64-latest.args
b/tests/qemuxml2argvdata/x86_64-default-cpu-kvm-pc-4.2.x86_64-latest.args
index c7bef11f22..7a335bc0c4 100644
--- a/tests/qemuxml2argvdata/x86_64-default-cpu-kvm-pc-4.2.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/x86_64-default-cpu-kvm-pc-4.2.x86_64-latest.args
@@ -13,6 +13,7 @@ QEMU_AUDIO_DRV=none \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-guest/master-key.aes \
-machine pc-i440fx-4.2,accel=kvm,usb=off,dump-guest-core=off \
+-cpu qemu64 \
-m 4096 \
-overcommit mem-lock=off \
-smp 4,sockets=4,cores=1,threads=1 \
diff --git a/tests/qemuxml2argvdata/x86_64-default-cpu-kvm-q35-4.2.x86_64-latest.args
b/tests/qemuxml2argvdata/x86_64-default-cpu-kvm-q35-4.2.x86_64-latest.args
index c65d29fc32..88a634fc68 100644
--- a/tests/qemuxml2argvdata/x86_64-default-cpu-kvm-q35-4.2.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/x86_64-default-cpu-kvm-q35-4.2.x86_64-latest.args
@@ -13,6 +13,7 @@ QEMU_AUDIO_DRV=none \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-guest/master-key.aes \
-machine pc-q35-4.2,accel=kvm,usb=off,dump-guest-core=off \
+-cpu qemu64 \
-m 4096 \
-overcommit mem-lock=off \
-smp 4,sockets=4,cores=1,threads=1 \
diff --git a/tests/qemuxml2argvdata/x86_64-default-cpu-tcg-pc-4.2.x86_64-latest.args
b/tests/qemuxml2argvdata/x86_64-default-cpu-tcg-pc-4.2.x86_64-latest.args
index 1c233243ad..5f11a07a19 100644
--- a/tests/qemuxml2argvdata/x86_64-default-cpu-tcg-pc-4.2.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/x86_64-default-cpu-tcg-pc-4.2.x86_64-latest.args
@@ -13,6 +13,7 @@ QEMU_AUDIO_DRV=none \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-guest/master-key.aes \
-machine pc-i440fx-4.2,accel=tcg,usb=off,dump-guest-core=off \
+-cpu qemu64 \
-m 4096 \
-overcommit mem-lock=off \
-smp 4,sockets=4,cores=1,threads=1 \
diff --git a/tests/qemuxml2argvdata/x86_64-default-cpu-tcg-q35-4.2.x86_64-latest.args
b/tests/qemuxml2argvdata/x86_64-default-cpu-tcg-q35-4.2.x86_64-latest.args
index 505eeb44b3..1c9330f720 100644
--- a/tests/qemuxml2argvdata/x86_64-default-cpu-tcg-q35-4.2.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/x86_64-default-cpu-tcg-q35-4.2.x86_64-latest.args
@@ -13,6 +13,7 @@ QEMU_AUDIO_DRV=none \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-guest/master-key.aes \
-machine pc-q35-4.2,accel=tcg,usb=off,dump-guest-core=off \
+-cpu qemu64 \
-m 4096 \
-overcommit mem-lock=off \
-smp 4,sockets=4,cores=1,threads=1 \
diff --git a/tests/qemuxml2xmloutdata/aarch64-default-cpu-tcg-virt-4.2.aarch64-latest.xml
b/tests/qemuxml2xmloutdata/aarch64-default-cpu-tcg-virt-4.2.aarch64-latest.xml
index 1f4104857a..c0aa2f39ee 100644
--- a/tests/qemuxml2xmloutdata/aarch64-default-cpu-tcg-virt-4.2.aarch64-latest.xml
+++ b/tests/qemuxml2xmloutdata/aarch64-default-cpu-tcg-virt-4.2.aarch64-latest.xml
@@ -11,6 +11,9 @@
<features>
<gic version='2'/>
</features>
+ <cpu mode='custom' match='exact' check='none'>
+ <model fallback='forbid'>cortex-a15</model>
+ </cpu>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
diff --git a/tests/qemuxml2xmloutdata/os-firmware-bios.x86_64-latest.xml
b/tests/qemuxml2xmloutdata/os-firmware-bios.x86_64-latest.xml
index 63886666dd..60d3498765 100644
--- a/tests/qemuxml2xmloutdata/os-firmware-bios.x86_64-latest.xml
+++ b/tests/qemuxml2xmloutdata/os-firmware-bios.x86_64-latest.xml
@@ -16,6 +16,9 @@
<apic/>
<pae/>
</features>
+ <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>
diff --git a/tests/qemuxml2xmloutdata/os-firmware-efi-secboot.x86_64-latest.xml
b/tests/qemuxml2xmloutdata/os-firmware-efi-secboot.x86_64-latest.xml
index a285e06334..938da73711 100644
--- a/tests/qemuxml2xmloutdata/os-firmware-efi-secboot.x86_64-latest.xml
+++ b/tests/qemuxml2xmloutdata/os-firmware-efi-secboot.x86_64-latest.xml
@@ -16,6 +16,9 @@
<apic/>
<pae/>
</features>
+ <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>
diff --git a/tests/qemuxml2xmloutdata/os-firmware-efi.x86_64-latest.xml
b/tests/qemuxml2xmloutdata/os-firmware-efi.x86_64-latest.xml
index 46a7b1b780..97ce8a75c7 100644
--- a/tests/qemuxml2xmloutdata/os-firmware-efi.x86_64-latest.xml
+++ b/tests/qemuxml2xmloutdata/os-firmware-efi.x86_64-latest.xml
@@ -16,6 +16,9 @@
<apic/>
<pae/>
</features>
+ <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>
diff --git a/tests/qemuxml2xmloutdata/ppc64-default-cpu-tcg-pseries-2.7.ppc64-latest.xml
b/tests/qemuxml2xmloutdata/ppc64-default-cpu-tcg-pseries-2.7.ppc64-latest.xml
index fc1714a17e..e76766ff5a 100644
--- a/tests/qemuxml2xmloutdata/ppc64-default-cpu-tcg-pseries-2.7.ppc64-latest.xml
+++ b/tests/qemuxml2xmloutdata/ppc64-default-cpu-tcg-pseries-2.7.ppc64-latest.xml
@@ -8,6 +8,9 @@
<type arch='ppc64' machine='pseries-2.7'>hvm</type>
<boot dev='hd'/>
</os>
+ <cpu mode='custom' match='exact' check='none'>
+ <model fallback='forbid'>POWER7</model>
+ </cpu>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
diff --git a/tests/qemuxml2xmloutdata/ppc64-default-cpu-tcg-pseries-3.1.ppc64-latest.xml
b/tests/qemuxml2xmloutdata/ppc64-default-cpu-tcg-pseries-3.1.ppc64-latest.xml
index f40f3be155..c1d619a9cb 100644
--- a/tests/qemuxml2xmloutdata/ppc64-default-cpu-tcg-pseries-3.1.ppc64-latest.xml
+++ b/tests/qemuxml2xmloutdata/ppc64-default-cpu-tcg-pseries-3.1.ppc64-latest.xml
@@ -8,6 +8,9 @@
<type arch='ppc64' machine='pseries-3.1'>hvm</type>
<boot dev='hd'/>
</os>
+ <cpu mode='custom' match='exact' check='none'>
+ <model fallback='forbid'>POWER8</model>
+ </cpu>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
diff --git a/tests/qemuxml2xmloutdata/ppc64-default-cpu-tcg-pseries-4.2.ppc64-latest.xml
b/tests/qemuxml2xmloutdata/ppc64-default-cpu-tcg-pseries-4.2.ppc64-latest.xml
index 9582223550..311a7ad9da 100644
--- a/tests/qemuxml2xmloutdata/ppc64-default-cpu-tcg-pseries-4.2.ppc64-latest.xml
+++ b/tests/qemuxml2xmloutdata/ppc64-default-cpu-tcg-pseries-4.2.ppc64-latest.xml
@@ -8,6 +8,9 @@
<type arch='ppc64' machine='pseries-4.2'>hvm</type>
<boot dev='hd'/>
</os>
+ <cpu mode='custom' match='exact' check='none'>
+ <model fallback='forbid'>POWER9</model>
+ </cpu>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
diff --git a/tests/qemuxml2xmloutdata/s390-default-cpu-tcg-ccw-virtio-4.2.s390x-latest.xml
b/tests/qemuxml2xmloutdata/s390-default-cpu-tcg-ccw-virtio-4.2.s390x-latest.xml
index 55149d4a78..8ccd460d01 100644
--- a/tests/qemuxml2xmloutdata/s390-default-cpu-tcg-ccw-virtio-4.2.s390x-latest.xml
+++ b/tests/qemuxml2xmloutdata/s390-default-cpu-tcg-ccw-virtio-4.2.s390x-latest.xml
@@ -8,6 +8,9 @@
<type arch='s390x'
machine='s390-ccw-virtio-4.2'>hvm</type>
<boot dev='hd'/>
</os>
+ <cpu mode='custom' match='exact' check='none'>
+ <model fallback='forbid'>qemu</model>
+ </cpu>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
diff --git a/tests/qemuxml2xmloutdata/tpm-emulator-tpm2-enc.x86_64-latest.xml
b/tests/qemuxml2xmloutdata/tpm-emulator-tpm2-enc.x86_64-latest.xml
index dcd504310f..8a842e4d22 100644
--- a/tests/qemuxml2xmloutdata/tpm-emulator-tpm2-enc.x86_64-latest.xml
+++ b/tests/qemuxml2xmloutdata/tpm-emulator-tpm2-enc.x86_64-latest.xml
@@ -12,6 +12,9 @@
<features>
<acpi/>
</features>
+ <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>
diff --git a/tests/qemuxml2xmloutdata/tpm-emulator-tpm2.x86_64-latest.xml
b/tests/qemuxml2xmloutdata/tpm-emulator-tpm2.x86_64-latest.xml
index 625aaa5f60..9143a1dde1 100644
--- a/tests/qemuxml2xmloutdata/tpm-emulator-tpm2.x86_64-latest.xml
+++ b/tests/qemuxml2xmloutdata/tpm-emulator-tpm2.x86_64-latest.xml
@@ -12,6 +12,9 @@
<features>
<acpi/>
</features>
+ <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>
diff --git a/tests/qemuxml2xmloutdata/tpm-emulator.x86_64-latest.xml
b/tests/qemuxml2xmloutdata/tpm-emulator.x86_64-latest.xml
index 002af76c21..ff4006b2e3 100644
--- a/tests/qemuxml2xmloutdata/tpm-emulator.x86_64-latest.xml
+++ b/tests/qemuxml2xmloutdata/tpm-emulator.x86_64-latest.xml
@@ -12,6 +12,9 @@
<features>
<acpi/>
</features>
+ <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>
diff --git a/tests/qemuxml2xmloutdata/tpm-passthrough-crb.x86_64-latest.xml
b/tests/qemuxml2xmloutdata/tpm-passthrough-crb.x86_64-latest.xml
index ef68c2d0d7..b8be67acfd 100644
--- a/tests/qemuxml2xmloutdata/tpm-passthrough-crb.x86_64-latest.xml
+++ b/tests/qemuxml2xmloutdata/tpm-passthrough-crb.x86_64-latest.xml
@@ -12,6 +12,9 @@
<features>
<acpi/>
</features>
+ <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>
diff --git a/tests/qemuxml2xmloutdata/tpm-passthrough.x86_64-latest.xml
b/tests/qemuxml2xmloutdata/tpm-passthrough.x86_64-latest.xml
index 2a99f35cf8..669992bcf6 100644
--- a/tests/qemuxml2xmloutdata/tpm-passthrough.x86_64-latest.xml
+++ b/tests/qemuxml2xmloutdata/tpm-passthrough.x86_64-latest.xml
@@ -12,6 +12,9 @@
<features>
<acpi/>
</features>
+ <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>
diff --git a/tests/qemuxml2xmloutdata/x86_64-default-cpu-kvm-pc-4.2.x86_64-latest.xml
b/tests/qemuxml2xmloutdata/x86_64-default-cpu-kvm-pc-4.2.x86_64-latest.xml
index 1f24dee8e7..c7b0f11cf8 100644
--- a/tests/qemuxml2xmloutdata/x86_64-default-cpu-kvm-pc-4.2.x86_64-latest.xml
+++ b/tests/qemuxml2xmloutdata/x86_64-default-cpu-kvm-pc-4.2.x86_64-latest.xml
@@ -12,6 +12,9 @@
<acpi/>
<apic/>
</features>
+ <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>
diff --git a/tests/qemuxml2xmloutdata/x86_64-default-cpu-kvm-q35-4.2.x86_64-latest.xml
b/tests/qemuxml2xmloutdata/x86_64-default-cpu-kvm-q35-4.2.x86_64-latest.xml
index 39a7013b67..be211acd29 100644
--- a/tests/qemuxml2xmloutdata/x86_64-default-cpu-kvm-q35-4.2.x86_64-latest.xml
+++ b/tests/qemuxml2xmloutdata/x86_64-default-cpu-kvm-q35-4.2.x86_64-latest.xml
@@ -12,6 +12,9 @@
<acpi/>
<apic/>
</features>
+ <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>
diff --git a/tests/qemuxml2xmloutdata/x86_64-default-cpu-tcg-pc-4.2.x86_64-latest.xml
b/tests/qemuxml2xmloutdata/x86_64-default-cpu-tcg-pc-4.2.x86_64-latest.xml
index b45ad4c051..159270b83a 100644
--- a/tests/qemuxml2xmloutdata/x86_64-default-cpu-tcg-pc-4.2.x86_64-latest.xml
+++ b/tests/qemuxml2xmloutdata/x86_64-default-cpu-tcg-pc-4.2.x86_64-latest.xml
@@ -12,6 +12,9 @@
<acpi/>
<apic/>
</features>
+ <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>
diff --git a/tests/qemuxml2xmloutdata/x86_64-default-cpu-tcg-q35-4.2.x86_64-latest.xml
b/tests/qemuxml2xmloutdata/x86_64-default-cpu-tcg-q35-4.2.x86_64-latest.xml
index c6a85977e9..b95e146c81 100644
--- a/tests/qemuxml2xmloutdata/x86_64-default-cpu-tcg-q35-4.2.x86_64-latest.xml
+++ b/tests/qemuxml2xmloutdata/x86_64-default-cpu-tcg-q35-4.2.x86_64-latest.xml
@@ -12,6 +12,9 @@
<acpi/>
<apic/>
</features>
+ <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>
--
2.23.0