aboutsummaryrefslogtreecommitdiff
path: root/util/qemu-config.c
diff options
context:
space:
mode:
authorEduardo Habkost <ehabkost@redhat.com>2015-04-08 14:57:31 -0300
committerEduardo Habkost <ehabkost@redhat.com>2015-04-27 15:38:13 -0300
commitd9f7e29ee5a6915caa049ba64c0a9f28766351d2 (patch)
tree04d2fc9f31ae039ee9e8d942c990b001adc66610 /util/qemu-config.c
parentb203a4ba93fc25bf1eb49039a8ec4b260b446211 (diff)
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/qemu-config.c')
-rw-r--r--util/qemu-config.c4
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");