qemu-config: Accept empty option values
Currently it is impossible to set an option in a config file to an empty string, because the parser matches only lines containing non-empty strings between double-quotes. As sscanf() "[" conversion specifier only matches non-empty strings, add a special case for empty strings. Reviewed-by: Eric Blake <eblake@redhat.com> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
This commit is contained in:
parent
b203a4ba93
commit
d9f7e29ee5
@ -413,7 +413,9 @@ int qemu_config_parse(FILE *fp, QemuOptsList **lists, const char *fname)
|
|||||||
opts = qemu_opts_create(list, NULL, 0, &error_abort);
|
opts = qemu_opts_create(list, NULL, 0, &error_abort);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (sscanf(line, " %63s = \"%1023[^\"]\"", arg, value) == 2) {
|
value[0] = '\0';
|
||||||
|
if (sscanf(line, " %63s = \"%1023[^\"]\"", arg, value) == 2 ||
|
||||||
|
sscanf(line, " %63s = \"\"", arg) == 1) {
|
||||||
/* arg = value */
|
/* arg = value */
|
||||||
if (opts == NULL) {
|
if (opts == NULL) {
|
||||||
error_report("no group defined");
|
error_report("no group defined");
|
||||||
|
Loading…
Reference in New Issue
Block a user