From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Alexey Kardashevskiy <aik@ozlabs.ru>
Cc: qemu-devel@nongnu.org, armbru@redhat.com
Subject: Re: [Qemu-devel] [RFC PATCH qemu] qdev: Use "string" for QOM string properties
Date: Tue, 5 Jun 2018 10:29:37 +0100 [thread overview]
Message-ID: <20180605092937.GK32286@redhat.com> (raw)
In-Reply-To: <20180605091508.14129-1-aik@ozlabs.ru>
On Tue, Jun 05, 2018 at 07:15:08PM +1000, Alexey Kardashevskiy wrote:
> For QOM properties QEMU uses "string", for example:
>
> {"execute": "qom-list", "arguments": {"path": "/machine"}}
> [{'return': [{'type': 'string', 'name': 'append'}, {'type': 'string', 'name': 'kernel'}]
>
> However for the device properties copied from DEVICE_CLASS(class)->props,
> "str" is used for a type (vnet0 is "-device virtio-net-pci,id=vnet0"):
>
> {"execute": "qom-list", "arguments": {"path": "/machine/peripheral/vnet0"}}
> ret=[{'return': [{'name': 'tx', 'type': 'str'}]
>
> This changes string type when adding them to QOM property list so
> we get one string type in QMP.
>
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
>
> Not a huge improvement and might actually break something but since
> I got that far I decided to post this anyway :)
>
> The alternatives are: 1) do nothing 2) do this:
>
> const PropertyInfo qdev_prop_string = {
> - .name = "str",
> + .name = "string",
> .release = release_string,
> .get = get_string,
> .set = set_string,
> };
As further points of reference:
- object_property_add_str & object_class_property_add_str
both use "string".
- QAPI schema uses "str"
So the inconsistency is even bigger than just qdev. I'm inclined
to say "QAPI schema" is the canonical source of truth, and so
every use of "string" should change to "str".
CC'd Markus for 2nd opinion.
>
>
> ---
> hw/core/qdev.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/hw/core/qdev.c b/hw/core/qdev.c
> index f6f9247..2895693 100644
> --- a/hw/core/qdev.c
> +++ b/hw/core/qdev.c
> @@ -687,7 +687,7 @@ static void qdev_property_add_legacy(DeviceState *dev, Property *prop,
> }
>
> name = g_strdup_printf("legacy-%s", prop->name);
> - object_property_add(OBJECT(dev), name, "str",
> + object_property_add(OBJECT(dev), name, "string",
> prop->info->print ? qdev_get_legacy_property : prop->info->get,
> NULL,
> NULL,
> @@ -711,6 +711,7 @@ void qdev_property_add_static(DeviceState *dev, Property *prop,
> {
> Error *local_err = NULL;
> Object *obj = OBJECT(dev);
> + const char *proptype;
>
> if (prop->info->create) {
> prop->info->create(obj, prop, &local_err);
> @@ -723,7 +724,11 @@ void qdev_property_add_static(DeviceState *dev, Property *prop,
> if (!prop->info->get && !prop->info->set) {
> return;
> }
> - object_property_add(obj, prop->name, prop->info->name,
> + proptype = prop->info->name;
> + if (0 == strncmp(proptype, "str", 3)) {
> + proptype = "string";
> + }
> + object_property_add(obj, prop->name, proptype,
> prop->info->get, prop->info->set,
> prop->info->release,
> prop, &local_err);
> --
> 2.11.0
>
>
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
next prev parent reply other threads:[~2018-06-05 9:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-05 9:15 [Qemu-devel] [RFC PATCH qemu] qdev: Use "string" for QOM string properties Alexey Kardashevskiy
2018-06-05 9:29 ` Daniel P. Berrangé [this message]
2018-06-07 8:43 ` 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=20180605092937.GK32286@redhat.com \
--to=berrange@redhat.com \
--cc=aik@ozlabs.ru \
--cc=armbru@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 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.