]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
Remove probing of CPU models when launching QEMU guests
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 22 Aug 2012 15:28:55 +0000 (16:28 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Thu, 27 Sep 2012 09:24:52 +0000 (10:24 +0100)
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>
55 files changed:
src/qemu/qemu_capabilities.c
src/qemu/qemu_capabilities.h
src/qemu/qemu_command.c
tests/qemuxml2argvdata/qemu-lib.sh [deleted file]
tests/qemuxml2argvdata/qemu-supported-cpus.sh [deleted file]
tests/qemuxml2argvdata/qemu.sh [deleted file]
tests/qemuxml2argvdata/qemuxml2argv-cpu-eoi-disabled.args
tests/qemuxml2argvdata/qemuxml2argv-cpu-eoi-disabled.xml
tests/qemuxml2argvdata/qemuxml2argv-cpu-eoi-enabled.args
tests/qemuxml2argvdata/qemuxml2argv-cpu-eoi-enabled.xml
tests/qemuxml2argvdata/qemuxml2argv-cpu-exact1.args
tests/qemuxml2argvdata/qemuxml2argv-cpu-exact1.xml
tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2-nofallback.args
tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2-nofallback.xml
tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.args
tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.xml
tests/qemuxml2argvdata/qemuxml2argv-cpu-fallback.args
tests/qemuxml2argvdata/qemuxml2argv-cpu-fallback.xml
tests/qemuxml2argvdata/qemuxml2argv-cpu-host-kvmclock.args
tests/qemuxml2argvdata/qemuxml2argv-cpu-host-kvmclock.xml
tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-fallback.args
tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-fallback.xml
tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-nofallback.xml
tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model.args
tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model.xml
tests/qemuxml2argvdata/qemuxml2argv-cpu-host-passthrough.args
tests/qemuxml2argvdata/qemuxml2argv-cpu-host-passthrough.xml
tests/qemuxml2argvdata/qemuxml2argv-cpu-kvmclock.args
tests/qemuxml2argvdata/qemuxml2argv-cpu-kvmclock.xml
tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum1.args
tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum1.xml
tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum2.args
tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum2.xml
tests/qemuxml2argvdata/qemuxml2argv-cpu-nofallback.xml
tests/qemuxml2argvdata/qemuxml2argv-cpu-numa1.args
tests/qemuxml2argvdata/qemuxml2argv-cpu-numa1.xml
tests/qemuxml2argvdata/qemuxml2argv-cpu-numa2.args
tests/qemuxml2argvdata/qemuxml2argv-cpu-numa2.xml
tests/qemuxml2argvdata/qemuxml2argv-cpu-qemu-host-passthrough.xml
tests/qemuxml2argvdata/qemuxml2argv-cpu-strict1.args
tests/qemuxml2argvdata/qemuxml2argv-cpu-strict1.xml
tests/qemuxml2argvdata/qemuxml2argv-cpu-topology1.args
tests/qemuxml2argvdata/qemuxml2argv-cpu-topology1.xml
tests/qemuxml2argvdata/qemuxml2argv-cpu-topology2.args
tests/qemuxml2argvdata/qemuxml2argv-cpu-topology2.xml
tests/qemuxml2argvdata/qemuxml2argv-cpu-topology3.args
tests/qemuxml2argvdata/qemuxml2argv-cpu-topology3.xml
tests/qemuxml2argvdata/qemuxml2argv-eoi-disabled.args
tests/qemuxml2argvdata/qemuxml2argv-eoi-disabled.xml
tests/qemuxml2argvdata/qemuxml2argv-eoi-enabled.args
tests/qemuxml2argvdata/qemuxml2argv-eoi-enabled.xml
tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.args
tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.xml
tests/qemuxml2argvtest.c
tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-timeout.xml

index d7d30e8fd209825b75508aee978dbabcf335423f..8f04027ae74dab362a037dbce961e5c027008368 100644 (file)
@@ -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)
 {
index 504b0ec7483ccb3dfb1eab0b0b22c0f72c23b526..3a68eb2d138d731b67c6f97cb5c46f5864ef1e61 100644 (file)
@@ -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,
index a0dc5a4a3956f3ece94498ad916254efc2f4f037..20730a90eb21f5d005a43b171ec3eef063117cb6 100644 (file)
@@ -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 (file)
index ba19119..0000000
+++ /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 <<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
-}
diff --git a/tests/qemuxml2argvdata/qemu-supported-cpus.sh b/tests/qemuxml2argvdata/qemu-supported-cpus.sh
deleted file mode 100755 (executable)
index 0204f51..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#! /bin/sh
-
-. ${0%/*}/qemu-lib.sh
-
-case $* in
-"-M ?")
-    faked_machine
-    ;;
-"-cpu ?")
-    faked_cpu | grep -Fv '['
-    ;;
-*)
-    real_qemu "$@"
-    ;;
-esac
diff --git a/tests/qemuxml2argvdata/qemu.sh b/tests/qemuxml2argvdata/qemu.sh
deleted file mode 100755 (executable)
index 5928c1b..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#! /bin/sh
-
-. ${0%/*}/qemu-lib.sh
-
-case $* in
-"-M ?")
-    faked_machine
-    ;;
-"-cpu ?")
-    faked_cpu
-    ;;
-*)
-    real_qemu "$@"
-    ;;
-esac
index 6d57f9101347de479c611d5e5223967d86322f6a..aee85c73d0104e503d85b64922fa9de5fdaf3241 100644 (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
index 467df3041705d628b04135fbaf3a44aff8926fa2..5e5bc040ba12d12923b40a89eb5d865b2648bce9 100644 (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>
index 3dc43107ceec3df2e172542d5e2d4326ca0212ba..3442cafc1dabb4deec0bd67e9d70d6fb1a8da85b 100644 (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
index 1ed630a0c70a06988664002430863f6e32200b55..ecc542e842774bccd6ed7719b6783ea459227088 100644 (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>
index 83f848f7e3107069cc1004df92102e42abbdb1a4..fce9ad1fb6b36b1cbeb37d4b2a56612b3bcb9035 100644 (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
index 9165fe3e01b3a11ee63e6cf53dd14a940ff96512..ddd9d5ad3541b0f2ac26a9c7c0bbf4e6bff7b55f 100644 (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>
index 198d0d8f171f8fbf57484fd4f5fbf858af5a51ef..7f91bc72ea3faef8cd8b1918fddbd27436969647 100644 (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
index 67785a922bdb11546b8ac79c926090aeddcc30f4..de4c8d2fff8bdeb94eaf30da2b5a3390a8b9e205 100644 (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>
index 198d0d8f171f8fbf57484fd4f5fbf858af5a51ef..7f91bc72ea3faef8cd8b1918fddbd27436969647 100644 (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
index 575541a3690ca88c544ce837ba86f4acec922405..e027e6fcd38519c2c75e47407ab42533b9e4f8ac 100644 (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>
index 658f1412a73718cf7ffe3f8bcf46c839616254c0..fe1b4708a5b2ba36f7a49398ab11a24e0aae806d 100644 (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 \
index 8f5987b077944ed35e8763bd7f1c3c250cff6239..6125f41f65b1790442e2b23e0aad601972097c97 100644 (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>
index 8472b8a002e7bb017a17f185aa66dd5fb8375c59..5e1e75925daa885886850d753759a17314167ef8 100644 (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
index cfbf4401222817807363e7af12be13c0d1ed7611..16d71a342c654abf80176441e052fa5a76079875 100644 (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>
index ac8ab1a6e4ae75cceb4a46a9c80f1dec742da6f0..6ec201a62b3b7ec8ab3246c9aeef34d01491188e 100644 (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 \
index 41d455fb5d7b743806c6d76348df960684c222d2..a1136e2765e02b12f9296cfeb3e42bcf3a3c5f68 100644 (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>
index e2b4b83c4c8716c529edc35262df4b99888647f5..d0219d5dbe47b17f2781e33b22dc94087cdaf3e4 100644 (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>
index cf7eb2ac813fa807bbef610d899d80d8851fc70b..426c1c084367c36c6b7a6b93b6a3fed985374fdd 100644 (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 \
index b7b95d71d0abd1a6f12b0701b7cdeebdf1e1b6da..7e3f617b85144cc1bbfcbd3139c105c84dbb5523 100644 (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>
index c63ecce629761d94cbb4e2d26417c6915587b8b7..a7c6a6afa41c1b019284f6c8b00c2000a878ed67 100644 (file)
@@ -3,7 +3,7 @@ PATH=/bin \
 HOME=/home/test \
 USER=test \
 LOGNAME=test \
-./qemu.sh \
+/usr/bin/qemu \
 -S \
 -M pc \
 -cpu host \
index f591a17e2d9f9d702c0168901152736beb7e34d4..f1233e1ee522af86dbd9003c38f879d8405bfa72 100644 (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>
index 6816c006a044c60ff0c0fcc24019ce613afe1845..16bcc44587ac018fec615607d3ca82e04112eb93 100644 (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
index 304d88caa08444ddb55b65a7c6cb02c8bb07ea99..0bbe8e025a207994cddab3b4b41b0718e521a334 100644 (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>
index df57c48098c9c8af4f1848ae55f21243c95b6483..22b6a1e96514cacf6d0f15cb866291b5d1071cdb 100644 (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
index 42026ab6e173ad6bc04e58804fbe983d85f16f98..4ba5d0b14f2454d4a6a9809214000a470641c8c1 100644 (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>
index 9fb164863b22936365bdcb906e6627bc2440adb9..cd615a2f7dc58b1a58c85311feba3ae145e2c2cc 100644 (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 \
index beb0551899740021bb4f070481855af0b2b65836..c43bf4f80efb3bbcd17ad36501bcfa3e93d98348 100644 (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>
index 31db01031fb9585ab1ce49cc877cbba60ebdc4a6..4ae0be8b23b181023c773c74588ce08210cf1f27 100644 (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>
index 7c0dd3029e82b7c56fa5728a6949d9f467d65a39..db70657da8e9c604329bb5941064d0932e82db25 100644 (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 \
index 53cc2949baab0262511f7a846265d101ba34416c..ee402c8f7446faa83d767b9613b9517953ac7678 100644 (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>
index 2ac25683c7419ece038827d4bcad3de07a80b7bb..1b2154d0e443b4b51114cfc704ac159ae3bc7e47 100644 (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 \
index 53cc2949baab0262511f7a846265d101ba34416c..ee402c8f7446faa83d767b9613b9517953ac7678 100644 (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>
index b8fbc51b1961ab348c9c01d53e074e13adc1ae45..7652a97ef3a33b81d23b66878b232c2e847c34ba 100644 (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>
index 3d0c61aab9ad2f67fa4196c249c306747bfc5bbf..41a674934a0ecb2ea19118a0fc2af5b0dd7ff6e4 100644 (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
index 02df183379b3b9754d0f7cd4058143ba5ef02470..935f46fb9590469f27f6be82bfeb19aa80470206 100644 (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>
index 25e56abb1b77d7545554605628f9adb798e2d5ef..89f07a9b5a7e6f8a1ac64b0f84032360a764c939 100644 (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
index 64783d181321e08e6229549c7192cbf2e514dc8b..6f70aa3597396f6df9ffa227263c2c32a8c156f8 100644 (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>
index 348b757ee00e6b0064cd067577facf86e0103094..8a65ae23e42e7ecb8e883b68fca739a8035d37c4 100644 (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
index 6f1630802ace8cf9a6d421a8980b1a68a751abfe..ab561fdd3c10c9f6c61ebfb05d619bbd8aef92af 100644 (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>
index 57b2eea090edd5508b89c15c6d780e925f2fd1f2..21e51c7b6ca833bab36747500cbc1f07f233fcff 100644 (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
index 64783d181321e08e6229549c7192cbf2e514dc8b..6f70aa3597396f6df9ffa227263c2c32a8c156f8 100644 (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>
index 93475bd0e614b34b9428f7ee1b4bd4e751778912..1d610f685ace77e274087971c3190cef10c9653d 100644 (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
index f84570e70e95269cd6e2b57cd2d7658f8f950d35..3173a4167d3618dc401ef4a6f25ecd3f267e2364 100644 (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>
index 13f570be49e75668c4cdd611ca9b388dedfa6d1c..02c8da3db9db1ea0a2c4f718bdbfad1595c9fa19 100644 (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
index 03b6b52e76523c64d077267d24402f849e9f6bbc..22f0803952e776e980e213fa1e2dc6b66c9b4eb5 100644 (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>
index ebda714f0744d040544f12b88b8abfd4a837cf15..453805a6ca774cafd39466373d6c1e43d4fdc6be 100644 (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 \
index b4a75f4c65f215b202952a85ce18152e78dc4f9c..f9fdf37b8ac7131a9ead59ec027f629c2b244ddd 100644 (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'/>
index aae0cdd59943dc31207a3b082dbebe57af835424..0757e37be44db0ec1fcf06694affa08180364217 100644 (file)
@@ -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 <emulator/> 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",
index 574d4743e9a8f0641b1890b38111d7f4f5a415fb..cd19b6442b3ac807dec27dcb62cb906754788753 100644 (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'/>