From: "Michael S. Tsirkin" <mst@redhat.com>
To: arei.gonglei@huawei.com
Cc: agraf@suse.de, weidong.huang@huawei.com, aliguori@amazon.com,
peter.huangpeng@huawei.com, qemu-devel@nongnu.org,
stefanha@redhat.com, pbonzini@redhat.com, lcapitulino@redhat.com
Subject: Re: [Qemu-devel] [PATCH 3/3] qmp: print real legacy_name for alias property
Date: Mon, 15 Sep 2014 20:46:31 +0300 [thread overview]
Message-ID: <20140915174631.GC13548@redhat.com> (raw)
In-Reply-To: <1410792279-2488-4-git-send-email-arei.gonglei@huawei.com>
On Mon, Sep 15, 2014 at 10:44:39PM +0800, arei.gonglei@huawei.com wrote:
> From: Gonglei <arei.gonglei@huawei.com>
>
> In this way, we can get the real legacy_name for
> alias properties, and avoide confusing people because of
> property type. People have no way to know they should
> have a specific format.
>
> Example:
>
> before output:
>
> virtio-blk-pci.physical_block_size=uint16
> virtio-blk-pci.logical_block_size=uint16
> virtio-blk-pci.drive=str
>
> after output applied this patch:
>
> virtio-blk-pci.physical_block_size=blocksize
> virtio-blk-pci.logical_block_size=blocksize
> virtio-blk-pci.drive=drive
>
> Cc: Stefan Hajnoczi <stefanha@redhat.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> qmp.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++---------------------
> 1 file changed, 47 insertions(+), 21 deletions(-)
>
> diff --git a/qmp.c b/qmp.c
> index c6767c4..9338bd4 100644
> --- a/qmp.c
> +++ b/qmp.c
> @@ -433,6 +433,40 @@ ObjectTypeInfoList *qmp_qom_list_types(bool has_implements,
> return ret;
> }
>
> +static bool find_device_property_info(ObjectClass *klass,
> + const char *name,
> + DevicePropertyInfo **info)
> +{
> + Property *prop;
> + bool found = false;
> +
> + for (prop = DEVICE_CLASS(klass)->props; prop && prop->name; prop++) {
> + if (strcmp(name, prop->name) != 0) {
> + continue;
> + }
> +
> + /*
> + * TODO Properties without a parser are just for dirty hacks.
> + * qdev_prop_ptr is the only such PropertyInfo. It's marked
> + * for removal. This conditional should be removed along with
> + * it.
> + */
> + if (!prop->info->set) {
> + found = true;
> + goto out; /* no way to set it, don't show */
> + }
> +
> + *info = g_malloc0(sizeof(**info));
> + (*info)->name = g_strdup(prop->name);
> + (*info)->type = g_strdup(prop->info->legacy_name ?: prop->info->name);
> +
> + found = true;
> + goto out;
> + }
> +out:
> + return found;
> +}
> +
> /* Return a DevicePropertyInfo for a qdev property.
> *
> * If a qdev property with the given name does not exist, use the given default
> @@ -442,30 +476,21 @@ ObjectTypeInfoList *qmp_qom_list_types(bool has_implements,
> */
> static DevicePropertyInfo *make_device_property_info(ObjectClass *klass,
> const char *name,
> - const char *default_type)
> + const char *default_type,
> + bool is_alias,
> + Object *target_obj)
> {
> DevicePropertyInfo *info;
> - Property *prop;
> -
> - do {
> - for (prop = DEVICE_CLASS(klass)->props; prop && prop->name; prop++) {
> - if (strcmp(name, prop->name) != 0) {
> - continue;
> - }
>
> - /*
> - * TODO Properties without a parser are just for dirty hacks.
> - * qdev_prop_ptr is the only such PropertyInfo. It's marked
> - * for removal. This conditional should be removed along with
> - * it.
> - */
> - if (!prop->info->set) {
> - return NULL; /* no way to set it, don't show */
> - }
> + if (is_alias) {
> + ObjectClass *class = object_get_class(target_obj);
> + if (find_device_property_info(class, name, &info)) {
> + return info;
> + }
> + }
>
> - info = g_malloc0(sizeof(*info));
> - info->name = g_strdup(prop->name);
> - info->type = g_strdup(prop->info->legacy_name ?: prop->info->name);
> + do {
> + if (find_device_property_info(klass, name, &info)) {
> return info;
> }
> klass = object_class_get_parent(klass);
> @@ -521,7 +546,8 @@ DevicePropertyInfoList *qmp_device_list_properties(const char *typename,
> continue;
> }
>
> - info = make_device_property_info(klass, prop->name, prop->type);
> + info = make_device_property_info(klass, prop->name, prop->type,
> + prop->is_alias, prop->target_obj);
> if (!info) {
> continue;
> }
> --
> 1.7.12.4
>
next prev parent reply other threads:[~2014-09-15 17:47 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-15 14:44 [Qemu-devel] [PATCH 0/3] Fix confused output for alias properties arei.gonglei
2014-09-15 14:44 ` [Qemu-devel] [PATCH 1/3] qom: add error handler for object alias property arei.gonglei
2014-09-15 15:56 ` Paolo Bonzini
2014-09-15 14:44 ` [Qemu-devel] [PATCH 2/3] qom: add target object poniter for alias property in ObjectProperty arei.gonglei
2014-09-15 14:44 ` [Qemu-devel] [PATCH 3/3] qmp: print real legacy_name for alias property arei.gonglei
2014-09-15 17:46 ` Michael S. Tsirkin [this message]
2014-09-15 15:57 ` [Qemu-devel] [PATCH 0/3] Fix confused output for alias properties Paolo Bonzini
2014-09-15 17:38 ` Eric Blake
2014-09-15 17:45 ` Michael S. Tsirkin
2014-09-16 7:21 ` Markus Armbruster
2014-09-16 7:53 ` Gonglei (Arei)
2014-09-16 8:36 ` Paolo Bonzini
2014-09-16 9:16 ` Markus Armbruster
2014-09-16 9:34 ` Paolo Bonzini
2014-09-16 10:37 ` Michael S. Tsirkin
2014-09-16 10:45 ` Paolo Bonzini
2014-09-16 13:31 ` Gonglei (Arei)
2014-09-16 16:26 ` Michael S. Tsirkin
2014-09-16 16:27 ` Paolo Bonzini
2014-09-16 16:56 ` Michael S. Tsirkin
2014-09-16 18:31 ` Paolo Bonzini
2014-09-16 19:01 ` Michael S. Tsirkin
2014-09-16 19:01 ` Michael S. Tsirkin
2014-09-17 6:02 ` Markus Armbruster
2014-09-16 20:00 ` Eric Blake
2014-09-17 5:54 ` Markus Armbruster
2014-09-17 12:58 ` Eric Blake
2014-09-16 14:32 ` Markus Armbruster
2014-09-16 14:36 ` Paolo Bonzini
2014-09-17 2:31 ` Gonglei (Arei)
2014-09-22 8:26 ` Gonglei (Arei)
2014-09-15 17:48 ` Michael S. Tsirkin
2014-09-15 17:49 ` Michael S. Tsirkin
2014-09-16 0:42 ` Gonglei (Arei)
2014-09-16 8:38 ` Paolo Bonzini
2014-09-22 8:34 ` Michael S. Tsirkin
2014-09-22 8:49 ` Gonglei (Arei)
2014-09-22 9:14 ` Paolo Bonzini
2014-09-22 9:33 ` Gonglei (Arei)
2014-09-22 10:03 ` Paolo Bonzini
2014-09-22 11:22 ` Gonglei (Arei)
2014-09-22 12:06 ` Paolo Bonzini
2014-09-22 12:34 ` Michael S. Tsirkin
2014-09-22 12:55 ` Paolo Bonzini
2014-09-23 3:09 ` Gonglei (Arei)
2014-09-23 8:39 ` Paolo Bonzini
2014-09-23 9:13 ` Markus Armbruster
2014-09-23 9:18 ` Gonglei (Arei)
2014-09-23 9:06 ` Markus Armbruster
2014-09-23 9:16 ` Michael S. Tsirkin
2014-09-23 9:17 ` Gonglei (Arei)
2014-09-22 12:48 ` Markus Armbruster
2014-09-22 13:13 ` Gonglei (Arei)
2014-09-22 13:24 ` Paolo Bonzini
2014-09-22 13:36 ` Gonglei (Arei)
2014-09-22 13:40 ` Paolo Bonzini
2014-09-22 13:45 ` Gonglei (Arei)
2014-09-22 13:19 ` Gonglei (Arei)
2014-09-22 11:43 ` Markus Armbruster
2014-09-22 13:08 ` Paolo Bonzini
2014-09-23 4:46 ` Michael S. Tsirkin
2014-09-23 11:39 ` Markus Armbruster
2014-09-22 9:29 ` Markus Armbruster
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=20140915174631.GC13548@redhat.com \
--to=mst@redhat.com \
--cc=agraf@suse.de \
--cc=aliguori@amazon.com \
--cc=arei.gonglei@huawei.com \
--cc=lcapitulino@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.huangpeng@huawei.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=weidong.huang@huawei.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.