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

Re: [libvirt] [PATCH] qemu driver: fix version parsing fix



Daniel P. Berrange wrote:
...
>> That patch looks fine, and is nicely minimal.
>> However, it does relax the test significantly.
>> Rather than requiring that QEMU_VERSION_STR be a prefix,
>> it would allow it to appear anywhere within the -help output.
...
> ACK, prefer the stricter check. One day QEMU might even provide this in a
> reliably parsable format like JSON...

FYI, here's the complete patch I'll push in an hour or so.
Note that I reordered, so that we check the new string before
the "old" one.

>From 3b7179866bd9e495332335df74b327cc156a298c Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering redhat com>
Date: Thu, 20 May 2010 15:43:47 +0200
Subject: [PATCH] qemu_conf.c: also recognize new first line of qemu -help output

* src/qemu/qemu_conf.c (QEMU_VERSION_STR_1, QEMU_VERSION_STR_2):
Define these instead of...
(QEMU_VERSION_STR): ... this.  Remove definition.
(qemudParseHelpStr): Check first for the new, shorter prefix,
"QEMU emulator version", and then for the old one,
"QEMU PC emulator version" when trying to parse the version number.
Based on a patch by Chris Wright.
---
 src/qemu/qemu_conf.c |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 5c14eb8..e1be340 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1246,7 +1246,9 @@ static unsigned long long qemudComputeCmdFlags(const char *help,

 /* We parse the output of 'qemu -help' to get the QEMU
  * version number. The first bit is easy, just parse
- * 'QEMU PC emulator version x.y.z'.
+ * 'QEMU PC emulator version x.y.z'
+ * or
+ * 'QEMU emulator version x.y.z'.
  *
  * With qemu-kvm, however, that is followed by a string
  * in parenthesis as follows:
@@ -1259,7 +1261,8 @@ static unsigned long long qemudComputeCmdFlags(const char *help,
  * and later, we just need the QEMU version number and
  * whether it is KVM QEMU or mainline QEMU.
  */
-#define QEMU_VERSION_STR    "QEMU PC emulator version"
+#define QEMU_VERSION_STR_1  "QEMU emulator version"
+#define QEMU_VERSION_STR_2  "QEMU PC emulator version"
 #define QEMU_KVM_VER_PREFIX "(qemu-kvm-"
 #define KVM_VER_PREFIX      "(kvm-"

@@ -1277,11 +1280,13 @@ int qemudParseHelpStr(const char *qemu,

     *flags = *version = *is_kvm = *kvm_version = 0;

-    if (!STRPREFIX(p, QEMU_VERSION_STR))
+    if (STRPREFIX(p, QEMU_VERSION_STR_1))
+        p += strlen(QEMU_VERSION_STR_1);
+    else if (STRPREFIX(p, QEMU_VERSION_STR_2))
+        p += strlen(QEMU_VERSION_STR_2);
+    else
         goto fail;

-    p += strlen(QEMU_VERSION_STR);
-
     SKIP_BLANKS(p);

     major = virParseNumber(&p);
--
1.7.1.262.g5ef3d


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