qemu-devel
[Top][All Lists]
Advanced

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

Re: [RFC PATCH] qom: Implement qom-get HMP command


From: Dr. David Alan Gilbert
Subject: Re: [RFC PATCH] qom: Implement qom-get HMP command
Date: Mon, 27 Apr 2020 20:19:08 +0100
User-agent: Mutt/1.13.4 (2020-02-15)

* Cédric Le Goater (address@hidden) wrote:
> From: "Dr. David Alan Gilbert" <address@hidden>
> 
> Reimplement it based on qmp_qom_get() to avoid converting QObjects back
> to strings.

<blows dust off patch>
I'd love to see this or something similar in;  what does it's output
look like for structures - I think that was the main problem people
complained about last time, although IMHO even a version that couldn't
do structures nicely would be better than nothing.

Dave

> 
> Inspired-by: Paolo Bonzini <address@hidden>
> Signed-off-by: Andreas Färber <address@hidden>
> 
> Slight fix for bit-rot:
> Signed-off-by: Dr. David Alan Gilbert <address@hidden>
> [clg: updates for QEMU 5.0 ]
> Signed-off-by: Cédric Le Goater <address@hidden>
> ---
> 
>  I would like to restart the discussion on qom-get command to understand
>  what was the conclusion and see if things have changed since.
> 
>  Thanks,
> 
>  C.
> 
>  include/monitor/hmp.h |  1 +
>  qom/qom-hmp-cmds.c    | 23 +++++++++++++++++++++++
>  hmp-commands.hx       | 13 +++++++++++++
>  3 files changed, 37 insertions(+)
> 
> diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
> index e33ca5a911a5..c986cfd28bc3 100644
> --- a/include/monitor/hmp.h
> +++ b/include/monitor/hmp.h
> @@ -96,6 +96,7 @@ void hmp_info_memdev(Monitor *mon, const QDict *qdict);
>  void hmp_info_numa(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 hmp_qom_get(Monitor *mon, const QDict *qdict);
>  void hmp_qom_set(Monitor *mon, const QDict *qdict);
>  void hmp_info_qom_tree(Monitor *mon, const QDict *dict);
>  void object_add_completion(ReadLineState *rs, int nb_args, const char *str);
> diff --git a/qom/qom-hmp-cmds.c b/qom/qom-hmp-cmds.c
> index cd08233a4cfe..b14cf6e785f4 100644
> --- a/qom/qom-hmp-cmds.c
> +++ b/qom/qom-hmp-cmds.c
> @@ -40,6 +40,29 @@ void hmp_qom_list(Monitor *mon, const QDict *qdict)
>      hmp_handle_error(mon, err);
>  }
>  
> +void hmp_qom_get(Monitor *mon, const QDict *qdict)
> +{
> +    const char *path = qdict_get_str(qdict, "path");
> +    const char *property = qdict_get_str(qdict, "property");
> +    Error *err = NULL;
> +    Object *obj;
> +    char *value;
> +
> +    obj = object_resolve_path(path, NULL);
> +    if (obj == NULL) {
> +        error_set(&err, ERROR_CLASS_DEVICE_NOT_FOUND,
> +                  "Device '%s' not found", path);
> +        hmp_handle_error(mon, err);
> +        return;
> +    }
> +    value = object_property_print(obj, property, true, &err);
> +    if (err == NULL) {
> +        monitor_printf(mon, "%s\n", value);
> +        g_free(value);
> +    }
> +    hmp_handle_error(mon, err);
> +}
> +
>  void hmp_qom_set(Monitor *mon, const QDict *qdict)
>  {
>      const char *path = qdict_get_str(qdict, "path");
> diff --git a/hmp-commands.hx b/hmp-commands.hx
> index 7f0f3974ad90..4e39b9caed3e 100644
> --- a/hmp-commands.hx
> +++ b/hmp-commands.hx
> @@ -1790,6 +1790,19 @@ SRST
>    Print QOM properties of object at location *path*
>  ERST
>  
> +    {
> +        .name       = "qom-get",
> +        .args_type  = "path:s,property:s",
> +        .params     = "path property",
> +        .help       = "print QOM property",
> +        .cmd        = hmp_qom_get,
> +    },
> +
> +SRST
> +``qom-get``  *path* *property*
> +  Print QOM property *property* of object at location *path*
> +ERST
> +
>      {
>          .name       = "qom-set",
>          .args_type  = "path:s,property:s,value:s",
> -- 
> 2.25.1
> 
--
Dr. David Alan Gilbert / address@hidden / Manchester, UK




reply via email to

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