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 <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrange
2012-08-22 16:28:55 +01:00
parent bd66c243b3
commit ed769e1854
55 changed files with 104 additions and 162 deletions

View File

@@ -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 <<EOF
x86 Opteron_G3
x86 Opteron_G2
x86 Opteron_G1
x86 Nehalem
x86 Penryn
x86 Conroe
x86 [n270]
x86 [athlon]
x86 [pentium3]
x86 [pentium2]
x86 [pentium]
x86 [486]
x86 [coreduo]
x86 [qemu32]
x86 [kvm64]
x86 [core2duo]
x86 [phenom]
x86 [qemu64]
x86 [host]
EOF
}

View File

@@ -1,15 +0,0 @@
#! /bin/sh
. ${0%/*}/qemu-lib.sh
case $* in
"-M ?")
faked_machine
;;
"-cpu ?")
faked_cpu | grep -Fv '['
;;
*)
real_qemu "$@"
;;
esac

View File

@@ -1,15 +0,0 @@
#! /bin/sh
. ${0%/*}/qemu-lib.sh
case $* in
"-M ?")
faked_machine
;;
"-cpu ?")
faked_cpu
;;
*)
real_qemu "$@"
;;
esac

View File

@@ -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

View File

@@ -21,7 +21,7 @@
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/./qemu.sh</emulator>
<emulator>/usr/bin/qemu</emulator>
<controller type='usb' index='0'/>
<memballoon model='virtio'/>
</devices>

View File

@@ -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

View File

@@ -21,7 +21,7 @@
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/./qemu.sh</emulator>
<emulator>/usr/bin/qemu</emulator>
<controller type='usb' index='0'/>
<memballoon model='virtio'/>
</devices>

View File

@@ -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

View File

@@ -23,6 +23,6 @@
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/./qemu.sh</emulator>
<emulator>/usr/bin/qemu</emulator>
</devices>
</domain>

View File

@@ -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

View File

@@ -30,6 +30,6 @@
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/./qemu.sh</emulator>
<emulator>/usr/bin/qemu</emulator>
</devices>
</domain>

View File

@@ -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

View File

@@ -30,6 +30,6 @@
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/./qemu.sh</emulator>
<emulator>/usr/bin/qemu</emulator>
</devices>
</domain>

View File

@@ -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 \

View File

@@ -20,6 +20,6 @@
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/./qemu.sh</emulator>
<emulator>/usr/bin/qemu</emulator>
</devices>
</domain>

View File

@@ -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

View File

@@ -17,7 +17,7 @@
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/./qemu.sh</emulator>
<emulator>/usr/bin/qemu</emulator>
<controller type='usb' index='0'/>
<memballoon model='virtio'/>
</devices>

View File

@@ -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 \

View File

@@ -14,6 +14,6 @@
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/./qemu-supported-cpus.sh</emulator>
<emulator>/usr/bin/qemu</emulator>
</devices>
</domain>

View File

@@ -16,6 +16,6 @@
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/./qemu-supported-cpus.sh</emulator>
<emulator>/usr/bin/qemu</emulator>
</devices>
</domain>

View File

@@ -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 \

View File

@@ -14,6 +14,6 @@
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/./qemu.sh</emulator>
<emulator>/usr/bin/qemu</emulator>
</devices>
</domain>

View File

@@ -3,7 +3,7 @@ PATH=/bin \
HOME=/home/test \
USER=test \
LOGNAME=test \
./qemu.sh \
/usr/bin/qemu \
-S \
-M pc \
-cpu host \

View File

@@ -14,6 +14,6 @@
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/./qemu.sh</emulator>
<emulator>/usr/bin/qemu</emulator>
</devices>
</domain>

View File

@@ -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

View File

@@ -18,7 +18,7 @@
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/./qemu.sh</emulator>
<emulator>/usr/bin/qemu</emulator>
<controller type='usb' index='0'/>
<memballoon model='virtio'/>
</devices>

View File

@@ -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

View File

@@ -16,6 +16,6 @@
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/./qemu.sh</emulator>
<emulator>/usr/bin/qemu</emulator>
</devices>
</domain>

View File

@@ -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 \

View File

@@ -20,6 +20,6 @@
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/./qemu.sh</emulator>
<emulator>/usr/bin/qemu</emulator>
</devices>
</domain>

View File

@@ -20,6 +20,6 @@
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/./qemu.sh</emulator>
<emulator>/usr/bin/qemu</emulator>
</devices>
</domain>

View File

@@ -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 \

View File

@@ -20,6 +20,6 @@
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/./qemu.sh</emulator>
<emulator>/usr/bin/qemu</emulator>
</devices>
</domain>

View File

@@ -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 \

View File

@@ -20,6 +20,6 @@
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/./qemu.sh</emulator>
<emulator>/usr/bin/qemu</emulator>
</devices>
</domain>

View File

@@ -14,6 +14,6 @@
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/./qemu.sh</emulator>
<emulator>/usr/bin/qemu</emulator>
</devices>
</domain>

View File

@@ -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

View File

@@ -33,6 +33,6 @@
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/./qemu.sh</emulator>
<emulator>/usr/bin/qemu</emulator>
</devices>
</domain>

View File

@@ -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

View File

@@ -16,6 +16,6 @@
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/./qemu.sh</emulator>
<emulator>/usr/bin/qemu</emulator>
</devices>
</domain>

View File

@@ -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

View File

@@ -17,6 +17,6 @@
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/./qemu.sh</emulator>
<emulator>/usr/bin/qemu</emulator>
</devices>
</domain>

View File

@@ -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

View File

@@ -16,6 +16,6 @@
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/./qemu.sh</emulator>
<emulator>/usr/bin/qemu</emulator>
</devices>
</domain>

View File

@@ -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

View File

@@ -18,7 +18,7 @@
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/./qemu.sh</emulator>
<emulator>/usr/bin/qemu</emulator>
<controller type='usb' index='0'/>
<memballoon model='virtio'/>
</devices>

View File

@@ -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

View File

@@ -18,7 +18,7 @@
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/./qemu.sh</emulator>
<emulator>/usr/bin/qemu</emulator>
<controller type='usb' index='0'/>
<memballoon model='virtio'/>
</devices>

View File

@@ -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 \

View File

@@ -38,7 +38,7 @@
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/./qemu.sh</emulator>
<emulator>/usr/bin/qemu</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/var/lib/libvirt/images/f14.img'/>