diff options
author | Eduardo Habkost | 2015-04-08 19:57:31 +0200 |
---|---|---|
committer | Eduardo Habkost | 2015-04-27 20:38:13 +0200 |
commit | d9f7e29ee5a6915caa049ba64c0a9f28766351d2 (patch) | |
tree | 04d2fc9f31ae039ee9e8d942c990b001adc66610 /util | |
parent | MAINTAINERS: Change status of X86 to Maintained (diff) | |
download | qemu-d9f7e29ee5a6915caa049ba64c0a9f28766351d2.tar.gz qemu-d9f7e29ee5a6915caa049ba64c0a9f28766351d2.tar.xz qemu-d9f7e29ee5a6915caa049ba64c0a9f28766351d2.zip |
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>
Diffstat (limited to 'util')
-rw-r--r-- | util/qemu-config.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/util/qemu-config.c b/util/qemu-config.c index 2d32ce7e91..a393a3d785 100644 --- a/util/qemu-config.c +++ b/util/qemu-config.c @@ -413,7 +413,9 @@ int qemu_config_parse(FILE *fp, QemuOptsList **lists, const char *fname) opts = qemu_opts_create(list, NULL, 0, &error_abort); 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 */ if (opts == NULL) { error_report("no group defined"); |