From patchwork Tue Aug 16 17:13:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lin Ma X-Patchwork-Id: 9284299 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 13CE360839 for ; Tue, 16 Aug 2016 17:14:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 03859286C1 for ; Tue, 16 Aug 2016 17:14:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EC899286C3; Tue, 16 Aug 2016 17:14:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 572F4286C1 for ; Tue, 16 Aug 2016 17:14:25 +0000 (UTC) Received: from localhost ([::1]:43283 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bZhwW-00070P-3u for patchwork-qemu-devel@patchwork.kernel.org; Tue, 16 Aug 2016 13:14:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54312) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bZhw1-0006xt-Oe for qemu-devel@nongnu.org; Tue, 16 Aug 2016 13:13:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bZhvy-0005ZK-HW for qemu-devel@nongnu.org; Tue, 16 Aug 2016 13:13:53 -0400 Received: from prv3-mh.provo.novell.com ([137.65.250.26]:33723) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bZhvy-0005YW-98 for qemu-devel@nongnu.org; Tue, 16 Aug 2016 13:13:50 -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:13:34 -0600 From: Lin Ma To: afaerber@suse.de, qemu-devel@nongnu.org Date: Wed, 17 Aug 2016 01:13:16 +0800 Message-Id: <20160816171316.16959-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] object: Add 'help' option to print all available object 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Lin Ma --- qemu-options.hx | 5 ++++- qom/object_interfaces.c | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/qemu-options.hx b/qemu-options.hx index a71aaf8..c5f4a12 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -3752,7 +3752,8 @@ DEF("object", HAS_ARG, QEMU_OPTION_object, " create a new object of type TYPENAME setting properties\n" " in the order they are specified. Note that the 'id'\n" " property must be set. These objects are placed in the\n" - " '/objects' path.\n", + " '/objects' path.\n" + " Use '-object help' to print available backend types.\n", QEMU_ARCH_ALL) STEXI @item -object @var{typename}[,@var{prop1}=@var{value1},...] @@ -3762,6 +3763,8 @@ in the order they are specified. Note that the 'id' property must be set. These objects are placed in the '/objects' path. +Use '-object help' to print available backend types. + @table @option @item -object memory-backend-file,id=@var{id},size=@var{size},mem-path=@var{dir},share=@var{on|off} diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c index bf59846..8f820a4 100644 --- a/qom/object_interfaces.c +++ b/qom/object_interfaces.c @@ -58,6 +58,22 @@ Object *user_creatable_add(const QDict *qdict, goto out_visit; } + if (!strcmp(type, "help")) { + printf("Available object backend types:\n"); + GSList *list = object_class_get_list(TYPE_USER_CREATABLE, false); + while (list) { + const char *name; + name = object_class_get_name(OBJECT_CLASS(list->data)); + /* Ignore user-creatable. */ + if (strcmp(name, TYPE_USER_CREATABLE)) { + printf("%s\n", name); + } + list = list->next; + } + g_slist_free(list); + exit(0); + } + qdict_del(pdict, "id"); visit_type_str(v, "id", &id, &local_err); if (local_err) {