mirror of https://gitee.com/openkylin/qemu.git
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>
This commit is contained in:
parent
7afcfd32a6
commit
20efc49ed6
|
@ -70,8 +70,8 @@ static int accel_init_machine(AccelClass *acc, MachineState *ms)
|
||||||
|
|
||||||
void configure_accelerator(MachineState *ms)
|
void configure_accelerator(MachineState *ms)
|
||||||
{
|
{
|
||||||
const char *accel, *p;
|
const char *accel;
|
||||||
char buf[10];
|
char **accel_list, **tmp;
|
||||||
int ret;
|
int ret;
|
||||||
bool accel_initialised = false;
|
bool accel_initialised = false;
|
||||||
bool init_failed = false;
|
bool init_failed = false;
|
||||||
|
@ -83,13 +83,10 @@ void configure_accelerator(MachineState *ms)
|
||||||
accel = "tcg";
|
accel = "tcg";
|
||||||
}
|
}
|
||||||
|
|
||||||
p = accel;
|
accel_list = g_strsplit(accel, ":", 0);
|
||||||
while (!accel_initialised && *p != '\0') {
|
|
||||||
if (*p == ':') {
|
for (tmp = accel_list; !accel_initialised && tmp && *tmp; tmp++) {
|
||||||
p++;
|
acc = accel_find(*tmp);
|
||||||
}
|
|
||||||
p = get_opt_name(buf, sizeof(buf), p, ':');
|
|
||||||
acc = accel_find(buf);
|
|
||||||
if (!acc) {
|
if (!acc) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -107,6 +104,7 @@ void configure_accelerator(MachineState *ms)
|
||||||
accel_initialised = true;
|
accel_initialised = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
g_strfreev(accel_list);
|
||||||
|
|
||||||
if (!accel_initialised) {
|
if (!accel_initialised) {
|
||||||
if (!init_failed) {
|
if (!init_failed) {
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
|
|
||||||
#include "qemu/queue.h"
|
#include "qemu/queue.h"
|
||||||
|
|
||||||
const char *get_opt_name(char *buf, int buf_size, const char *p, char delim);
|
|
||||||
const char *get_opt_value(char *buf, int buf_size, const char *p);
|
const char *get_opt_value(char *buf, int buf_size, const char *p);
|
||||||
|
|
||||||
void parse_option_size(const char *name, const char *value,
|
void parse_option_size(const char *name, const char *value,
|
||||||
|
|
|
@ -49,7 +49,8 @@
|
||||||
* The return value is the position of the delimiter/zero byte after the option
|
* The return value is the position of the delimiter/zero byte after the option
|
||||||
* name in p.
|
* name in p.
|
||||||
*/
|
*/
|
||||||
const char *get_opt_name(char *buf, int buf_size, const char *p, char delim)
|
static const char *get_opt_name(char *buf, int buf_size, const char *p,
|
||||||
|
char delim)
|
||||||
{
|
{
|
||||||
char *q;
|
char *q;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue