From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: "Cédric Le Goater" <clg@kaod.org>
Cc: "Daniel P . Berrangé" <berrange@redhat.com>,
"Eduardo Habkost" <ehabkost@redhat.com>,
qemu-devel@nongnu.org, armbru@redhat.com,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Andreas Färber" <afaerber@suse.de>
Subject: Re: [RFC PATCH] qom: Implement qom-get HMP command
Date: Mon, 27 Apr 2020 20:19:08 +0100 [thread overview]
Message-ID: <20200427191908.GO2923@work-vm> (raw)
In-Reply-To: <20200407114449.482532-1-clg@kaod.org>
* Cédric Le Goater (clg@kaod.org) wrote:
> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
>
> 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 <pbonzini@redhat.com>
> Signed-off-by: Andreas Färber <afaerber@suse.de>
>
> Slight fix for bit-rot:
> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> [clg: updates for QEMU 5.0 ]
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---
>
> 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 / dgilbert@redhat.com / Manchester, UK
next prev parent reply other threads:[~2020-04-27 19:20 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-07 11:44 [RFC PATCH] qom: Implement qom-get HMP command Cédric Le Goater
2020-04-27 19:19 ` Dr. David Alan Gilbert [this message]
2020-04-29 7:45 ` Cédric Le Goater
2020-05-02 6:02 ` Markus Armbruster
2020-05-07 17:06 ` Dr. David Alan Gilbert
2020-05-08 6:48 ` Markus Armbruster
2020-05-20 9:59 ` Dr. David Alan Gilbert
2020-05-21 14:24 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200427191908.GO2923@work-vm \
--to=dgilbert@redhat.com \
--cc=afaerber@suse.de \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=clg@kaod.org \
--cc=ehabkost@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).