Blame SOURCES/kvm-accel-use-g_strsplit-for-parsing-accelerator-names.patch

4ec855
From 28a766b8099f5e745dbfc18834277039643214a3 Mon Sep 17 00:00:00 2001
4ec855
From: Laszlo Ersek <lersek@redhat.com>
4ec855
Date: Thu, 12 Sep 2019 13:04:58 +0100
4ec855
Subject: [PATCH 01/22] accel: use g_strsplit for parsing accelerator names
4ec855
MIME-Version: 1.0
4ec855
Content-Type: text/plain; charset=UTF-8
4ec855
Content-Transfer-Encoding: 8bit
4ec855
4ec855
RH-Author: Laszlo Ersek <lersek@redhat.com>
4ec855
Message-id: <20190912130503.14094-2-lersek@redhat.com>
4ec855
Patchwork-id: 90437
4ec855
O-Subject: [RHEL-8.2.0 qemu-kvm PATCH 1/6] accel: use g_strsplit for parsing accelerator names
4ec855
Bugzilla: 1749022
4ec855
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
4ec855
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4ec855
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
4ec855
4ec855
From: Daniel P. Berrangé <berrange@redhat.com>
4ec855
4ec855
Instead of re-using the get_opt_name() method from QemuOpts to split a
4ec855
string on ':', just use g_strsplit().
4ec855
4ec855
RHEL8 notes:
4ec855
4ec855
- Fix up upstream's obviously garbled UTF8 sequences in Dan's name (Author
4ec855
  meta-datum, Signed-off-by tags).
4ec855
4ec855
- Harmless context difference due to downstream-only commit 8b53513834e6
4ec855
  ("Use kvm by default", 2018-04-24).
4ec855
4ec855
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4ec855
Message-Id: <20180416111743.8473-2-berrange@redhat.com>
4ec855
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4ec855
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4ec855
(cherry picked from commit 20efc49ed625585809401d8293ad9267927a6a4a)
4ec855
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
4ec855
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
4ec855
---
4ec855
 accel/accel.c         | 16 +++++++---------
4ec855
 include/qemu/option.h |  1 -
4ec855
 util/qemu-option.c    |  3 ++-
4ec855
 3 files changed, 9 insertions(+), 11 deletions(-)
4ec855
4ec855
diff --git a/accel/accel.c b/accel/accel.c
4ec855
index 5f3d73f..57390e5 100644
4ec855
--- a/accel/accel.c
4ec855
+++ b/accel/accel.c
4ec855
@@ -70,8 +70,8 @@ static int accel_init_machine(AccelClass *acc, MachineState *ms)
4ec855
 
4ec855
 void configure_accelerator(MachineState *ms)
4ec855
 {
4ec855
-    const char *accel, *p;
4ec855
-    char buf[10];
4ec855
+    const char *accel;
4ec855
+    char **accel_list, **tmp;
4ec855
     int ret;
4ec855
     bool accel_initialised = false;
4ec855
     bool init_failed = false;
4ec855
@@ -83,13 +83,10 @@ void configure_accelerator(MachineState *ms)
4ec855
         accel = "kvm:tcg";
4ec855
     }
4ec855
 
4ec855
-    p = accel;
4ec855
-    while (!accel_initialised && *p != '\0') {
4ec855
-        if (*p == ':') {
4ec855
-            p++;
4ec855
-        }
4ec855
-        p = get_opt_name(buf, sizeof(buf), p, ':');
4ec855
-        acc = accel_find(buf);
4ec855
+    accel_list = g_strsplit(accel, ":", 0);
4ec855
+
4ec855
+    for (tmp = accel_list; !accel_initialised && tmp && *tmp; tmp++) {
4ec855
+        acc = accel_find(*tmp);
4ec855
         if (!acc) {
4ec855
             continue;
4ec855
         }
4ec855
@@ -107,6 +104,7 @@ void configure_accelerator(MachineState *ms)
4ec855
             accel_initialised = true;
4ec855
         }
4ec855
     }
4ec855
+    g_strfreev(accel_list);
4ec855
 
4ec855
     if (!accel_initialised) {
4ec855
         if (!init_failed) {
4ec855
diff --git a/include/qemu/option.h b/include/qemu/option.h
4ec855
index 306fdb5..1cfe5cb 100644
4ec855
--- a/include/qemu/option.h
4ec855
+++ b/include/qemu/option.h
4ec855
@@ -28,7 +28,6 @@
4ec855
 
4ec855
 #include "qemu/queue.h"
4ec855
 
4ec855
-const char *get_opt_name(char *buf, int buf_size, const char *p, char delim);
4ec855
 const char *get_opt_value(char *buf, int buf_size, const char *p);
4ec855
 
4ec855
 void parse_option_size(const char *name, const char *value,
4ec855
diff --git a/util/qemu-option.c b/util/qemu-option.c
4ec855
index 95e6cf4..a8db173 100644
4ec855
--- a/util/qemu-option.c
4ec855
+++ b/util/qemu-option.c
4ec855
@@ -49,7 +49,8 @@
4ec855
  * The return value is the position of the delimiter/zero byte after the option
4ec855
  * name in p.
4ec855
  */
4ec855
-const char *get_opt_name(char *buf, int buf_size, const char *p, char delim)
4ec855
+static const char *get_opt_name(char *buf, int buf_size, const char *p,
4ec855
+                                char delim)
4ec855
 {
4ec855
     char *q;
4ec855
 
4ec855
-- 
4ec855
1.8.3.1
4ec855