Received: from eggs.gnu.org ([2001:4830:134:3::10]:35819) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WiPCZ-0006g0-0h for qemu-devel@nongnu.org; Thu, 08 May 2014 10:21:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WiPCL-0005vO-Js for qemu-devel@nongnu.org; Thu, 08 May 2014 10:21:34 -0400 Received: from cantor2.suse.de ([195.135.220.15]:52616 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WiPCL-0005uy-D6 for qemu-devel@nongnu.org; Thu, 08 May 2014 10:21:21 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Thu, 8 May 2014 16:21:15 +0200 Message-Id: <1399558877-4915-3-git-send-email-afaerber@suse.de> In-Reply-To: <1399558877-4915-1-git-send-email-afaerber@suse.de> References: <1399558877-4915-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH qom-next 2/4] qom: Implement qom-list HMP command List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= , Luiz Capitulino 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=C3=A4rber --- hmp-commands.hx | 13 +++++++++++++ hmp.c | 27 +++++++++++++++++++++++++++ hmp.h | 1 + 3 files changed, 41 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index 8971f1b..a0166af 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1678,6 +1678,19 @@ Add CPU with id @var{id} ETEXI =20 { + .name =3D "qom-list", + .args_type =3D "path:s?", + .params =3D "path", + .help =3D "list QOM properties", + .mhandler.cmd =3D hmp_qom_list, + }, + +STEXI +@item qom-list [@var{path}] +Print QOM properties of object at location @var{path} +ETEXI + + { .name =3D "info", .args_type =3D "item:s?", .params =3D "[subcommand]", diff --git a/hmp.c b/hmp.c index ca869ba..1c29c8a 100644 --- a/hmp.c +++ b/hmp.c @@ -1666,3 +1666,30 @@ void hmp_object_del(Monitor *mon, const QDict *qdi= ct) qmp_object_del(id, &err); hmp_handle_error(mon, &err); } + +void hmp_qom_list(Monitor *mon, const QDict *qdict) +{ + const char *path =3D qdict_get_try_str(qdict, "path"); + ObjectPropertyInfoList *list; + Error *err =3D NULL; + + if (path =3D=3D NULL) { + monitor_printf(mon, "/\n"); + return; + } + list =3D qmp_qom_list(path, &err); + if (err =3D=3D NULL) { + while (list !=3D NULL) { + ObjectPropertyInfoList *next =3D list->next; + + monitor_printf(mon, "%s (%s)\n", + list->value->name, list->value->type); + g_free(list->value->name); + g_free(list->value->type); + g_free(list->value); + g_free(list); + list =3D next; + } + } + hmp_handle_error(mon, &err); +} diff --git a/hmp.h b/hmp.h index 20ef454..7ab969e 100644 --- a/hmp.h +++ b/hmp.h @@ -93,6 +93,7 @@ void hmp_qemu_io(Monitor *mon, const QDict *qdict); void hmp_cpu_add(Monitor *mon, const QDict *qdict); void hmp_object_add(Monitor *mon, const QDict *qdict); void hmp_object_del(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 *s= tr); void object_del_completion(ReadLineState *rs, int nb_args, const char *s= tr); void device_add_completion(ReadLineState *rs, int nb_args, const char *s= tr); --=20 1.8.4.5