From ed769e1854080696b51e76d9b247a512f0bf1e29 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Wed, 22 Aug 2012 16:28:55 +0100 Subject: [PATCH] Remove probing of CPU models when launching QEMU guests When launching a QEMU guest the binary is probed to discover the list of supported CPU names. Remove this probing with a simple lookup of CPU models in the qemuCapsPtr object. This avoids another invocation of the QEMU binary during the startup path. As a nice benefit we can now remove all the nasty hacks from the test suite which were done to avoid having to exec QEMU on the test system. The building of the -cpu command line can just rely on data we pre-populate in qemuCapsPtr. Signed-off-by: Daniel P. Berrange --- src/qemu/qemu_capabilities.c | 18 +++++++ src/qemu/qemu_capabilities.h | 2 + src/qemu/qemu_command.c | 18 ++----- tests/qemuxml2argvdata/qemu-lib.sh | 50 ------------------ tests/qemuxml2argvdata/qemu-supported-cpus.sh | 15 ------ tests/qemuxml2argvdata/qemu.sh | 15 ------ .../qemuxml2argv-cpu-eoi-disabled.args | 2 +- .../qemuxml2argv-cpu-eoi-disabled.xml | 2 +- .../qemuxml2argv-cpu-eoi-enabled.args | 2 +- .../qemuxml2argv-cpu-eoi-enabled.xml | 2 +- .../qemuxml2argv-cpu-exact1.args | 2 +- .../qemuxml2argv-cpu-exact1.xml | 2 +- .../qemuxml2argv-cpu-exact2-nofallback.args | 2 +- .../qemuxml2argv-cpu-exact2-nofallback.xml | 2 +- .../qemuxml2argv-cpu-exact2.args | 2 +- .../qemuxml2argv-cpu-exact2.xml | 2 +- .../qemuxml2argv-cpu-fallback.args | 2 +- .../qemuxml2argv-cpu-fallback.xml | 2 +- .../qemuxml2argv-cpu-host-kvmclock.args | 2 +- .../qemuxml2argv-cpu-host-kvmclock.xml | 2 +- .../qemuxml2argv-cpu-host-model-fallback.args | 2 +- .../qemuxml2argv-cpu-host-model-fallback.xml | 2 +- ...qemuxml2argv-cpu-host-model-nofallback.xml | 2 +- .../qemuxml2argv-cpu-host-model.args | 2 +- .../qemuxml2argv-cpu-host-model.xml | 2 +- .../qemuxml2argv-cpu-host-passthrough.args | 2 +- .../qemuxml2argv-cpu-host-passthrough.xml | 2 +- .../qemuxml2argv-cpu-kvmclock.args | 2 +- .../qemuxml2argv-cpu-kvmclock.xml | 2 +- .../qemuxml2argv-cpu-minimum1.args | 2 +- .../qemuxml2argv-cpu-minimum1.xml | 2 +- .../qemuxml2argv-cpu-minimum2.args | 2 +- .../qemuxml2argv-cpu-minimum2.xml | 2 +- .../qemuxml2argv-cpu-nofallback.xml | 2 +- .../qemuxml2argv-cpu-numa1.args | 2 +- .../qemuxml2argv-cpu-numa1.xml | 2 +- .../qemuxml2argv-cpu-numa2.args | 2 +- .../qemuxml2argv-cpu-numa2.xml | 2 +- ...qemuxml2argv-cpu-qemu-host-passthrough.xml | 2 +- .../qemuxml2argv-cpu-strict1.args | 2 +- .../qemuxml2argv-cpu-strict1.xml | 2 +- .../qemuxml2argv-cpu-topology1.args | 2 +- .../qemuxml2argv-cpu-topology1.xml | 2 +- .../qemuxml2argv-cpu-topology2.args | 2 +- .../qemuxml2argv-cpu-topology2.xml | 2 +- .../qemuxml2argv-cpu-topology3.args | 2 +- .../qemuxml2argv-cpu-topology3.xml | 2 +- .../qemuxml2argv-eoi-disabled.args | 2 +- .../qemuxml2argv-eoi-disabled.xml | 2 +- .../qemuxml2argv-eoi-enabled.args | 2 +- .../qemuxml2argv-eoi-enabled.xml | 2 +- .../qemuxml2argv-graphics-spice-timeout.args | 2 +- .../qemuxml2argv-graphics-spice-timeout.xml | 2 +- tests/qemuxml2argvtest.c | 52 ++++++++++++------- .../qemuxml2xmlout-graphics-spice-timeout.xml | 2 +- 55 files changed, 104 insertions(+), 162 deletions(-) delete mode 100644 tests/qemuxml2argvdata/qemu-lib.sh delete mode 100755 tests/qemuxml2argvdata/qemu-supported-cpus.sh delete mode 100755 tests/qemuxml2argvdata/qemu.sh diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index d7d30e8fd..8f04027ae 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -1683,6 +1683,24 @@ unsigned int qemuCapsGetKVMVersion(qemuCapsPtr caps) } +int qemuCapsAddCPUDefinition(qemuCapsPtr caps, + const char *name) +{ + char *tmp = strdup(name); + if (!tmp) { + virReportOOMError(); + return -1; + } + if (VIR_EXPAND_N(caps->cpuDefinitions, caps->ncpuDefinitions, 1) < 0) { + VIR_FREE(tmp); + virReportOOMError(); + return -1; + } + caps->cpuDefinitions[caps->ncpuDefinitions-1] = tmp; + return 0; +} + + size_t qemuCapsGetCPUDefinitions(qemuCapsPtr caps, char ***names) { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 504b0ec74..3a68eb2d1 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -180,6 +180,8 @@ const char *qemuCapsGetBinary(qemuCapsPtr caps); const char *qemuCapsGetArch(qemuCapsPtr caps); unsigned int qemuCapsGetVersion(qemuCapsPtr caps); unsigned int qemuCapsGetKVMVersion(qemuCapsPtr caps); +int qemuCapsAddCPUDefinition(qemuCapsPtr caps, + const char *name); size_t qemuCapsGetCPUDefinitions(qemuCapsPtr caps, char ***names); size_t qemuCapsGetMachineTypes(qemuCapsPtr caps, diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index a0dc5a4a3..20730a90e 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4067,7 +4067,7 @@ qemuBuildCpuArgStr(const struct qemud_driver *driver, virCPUDefPtr guest = NULL; virCPUDefPtr cpu = NULL; size_t ncpus = 0; - const char **cpus = NULL; + char **cpus = NULL; const char *default_model; union cpuData *data = NULL; bool have_cpu = false; @@ -4089,12 +4089,8 @@ qemuBuildCpuArgStr(const struct qemud_driver *driver, const char *preferred; int hasSVM; - if (host && - qemuCapsProbeCPUModels(emulator, caps, host->arch, - &ncpus, &cpus) < 0) - goto cleanup; - - if (!ncpus || !host) { + if (!host || + (ncpus = qemuCapsGetCPUDefinitions(caps, &cpus)) == 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("CPU specification not supported by hypervisor")); goto cleanup; @@ -4163,7 +4159,7 @@ qemuBuildCpuArgStr(const struct qemud_driver *driver, guest->type = VIR_CPU_TYPE_GUEST; guest->fallback = cpu->fallback; - if (cpuDecode(guest, data, cpus, ncpus, preferred) < 0) + if (cpuDecode(guest, data, (const char **)cpus, ncpus, preferred) < 0) goto cleanup; virBufferAdd(&buf, guest->model, -1); @@ -4244,12 +4240,6 @@ cleanup: virCPUDefFree(guest); virCPUDefFree(cpu); - if (cpus) { - for (i = 0; i < ncpus; i++) - VIR_FREE(cpus[i]); - VIR_FREE(cpus); - } - return ret; no_memory: diff --git a/tests/qemuxml2argvdata/qemu-lib.sh b/tests/qemuxml2argvdata/qemu-lib.sh deleted file mode 100644 index ba1911991..000000000 --- a/tests/qemuxml2argvdata/qemu-lib.sh +++ /dev/null @@ -1,50 +0,0 @@ -candidates="/usr/bin/qemu-kvm - /usr/libexec/qemu-kvm - /usr/bin/qemu-system-x86_64 - /usr/bin/qemu" -qemu= -for candidate in $candidates; do - if test -x $candidate; then - qemu=$candidate - break - fi -done - -real_qemu() -{ - if test x$qemu != x; then - exec $qemu "$@" - else - return 1 - fi -} - -faked_machine() -{ - echo "pc" -} - -faked_cpu() -{ - cat <restart destroy - /./qemu.sh + /usr/bin/qemu diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-eoi-enabled.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-eoi-enabled.args index 3dc43107c..3442cafc1 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-eoi-enabled.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-eoi-enabled.args @@ -1,4 +1,4 @@ -LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test ./qemu.sh -S -M pc \ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc \ -cpu qemu32,+kvm_pv_eoi -m 214 -smp 6 -nographic -monitor \ unix:/tmp/test-monitor,server,nowait -boot n -net none -serial none \ -parallel none -usb diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-eoi-enabled.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-eoi-enabled.xml index 1ed630a0c..ecc542e84 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-eoi-enabled.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-eoi-enabled.xml @@ -21,7 +21,7 @@ restart destroy - /./qemu.sh + /usr/bin/qemu diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact1.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact1.args index 83f848f7e..fce9ad1fb 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact1.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact1.args @@ -1,4 +1,4 @@ -LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test ./qemu.sh -S -M pc \ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -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 -net \ none -serial none -parallel none -usb diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact1.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact1.xml index 9165fe3e0..ddd9d5ad3 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact1.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact1.xml @@ -23,6 +23,6 @@ restart destroy - /./qemu.sh + /usr/bin/qemu diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2-nofallback.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2-nofallback.args index 198d0d8f1..7f91bc72e 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2-nofallback.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2-nofallback.args @@ -1,4 +1,4 @@ -LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test ./qemu.sh -S -M pc \ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -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 -net \ none -serial none -parallel none -usb diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2-nofallback.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2-nofallback.xml index 67785a922..de4c8d2ff 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2-nofallback.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2-nofallback.xml @@ -30,6 +30,6 @@ restart destroy - /./qemu.sh + /usr/bin/qemu diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.args index 198d0d8f1..7f91bc72e 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.args @@ -1,4 +1,4 @@ -LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test ./qemu.sh -S -M pc \ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -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 -net \ none -serial none -parallel none -usb diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.xml index 575541a36..e027e6fcd 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.xml @@ -30,6 +30,6 @@ restart destroy - /./qemu.sh + /usr/bin/qemu diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-fallback.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-fallback.args index 658f1412a..fe1b4708a 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-fallback.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-fallback.args @@ -3,7 +3,7 @@ PATH=/bin \ HOME=/home/test \ USER=test \ LOGNAME=test \ -./qemu.sh \ +/usr/bin/qemu \ -S \ -M pc \ -cpu Penryn,-sse4.1 \ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-fallback.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-fallback.xml index 8f5987b07..6125f41f6 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-fallback.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-fallback.xml @@ -20,6 +20,6 @@ restart destroy - /./qemu.sh + /usr/bin/qemu diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-kvmclock.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-kvmclock.args index 8472b8a00..5e1e75925 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-kvmclock.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-kvmclock.args @@ -1,4 +1,4 @@ -LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test ./qemu.sh -S -M pc \ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc \ -cpu host,-kvmclock -enable-kvm -m 214 -smp 6 \ -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot n -net \ none -serial none -parallel none -usb diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-kvmclock.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-kvmclock.xml index cfbf44012..16d71a342 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-kvmclock.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-kvmclock.xml @@ -17,7 +17,7 @@ restart destroy - /./qemu.sh + /usr/bin/qemu diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-fallback.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-fallback.args index ac8ab1a6e..6ec201a62 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-fallback.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-fallback.args @@ -3,7 +3,7 @@ PATH=/bin \ HOME=/home/test \ USER=test \ LOGNAME=test \ -./qemu-supported-cpus.sh \ +/usr/bin/qemu \ -S \ -M pc \ -cpu Penryn,+xtpr,+tm2,+est,+vmx,+ds_cpl,+monitor,+pbe,+tm,+ht,+ss,+acpi,+ds,+vme,-sse4.1 \ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-fallback.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-fallback.xml index 41d455fb5..a1136e276 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-fallback.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-fallback.xml @@ -14,6 +14,6 @@ restart destroy - /./qemu-supported-cpus.sh + /usr/bin/qemu diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-nofallback.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-nofallback.xml index e2b4b83c4..d0219d5db 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-nofallback.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-nofallback.xml @@ -16,6 +16,6 @@ restart destroy - /./qemu-supported-cpus.sh + /usr/bin/qemu diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model.args index cf7eb2ac8..426c1c084 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model.args @@ -3,7 +3,7 @@ PATH=/bin \ HOME=/home/test \ USER=test \ LOGNAME=test \ -./qemu.sh \ +/usr/bin/qemu \ -S \ -M pc \ -cpu core2duo,+lahf_lm,+xtpr,+cx16,+tm2,+est,+vmx,+ds_cpl,+pbe,+tm,+ht,+ss,+acpi,+ds \ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model.xml index b7b95d71d..7e3f617b8 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model.xml @@ -14,6 +14,6 @@ restart destroy - /./qemu.sh + /usr/bin/qemu diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-passthrough.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-passthrough.args index c63ecce62..a7c6a6afa 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-passthrough.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-passthrough.args @@ -3,7 +3,7 @@ PATH=/bin \ HOME=/home/test \ USER=test \ LOGNAME=test \ -./qemu.sh \ +/usr/bin/qemu \ -S \ -M pc \ -cpu host \ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-passthrough.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-passthrough.xml index f591a17e2..f1233e1ee 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-passthrough.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-passthrough.xml @@ -14,6 +14,6 @@ restart destroy - /./qemu.sh + /usr/bin/qemu diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-kvmclock.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-kvmclock.args index 6816c006a..16bcc4458 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-kvmclock.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-kvmclock.args @@ -1,4 +1,4 @@ -LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test ./qemu.sh -S -M pc \ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc \ -cpu core2duo,-kvmclock -enable-kvm -m 214 -smp 6 \ -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot n -net \ none -serial none -parallel none -usb diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-kvmclock.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-kvmclock.xml index 304d88caa..0bbe8e025 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-kvmclock.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-kvmclock.xml @@ -18,7 +18,7 @@ restart destroy - /./qemu.sh + /usr/bin/qemu diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum1.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum1.args index df57c4809..22b6a1e96 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum1.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum1.args @@ -1,4 +1,4 @@ -LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test ./qemu.sh -S -M pc \ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -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 -net none -serial none -parallel none -usb diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum1.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum1.xml index 42026ab6e..4ba5d0b14 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum1.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum1.xml @@ -16,6 +16,6 @@ restart destroy - /./qemu.sh + /usr/bin/qemu diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum2.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum2.args index 9fb164863..cd615a2f7 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum2.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum2.args @@ -1,4 +1,4 @@ -LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test ./qemu.sh -S -M pc \ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -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 -net none -serial none \ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum2.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum2.xml index beb055189..c43bf4f80 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum2.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum2.xml @@ -20,6 +20,6 @@ restart destroy - /./qemu.sh + /usr/bin/qemu diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-nofallback.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-nofallback.xml index 31db01031..4ae0be8b2 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-nofallback.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-nofallback.xml @@ -20,6 +20,6 @@ restart destroy - /./qemu.sh + /usr/bin/qemu diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa1.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa1.args index 7c0dd3029..db70657da 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa1.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa1.args @@ -1,4 +1,4 @@ -LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test ./qemu.sh -S -M pc \ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc \ -m 214 -smp 16 -numa node,nodeid=0,cpus=0-7,mem=107 \ -numa node,nodeid=1,cpus=8-15,mem=107 -nographic -monitor \ unix:/tmp/test-monitor,server,nowait -no-acpi -boot n -net none -serial none \ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa1.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa1.xml index 53cc2949b..ee402c8f7 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa1.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa1.xml @@ -20,6 +20,6 @@ restart destroy - /./qemu.sh + /usr/bin/qemu diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa2.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa2.args index 2ac25683c..1b2154d0e 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa2.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa2.args @@ -1,4 +1,4 @@ -LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test ./qemu.sh -S -M pc \ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc \ -m 214 -smp 16,sockets=2,cores=4,threads=2 \ -numa node,nodeid=0,cpus=0-7,mem=107 \ -numa node,nodeid=1,cpus=8-15,mem=107 -nographic -monitor \ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa2.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa2.xml index 53cc2949b..ee402c8f7 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa2.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa2.xml @@ -20,6 +20,6 @@ restart destroy - /./qemu.sh + /usr/bin/qemu diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-qemu-host-passthrough.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-qemu-host-passthrough.xml index b8fbc51b1..7652a97ef 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-qemu-host-passthrough.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-qemu-host-passthrough.xml @@ -14,6 +14,6 @@ restart destroy - /./qemu.sh + /usr/bin/qemu diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-strict1.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-strict1.args index 3d0c61aab..41a674934 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-strict1.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-strict1.args @@ -1,4 +1,4 @@ -LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test ./qemu.sh -S -M pc \ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -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 -net none -serial none -parallel none -usb diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-strict1.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-strict1.xml index 02df18337..935f46fb9 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-strict1.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-strict1.xml @@ -33,6 +33,6 @@ restart destroy - /./qemu.sh + /usr/bin/qemu diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-topology1.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-topology1.args index 25e56abb1..89f07a9b5 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-topology1.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-topology1.args @@ -1,4 +1,4 @@ -LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test ./qemu.sh -S -M pc \ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc \ -m 214 -smp 6,sockets=3,cores=2,threads=1 -nographic -monitor \ unix:/tmp/test-monitor,server,nowait -no-acpi -boot n -net none -serial none \ -parallel none -usb diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-topology1.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-topology1.xml index 64783d181..6f70aa359 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-topology1.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-topology1.xml @@ -16,6 +16,6 @@ restart destroy - /./qemu.sh + /usr/bin/qemu diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-topology2.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-topology2.args index 348b757ee..8a65ae23e 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-topology2.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-topology2.args @@ -1,4 +1,4 @@ -LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test ./qemu.sh -S -M pc \ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc \ -cpu core2duo -m 214 -smp 6,sockets=1,cores=2,threads=3 -nographic -monitor \ unix:/tmp/test-monitor,server,nowait -no-acpi -boot n -net none -serial none \ -parallel none -usb diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-topology2.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-topology2.xml index 6f1630802..ab561fdd3 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-topology2.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-topology2.xml @@ -17,6 +17,6 @@ restart destroy - /./qemu.sh + /usr/bin/qemu diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-topology3.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-topology3.args index 57b2eea09..21e51c7b6 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-topology3.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-topology3.args @@ -1,3 +1,3 @@ -LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test ./qemu.sh -S -M pc \ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc \ -m 214 -smp 6 -nographic -monitor unix:/tmp/test-monitor,server,nowait \ -no-acpi -boot n -net none -serial none -parallel none -usb diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-topology3.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-topology3.xml index 64783d181..6f70aa359 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-topology3.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-topology3.xml @@ -16,6 +16,6 @@ restart destroy - /./qemu.sh + /usr/bin/qemu diff --git a/tests/qemuxml2argvdata/qemuxml2argv-eoi-disabled.args b/tests/qemuxml2argvdata/qemuxml2argv-eoi-disabled.args index 93475bd0e..1d610f685 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-eoi-disabled.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-eoi-disabled.args @@ -1,4 +1,4 @@ -LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test ./qemu.sh -S -M pc \ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc \ -cpu qemu32,-kvm_pv_eoi -m 214 -smp 6 -nographic -monitor \ unix:/tmp/test-monitor,server,nowait -boot n -net none -serial \ none -parallel none -usb diff --git a/tests/qemuxml2argvdata/qemuxml2argv-eoi-disabled.xml b/tests/qemuxml2argvdata/qemuxml2argv-eoi-disabled.xml index f84570e70..3173a4167 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-eoi-disabled.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-eoi-disabled.xml @@ -18,7 +18,7 @@ restart destroy - /./qemu.sh + /usr/bin/qemu diff --git a/tests/qemuxml2argvdata/qemuxml2argv-eoi-enabled.args b/tests/qemuxml2argvdata/qemuxml2argv-eoi-enabled.args index 13f570be4..02c8da3db 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-eoi-enabled.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-eoi-enabled.args @@ -1,4 +1,4 @@ -LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test ./qemu.sh -S -M pc \ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc \ -cpu qemu32,+kvm_pv_eoi -m 214 -smp 6 -nographic -monitor \ unix:/tmp/test-monitor,server,nowait -boot n -net none -serial \ none -parallel none -usb diff --git a/tests/qemuxml2argvdata/qemuxml2argv-eoi-enabled.xml b/tests/qemuxml2argvdata/qemuxml2argv-eoi-enabled.xml index 03b6b52e7..22f080395 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-eoi-enabled.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-eoi-enabled.xml @@ -18,7 +18,7 @@ restart destroy - /./qemu.sh + /usr/bin/qemu diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.args index ebda714f0..453805a6c 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.args @@ -1,5 +1,5 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=spice \ -./qemu.sh -S -M pc -cpu core2duo,+lahf_lm,+xtpr,+cx16,+tm2,\ +/usr/bin/qemu -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 \ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.xml index b4a75f4c6..f9fdf37b8 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.xml @@ -38,7 +38,7 @@ restart restart - /./qemu.sh + /usr/bin/qemu diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index aae0cdd59..0757e37be 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -106,26 +106,6 @@ static int testCompareXMLToArgvFiles(const char *xml, goto out; } - /* - * For test purposes, we may want to fake emulator's output by providing - * our own script instead of a real emulator. For this to work we need to - * specify a relative path in element, which, however, is not - * allowed by RelaxNG schema for domain XML. To work around it we add an - * extra '/' at the beginning of relative emulator path so that it looks - * like, e.g., "/./qemu.sh" or "/../emulator/qemu.sh" instead of - * "./qemu.sh" or "../emulator/qemu.sh" respectively. The following code - * detects such paths, strips the extra '/' and makes the path absolute. - */ - if (vmdef->emulator && STRPREFIX(vmdef->emulator, "/.")) { - if (!(emulator = strdup(vmdef->emulator + 1))) - goto out; - VIR_FREE(vmdef->emulator); - vmdef->emulator = NULL; - if (virAsprintf(&vmdef->emulator, "%s/qemuxml2argvdata/%s", - abs_srcdir, emulator) < 0) - goto out; - } - if (qemuCapsGet(extraFlags, QEMU_CAPS_DOMID)) vmdef->id = 6; else @@ -270,12 +250,40 @@ cleanup: } +static int +testAddCPUModels(qemuCapsPtr caps, bool skipLegacy) +{ + const char *newModels[] = { + "Opteron_G3", "Opteron_G2", "Opteron_G1", + "Nehalem", "Penryn", "Conroe", + }; + const char *legacyModels[] = { + "n270", "athlon", "pentium3", "pentium2", "pentium", + "486", "coreduo", "kvm32", "qemu32", "kvm64", + "core2duo", "phenom", "qemu64", + }; + size_t i; + + for (i = 0 ; i < ARRAY_CARDINALITY(newModels) ; i++) { + if (qemuCapsAddCPUDefinition(caps, newModels[i]) < 0) + return -1; + } + if (skipLegacy) + return 0; + for (i = 0 ; i < ARRAY_CARDINALITY(legacyModels) ; i++) { + if (qemuCapsAddCPUDefinition(caps, legacyModels[i]) < 0) + return -1; + } + return 0; +} + static int mymain(void) { int ret = 0; char *map = NULL; + bool skipLegacyCPUs = false; abs_top_srcdir = getenv("abs_top_srcdir"); if (!abs_top_srcdir) @@ -307,6 +315,8 @@ mymain(void) }; \ if (!(info.extraFlags = qemuCapsNew())) \ return EXIT_FAILURE; \ + if (testAddCPUModels(info.extraFlags, skipLegacyCPUs) < 0) \ + return EXIT_FAILURE; \ qemuCapsSetList(info.extraFlags, __VA_ARGS__, QEMU_CAPS_LAST); \ if (virtTestRun("QEMU XML-2-ARGV " name, \ 1, testCompareXMLToArgvHelper, &info) < 0) \ @@ -766,8 +776,10 @@ mymain(void) DO_TEST("cpu-numa1", NONE); DO_TEST("cpu-numa2", QEMU_CAPS_SMP_TOPOLOGY); DO_TEST("cpu-host-model", NONE); + skipLegacyCPUs = true; DO_TEST("cpu-host-model-fallback", NONE); DO_TEST_FAILURE("cpu-host-model-nofallback", NONE); + skipLegacyCPUs = false; DO_TEST("cpu-host-passthrough", QEMU_CAPS_KVM, QEMU_CAPS_CPU_HOST); DO_TEST_FAILURE("cpu-host-passthrough", NONE); DO_TEST_FAILURE("cpu-qemu-host-passthrough", diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-timeout.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-timeout.xml index 574d4743e..cd19b6442 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-timeout.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-timeout.xml @@ -38,7 +38,7 @@ restart restart - /./qemu.sh + /usr/bin/qemu -- 2.39.5