From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43411) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWESZ-0005xt-77 for qemu-devel@nongnu.org; Thu, 12 Mar 2015 21:32:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YWESU-0001zJ-RJ for qemu-devel@nongnu.org; Thu, 12 Mar 2015 21:32:19 -0400 Received: from szxga01-in.huawei.com ([58.251.152.64]:36875) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWESU-0001yb-71 for qemu-devel@nongnu.org; Thu, 12 Mar 2015 21:32:14 -0400 Message-ID: <55023E12.2030502@huawei.com> Date: Fri, 13 Mar 2015 09:32:02 +0800 From: Gonglei MIME-Version: 1.0 References: <1426178624-32638-1-git-send-email-afaerber@suse.de> <1426178624-32638-3-git-send-email-afaerber@suse.de> In-Reply-To: <1426178624-32638-3-git-send-email-afaerber@suse.de> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH v2 2/9] qom: Implement qom-list HMP command List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= , qemu-devel@nongnu.org Cc: Luiz Capitulino On 2015/3/13 0:43, Andreas Färber wrote: > Implement it as a wrapper for QMP qom-list, but mimic the behavior of > scripts/qmp/qom-list in making the path argument optional and listing > the root if absent, to hint users what kind of path to pass. > > Signed-off-by: Andreas Färber > --- > hmp-commands.hx | 13 +++++++++++++ > hmp.c | 26 ++++++++++++++++++++++++++ > hmp.h | 1 + > 3 files changed, 40 insertions(+) > Reviewed-by: Gonglei > diff --git a/hmp-commands.hx b/hmp-commands.hx > index d5022d8..c3b93d6 100644 > --- a/hmp-commands.hx > +++ b/hmp-commands.hx > @@ -1658,6 +1658,19 @@ Add CPU with id @var{id} > ETEXI > > { > + .name = "qom-list", > + .args_type = "path:s?", > + .params = "path", > + .help = "list QOM properties", > + .mhandler.cmd = hmp_qom_list, > + }, > + > +STEXI > +@item qom-list [@var{path}] > +Print QOM properties of object at location @var{path} > +ETEXI > + > + { > .name = "info", > .args_type = "item:s?", > .params = "[subcommand]", > diff --git a/hmp.c b/hmp.c > index 71c28bc..f6df075 100644 > --- a/hmp.c > +++ b/hmp.c > @@ -1852,3 +1852,29 @@ void hmp_info_memory_devices(Monitor *mon, const QDict *qdict) > > qapi_free_MemoryDeviceInfoList(info_list); > } > + > +void hmp_qom_list(Monitor *mon, const QDict *qdict) > +{ > + const char *path = qdict_get_try_str(qdict, "path"); > + ObjectPropertyInfoList *list; > + Error *err = NULL; > + > + if (path == NULL) { > + monitor_printf(mon, "/\n"); > + return; > + } > + > + list = qmp_qom_list(path, &err); > + if (err == NULL) { > + ObjectPropertyInfoList *start = list; > + while (list != NULL) { > + ObjectPropertyInfo *value = list->value; > + > + monitor_printf(mon, "%s (%s)\n", > + value->name, value->type); > + list = list->next; > + } > + qapi_free_ObjectPropertyInfoList(start); > + } > + hmp_handle_error(mon, &err); > +} > diff --git a/hmp.h b/hmp.h > index 81177b2..18c0f52 100644 > --- a/hmp.h > +++ b/hmp.h > @@ -95,6 +95,7 @@ void hmp_object_add(Monitor *mon, const QDict *qdict); > void hmp_object_del(Monitor *mon, const QDict *qdict); > void hmp_info_memdev(Monitor *mon, const QDict *qdict); > void hmp_info_memory_devices(Monitor *mon, const QDict *qdict); > +void hmp_qom_list(Monitor *mon, const QDict *qdict); > void object_add_completion(ReadLineState *rs, int nb_args, const char *str); > void object_del_completion(ReadLineState *rs, int nb_args, const char *str); > void device_add_completion(ReadLineState *rs, int nb_args, const char *str); >