Re: [libvirt] Re: [PATCH 0/3] A small example program

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Daniel P. Berrange" <berrange@xxxxxxxxxx> wrote:

> On Fri, Jan 30, 2009 at 02:32:00PM +0100, Jim Meyering wrote:
>> Jim Meyering <jim@xxxxxxxxxxxx> wrote:
>> > I've just applied your 3 patches and built the example.
>> > That went fine.  Then I tried to run it like this:
>> ...
>> >      $ kill $pid
>> >      $ LIBVIRT_DEBUG=1 ../../qemud/libvirtd 2> log &
>> >      $ ./hellolibvirt
>> >      Attempting to connect to hypervisor
>> >      Connected to hypervisor at "qemu:///session"
>> > ? -> libvir: error : Unknown failure
>> >      Failed to get hypervisor version
>> >      Disconnected from hypervisor
>> >      [Exit 1]
>> >
>> > This is on F10 x86_64.
>>
>> FYI, I poked around in the server to see what was going wrong.
>> qemudGetVersion calls qemudExtractVersion, which calls
>> virCapabilitiesDefaultGuestEmulator, which compares the
>> single guest cap and gets an arch mismatch:
>
> Hmm, it should use the native arch - virExtractVersionInfo needs
> fixing to call uname, and extract the native arch. Hardcoding
> i386 was sufficient, when we mandated that 'qemu' was always
> present, but now we allow either qemu or KVM, so we need to
> always use native.  NB, i3/4/586 should be mapped to i686.

I see you already had to do that once.

>From 0131996b3cd819624259d6adcc5d968d6a0210b1 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@xxxxxxxxxx>
Date: Fri, 30 Jan 2009 15:41:39 +0100
Subject: [PATCH] fix qemud version reporting when qemu is not installed

* src/qemu_conf.c (uname_normalize): New function, factored out of...
(qemudBuildCommandLine): ...here.  Use the new function.
(qemudExtractVersion): Use it here, rather than hard-coding "i686".
---
 src/qemu_conf.c |   27 ++++++++++++++++++---------
 1 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/src/qemu_conf.c b/src/qemu_conf.c
index b4ec733..972ea50 100644
--- a/src/qemu_conf.c
+++ b/src/qemu_conf.c
@@ -486,17 +486,33 @@ 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",
+                                                      ut.machine,
                                                       "qemu")) == NULL)
         return -1;

@@ -718,14 +734,7 @@ int qemudBuildCommandLine(virConnectPtr conn,
     char domid[50];
     char *pidfile;

-    uname(&ut);
-
-    /* Nasty hack make i?86 look like i686 to simplify next comparison */
-    if (ut.machine[0] == 'i' &&
-        ut.machine[2] == '8' &&
-        ut.machine[3] == '6' &&
-        !ut.machine[4])
-        ut.machine[1] = '6';
+    uname_normalize(&ut);

     virUUIDFormat(vm->def->uuid, uuid);

--
1.6.1.2.418.gd79e6

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]