From: Paolo Bonzini Date: Fri, 27 Jan 2012 13:49:49 +0000 (+0100) Subject: qemu: get arch name from element X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=d5e88b2c33e11bbfdfaab8ba754e4f22521ae479;p=people%2Fliuw%2Flibxenctrl-split%2Flibvirt.git qemu: get arch name from element The qemu32 CPU model is chosen based on the 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 --- diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 0cc9f42fd..03cf9a3d0 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -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: