qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH-for-6.2 v3] qdev-monitor: Only allow full --global <driver>.<property>=<val> option
@ 2021-11-19 18:26 Philippe Mathieu-Daudé
  2021-11-19 18:46 ` BALATON Zoltan
  2021-11-20  6:53 ` Markus Armbruster
  0 siblings, 2 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-11-19 18:26 UTC (permalink / raw)
  To: qemu-devel
  Cc: Thomas Huth, Daniel P. Berrangé, Eduardo Habkost,
	Markus Armbruster, Paolo Bonzini, 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 <thuth@redhat.com>
Suggested-by: Markus Armbruster <armbru@redhat.com>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/604
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
v3: Change qemu_global_option (Markus)

Supersedes: <20211119122911.365036-1-philmd@redhat.com>
---
 softmmu/qdev-monitor.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c
index 01f3834db57..558272b147c 100644
--- a/softmmu/qdev-monitor.c
+++ b/softmmu/qdev-monitor.c
@@ -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)
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-11-23 13:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-19 18:26 [RFC PATCH-for-6.2 v3] qdev-monitor: Only allow full --global <driver>.<property>=<val> option Philippe Mathieu-Daudé
2021-11-19 18:46 ` BALATON Zoltan
2021-11-19 19:07   ` Philippe Mathieu-Daudé
2021-11-20  6:53 ` Markus Armbruster
2021-11-22 13:21   ` Daniel P. Berrangé
2021-11-22 14:32     ` Markus Armbruster
2021-11-23 13:17       ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).