vl: allow full-blown QemuOpts syntax for -global

-global does not work for drivers that have a dot in their name, such as
cfi.pflash01.  This is just a parsing limitation, because such globals
can be declared easily inside a -readconfig file.

To allow this usage, support the full QemuOpts key/value syntax for -global
too, for example "-global driver=cfi.pflash01,property=secure,value=on".
The two formats do not conflict, because the key/value syntax does not have
a period before the first equal sign.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Paolo Bonzini 2015-04-09 14:16:19 +02:00
parent f71e42a5c9
commit 3751d7c43f
2 changed files with 17 additions and 8 deletions

View file

@ -822,15 +822,19 @@ int qemu_global_option(const char *str)
QemuOpts *opts;
int rc, offset;
rc = sscanf(str, "%63[^.].%63[^=]%n", driver, property, &offset);
if (rc < 2 || str[offset] != '=') {
error_report("can't parse: \"%s\"", str);
rc = sscanf(str, "%63[^.=].%63[^=]%n", driver, property, &offset);
if (rc == 2 && str[offset] == '=') {
opts = qemu_opts_create(&qemu_global_opts, NULL, 0, &error_abort);
qemu_opt_set(opts, "driver", driver, &error_abort);
qemu_opt_set(opts, "property", property, &error_abort);
qemu_opt_set(opts, "value", str + offset + 1, &error_abort);
return 0;
}
opts = qemu_opts_parse(&qemu_global_opts, str, false);
if (!opts) {
return -1;
}
opts = qemu_opts_create(&qemu_global_opts, NULL, 0, &error_abort);
qemu_opt_set(opts, "driver", driver, &error_abort);
qemu_opt_set(opts, "property", property, &error_abort);
qemu_opt_set(opts, "value", str + offset + 1, &error_abort);
return 0;
}