qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Lin Ma <lma@suse.com>
To: pbonzini@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] chardev: Add 'help' option to print all available chardev backend types
Date: Wed, 17 Aug 2016 01:13:52 +0800	[thread overview]
Message-ID: <20160816171352.17021-1-lma@suse.com> (raw)

Signed-off-by: Lin Ma <lma@suse.com>
---
 qemu-char.c     | 21 ++++++++++++++++-----
 qemu-options.hx |  3 +++
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/qemu-char.c b/qemu-char.c
index 8a0ab05..8a7aef3 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -39,6 +39,7 @@
 #include "io/channel-file.h"
 #include "io/channel-tls.h"
 #include "sysemu/replay.h"
+#include "qemu/help_option.h"
 
 #include <zlib.h>
 
@@ -3877,16 +3878,26 @@ CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts,
     const char *id = qemu_opts_id(opts);
     char *bid = NULL;
 
-    if (id == NULL) {
-        error_setg(errp, "chardev: no id specified");
-        goto err;
-    }
-
     if (qemu_opt_get(opts, "backend") == NULL) {
         error_setg(errp, "chardev: \"%s\" missing backend",
                    qemu_opts_id(opts));
         goto err;
     }
+
+    if (is_help_option(qemu_opt_get(opts, "backend"))) {
+        fprintf(stderr, "Available chardev backend types:\n");
+        for (i = backends; i; i = i->next) {
+            cd = i->data;
+            fprintf(stderr, "%s\n", cd->name);
+        }
+        exit(!is_help_option(qemu_opt_get(opts, "backend")));
+    }
+
+    if (id == NULL) {
+        error_setg(errp, "chardev: no id specified");
+        goto err;
+    }
+
     for (i = backends; i; i = i->next) {
         cd = i->data;
 
diff --git a/qemu-options.hx b/qemu-options.hx
index a71aaf8..379f7a5 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -2148,6 +2148,7 @@ The general form of a character device option is:
 ETEXI
 
 DEF("chardev", HAS_ARG, QEMU_OPTION_chardev,
+    "-chardev help\n"
     "-chardev null,id=id[,mux=on|off][,logfile=PATH][,logappend=on|off]\n"
     "-chardev socket,id=id[,host=host],port=port[,to=to][,ipv4][,ipv6][,nodelay][,reconnect=seconds]\n"
     "         [,server][,nowait][,telnet][,reconnect=seconds][,mux=on|off]\n"
@@ -2213,6 +2214,8 @@ Backend is one of:
 @option{spiceport}.
 The specific backend will determine the applicable options.
 
+Use "-chardev help" to print all available chardev backend types.
+
 All devices must have an id, which can be any string up to 127 characters long.
 It is used to uniquely identify this device in other command line directives.
 
-- 
2.9.2

             reply	other threads:[~2016-08-16 17:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-16 17:13 Lin Ma [this message]
2016-08-16 17:25 ` [Qemu-devel] [PATCH] chardev: Add 'help' option to print all available chardev backend types Marc-André Lureau
2016-08-17  3:11   ` [Qemu-devel] 答复: " Lin Ma
2016-08-17  6:52     ` Markus Armbruster
2016-08-25  6:08       ` Lin Ma
2016-09-02 10:50         ` Paolo Bonzini
2016-09-02 10:50 ` [Qemu-devel] " Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160816171352.17021-1-lma@suse.com \
    --to=lma@suse.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).