qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH qom-next 1/4] qom: Implement info qom-compositio


From: Hani Benhabiles
Subject: Re: [Qemu-devel] [PATCH qom-next 1/4] qom: Implement info qom-composition HMP command
Date: Sun, 11 May 2014 14:26:47 +0100
User-agent: Mutt/1.5.23 (2014-03-12)

On Thu, May 08, 2014 at 04:21:14PM +0200, Andreas Färber wrote:
> To complement qdev's bus-oriented info qtree, info qom-composition
> prints a hierarchical view of the machine composition tree.
> 
> Signed-off-by: Andreas Färber <address@hidden>
> ---
>  include/monitor/qdev.h |  1 +
>  monitor.c              |  7 +++++++
>  qdev-monitor.c         | 35 +++++++++++++++++++++++++++++++++++
>  3 files changed, 43 insertions(+)
> 
> diff --git a/include/monitor/qdev.h b/include/monitor/qdev.h
> index 8d16e11..cb5c8ee 100644
> --- a/include/monitor/qdev.h
> +++ b/include/monitor/qdev.h
> @@ -8,6 +8,7 @@
>  
>  void do_info_qtree(Monitor *mon, const QDict *qdict);
>  void do_info_qdm(Monitor *mon, const QDict *qdict);
> +void do_info_qom_composition(Monitor *mon, const QDict *dict);
>  int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data);
>  int qdev_device_help(QemuOpts *opts);
>  DeviceState *qdev_device_add(QemuOpts *opts);
> diff --git a/monitor.c b/monitor.c
> index 1266ba0..c2b9315 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -2920,6 +2920,13 @@ static mon_cmd_t info_cmds[] = {
>          .mhandler.cmd = do_info_qdm,
>      },
>      {
> +        .name       = "qom-composition",
> +        .args_type  = "",
> +        .params     = "",
> +        .help       = "show QOM machine composition tree",
> +        .mhandler.cmd = do_info_qom_composition,
> +    },
> +    {
>          .name       = "roms",
>          .args_type  = "",
>          .params     = "",
> diff --git a/qdev-monitor.c b/qdev-monitor.c
> index 02cbe43..744144a 100644
> --- a/qdev-monitor.c
> +++ b/qdev-monitor.c
> @@ -658,6 +658,41 @@ void do_info_qdm(Monitor *mon, const QDict *qdict)
>      qdev_print_devinfos(true);
>  }
>  
> +typedef struct QOMCompositionState {
> +    Monitor *mon;
> +    int indent;
> +} QOMCompositionState;
> +
> +static void print_qom_composition(Monitor *mon, Object *obj, int indent);
> +
> +static int print_qom_composition_child(Object *obj, void *opaque)
> +{
> +    QOMCompositionState *s = opaque;
> +
> +    print_qom_composition(s->mon, obj, s->indent);
> +
> +    return 0;
> +}
> +
> +static void print_qom_composition(Monitor *mon, Object *obj, int indent)
> +{
> +    QOMCompositionState s = {
> +        .mon = mon,
> +        .indent = indent + 2,
> +    };
> +    char *name = object_get_canonical_path_component(obj);
> +
> +    monitor_printf(mon, "%*s/%s (%s)\n", indent, "", name,
> +                   object_get_typename(obj));
> +    g_free(name);
> +    object_child_foreach(obj, print_qom_composition_child, &s);
> +}
> +
> +void do_info_qom_composition(Monitor *mon, const QDict *dict)
> +{
> +    print_qom_composition(mon, qdev_get_machine(), 0);
> +}
> +
>  int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data)
>  {
>      Error *local_err = NULL;

Reviewed-by: Hani Benhabiles <address@hidden>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]