From: Eduardo Habkost <ehabkost@redhat.com>
To: Denis Plotnikov <dplotnikov@virtuozzo.com>
Cc: "kwolf@redhat.com" <kwolf@redhat.com>,
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
"berrange@redhat.com" <berrange@redhat.com>,
Denis Lunev <den@virtuozzo.com>,
"qemu-block@nongnu.org" <qemu-block@nongnu.org>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
"mreitz@redhat.com" <mreitz@redhat.com>,
"pbonzini@redhat.com" <pbonzini@redhat.com>
Subject: Re: [PATCH v0 1/2] qdev-properties-system: extend set_pionter for unrealized devices
Date: Mon, 25 Nov 2019 12:30:11 -0300 [thread overview]
Message-ID: <20191125153011.GL4438@habkost.net> (raw)
In-Reply-To: <d5d3ac62-4f46-08d6-bf66-620e410fa954@virtuozzo.com>
On Fri, Nov 22, 2019 at 11:36:30AM +0000, Denis Plotnikov wrote:
>
>
> On 18.11.2019 21:54, Eduardo Habkost wrote:
> > On Sun, Nov 10, 2019 at 10:03:09PM +0300, Denis Plotnikov wrote:
> >> Some device's property can be changed if the device has been already
> >> realized. For example, it could be "drive" property of a scsi disk device.
> >>
> >> So far, set_pointer could operate only on a relized device. The patch
> >> extends its interface for operation on an unrealized device.
> >>
> >> Signed-off-by: Denis Plotnikov <dplotnikov@virtuozzo.com>
> >> ---
> >> hw/core/qdev-properties-system.c | 32 +++++++++++++++++++++-----------
> >> 1 file changed, 21 insertions(+), 11 deletions(-)
> >>
> >> diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
> >> index ba412dd2ca..c534590dcd 100644
> >> --- a/hw/core/qdev-properties-system.c
> >> +++ b/hw/core/qdev-properties-system.c
> >> @@ -38,9 +38,14 @@ static void get_pointer(Object *obj, Visitor *v, Property *prop,
> >> }
> >>
> >> static void set_pointer(Object *obj, Visitor *v, Property *prop,
> >> - void (*parse)(DeviceState *dev, const char *str,
> >> - void **ptr, const char *propname,
> >> - Error **errp),
> >> + void (*parse_realized)(DeviceState *dev,
> >> + const char *str, void **ptr,
> >> + const char *propname,
> >> + Error **errp),
> >> + void (*parse_unrealized)(DeviceState *dev,
> >> + const char *str, void **ptr,
> >> + const char *propname,
> >> + Error **errp),
> >> const char *name, Error **errp)
> > Wouldn't it be simpler to just add a PropertyInfo::allow_set_after_realize
> > bool field, and call the same setter function? Then you can
> > simply change do_parse_drive() to check if realized is true.
> May be, but I thought It would be more clear to have a separate callback
> for all the devices supporting the property setting when realized.
> Also the "drive" property setting on realized and non-realized device a
> little bit different: in the realized case the setter function expects
> to get
> BlockDriverState only, when in the unrealized case the setter can accept
> both BlockBackend and BlockDriverState. Also, in the unrealized case the
> setter function doesn't expect to have a device with an empty BlockBackend.
> I decided that extending do_parse_drive would make it more complex for
> understanding. That's why I made two separate functions for both cases.
I understand you might want two separate functions in the
specific case of drive. You can still call different
functions after checking dev->realized inside do_parse_drive().
My point was that you don't need to make set_pointer() require
two separate function pointers just to propagate 1 bit of
information that is already available in DeviceState. In patch
2/2 you had to create 4 different copies of parse_drive*()
because of this.
>
> I'd like to mention that I have a few concerns about
> do_parse_drive_realized (please see the next patch from the series) and
> I'd like them to be reviewed as well. After that, may be it would be
> better to go the way you suggested.
In the case if your questions in patch 2/2, I'm afraid I don't
know the answers and we need help from the block maintainers.
--
Eduardo
next prev parent reply other threads:[~2019-11-25 15:32 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-10 19:03 [PATCH v0 0/2] allow to set 'drive' property on a realized block device Denis Plotnikov
2019-11-10 19:03 ` [PATCH v0 1/2] qdev-properties-system: extend set_pionter for unrealized devices Denis Plotnikov
2019-11-18 18:54 ` Eduardo Habkost
2019-11-22 11:36 ` Denis Plotnikov
2019-11-25 15:30 ` Eduardo Habkost [this message]
2019-11-26 6:49 ` Denis Plotnikov
2019-11-26 16:38 ` Kevin Wolf
2019-11-10 19:03 ` [PATCH v0 2/2] block: allow to set 'drive' property on a realized block device Denis Plotnikov
2019-11-10 19:08 ` Denis Plotnikov
2019-11-18 10:50 ` Denis Plotnikov
2019-12-13 7:30 ` [PING]Re: " Denis Plotnikov
2019-12-13 10:32 ` Kevin Wolf
2019-12-16 14:51 ` Denis Plotnikov
2019-12-16 15:38 ` Kevin Wolf
2019-12-16 15:58 ` Denis Plotnikov
2019-11-18 10:30 ` [PATCH v0 0/2] " Denis Plotnikov
2020-03-02 13:38 ` Kevin Wolf
2020-03-02 13:55 ` Denis Plotnikov
2020-03-02 15:39 ` Kevin Wolf
2020-03-03 7:43 ` Vladimir Sementsov-Ogievskiy
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=20191125153011.GL4438@habkost.net \
--to=ehabkost@redhat.com \
--cc=berrange@redhat.com \
--cc=den@virtuozzo.com \
--cc=dplotnikov@virtuozzo.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@virtuozzo.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).