mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 03:12:22 +00:00
qemu: Don't compare CPU against host for TCG
Right now when building the qemu command line, we try to do various unconditional validations of the guest CPU against the host CPU. However this checks are overly applied. The only time we should use the checks are: - The user requests host-model/host-passthrough, or - When KVM is requsted. CPU features requested in TCG mode are always emulated by qemu and are independent of the host CPU, so no host CPU checks should be performed. Right now if trying to specify a CPU for arm on an x86 host, it attempts to do non-sensical validation and falls over. Switch all the test cases that were intending to test CPU validation to use KVM, so they continue to test the intended code. Amend some aarch64 XML tests with a CPU model, to ensure things work correctly.
This commit is contained in:
parent
3bc6dda6c5
commit
445a09bdc9
@ -6160,6 +6160,8 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
|
||||
virCPUCompareResult cmp;
|
||||
const char *preferred;
|
||||
virCapsPtr caps = NULL;
|
||||
bool compareAgainstHost = (def->virtType == VIR_DOMAIN_VIRT_KVM ||
|
||||
def->cpu->mode != VIR_CPU_MODE_CUSTOM);
|
||||
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto cleanup;
|
||||
@ -6182,30 +6184,33 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
|
||||
cpuUpdate(cpu, host) < 0)
|
||||
goto cleanup;
|
||||
|
||||
cmp = cpuGuestData(host, cpu, &data, &compare_msg);
|
||||
switch (cmp) {
|
||||
case VIR_CPU_COMPARE_INCOMPATIBLE:
|
||||
if (compare_msg) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("guest and host CPU are not compatible: %s"),
|
||||
compare_msg);
|
||||
} else {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("guest CPU is not compatible with host CPU"));
|
||||
}
|
||||
/* fall through */
|
||||
case VIR_CPU_COMPARE_ERROR:
|
||||
goto cleanup;
|
||||
/* For non-KVM, CPU features are emulated, so host compat doesn't matter */
|
||||
if (compareAgainstHost) {
|
||||
cmp = cpuGuestData(host, cpu, &data, &compare_msg);
|
||||
switch (cmp) {
|
||||
case VIR_CPU_COMPARE_INCOMPATIBLE:
|
||||
if (compare_msg) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("guest and host CPU are not compatible: %s"),
|
||||
compare_msg);
|
||||
} else {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("guest CPU is not compatible with host CPU"));
|
||||
}
|
||||
/* fall through */
|
||||
case VIR_CPU_COMPARE_ERROR:
|
||||
goto cleanup;
|
||||
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Only 'svm' requires --enable-nesting. The nested
|
||||
* 'vmx' patches now simply hook off the CPU features
|
||||
*/
|
||||
if (def->os.arch == VIR_ARCH_X86_64 ||
|
||||
def->os.arch == VIR_ARCH_I686) {
|
||||
if ((def->os.arch == VIR_ARCH_X86_64 || def->os.arch == VIR_ARCH_I686) &&
|
||||
compareAgainstHost) {
|
||||
int hasSVM = cpuHasFeature(data, "svm");
|
||||
if (hasSVM < 0)
|
||||
goto cleanup;
|
||||
@ -6233,16 +6238,23 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
|
||||
if (VIR_STRDUP(guest->vendor_id, cpu->vendor_id) < 0)
|
||||
goto cleanup;
|
||||
|
||||
guest->arch = host->arch;
|
||||
if (cpu->match == VIR_CPU_MATCH_MINIMUM)
|
||||
preferred = host->model;
|
||||
else
|
||||
preferred = cpu->model;
|
||||
if (compareAgainstHost) {
|
||||
guest->arch = host->arch;
|
||||
if (cpu->match == VIR_CPU_MATCH_MINIMUM)
|
||||
preferred = host->model;
|
||||
else
|
||||
preferred = cpu->model;
|
||||
|
||||
guest->type = VIR_CPU_TYPE_GUEST;
|
||||
guest->fallback = cpu->fallback;
|
||||
if (cpuDecode(guest, data, (const char **)cpus, ncpus, preferred) < 0)
|
||||
goto cleanup;
|
||||
guest->type = VIR_CPU_TYPE_GUEST;
|
||||
guest->fallback = cpu->fallback;
|
||||
if (cpuDecode(guest, data,
|
||||
(const char **)cpus, ncpus, preferred) < 0)
|
||||
goto cleanup;
|
||||
} else {
|
||||
guest->arch = def->os.arch;
|
||||
if (VIR_STRDUP(guest->model, cpu->model) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
virBufferAdd(buf, guest->model, -1);
|
||||
if (guest->vendor_id)
|
||||
@ -6259,7 +6271,7 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
cleanup:
|
||||
virObjectUnref(caps);
|
||||
VIR_FREE(compare_msg);
|
||||
cpuDataFree(data);
|
||||
|
@ -1,5 +1,6 @@
|
||||
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
|
||||
/usr/bin/qemu-system-aarch64 -S -M virt -m 1024 -smp 1 -nographic \
|
||||
/usr/bin/qemu-system-aarch64 -S -M virt -cpu cortex-a53 \
|
||||
-m 1024 -smp 1 -nographic \
|
||||
-nodefconfig -nodefaults -monitor unix:/tmp/test-monitor,server,nowait \
|
||||
-boot c -kernel /aarch64.kernel -initrd /aarch64.initrd -append console=ttyAMA0 \
|
||||
-usb -device virtio-net-device,vlan=0,id=net0,mac=52:54:00:09:a4:37 \
|
||||
|
@ -7,6 +7,9 @@
|
||||
<features>
|
||||
<acpi/>
|
||||
</features>
|
||||
<cpu match='exact'>
|
||||
<model>cortex-a53</model>
|
||||
</cpu>
|
||||
<os>
|
||||
<type arch="aarch64" machine="virt">hvm</type>
|
||||
<kernel>/aarch64.kernel</kernel>
|
||||
|
@ -1,5 +1,6 @@
|
||||
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
|
||||
/usr/bin/qemu-system-aarch64 -S -M virt -m 1024 -smp 1 -nographic \
|
||||
/usr/bin/qemu-system-aarch64 -S -M virt -cpu cortex-a53 \
|
||||
-m 1024 -smp 1 -nographic \
|
||||
-nodefconfig -nodefaults -monitor unix:/tmp/test-monitor,server,nowait \
|
||||
-boot c -kernel /aarch64.kernel -initrd /aarch64.initrd -append \
|
||||
'earlyprintk console=ttyAMA0,115200n8 rw root=/dev/vda rootwait' \
|
||||
|
@ -16,6 +16,9 @@
|
||||
<apic/>
|
||||
<pae/>
|
||||
</features>
|
||||
<cpu match='exact'>
|
||||
<model>cortex-a53</model>
|
||||
</cpu>
|
||||
<clock offset="utc"/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
|
@ -1,5 +1,5 @@
|
||||
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
|
||||
/usr/bin/qemu -S -M pc \
|
||||
/usr/bin/qemu-kvm -S -M pc \
|
||||
-cpu qemu64,-svm,-lm,-nx,-syscall,-clflush,-pse36,-mca -m 214 -smp 6 \
|
||||
-nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot n -usb -net \
|
||||
none -serial none -parallel none
|
||||
|
@ -1,4 +1,4 @@
|
||||
<domain type='qemu'>
|
||||
<domain type='kvm'>
|
||||
<name>QEMUGuest1</name>
|
||||
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||
<memory unit='KiB'>219100</memory>
|
||||
@ -23,6 +23,6 @@
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu</emulator>
|
||||
<emulator>/usr/bin/qemu-kvm</emulator>
|
||||
</devices>
|
||||
</domain>
|
||||
|
@ -1,5 +1,5 @@
|
||||
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
|
||||
/usr/bin/qemu -S -M pc \
|
||||
/usr/bin/qemu-kvm -S -M pc \
|
||||
-cpu core2duo,+lahf_lm,+3dnowext,+xtpr,+ds_cpl,+tm,+ht,+ds,-nx -m 214 -smp 6 \
|
||||
-nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot n -usb -net \
|
||||
none -serial none -parallel none
|
||||
|
@ -1,4 +1,4 @@
|
||||
<domain type='qemu'>
|
||||
<domain type='kvm'>
|
||||
<name>QEMUGuest1</name>
|
||||
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||
<memory unit='KiB'>219100</memory>
|
||||
@ -30,6 +30,6 @@
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu</emulator>
|
||||
<emulator>/usr/bin/qemu-kvm</emulator>
|
||||
</devices>
|
||||
</domain>
|
||||
|
@ -1,5 +1,5 @@
|
||||
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
|
||||
/usr/bin/qemu -S -M pc \
|
||||
/usr/bin/qemu-kvm -S -M pc \
|
||||
-cpu core2duo,+lahf_lm,+3dnowext,+xtpr,+ds_cpl,+tm,+ht,+ds,-nx -m 214 -smp 6 \
|
||||
-nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot n -usb -net \
|
||||
none -serial none -parallel none
|
||||
|
@ -1,4 +1,4 @@
|
||||
<domain type='qemu'>
|
||||
<domain type='kvm'>
|
||||
<name>QEMUGuest1</name>
|
||||
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||
<memory unit='KiB'>219100</memory>
|
||||
@ -30,6 +30,6 @@
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu</emulator>
|
||||
<emulator>/usr/bin/qemu-kvm</emulator>
|
||||
</devices>
|
||||
</domain>
|
||||
|
@ -3,7 +3,7 @@ PATH=/bin \
|
||||
HOME=/home/test \
|
||||
USER=test \
|
||||
LOGNAME=test QEMU_AUDIO_DRV=none \
|
||||
/usr/bin/qemu \
|
||||
/usr/bin/qemu-kvm \
|
||||
-S \
|
||||
-M pc \
|
||||
-cpu Penryn,-sse4.1 \
|
||||
|
@ -1,4 +1,4 @@
|
||||
<domain type='qemu'>
|
||||
<domain type='kvm'>
|
||||
<name>QEMUGuest1</name>
|
||||
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||
<memory unit='KiB'>219100</memory>
|
||||
@ -20,6 +20,6 @@
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu</emulator>
|
||||
<emulator>/usr/bin/qemu-kvm</emulator>
|
||||
</devices>
|
||||
</domain>
|
||||
|
@ -1,5 +1,5 @@
|
||||
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
|
||||
/usr/bin/qemu -S -M pc \
|
||||
/usr/bin/qemu-kvm -S -M pc \
|
||||
-cpu core2duo,+lahf_lm,+xtpr,+cx16,+tm2,+est,+vmx,+ds_cpl,+pbe,+tm,+ht,+ss,\
|
||||
+acpi,+ds -m 214 -smp 6 -nographic -monitor unix:/tmp/test-monitor,server,\
|
||||
nowait -no-acpi -boot n -usb -net none -serial none -parallel none
|
||||
|
@ -1,4 +1,4 @@
|
||||
<domain type='qemu'>
|
||||
<domain type='kvm'>
|
||||
<name>QEMUGuest1</name>
|
||||
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||
<memory unit='KiB'>219100</memory>
|
||||
@ -16,6 +16,6 @@
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu</emulator>
|
||||
<emulator>/usr/bin/qemu-kvm</emulator>
|
||||
</devices>
|
||||
</domain>
|
||||
|
@ -1,5 +1,5 @@
|
||||
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
|
||||
/usr/bin/qemu -S -M pc \
|
||||
/usr/bin/qemu-kvm -S -M pc \
|
||||
-cpu core2duo,+lahf_lm,+xtpr,+cx16,+tm2,+est,+vmx,+ds_cpl,+pbe,+tm,+ht,+ss,\
|
||||
+acpi,+ds,-lm,-nx,-syscall -m 214 -smp 6 -nographic -monitor \
|
||||
unix:/tmp/test-monitor,server,nowait -no-acpi -boot n -usb -net none -serial none \
|
||||
|
@ -1,4 +1,4 @@
|
||||
<domain type='qemu'>
|
||||
<domain type='kvm'>
|
||||
<name>QEMUGuest1</name>
|
||||
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||
<memory unit='KiB'>219100</memory>
|
||||
@ -20,6 +20,6 @@
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu</emulator>
|
||||
<emulator>/usr/bin/qemu-kvm</emulator>
|
||||
</devices>
|
||||
</domain>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<domain type='qemu'>
|
||||
<domain type='kvm'>
|
||||
<name>QEMUGuest1</name>
|
||||
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||
<memory unit='KiB'>219100</memory>
|
||||
|
@ -1,5 +1,5 @@
|
||||
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
|
||||
/usr/bin/qemu -S -M pc \
|
||||
/usr/bin/qemu-kvm -S -M pc \
|
||||
-cpu core2duo,+lahf_lm,+3dnowext,+xtpr,+est,+vmx,+ds_cpl,+tm,+ht,+acpi,+ds,-nx \
|
||||
-m 214 -smp 6 -nographic -monitor unix:/tmp/test-monitor,server,nowait \
|
||||
-no-acpi -boot n -usb -net none -serial none -parallel none
|
||||
|
@ -1,4 +1,4 @@
|
||||
<domain type='qemu'>
|
||||
<domain type='kvm'>
|
||||
<name>QEMUGuest1</name>
|
||||
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||
<memory unit='KiB'>219100</memory>
|
||||
@ -33,6 +33,6 @@
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu</emulator>
|
||||
<emulator>/usr/bin/qemu-kvm</emulator>
|
||||
</devices>
|
||||
</domain>
|
||||
|
@ -1,5 +1,5 @@
|
||||
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=spice \
|
||||
/usr/bin/qemu -S -M pc -cpu core2duo,+lahf_lm,+xtpr,+cx16,+tm2,\
|
||||
/usr/bin/qemu-kvm -S -M pc -cpu core2duo,+lahf_lm,+xtpr,+cx16,+tm2,\
|
||||
+est,+vmx,+ds_cpl,+pbe,+tm,+ht,+ss,+acpi,+ds \
|
||||
-m 1024 -smp 2 -nodefaults -monitor unix:/tmp/test-monitor,server,nowait \
|
||||
-boot dc -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x6 \
|
||||
|
@ -1,4 +1,4 @@
|
||||
<domain type='qemu'>
|
||||
<domain type='kvm'>
|
||||
<name>f14</name>
|
||||
<uuid>553effab-b5e1-2d80-dfe3-da4344826c43</uuid>
|
||||
<memory unit='KiB'>1048576</memory>
|
||||
@ -38,7 +38,7 @@
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>restart</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu</emulator>
|
||||
<emulator>/usr/bin/qemu-kvm</emulator>
|
||||
<disk type='file' device='disk'>
|
||||
<driver name='qemu' type='qcow2'/>
|
||||
<source file='/var/lib/libvirt/images/f14.img'/>
|
||||
|
@ -1,6 +1,6 @@
|
||||
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test \
|
||||
/usr/bin/qemu-system-ppc64 -S -M pseries -cpu POWER7_v2.3 -m 512 -smp 1 -nographic \
|
||||
-nodefconfig -nodefaults \
|
||||
QEMU_AUDIO_DRV=none /usr/bin/qemu-system-ppc64 -S -M pseries -cpu POWER7_v2.3 \
|
||||
-m 512 -smp 1 -nographic -nodefconfig -nodefaults \
|
||||
-chardev socket,id=charmonitor,path=/tmp/test-monitor,server,nowait \
|
||||
-mon chardev=charmonitor,id=monitor,mode=readline -no-acpi -boot c -usb \
|
||||
-chardev pty,id=charserial0 \
|
||||
|
@ -933,7 +933,7 @@ mymain(void)
|
||||
QEMU_CAPS_DEVICE, QEMU_CAPS_SPICE,
|
||||
QEMU_CAPS_DEVICE_QXL);
|
||||
DO_TEST("graphics-spice-timeout",
|
||||
QEMU_CAPS_DRIVE,
|
||||
QEMU_CAPS_KVM, QEMU_CAPS_DRIVE,
|
||||
QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL,
|
||||
QEMU_CAPS_DEVICE, QEMU_CAPS_SPICE,
|
||||
QEMU_CAPS_DEVICE_QXL_VGA);
|
||||
@ -1208,14 +1208,14 @@ mymain(void)
|
||||
DO_TEST("cpu-topology1", QEMU_CAPS_SMP_TOPOLOGY);
|
||||
DO_TEST("cpu-topology2", QEMU_CAPS_SMP_TOPOLOGY);
|
||||
DO_TEST("cpu-topology3", NONE);
|
||||
DO_TEST("cpu-minimum1", NONE);
|
||||
DO_TEST("cpu-minimum2", NONE);
|
||||
DO_TEST("cpu-exact1", NONE);
|
||||
DO_TEST("cpu-exact2", NONE);
|
||||
DO_TEST("cpu-exact2-nofallback", NONE);
|
||||
DO_TEST("cpu-fallback", NONE);
|
||||
DO_TEST_FAILURE("cpu-nofallback", NONE);
|
||||
DO_TEST("cpu-strict1", NONE);
|
||||
DO_TEST("cpu-minimum1", QEMU_CAPS_KVM);
|
||||
DO_TEST("cpu-minimum2", QEMU_CAPS_KVM);
|
||||
DO_TEST("cpu-exact1", QEMU_CAPS_KVM);
|
||||
DO_TEST("cpu-exact2", QEMU_CAPS_KVM);
|
||||
DO_TEST("cpu-exact2-nofallback", QEMU_CAPS_KVM);
|
||||
DO_TEST("cpu-fallback", QEMU_CAPS_KVM);
|
||||
DO_TEST_FAILURE("cpu-nofallback", QEMU_CAPS_KVM);
|
||||
DO_TEST("cpu-strict1", QEMU_CAPS_KVM);
|
||||
DO_TEST("cpu-numa1", NONE);
|
||||
DO_TEST("cpu-numa2", QEMU_CAPS_SMP_TOPOLOGY);
|
||||
DO_TEST_PARSE_ERROR("cpu-numa3", NONE);
|
||||
@ -1303,7 +1303,8 @@ mymain(void)
|
||||
DO_TEST("pseries-usb-kbd", QEMU_CAPS_PCI_OHCI,
|
||||
QEMU_CAPS_DEVICE_USB_KBD, QEMU_CAPS_CHARDEV,
|
||||
QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
|
||||
DO_TEST_FAILURE("pseries-cpu-exact", QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
|
||||
DO_TEST("pseries-cpu-exact", QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE,
|
||||
QEMU_CAPS_NODEFCONFIG);
|
||||
DO_TEST("disk-ide-drive-split",
|
||||
QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
|
||||
QEMU_CAPS_IDE_CD);
|
||||
|
@ -1,4 +1,4 @@
|
||||
<domain type='qemu'>
|
||||
<domain type='kvm'>
|
||||
<name>f14</name>
|
||||
<uuid>553effab-b5e1-2d80-dfe3-da4344826c43</uuid>
|
||||
<memory unit='KiB'>1048576</memory>
|
||||
@ -38,7 +38,7 @@
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>restart</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu</emulator>
|
||||
<emulator>/usr/bin/qemu-kvm</emulator>
|
||||
<disk type='file' device='disk'>
|
||||
<driver name='qemu' type='qcow2'/>
|
||||
<source file='/var/lib/libvirt/images/f14.img'/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user