Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx> --- src/qemu/qemu_domain.c | 42 ++++++++++++++++++++++ src/qemu/qemu_process.c | 13 +++---- .../qemuxml2argv-aarch64-gic-host.xml | 2 +- .../qemuxml2argv-aarch64-gic-v2.xml | 2 +- .../qemuxml2argv-aarch64-gic-v3.xml | 2 +- .../qemuxml2argv-cpu-check-default-none.args | 21 +++++++++++ .../qemuxml2argv-cpu-check-default-none.xml | 19 ++++++++++ .../qemuxml2argv-cpu-check-default-none2.args | 21 +++++++++++ .../qemuxml2argv-cpu-check-default-none2.xml | 21 +++++++++++ .../qemuxml2argv-cpu-check-default-partial.args | 22 ++++++++++++ .../qemuxml2argv-cpu-check-default-partial.xml | 19 ++++++++++ .../qemuxml2argv-cpu-check-default-partial2.args | 21 +++++++++++ .../qemuxml2argv-cpu-check-default-partial2.xml | 21 +++++++++++ .../qemuxml2argv-cpu-check-full.args | 1 + .../qemuxml2argv-cpu-check-full.xml | 21 +++++++++++ .../qemuxml2argv-cpu-check-none.args | 21 +++++++++++ .../qemuxml2argv-cpu-check-none.xml | 21 +++++++++++ .../qemuxml2argv-cpu-check-partial.args | 1 + .../qemuxml2argv-cpu-check-partial.xml | 21 +++++++++++ tests/qemuxml2argvtest.c | 8 +++++ .../qemuxml2xmlout-aarch64-aavmf-virtio-mmio.xml | 2 +- ...qemuxml2xmlout-aarch64-video-virtio-gpu-pci.xml | 2 +- .../qemuxml2xmlout-aarch64-virtio-pci-default.xml | 2 +- ...2xmlout-aarch64-virtio-pci-manual-addresses.xml | 2 +- .../qemuxml2xmlout-cpu-check-default-none.xml | 28 +++++++++++++++ .../qemuxml2xmlout-cpu-check-default-none2.xml | 30 ++++++++++++++++ .../qemuxml2xmlout-cpu-check-default-partial.xml | 30 ++++++++++++++++ .../qemuxml2xmlout-cpu-check-default-partial2.xml | 30 ++++++++++++++++ .../qemuxml2xmlout-cpu-check-full.xml | 30 ++++++++++++++++ .../qemuxml2xmlout-cpu-check-none.xml | 30 ++++++++++++++++ .../qemuxml2xmlout-cpu-check-partial.xml | 30 ++++++++++++++++ .../qemuxml2xmlout-cpu-eoi-disabled.xml | 2 +- .../qemuxml2xmlout-cpu-eoi-enabled.xml | 2 +- .../qemuxml2xmlout-cpu-host-kvmclock.xml | 2 +- .../qemuxml2xmlout-cpu-host-model-features.xml | 2 +- ...emuxml2xmlout-cpu-host-passthrough-features.xml | 2 +- .../qemuxml2xmlout-cpu-kvmclock.xml | 2 +- .../qemuxml2xmlout-graphics-spice-timeout.xml | 2 +- tests/qemuxml2xmltest.c | 8 +++++ 39 files changed, 536 insertions(+), 22 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-none.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-none.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-none2.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-none2.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-partial.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-partial.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-partial2.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-partial2.xml create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-cpu-check-full.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-check-full.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-check-none.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-check-none.xml create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-cpu-check-partial.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-check-partial.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-default-none.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-default-none2.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-default-partial.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-default-partial2.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-full.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-none.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-partial.xml diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 07ce22417..8ebc92479 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2675,6 +2675,45 @@ qemuDomainDefVcpusPostParse(virDomainDefPtr def) static int +qemuDomainDefCPUPostParse(virDomainDefPtr def) +{ + if (!def->cpu) + return 0; + + /* Nothing to be done if only CPU topology is specified. */ + if (def->cpu->mode == VIR_CPU_MODE_CUSTOM && + !def->cpu->model) + return 0; + + if (def->cpu->check != VIR_CPU_CHECK_DEFAULT) + return 0; + + switch ((virCPUMode) def->cpu->mode) { + case VIR_CPU_MODE_HOST_PASSTHROUGH: + def->cpu->check = VIR_CPU_CHECK_NONE; + break; + + case VIR_CPU_MODE_HOST_MODEL: + def->cpu->check = VIR_CPU_CHECK_PARTIAL; + break; + + case VIR_CPU_MODE_CUSTOM: + /* Custom CPUs in TCG mode are not compared to host CPU by default. */ + if (def->virtType == VIR_DOMAIN_VIRT_QEMU) + def->cpu->check = VIR_CPU_CHECK_NONE; + else + def->cpu->check = VIR_CPU_CHECK_PARTIAL; + break; + + case VIR_CPU_MODE_LAST: + break; + } + + return 0; +} + + +static int qemuDomainDefPostParse(virDomainDefPtr def, virCapsPtr caps, unsigned int parseFlags, @@ -2738,6 +2777,9 @@ qemuDomainDefPostParse(virDomainDefPtr def, if (qemuDomainDefVcpusPostParse(def) < 0) goto cleanup; + if (qemuDomainDefCPUPostParse(def) < 0) + goto cleanup; + ret = 0; cleanup: virObjectUnref(qemuCaps); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index b9c1847bb..e9631c111 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5184,14 +5184,11 @@ qemuProcessUpdateGuestCPU(virDomainDefPtr def, if (def->cpu->mode == VIR_CPU_MODE_HOST_PASSTHROUGH) return 0; - /* custom CPUs in TCG mode don't need to be compared to host CPU */ - if (def->virtType != VIR_DOMAIN_VIRT_QEMU || - def->cpu->mode != VIR_CPU_MODE_CUSTOM) { - if (virCPUCompare(caps->host.arch, - virQEMUCapsGetHostModel(qemuCaps, def->virtType), - def->cpu, true) < 0) - return -1; - } + if (def->cpu->check == VIR_CPU_CHECK_PARTIAL && + virCPUCompare(caps->host.arch, + virQEMUCapsGetHostModel(qemuCaps, def->virtType), + def->cpu, true) < 0) + return -1; if (virCPUUpdate(def->os.arch, def->cpu, virQEMUCapsGetHostModel(qemuCaps, def->virtType)) < 0) diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-host.xml b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-host.xml index 445b35857..b14d14281 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-host.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-host.xml @@ -11,7 +11,7 @@ <features> <gic version='host'/> </features> - <cpu mode='host-passthrough'/> + <cpu mode='host-passthrough' check='none'/> <clock offset='utc'/> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v2.xml b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v2.xml index 9ccba9904..8b9983752 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v2.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v2.xml @@ -11,7 +11,7 @@ <features> <gic version='2'/> </features> - <cpu mode='host-passthrough'/> + <cpu mode='host-passthrough' check='none'/> <clock offset='utc'/> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v3.xml b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v3.xml index 7c9ee92b3..bde94e16c 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v3.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v3.xml @@ -11,7 +11,7 @@ <features> <gic version='3'/> </features> - <cpu mode='host-passthrough'/> + <cpu mode='host-passthrough' check='none'/> <clock offset='utc'/> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-none.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-none.args new file mode 100644 index 000000000..24d9f5306 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-none.args @@ -0,0 +1,21 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-kvm \ +-name QEMUGuest1 \ +-S \ +-M pc \ +-cpu host \ +-m 214 \ +-smp 6,sockets=6,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-nographic \ +-nodefaults \ +-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \ +-no-acpi \ +-boot n \ +-usb \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-none.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-none.xml new file mode 100644 index 000000000..314cdf52a --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-none.xml @@ -0,0 +1,19 @@ +<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'>6</vcpu> + <os> + <type arch='x86_64' machine='pc'>hvm</type> + <boot dev='network'/> + </os> + <cpu mode='host-passthrough'/> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu-kvm</emulator> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-none2.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-none2.args new file mode 100644 index 000000000..b6a5d4dd4 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-none2.args @@ -0,0 +1,21 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu \ +-name QEMUGuest1 \ +-S \ +-M pc \ +-cpu core2duo \ +-m 214 \ +-smp 6,sockets=6,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-nographic \ +-nodefaults \ +-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \ +-no-acpi \ +-boot n \ +-usb \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-none2.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-none2.xml new file mode 100644 index 000000000..286d2d5d7 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-none2.xml @@ -0,0 +1,21 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>6</vcpu> + <os> + <type arch='x86_64' machine='pc'>hvm</type> + <boot dev='network'/> + </os> + <cpu mode='custom' match='exact'> + <model fallback='forbid'>core2duo</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</emulator> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-partial.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-partial.args new file mode 100644 index 000000000..decf7fdd4 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-partial.args @@ -0,0 +1,22 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-kvm \ +-name QEMUGuest1 \ +-S \ +-M pc \ +-cpu core2duo,+ds,+acpi,+ss,+ht,+tm,+pbe,+ds_cpl,+vmx,+est,+tm2,+cx16,+xtpr,\ ++lahf_lm \ +-m 214 \ +-smp 6,sockets=6,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-nographic \ +-nodefaults \ +-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \ +-no-acpi \ +-boot n \ +-usb \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-partial.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-partial.xml new file mode 100644 index 000000000..3dd45a704 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-partial.xml @@ -0,0 +1,19 @@ +<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'>6</vcpu> + <os> + <type arch='x86_64' machine='pc'>hvm</type> + <boot dev='network'/> + </os> + <cpu mode='host-model'/> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu-kvm</emulator> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-partial2.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-partial2.args new file mode 100644 index 000000000..bd4cefaeb --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-partial2.args @@ -0,0 +1,21 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-kvm \ +-name QEMUGuest1 \ +-S \ +-M pc \ +-cpu core2duo \ +-m 214 \ +-smp 6,sockets=6,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-nographic \ +-nodefaults \ +-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \ +-no-acpi \ +-boot n \ +-usb \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-partial2.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-partial2.xml new file mode 100644 index 000000000..6c7690a95 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-partial2.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'>6</vcpu> + <os> + <type arch='x86_64' machine='pc'>hvm</type> + <boot dev='network'/> + </os> + <cpu mode='custom' match='exact'> + <model fallback='forbid'>core2duo</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-kvm</emulator> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-full.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-full.args new file mode 120000 index 000000000..dd946106e --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-full.args @@ -0,0 +1 @@ +qemuxml2argv-cpu-check-none.args \ No newline at end of file diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-full.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-full.xml new file mode 100644 index 000000000..653c2aaad --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-full.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'>6</vcpu> + <os> + <type arch='x86_64' machine='pc'>hvm</type> + <boot dev='network'/> + </os> + <cpu mode='custom' match='exact' check='full'> + <model fallback='forbid'>core2duo</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-kvm</emulator> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-none.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-none.args new file mode 100644 index 000000000..bd4cefaeb --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-none.args @@ -0,0 +1,21 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-kvm \ +-name QEMUGuest1 \ +-S \ +-M pc \ +-cpu core2duo \ +-m 214 \ +-smp 6,sockets=6,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-nographic \ +-nodefaults \ +-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \ +-no-acpi \ +-boot n \ +-usb \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-none.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-none.xml new file mode 100644 index 000000000..632074626 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-none.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'>6</vcpu> + <os> + <type arch='x86_64' machine='pc'>hvm</type> + <boot dev='network'/> + </os> + <cpu mode='custom' match='exact' check='none'> + <model fallback='forbid'>core2duo</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-kvm</emulator> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-partial.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-partial.args new file mode 120000 index 000000000..dd946106e --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-partial.args @@ -0,0 +1 @@ +qemuxml2argv-cpu-check-none.args \ No newline at end of file diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-partial.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-partial.xml new file mode 100644 index 000000000..8e7850df8 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-partial.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'>6</vcpu> + <os> + <type arch='x86_64' machine='pc'>hvm</type> + <boot dev='network'/> + </os> + <cpu mode='custom' match='exact' check='partial'> + <model fallback='forbid'>core2duo</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-kvm</emulator> + </devices> +</domain> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 6bd746599..db21edbbf 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2468,6 +2468,14 @@ mymain(void) DO_TEST("fd-memory-no-numa-topology", QEMU_CAPS_MEM_PATH, QEMU_CAPS_OBJECT_MEMORY_FILE, QEMU_CAPS_KVM); + DO_TEST("cpu-check-none", QEMU_CAPS_KVM); + DO_TEST("cpu-check-partial", QEMU_CAPS_KVM); + DO_TEST("cpu-check-full", QEMU_CAPS_KVM); + DO_TEST("cpu-check-default-none", QEMU_CAPS_KVM); + DO_TEST("cpu-check-default-none2", NONE); + DO_TEST("cpu-check-default-partial", QEMU_CAPS_KVM); + DO_TEST("cpu-check-default-partial2", QEMU_CAPS_KVM); + qemuTestDriverFree(&driver); return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-aavmf-virtio-mmio.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-aavmf-virtio-mmio.xml index 2f1f8dd3d..bea65990e 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-aavmf-virtio-mmio.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-aavmf-virtio-mmio.xml @@ -18,7 +18,7 @@ <pae/> <gic version='2'/> </features> - <cpu mode='custom' match='exact'> + <cpu mode='custom' match='exact' check='none'> <model fallback='allow'>cortex-a53</model> </cpu> <clock offset='utc'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-video-virtio-gpu-pci.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-video-virtio-gpu-pci.xml index 26f6a5162..2c765e7c3 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-video-virtio-gpu-pci.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-video-virtio-gpu-pci.xml @@ -11,7 +11,7 @@ <acpi/> <gic version='2'/> </features> - <cpu mode='custom' match='exact'> + <cpu mode='custom' match='exact' check='none'> <model fallback='allow'>cortex-a57</model> </cpu> <clock offset='utc'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-default.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-default.xml index f7fbdc7a9..88a6a6a0c 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-default.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-default.xml @@ -18,7 +18,7 @@ <pae/> <gic version='2'/> </features> - <cpu mode='custom' match='exact'> + <cpu mode='custom' match='exact' check='none'> <model fallback='allow'>cortex-a53</model> </cpu> <clock offset='utc'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-manual-addresses.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-manual-addresses.xml index 1b50f75f0..83cf0d1f5 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-manual-addresses.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-manual-addresses.xml @@ -18,7 +18,7 @@ <pae/> <gic version='2'/> </features> - <cpu mode='custom' match='exact'> + <cpu mode='custom' match='exact' check='none'> <model fallback='allow'>cortex-a53</model> </cpu> <clock offset='utc'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-default-none.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-default-none.xml new file mode 100644 index 000000000..b25cdd599 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-default-none.xml @@ -0,0 +1,28 @@ +<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'>6</vcpu> + <os> + <type arch='x86_64' machine='pc'>hvm</type> + <boot dev='network'/> + </os> + <cpu mode='host-passthrough' check='none'/> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu-kvm</emulator> + <controller type='usb' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <memballoon model='virtio'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </memballoon> + </devices> +</domain> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-default-none2.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-default-none2.xml new file mode 100644 index 000000000..310b95e58 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-default-none2.xml @@ -0,0 +1,30 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>6</vcpu> + <os> + <type arch='x86_64' machine='pc'>hvm</type> + <boot dev='network'/> + </os> + <cpu mode='custom' match='exact' check='none'> + <model fallback='forbid'>core2duo</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</emulator> + <controller type='usb' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <memballoon model='virtio'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </memballoon> + </devices> +</domain> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-default-partial.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-default-partial.xml new file mode 100644 index 000000000..f4bfe54ee --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-default-partial.xml @@ -0,0 +1,30 @@ +<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'>6</vcpu> + <os> + <type arch='x86_64' machine='pc'>hvm</type> + <boot dev='network'/> + </os> + <cpu mode='host-model' check='partial'> + <model fallback='allow'/> + </cpu> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu-kvm</emulator> + <controller type='usb' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <memballoon model='virtio'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </memballoon> + </devices> +</domain> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-default-partial2.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-default-partial2.xml new file mode 100644 index 000000000..8619f009c --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-default-partial2.xml @@ -0,0 +1,30 @@ +<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'>6</vcpu> + <os> + <type arch='x86_64' machine='pc'>hvm</type> + <boot dev='network'/> + </os> + <cpu mode='custom' match='exact' check='partial'> + <model fallback='forbid'>core2duo</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-kvm</emulator> + <controller type='usb' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <memballoon model='virtio'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </memballoon> + </devices> +</domain> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-full.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-full.xml new file mode 100644 index 000000000..3fd13f27e --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-full.xml @@ -0,0 +1,30 @@ +<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'>6</vcpu> + <os> + <type arch='x86_64' machine='pc'>hvm</type> + <boot dev='network'/> + </os> + <cpu mode='custom' match='exact' check='full'> + <model fallback='forbid'>core2duo</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-kvm</emulator> + <controller type='usb' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <memballoon model='virtio'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </memballoon> + </devices> +</domain> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-none.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-none.xml new file mode 100644 index 000000000..d71ad5fde --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-none.xml @@ -0,0 +1,30 @@ +<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'>6</vcpu> + <os> + <type arch='x86_64' machine='pc'>hvm</type> + <boot dev='network'/> + </os> + <cpu mode='custom' match='exact' check='none'> + <model fallback='forbid'>core2duo</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-kvm</emulator> + <controller type='usb' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <memballoon model='virtio'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </memballoon> + </devices> +</domain> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-partial.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-partial.xml new file mode 100644 index 000000000..8619f009c --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-partial.xml @@ -0,0 +1,30 @@ +<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'>6</vcpu> + <os> + <type arch='x86_64' machine='pc'>hvm</type> + <boot dev='network'/> + </os> + <cpu mode='custom' match='exact' check='partial'> + <model fallback='forbid'>core2duo</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-kvm</emulator> + <controller type='usb' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <memballoon model='virtio'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </memballoon> + </devices> +</domain> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-eoi-disabled.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-eoi-disabled.xml index 7a51e3ddf..b29a24e52 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-eoi-disabled.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-eoi-disabled.xml @@ -13,7 +13,7 @@ <apic eoi='off'/> <pae/> </features> - <cpu mode='custom' match='exact'> + <cpu mode='custom' match='exact' check='none'> <model fallback='allow'>qemu32</model> </cpu> <clock offset='utc'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-eoi-enabled.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-eoi-enabled.xml index ae8ab6aee..efba9e5db 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-eoi-enabled.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-eoi-enabled.xml @@ -13,7 +13,7 @@ <apic eoi='on'/> <pae/> </features> - <cpu mode='custom' match='exact'> + <cpu mode='custom' match='exact' check='none'> <model fallback='allow'>qemu32</model> </cpu> <clock offset='utc'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-host-kvmclock.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-host-kvmclock.xml index c2bdad91f..df0aecb3e 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-host-kvmclock.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-host-kvmclock.xml @@ -8,7 +8,7 @@ <type arch='x86_64' machine='pc'>hvm</type> <boot dev='network'/> </os> - <cpu mode='host-passthrough'/> + <cpu mode='host-passthrough' check='none'/> <clock offset='utc'> <timer name='kvmclock' present='no'/> </clock> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-host-model-features.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-host-model-features.xml index 161fcfe39..b1e194910 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-host-model-features.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-host-model-features.xml @@ -13,7 +13,7 @@ <type arch='i686' machine='pc'>hvm</type> <boot dev='hd'/> </os> - <cpu mode='host-model'> + <cpu mode='host-model' check='partial'> <model fallback='allow'/> <feature policy='require' name='abm'/> <feature policy='force' name='ds'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-host-passthrough-features.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-host-passthrough-features.xml index 935f8cd39..98189c43f 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-host-passthrough-features.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-host-passthrough-features.xml @@ -13,7 +13,7 @@ <type arch='i686' machine='pc'>hvm</type> <boot dev='hd'/> </os> - <cpu mode='host-passthrough'> + <cpu mode='host-passthrough' check='none'> <feature policy='require' name='abm'/> <feature policy='force' name='ds'/> <feature policy='disable' name='invtsc'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-kvmclock.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-kvmclock.xml index 4d222de4a..a483025a0 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-kvmclock.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-kvmclock.xml @@ -8,7 +8,7 @@ <type arch='i686' machine='pc'>hvm</type> <boot dev='network'/> </os> - <cpu mode='custom' match='exact'> + <cpu mode='custom' match='exact' check='partial'> <model fallback='allow'>core2duo</model> </cpu> <clock offset='utc'> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-timeout.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-timeout.xml index 5f881f1fb..b807ac31b 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-timeout.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-timeout.xml @@ -15,7 +15,7 @@ <apic/> <pae/> </features> - <cpu mode='custom' match='exact'> + <cpu mode='custom' match='exact' check='partial'> <model fallback='allow'>core2duo</model> <vendor>Intel</vendor> <topology sockets='1' cores='2' threads='1'/> diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 4353ad245..af56dd4e5 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1108,6 +1108,14 @@ mymain(void) QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_MACHINE_IOMMU); + DO_TEST("cpu-check-none", NONE); + DO_TEST("cpu-check-partial", NONE); + DO_TEST("cpu-check-full", NONE); + DO_TEST("cpu-check-default-none", NONE); + DO_TEST("cpu-check-default-none2", NONE); + DO_TEST("cpu-check-default-partial", NONE); + DO_TEST("cpu-check-default-partial2", NONE); + qemuTestDriverFree(&driver); return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; -- 2.12.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list