qdev-monitor: Only allow full --global <driver>.<property>=<val> option
RFC v3 1/1 qdev-monitor: Only allow full --global <driver>.<property>=<val> option
When not all fields of the --global option are provided, QEMU might crash:
$ qemu-system-x86_64 -global driver=isa-fdc qemu-system-x86_64: ../../devel/qemu/qapi/string-input-visitor.c:394: string_input_visitor_new: Assertion `str' failed. Aborted (core dumped)
Fix by only allowing --global with all 3 fields:
$ qemu-system-x86_64 -global driver=isa-fdc
Invalid 'global' option format. It must be provided as:
--global <driver>.<property>=<value>Resolves: https://gitlab.com/qemu-project/qemu/-/issues/604
---
v3: Change qemu_global_option (Markus)
Supersedes: <[email protected]>
--- softmmu/qdev-monitor.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
softmmu/qdev-monitor.c +3 -6
@@ -1029,13 +1029,10 @@ int qemu_global_option(const char *str)qemu_opt_set (opts,"value" , str + offset +1 , &error_abort);return 0 ; } +printf ("Invalid 'global' option format. It must be provided as:\n" ); +printf (" --global <driver>.<property>=<value>\n" ); - opts =qemu_opts_parse_noisily (&qemu_global_opts, str, false); -if (!opts) { -return -1 ; - } - -return 0 ; +return -1 ; }bool qmp_command_available (const QmpCommand *cmd,Error **errp)
Signature · 1 line
2.31.1
Quoted 31 lines · Philippe Mathieu-Daudé
When not all fields of the --global option are provided, QEMU might crash:
$ qemu-system-x86_64 -global driver=isa-fdc qemu-system-x86_64: ../../devel/qemu/qapi/string-input-visitor.c:394: string_input_visitor_new: Assertion `str' failed. Aborted (core dumped)Fix by only allowing --global with all 3 fields:
$ qemu-system-x86_64 -global driver=isa-fdc Invalid 'global' option format. It must be provided as: --global <driver>.<property>=<value>Reported-by Thomas Huth <[email protected]>Suggested-by Markus Armbruster <[email protected]>Resolves: https://gitlab.com/qemu-project/qemu/-/issues/604
Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
v3: Changeqemu_global_option(Markus)Supersedes: <[email protected]>
---softmmu/qdev-monitor.c| 9 +++------1 file changed, 3 insertions(+), 6 deletions(-)softmmu/qdev-monitor.c +0
-0
softmmu/qdev-monitor.c int qemu_global_option(const char *str) · line 1033
Quoted 5 lines
softmmu/qdev-monitor.c +2
-0@@ -1029,13 +1029,10 @@ int qemu_global_option(const char *str)qemu_opt_set (opts,"value" , str + offset +1 , &error_abort);return 0 ; } +printf ("Invalid 'global' option format. It must be provided as:\n" ); +printf (" --global <driver>.<property>=<value>\n" );
Should these be something else tnan plain printf? (Such as qemu_prinf or qdev_printf or similar? Not sure how these work but plain printf in QEMU is usually not what's meant.)
Regards,
BALATON Zoltan
Quoted 11 lines
softmmu/qdev-monitor.c +1
-6- opts =qemu_opts_parse_noisily (&qemu_global_opts, str, false); -if (!opts) { -return -1 ; - } - -return 0 ; +return -1 ; }bool qmp_command_available (const QmpCommand *cmd,Error **errp)
Quoted 27 lines · BALATON Zoltan
Quoted 26 lines · Philippe Mathieu-Daudé
When not all fields of the --global option are provided, QEMU might crash:
$ qemu-system-x86_64 -global driver=isa-fdc qemu-system-x86_64: ../../devel/qemu/qapi/string-input-visitor.c:394: string_input_visitor_new: Assertion `str' failed. Aborted (core dumped)Fix by only allowing --global with all 3 fields:
$ qemu-system-x86_64 -global driver=isa-fdc Invalid 'global' option format. It must be provided as: --global <driver>.<property>=<value>Reported-by Thomas Huth <[email protected]>Suggested-by Markus Armbruster <[email protected]>Resolves: https://gitlab.com/qemu-project/qemu/-/issues/604
Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
v3: Changeqemu_global_option(Markus)Supersedes: <[email protected]>
---softmmu/qdev-monitor.c| 9 +++------1 file changed, 3 insertions(+), 6 deletions(-)
Quoted 14 lines
softmmu/qdev-monitor.c int qemu_global_option(const char *str) · line 1033
Quoted 10 lines
softmmu/qdev-monitor.c +2
-0@@ -1029,13 +1029,10 @@ int qemu_global_option(const char *str) qemu_opt_set(opts, "value", str + offset + 1, &error_abort); return 0; } + printf("Invalid 'global' option format. It must be provided as:\n"); + printf(" --global <driver>.<property>=<value>\n");Should these be something else tnan plain printf? (Such as
qemu_prinforqdev_printfor similar? Not sure how these work but plain printf in QEMU is usually not what's meant.)
I thought so first, but qemu_opts_print_help() calls plain printf()...
Quoted 7 lines
Regards,
BALATON ZoltanQuoted 4 lines
softmmu/qdev-monitor.c +0
-4- opts = qemu_opts_parse_noisily(&qemu_global_opts, str, false); - if (!opts) { - return -1; - }
Quoted 37 lines · Philippe Mathieu-Daudé
When not all fields of the --global option are provided, QEMU might crash:
$ qemu-system-x86_64 -global driver=isa-fdc qemu-system-x86_64: ../../devel/qemu/qapi/string-input-visitor.c:394: string_input_visitor_new: Assertion `str' failed. Aborted (core dumped)Fix by only allowing --global with all 3 fields:
$ qemu-system-x86_64 -global driver=isa-fdc Invalid 'global' option format. It must be provided as: --global <driver>.<property>=<value>Reported-by Thomas Huth <[email protected]>Suggested-by Markus Armbruster <[email protected]>Resolves: https://gitlab.com/qemu-project/qemu/-/issues/604
Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
v3: Changeqemu_global_option(Markus)Supersedes: <[email protected]>
--- softmmu/qdev-monitor.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)softmmu/qdev-monitor.c +2
-0@@ -1029,13 +1029,10 @@ int qemu_global_option(const char *str)qemu_opt_set (opts,"value" , str + offset +1 , &error_abort);return 0 ; } +printf ("Invalid 'global' option format. It must be provided as:\n" ); +printf (" --global <driver>.<property>=<value>\n" );
softmmu/qdev-monitor.c int qemu_global_option(const char *str) · line 1038
Quoted 10 lines
softmmu/qdev-monitor.c +1
-6- opts =qemu_opts_parse_noisily (&qemu_global_opts, str, false); -if (!opts) { -return -1 ; - } - -return 0 ; +return -1 ; }bool qmp_command_available (const QmpCommand *cmd,Error **errp)
This drops a documented part of the external interface:
$ qemu-system-x86_64 -help | grep -C 1 global
i.e. -set drive.$id.file=/path/to/image
-global driver.property=value
--> -global driver=driver,property=property,value=value
set a global default for a driver property
-boot [order=drives][,once=drives][,menu=on|off]It goes back to commit 3751d7c43f "vl: allow full-blown QemuOpts syntax for -global", v2.4.0.
The appropriate fix is to check @opts for presence of all three parameters.
Quoted 52 lines · Markus Armbruster
Quoted 37 lines · Philippe Mathieu-Daudé
When not all fields of the --global option are provided, QEMU might crash:
$ qemu-system-x86_64 -global driver=isa-fdc qemu-system-x86_64: ../../devel/qemu/qapi/string-input-visitor.c:394: string_input_visitor_new: Assertion `str' failed. Aborted (core dumped)Fix by only allowing --global with all 3 fields:
$ qemu-system-x86_64 -global driver=isa-fdc Invalid 'global' option format. It must be provided as: --global <driver>.<property>=<value>Reported-by Thomas Huth <[email protected]>Suggested-by Markus Armbruster <[email protected]>Resolves: https://gitlab.com/qemu-project/qemu/-/issues/604
Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
v3: Changeqemu_global_option(Markus)Supersedes: <[email protected]>
--- softmmu/qdev-monitor.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)softmmu/qdev-monitor.c +2
-0@@ -1029,13 +1029,10 @@ int qemu_global_option(const char *str)qemu_opt_set (opts,"value" , str + offset +1 , &error_abort);return 0 ; } +printf ("Invalid 'global' option format. It must be provided as:\n" ); +printf (" --global <driver>.<property>=<value>\n" );softmmu/qdev-monitor.c int qemu_global_option(const char *str) · line 1038
Quoted 10 lines
softmmu/qdev-monitor.c +1
-6- opts =qemu_opts_parse_noisily (&qemu_global_opts, str, false); -if (!opts) { -return -1 ; - } - -return 0 ; +return -1 ; }bool qmp_command_available (const QmpCommand *cmd,Error **errp)This drops a documented part of the external interface:
Quoted 5 lines
$ qemu-system-x86_64 -help | grep -C 1 global
i.e. -set drive.$id.file=/path/to/image
-global driver.property=value
--> -global driver=driver,property=property,value=value
set a global default for a driver propertyThis doc makes it look like the two syntaxes are functionally equivalent, but it seems that's not quite the case.
libvirt uses the driver.propert=value syntax for everything except one case
-global driver=cfi.pflash01,property=secure,value=on
for that one if we try to use
-global cfi.pflash01.secure=on
it complains
qemu-system-x86_64: warning: global cfi.pflash01.secure has invalid class name
what's going on here ?
Quoted 8 lines
-boot [order=drives][,once=drives][,menu=on|off]It goes back to commit
3751d7c43f"vl: allow full-blown QemuOpts syntax for -global", v2.4.0.The appropriate fix is to check @opts for presence of all three parameters.
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Quoted 69 lines · Daniel P. Berrangé
Quoted 52 lines · Markus Armbruster
Quoted 37 lines · Philippe Mathieu-Daudé
When not all fields of the --global option are provided, QEMU might crash:
$ qemu-system-x86_64 -global driver=isa-fdc qemu-system-x86_64: ../../devel/qemu/qapi/string-input-visitor.c:394: string_input_visitor_new: Assertion `str' failed. Aborted (core dumped)Fix by only allowing --global with all 3 fields:
$ qemu-system-x86_64 -global driver=isa-fdc Invalid 'global' option format. It must be provided as: --global <driver>.<property>=<value>Reported-by Thomas Huth <[email protected]>Suggested-by Markus Armbruster <[email protected]>Resolves: https://gitlab.com/qemu-project/qemu/-/issues/604
Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
v3: Changeqemu_global_option(Markus)Supersedes: <[email protected]>
--- softmmu/qdev-monitor.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)softmmu/qdev-monitor.c +2
-0@@ -1029,13 +1029,10 @@ int qemu_global_option(const char *str)qemu_opt_set (opts,"value" , str + offset +1 , &error_abort);return 0 ; } +printf ("Invalid 'global' option format. It must be provided as:\n" ); +printf (" --global <driver>.<property>=<value>\n" );softmmu/qdev-monitor.c int qemu_global_option(const char *str) · line 1038
Quoted 10 lines
softmmu/qdev-monitor.c +1
-6- opts =qemu_opts_parse_noisily (&qemu_global_opts, str, false); -if (!opts) { -return -1 ; - } - -return 0 ; +return -1 ; }bool qmp_command_available (const QmpCommand *cmd,Error **errp)This drops a documented part of the external interface:
Quoted 5 lines
$ qemu-system-x86_64 -help | grep -C 1 global i.e. -set drive.$id.file=/path/to/image -global driver.property=value --> -global driver=driver,property=property,value=value set a global default for a driver propertyThis doc makes it look like the two syntaxes are functionally equivalent, but it seems that's not quite the case.
libvirt uses the driver.propert=value syntax for everything except one case
-global driver=cfi.pflash01,property=secure,value=on
for that one if we try to use
Quoted 7 lines
-global cfi.pflash01.secure=on
it complains
qemu-system-x86_64: warning: global cfi.pflash01.secure has invalid class name
what's going on here ?
Off-the-cuff guess: cfi.pflash01.secure=on gets parsed as
driver=cfi
property=pflash01.secure
value=on
Once again our "anything goes" attitude to naming wastes us time and thus money.
In contrast, QAPI restricts names to "only ASCII letters, digits, hyphen, and underscore" (see docs/devel/qapi-code-gen.rst section Naming rules and reserved names).
Quoted 11 lines · Markus Armbruster
Quoted 3 lines
qemu-system-x86_64: warning: global cfi.pflash01.secure has invalid class name
what's going on here ?
Off-the-cuff guess: cfi.pflash01.secure=on gets parsed as
driver=cfi
property=pflash01.secure
value=onOnce again our "anything goes" attitude to naming wastes us time and thus money.
I'd blame more the sscanf parsing. Anyway, -global driver=...,property=...,value=... works just fine in all cases, it's just more verbose---and it might even be easier to use for Libvirt, if it can use its usual QemuOpts-building facilities.
Anyhow, this patch breaks existing clients, as pointed out by Markus.
Paolo
Quoted 3 lines
In contrast, QAPI restricts names to "only ASCII letters, digits, hyphen, and underscore" (see
docs/devel/qapi-code-gen.rstsection Naming rules and reserved names).