[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 3/3] qmp: print real legacy_name for alias prope
From: |
Michael S. Tsirkin |
Subject: |
Re: [Qemu-devel] [PATCH 3/3] qmp: print real legacy_name for alias property |
Date: |
Mon, 15 Sep 2014 20:46:31 +0300 |
On Mon, Sep 15, 2014 at 10:44:39PM +0800, address@hidden wrote:
> From: Gonglei <address@hidden>
>
> 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 <address@hidden>
> Cc: Paolo Bonzini <address@hidden>
> Cc: Michael S. Tsirkin <address@hidden>
> Signed-off-by: Gonglei <address@hidden>
Acked-by: Michael S. Tsirkin <address@hidden>
> ---
> 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
>
- [Qemu-devel] [PATCH 0/3] Fix confused output for alias properties, arei.gonglei, 2014/09/15
- [Qemu-devel] [PATCH 1/3] qom: add error handler for object alias property, arei.gonglei, 2014/09/15
- [Qemu-devel] [PATCH 2/3] qom: add target object poniter for alias property in ObjectProperty, arei.gonglei, 2014/09/15
- [Qemu-devel] [PATCH 3/3] qmp: print real legacy_name for alias property, arei.gonglei, 2014/09/15
- Re: [Qemu-devel] [PATCH 3/3] qmp: print real legacy_name for alias property,
Michael S. Tsirkin <=
- Re: [Qemu-devel] [PATCH 0/3] Fix confused output for alias properties, Paolo Bonzini, 2014/09/15
- Re: [Qemu-devel] [PATCH 0/3] Fix confused output for alias properties, Eric Blake, 2014/09/15
- Re: [Qemu-devel] [PATCH 0/3] Fix confused output for alias properties, Michael S. Tsirkin, 2014/09/15
- Re: [Qemu-devel] [PATCH 0/3] Fix confused output for alias properties, Markus Armbruster, 2014/09/16
- Re: [Qemu-devel] [PATCH 0/3] Fix confused output for alias properties, Gonglei (Arei), 2014/09/16
- Re: [Qemu-devel] [PATCH 0/3] Fix confused output for alias properties, Paolo Bonzini, 2014/09/16
- Re: [Qemu-devel] [PATCH 0/3] Fix confused output for alias properties, Markus Armbruster, 2014/09/16
- Re: [Qemu-devel] [PATCH 0/3] Fix confused output for alias properties, Paolo Bonzini, 2014/09/16
- Re: [Qemu-devel] [PATCH 0/3] Fix confused output for alias properties, Michael S. Tsirkin, 2014/09/16
- Re: [Qemu-devel] [PATCH 0/3] Fix confused output for alias properties, Paolo Bonzini, 2014/09/16