]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
qemu: get arch name from <cpu> element
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 27 Jan 2012 13:49:49 +0000 (14:49 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Fri, 27 Jan 2012 15:51:50 +0000 (16:51 +0100)
The qemu32 CPU model is chosen based on the <os arch=...> name when
creating the QEMU command line for a 64-bit host.  For the opposite
transformation we can test the guest CPU model for the "lm" feature.
If it is absent, def->os.arch needs to be corrected.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
src/qemu/qemu_command.c

index 0cc9f42fdd4f21025fbdbbafb72e21f662e9b48d..03cf9a3d069cee29922953032cd6e727696fed91 100644 (file)
@@ -6830,6 +6830,24 @@ qemuParseCommandLineCPU(virDomainDefPtr dom,
         }
     } while ((p = next));
 
+    if (STREQ(dom->os.arch, "x86_64")) {
+        bool is_32bit = false;
+        union cpuData *cpuData = NULL;
+        int ret;
+
+        ret = cpuEncode("x86_64", cpu, NULL, &cpuData,
+                        NULL, NULL, NULL, NULL);
+        if (ret < 0)
+            goto error;
+
+        is_32bit = (cpuHasFeature("x86_64", cpuData, "lm") != 1);
+        cpuDataFree("x86_64", cpuData);
+
+        if (is_32bit) {
+            VIR_FREE(dom->os.arch);
+            dom->os.arch = strdup("i686");
+        }
+    }
     return 0;
 
 syntax: