]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Fix command line generation with faked host CPU
authorJiri Denemark <jdenemar@redhat.com>
Tue, 15 Feb 2011 14:23:17 +0000 (15:23 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Tue, 15 Feb 2011 21:51:50 +0000 (22:51 +0100)
The code expected that host CPU architecture matches the architecture on
which libvirt runs. This is normally true but not in tests, where host
CPU is faked to produce consistent results.

src/qemu/qemu_command.c

index d9af82913708d76af99ff8631e8765a33a4bfd81..05f427cc72bc89be4814c0bc4d4729529dbfcc1b 100644 (file)
@@ -2440,7 +2440,8 @@ qemuBuildCpuArgStr(const struct qemud_driver *driver,
     *hasHwVirt = false;
 
     if (def->cpu && def->cpu->model) {
-        if (qemuCapsProbeCPUModels(emulator, qemuCmdFlags, ut->machine,
+        if (host &&
+            qemuCapsProbeCPUModels(emulator, qemuCmdFlags, host->arch,
                                    &ncpus, &cpus) < 0)
             goto cleanup;
 
@@ -2469,7 +2470,7 @@ qemuBuildCpuArgStr(const struct qemud_driver *driver,
             break;
         }
 
-        if (VIR_ALLOC(guest) < 0 || !(guest->arch = strdup(ut->machine)))
+        if (VIR_ALLOC(guest) < 0 || !(guest->arch = strdup(host->arch)))
             goto no_memory;
 
         if (def->cpu->match == VIR_CPU_MATCH_MINIMUM)
@@ -2528,8 +2529,9 @@ qemuBuildCpuArgStr(const struct qemud_driver *driver,
     ret = 0;
 
 cleanup:
+    if (guest)
+        cpuDataFree(guest->arch, data);
     virCPUDefFree(guest);
-    cpuDataFree(ut->machine, data);
 
     if (cpus) {
         for (i = 0; i < ncpus; i++)