aboutsummaryrefslogtreecommitdiff
path: root/accel/accel.c
diff options
context:
space:
mode:
authorDaniel P. Berrangé <berrange@redhat.com>2018-04-16 12:17:41 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2018-05-09 00:13:38 +0200
commit20efc49ed625585809401d8293ad9267927a6a4a (patch)
tree1aa693795e4767b04a7a62ce1fe59164035226fe /accel/accel.c
parent7afcfd32a65688401cba337eb99f65dc24d9750e (diff)
accel: use g_strsplit for parsing accelerator names
Instead of re-using the get_opt_name() method from QemuOpts to split a string on ':', just use g_strsplit(). Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20180416111743.8473-2-berrange@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Diffstat (limited to 'accel/accel.c')
-rw-r--r--accel/accel.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/accel/accel.c b/accel/accel.c
index 9cfab115d0..966b2d8f53 100644
--- a/accel/accel.c
+++ b/accel/accel.c
@@ -70,8 +70,8 @@ static int accel_init_machine(AccelClass *acc, MachineState *ms)
void configure_accelerator(MachineState *ms)
{
- const char *accel, *p;
- char buf[10];
+ const char *accel;
+ char **accel_list, **tmp;
int ret;
bool accel_initialised = false;
bool init_failed = false;
@@ -83,13 +83,10 @@ void configure_accelerator(MachineState *ms)
accel = "tcg";
}
- p = accel;
- while (!accel_initialised && *p != '\0') {
- if (*p == ':') {
- p++;
- }
- p = get_opt_name(buf, sizeof(buf), p, ':');
- acc = accel_find(buf);
+ accel_list = g_strsplit(accel, ":", 0);
+
+ for (tmp = accel_list; !accel_initialised && tmp && *tmp; tmp++) {
+ acc = accel_find(*tmp);
if (!acc) {
continue;
}
@@ -107,6 +104,7 @@ void configure_accelerator(MachineState *ms)
accel_initialised = true;
}
}
+ g_strfreev(accel_list);
if (!accel_initialised) {
if (!init_failed) {