From patchwork Tue Aug 16 17:13:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lin Ma X-Patchwork-Id: 659789 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sDJxH0gyHz9t0G for ; Wed, 17 Aug 2016 03:18:59 +1000 (AEST) Received: from localhost ([::1]:43303 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bZi0v-0002EO-2w for incoming@patchwork.ozlabs.org; Tue, 16 Aug 2016 13:18:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54440) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bZhwU-0007UJ-97 for qemu-devel@nongnu.org; Tue, 16 Aug 2016 13:14:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bZhwR-0005gq-2I for qemu-devel@nongnu.org; Tue, 16 Aug 2016 13:14:22 -0400 Received: from prv3-mh.provo.novell.com ([137.65.250.26]:35783) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bZhwQ-0005gg-Qm for qemu-devel@nongnu.org; Tue, 16 Aug 2016 13:14:19 -0400 Received: from localhost.localdomain (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by prv3-mh.provo.novell.com with ESMTP (NOT encrypted); Tue, 16 Aug 2016 11:14:02 -0600 From: Lin Ma To: pbonzini@redhat.com, qemu-devel@nongnu.org Date: Wed, 17 Aug 2016 01:13:52 +0800 Message-Id: <20160816171352.17021-1-lma@suse.com> X-Mailer: git-send-email 2.9.2 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 137.65.250.26 Subject: [Qemu-devel] [PATCH] chardev: Add 'help' option to print all available chardev backend types X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Lin Ma --- 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 @@ -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.