QDev options accept '?' or 'help' in the list of parameters, which is
really handy to list the available options.

Unfortunately, this isn't built in QemuOpts. qemu_opts_parse_noisily()
seems to be the common path for command line options, so place a
fallback to check for '?' and print help listing available options.

This is very handy, for example with qemu "-spice ?".

Signed-off-by: Marc-André Lureau <marcandre.lur...@redhat.com>
---
 util/qemu-option.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/util/qemu-option.c b/util/qemu-option.c
index 01886efe90..8839ee6523 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -889,7 +889,12 @@ QemuOpts *qemu_opts_parse_noisily(QemuOptsList *list, 
const char *params,
 
     opts = opts_parse(list, params, permit_abbrev, false, &err);
     if (err) {
-        error_report_err(err);
+        if (has_help_option(params)) {
+            qemu_opts_print_help(list);
+            error_free(err);
+        } else {
+            error_report_err(err);
+        }
     }
     return opts;
 }
-- 
2.18.0.547.g1d89318c48


Reply via email to