File libvirt-qemu-Fix-parsing-of-x86-CPU-models.patch of Package libvirt

From 08df5a04bc8f6ec4a90c23b5901dfef74b6575cf Mon Sep 17 00:00:00 2001
Message-Id: <08df5a04bc8f6ec4a90c23b5901dfef74b6575cf.1350297261.git.jdenemar@redhat.com>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Mon, 8 Oct 2012 16:03:17 +0200
Subject: [PATCH] qemu: Fix parsing of x86 CPU models

https://bugzilla.redhat.com/show_bug.cgi?id=864097

QEMU changed the output of -cpu ? and CPU models can now be followed by
its description. Our parser just used both model name and its
description as a model name, which made any model with a description
unusable with libvirt.

RHEL-only since the first upstream QEMU shipped with changed -cpu ?
output will be 1.3 and starting with QEMU 1.2 libvirt uses QMP
capabilities probing and thus the affected parsing code will never be
used in combination with the changed output.
---
 src/qemu/qemu_capabilities.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index d8247ed..b626424 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -380,7 +380,7 @@ typedef int
                           qemuCapsPtr caps);
 
 /* Format:
- *      <arch> <model>
+ *      <arch> <model>  <description>
  * qemu-0.13 encloses some model names in []:
  *      <arch> [<model>]
  */
@@ -390,6 +390,7 @@ qemuCapsParseX86Models(const char *output,
 {
     const char *p = output;
     const char *next;
+    const char *end;
     int ret = -1;
 
     do {
@@ -417,8 +418,12 @@ qemuCapsParseX86Models(const char *output,
             goto cleanup;
         }
 
-        if (next)
-            len = next - p - 1;
+        end = next ? next - 1 : NULL;
+        if ((t = strchr(p, ' ')) && (!next || t < next))
+            end = t;
+
+        if (end)
+            len = end - p;
         else
             len = strlen(p);
 
-- 
1.7.12.3

openSUSE Build Service is sponsored by