qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: Kevin Wolf <kwolf@redhat.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Anthony Liguori <aliguori@us.ibm.com>,
	Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>,
	Jan Kiszka <jan.kiszka@siemens.com>,
	qemu-devel@nongnu.org, Markus Armbruster <armbru@redhat.com>,
	Luiz Capitulino <lcapitulino@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 02/18] qom: register legacy properties as new style properties
Date: Thu, 01 Dec 2011 19:05:14 -0600	[thread overview]
Message-ID: <4ED8244A.4040706@codemonkey.ws> (raw)
In-Reply-To: <4ED7A7ED.7040903@redhat.com>

On 12/01/2011 10:14 AM, Kevin Wolf wrote:
> Am 30.11.2011 22:03, schrieb Anthony Liguori:
>> Expose all legacy properties through the new QOM property mechanism.  The qdev
>> property types are exposed through the 'legacy<>' namespace.  They are always
>> visited as strings since they do their own string parsing.
>>
>> Signed-off-by: Anthony Liguori<aliguori@us.ibm.com>
>> ---
>>   hw/qdev.c |   82 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>   hw/qdev.h |    7 +++++
>>   2 files changed, 89 insertions(+), 0 deletions(-)
>
> Not directly related to this patch, but looking for the first time at
> visitor code, visitors are clearly underdocumented.

Yes.  I need to spend time documenting it.

>> +static void qdev_get_legacy_property(DeviceState *dev, Visitor *v, void *opaque,
>> +                                     const char *name, Error **errp)
>> +{
>> +    Property *prop = opaque;
>> +
>> +    if (prop->info->print) {
>> +        char buffer[1024];
>> +        char *ptr = buffer;
>> +
>> +        prop->info->print(dev, prop, buffer, sizeof(buffer));
>> +        visit_type_str(v,&ptr, name, errp);
>
> So a string output visitor (this is what it's called, right?) takes a
> buffer on the stack that the visitor must not free...

An output visitor does not take ownership of the string pointer.  An input 
visitor transfers ownership of the returned string to the caller.

The semantics suck.  See my other comments about changing this behavior.  I 
think I'm convinced we need to change the visitor interface here.

>
>> +    } else {
>> +        error_set(errp, QERR_PERMISSION_DENIED);
>> +    }
>> +}
>> +
>> +static void qdev_set_legacy_property(DeviceState *dev, Visitor *v, void *opaque,
>> +                                     const char *name, Error **errp)
>> +{
>> +    Property *prop = opaque;
>> +
>> +    if (dev->state != DEV_STATE_CREATED) {
>> +        error_set(errp, QERR_PERMISSION_DENIED);
>> +        return;
>> +    }
>> +
>> +    if (prop->info->parse) {
>> +        Error *local_err = NULL;
>> +        char *ptr = NULL;
>> +
>> +        visit_type_str(v,&ptr, name,&local_err);
>> +        if (!local_err) {
>> +            int ret;
>> +            ret = prop->info->parse(dev, prop, ptr);
>> +            if (ret != 0) {
>> +                error_set(errp, QERR_INVALID_PARAMETER_VALUE,
>> +                          name, prop->info->name);
>> +            }
>> +            g_free(ptr);
>
> ...but a string input visitor creates a copy that must be freed.
>
> Kind of surprising behaviour, and qapi-visit-core.h doesn't document it.

Yes, I'll fix that (the lack of docs).

Regards,

Anthony Liguori

> Kevin
>

  reply	other threads:[~2011-12-02  1:05 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-30 21:03 [Qemu-devel] [PATCH 00/18] qom: dynamic properties and composition tree Anthony Liguori
2011-11-30 21:03 ` [Qemu-devel] [PATCH 01/18] qom: add new dynamic property infrastructure based on Visitors Anthony Liguori
2011-12-01  8:19   ` Stefan Hajnoczi
2011-12-01 13:30     ` Anthony Liguori
2011-12-01 15:52   ` Kevin Wolf
2011-12-02  1:08     ` Anthony Liguori
2011-12-02  9:43       ` Kevin Wolf
2011-12-02 18:47     ` Anthony Liguori
2011-12-05  9:16       ` Kevin Wolf
2011-11-30 21:03 ` [Qemu-devel] [PATCH 02/18] qom: register legacy properties as new style properties Anthony Liguori
2011-12-01  8:33   ` Stefan Hajnoczi
2011-12-01 13:31     ` Anthony Liguori
2011-12-01 15:51   ` Gerd Hoffmann
2011-12-02  1:03     ` Anthony Liguori
2011-12-02 12:19       ` Gerd Hoffmann
2011-12-01 16:14   ` Kevin Wolf
2011-12-02  1:05     ` Anthony Liguori [this message]
2011-11-30 21:03 ` [Qemu-devel] [PATCH 03/18] qom: introduce root device Anthony Liguori
2011-11-30 21:03 ` [Qemu-devel] [PATCH 04/18] qdev: provide an interface to return canonical path from root Anthony Liguori
2011-11-30 21:03 ` [Qemu-devel] [PATCH 05/18] qdev: provide a path resolution Anthony Liguori
2011-12-01 10:24   ` Stefan Hajnoczi
2011-12-01 13:34     ` Anthony Liguori
2011-11-30 21:03 ` [Qemu-devel] [PATCH 06/18] qom: add child properties (composition) Anthony Liguori
2011-12-02 11:54   ` Kevin Wolf
2011-12-02 14:54     ` Anthony Liguori
2011-11-30 21:03 ` [Qemu-devel] [PATCH 07/18] qom: add link properties Anthony Liguori
2011-12-01 10:55   ` Stefan Hajnoczi
2011-12-01 13:40     ` Anthony Liguori
2011-12-01 11:21   ` Avi Kivity
2011-12-01 11:35     ` Stefan Hajnoczi
2011-12-01 12:34       ` Avi Kivity
2011-12-01 13:47         ` Anthony Liguori
2011-12-01 13:50           ` Avi Kivity
2011-12-01 14:56             ` Anthony Liguori
2011-12-01 13:44     ` Anthony Liguori
2011-12-01 14:03       ` Avi Kivity
2011-12-01 14:53         ` Anthony Liguori
2011-12-01 15:00           ` Avi Kivity
2011-12-01 15:10             ` Anthony Liguori
2011-12-01 15:03           ` Gerd Hoffmann
2011-12-01 15:13             ` Avi Kivity
2011-12-01 15:14             ` Anthony Liguori
2011-12-02 12:15   ` Kevin Wolf
2011-12-02 14:57     ` Anthony Liguori
2011-11-30 21:03 ` [Qemu-devel] [PATCH 08/18] qapi: allow a 'gen' key to suppress code generation Anthony Liguori
2011-11-30 21:03 ` [Qemu-devel] [PATCH 09/18] qmp: add qom-list command Anthony Liguori
2011-11-30 21:03 ` [Qemu-devel] [PATCH 10/18] qom: qom_{get,set} monitor commands Anthony Liguori
2011-12-01 11:04   ` Stefan Hajnoczi
2011-12-01 13:35     ` Anthony Liguori
2011-11-30 21:03 ` [Qemu-devel] [PATCH 11/18] qdev: add explicitly named devices to the root complex Anthony Liguori
2011-11-30 21:03 ` [Qemu-devel] [PATCH 12/18] dev: add an anonymous peripheral container Anthony Liguori
2011-11-30 21:03 ` [Qemu-devel] [PATCH 13/18] rtc: make piix3 set the rtc as a child Anthony Liguori
2011-12-01 11:07   ` Stefan Hajnoczi
2011-12-01 13:35     ` Anthony Liguori
2011-11-30 21:03 ` [Qemu-devel] [PATCH 14/18] rtc: add a dynamic property for retrieving the date Anthony Liguori
2011-12-01 15:46   ` Gerd Hoffmann
2011-12-02  1:19     ` Anthony Liguori
2011-12-02 12:35       ` Gerd Hoffmann
2011-12-02 13:20         ` Anthony Liguori
2011-12-02 13:34           ` Gerd Hoffmann
2011-12-02 15:05             ` Anthony Liguori
2011-11-30 21:03 ` [Qemu-devel] [PATCH 15/18] qom: optimize qdev_get_canonical_path using a parent link Anthony Liguori
2011-12-01 11:21   ` Stefan Hajnoczi
2011-12-01 13:38     ` Anthony Liguori
2011-11-30 21:03 ` [Qemu-devel] [PATCH 16/18] Make qmp.py easier to use Anthony Liguori
2011-11-30 21:03 ` [Qemu-devel] [PATCH 17/18] Add test tools Anthony Liguori
2011-12-01 11:26   ` Stefan Hajnoczi
2011-12-01 13:39     ` Anthony Liguori
2011-12-01 14:03       ` Stefan Hajnoczi
2011-11-30 21:03 ` [Qemu-devel] [PATCH 18/18] qdev: split out QOM functions to separate files Anthony Liguori
2011-11-30 22:54 ` [Qemu-devel] [PATCH 00/18] qom: dynamic properties and composition tree Anthony Liguori
2011-12-01 14:20 ` Avi Kivity
2011-12-01 14:42   ` Anthony Liguori
2011-12-01 14:48     ` Avi Kivity
2011-12-01 15:01       ` Anthony Liguori

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=4ED8244A.4040706@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=aliguori@us.ibm.com \
    --cc=armbru@redhat.com \
    --cc=jan.kiszka@siemens.com \
    --cc=kwolf@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@linux.vnet.ibm.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 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).