[PATCH] Fix type detection

Guido Günther agx at sigxcpu.org
Fri Oct 8 12:45:20 UTC 2010


---
 src/qemu_conf.c |   30 ++++++++++++++++++++++++++----
 1 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/src/qemu_conf.c b/src/qemu_conf.c
index 23ef050..65ec465 100644
--- a/src/qemu_conf.c
+++ b/src/qemu_conf.c
@@ -233,7 +233,8 @@ qemudCapsInitGuest(virCapsPtr caps,
     hasbase = (access(info->binary, X_OK) == 0);
 
     samearch = STREQ(info->arch, hostmachine);
-    if (samearch) {
+    if (samearch ||
+        (STREQ(hostmachine, "x86_64") && STREQ(info->arch, "i686"))) {
         const char *const kvmbins[] = { "/usr/bin/qemu-kvm", /* Fedora */
                                         "/usr/bin/kvm" }; /* Upstream .spec */
 
@@ -280,7 +281,9 @@ qemudCapsInitGuest(virCapsPtr caps,
                                               0,
                                               NULL) == NULL)
                 return -1;
-
+        }
+        if (samearch ||
+            (STREQ(hostmachine, "x86_64") && STREQ(info->arch, "i686"))) {
             if (access("/dev/kvm", F_OK) == 0 &&
                 haskvm &&
                 virCapabilitiesAddGuestDomain(guest,
@@ -500,19 +503,38 @@ rewait:
     return ret;
 }
 
+static void
+uname_normalize (struct utsname *ut)
+{
+    uname(ut);
+
+    /* Map i386, i486, i586 to i686.  */
+    if (ut->machine[0] == 'i' &&
+        ut->machine[1] != '\0' &&
+        ut->machine[2] == '8' &&
+        ut->machine[3] == '6' &&
+        ut->machine[4] == '\0')
+        ut->machine[1] = '6';
+}
+
 int qemudExtractVersion(virConnectPtr conn,
                         struct qemud_driver *driver) {
     const char *binary;
     struct stat sb;
+    struct utsname ut;
 
     if (driver->qemuVersion > 0)
         return 0;
 
+    uname_normalize(&ut);
     if ((binary = virCapabilitiesDefaultGuestEmulator(driver->caps,
                                                       "hvm",
-                                                      "i686",
-                                                      "qemu")) == NULL)
+                                                      ut.machine,
+                                                      "qemu")) == NULL) {
+        qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+                        _("Cannot find suitable emulator for %s"), ut.machine);
         return -1;
+    }
 
     if (stat(binary, &sb) < 0) {
         qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
-- 
1.7.1


--r5Pyd7+fXNt84Ff3--





More information about the Pkg-libvirt-maintainers mailing list