yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

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