[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v2 3/6] qemu-config: Accept empty option values
From: |
Eduardo Habkost |
Subject: |
[Qemu-devel] [PULL v2 3/6] qemu-config: Accept empty option values |
Date: |
Mon, 27 Apr 2015 15:45:04 -0300 |
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 <address@hidden>
Acked-by: Paolo Bonzini <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>
---
util/qemu-config.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/util/qemu-config.c b/util/qemu-config.c
index 2d32ce7..a393a3d 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");
--
2.1.0
- [Qemu-devel] [PULL v2 0/6] X86 patches, Eduardo Habkost, 2015/04/27
- [Qemu-devel] [PULL v2 1/6] MAINTAINERS: Add myself to X86, Eduardo Habkost, 2015/04/27
- [Qemu-devel] [PULL v2 2/6] MAINTAINERS: Change status of X86 to Maintained, Eduardo Habkost, 2015/04/27
- [Qemu-devel] [PULL v2 3/6] qemu-config: Accept empty option values,
Eduardo Habkost <=
- [Qemu-devel] [PULL v2 4/6] target-i386: Make "level" and "xlevel" properties static, Eduardo Habkost, 2015/04/27
- [Qemu-devel] [PULL v2 5/6] target-i386: X86CPU::xlevel2 QOM property, Eduardo Habkost, 2015/04/27
- [Qemu-devel] [PULL v2 6/6] target-i386: Remove AMD feature flag aliases from CPU model table, Eduardo Habkost, 2015/04/27
- Re: [Qemu-devel] [PULL v2 0/6] X86 patches, Peter Maydell, 2015/04/28