From: Marcel Apfelbaum <marcel.a@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org,
chouteau@adacore.com, blauwirbel@gmail.com, kraxel@redhat.com,
aliguori@amazon.com, "Paolo Bonzini" <pbonzini@redhat.com>,
edgar.iglesias@gmail.com, "Andreas Färber" <afaerber@suse.de>
Subject: Re: [Qemu-devel] [PATCH 0/2] Pointer properties and device_add
Date: Mon, 02 Dec 2013 11:05:26 +0200 [thread overview]
Message-ID: <1385975126.2367.15.camel@localhost.localdomain> (raw)
In-Reply-To: <87eh5vzp44.fsf@blackfin.pond.sub.org>
On Mon, 2013-12-02 at 08:30 +0100, Markus Armbruster wrote:
> Andreas Färber <afaerber@suse.de> writes:
>
> > Am 01.12.2013 14:13, schrieb Marcel Apfelbaum:
> >> On Fri, 2013-11-29 at 10:43 +0100, armbru@redhat.com wrote:
> >>> From: Markus Armbruster <armbru@redhat.com>
> >>>
> >>> Pointer properties can be set only by code, not by device_add. A
> >>> device with a pointer property can't work with device_add only unless
> >>> the property may remain null. cannot_instantiate_with_device_add_yet
> >>> needs to be set then. PATCH 1/2 sets it when needed and else
> >>> documents why not. PATCH 2/2 documents this for future users of
> >>> pointer properties.
> >>>
> >>> This applies on top of my "[PATCH v4 00/10] Clean up and fix no_user"
> >>> series.
> >>
> >> Even that I am not familiar with this code, I've checked all the changes
> >> and I agree with them.
> >>
> >> Reviewed-by: Marcel Apfelbaum <marcel.a@redhat.com>
> >>
> >> Anyway, I do have a question:
> >> Why not asserting on qdev_device_add if we have a pointer property?
>
> This is a really good thought. In fact, it occurred to me, too.
> However, see "unless the property may remain null" above: there are uses
> of pointer properties that do *not* make the device unusable with
> device_add. We even have an example: etraxfs,pic; see PATCH 1/1. It's
> a sysbus device, so it's unavailable anyway. But there certainly could
> be a device with an optional property that does not and should not have
> cannot_instantiate_with_device_add_yet set.
>
> > When we do device_add / device-add, the guest is usually running and we
> > shouldn't kill a running guest just because the user is trying something
> > stupid that we can easily prevent. ;)
>
> You have a point on assert(bad_input), but this would be
> assert(programming_error), where the error is "device doesn't have
> cannot_instantiate_with_device_add_yet set". I'm advocating to be
> ruthless with programming error asserts.
>
> > The alternative BTW is dropping all those pointer properties and
> > replacing them with link<> properties. Paolo tried that for the OMAP
> > timers once but I fear that series was never picked up...?
>
> /* FIXME: Remove opaque pointer properties. */
>
> /* Not a proper property, just for dirty hacks. TODO Remove it! */
>
> :)
>
> >> Instead of checking only cannot_instantiate_with_device_add_yet,
> >> we can go over properties and if we have a pointer property, assert or
> >> return...
> >
> > Raising an error for certain property types may be an option. Although
> > theoretically the existence of an incompatible property would not
> > necessarily indicate incompatibility to instantiate the device, in
> > practice I believe we don't have such excess properties.
>
> We don't have them now. I hope we won't permit any new pointer
> properties. If you guys want pointer property imply its owner's
> cannot_instantiate_with_device_add_yet, even though it's not generally
> necessary, I'm fine with that.
It was merely a design (and understanding) question, if we prefer to enforce
such things and not rely on future work to comply with rules defined in comments.
Though I am curios what others think about this specific scenario?
Worst case scenario: the coder forgets about it, the reviewers don't catch
this, the initialization code does not ensure the property is set and
the device is added with an "unhealthy" state. But I suppose such a scenario
would be caught early in the development cycle and is not a real issue.
Markus, thanks for the explanations,
Marcel
>
> [...]
next prev parent reply other threads:[~2013-12-02 9:05 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-29 9:43 [Qemu-devel] [PATCH 0/2] Pointer properties and device_add armbru
2013-11-29 9:43 ` [Qemu-devel] [PATCH 1/2] hw: cannot_instantiate_with_device_add_yet due to pointer props armbru
2013-11-29 10:23 ` Edgar E. Iglesias
2013-12-15 20:55 ` Andreas Färber
2013-12-15 21:10 ` Peter Maydell
2013-12-16 8:48 ` Markus Armbruster
2013-12-16 9:33 ` Peter Maydell
2013-12-16 11:17 ` Markus Armbruster
2014-01-07 12:33 ` Andreas Färber
2014-01-07 12:43 ` Peter Maydell
2014-01-07 13:04 ` Andreas Färber
2014-01-07 13:05 ` Peter Crosthwaite
2014-01-10 9:10 ` Andreas Färber
2014-01-10 10:35 ` Peter Crosthwaite
2014-01-07 14:08 ` Markus Armbruster
2014-01-07 16:50 ` Paolo Bonzini
2013-11-29 9:43 ` [Qemu-devel] [PATCH 2/2] qdev: Document that pointer properties kill device_add armbru
2013-12-01 13:13 ` [Qemu-devel] [PATCH 0/2] Pointer properties and device_add Marcel Apfelbaum
2013-12-01 15:14 ` Andreas Färber
2013-12-02 7:30 ` Markus Armbruster
2013-12-02 9:05 ` Marcel Apfelbaum [this message]
2013-12-02 8:52 ` Marcel Apfelbaum
2013-12-15 20:51 ` Andreas Färber
2013-12-16 8:26 ` Marcel Apfelbaum
2013-12-15 21:02 ` Andreas Färber
2013-12-16 8:52 ` 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=1385975126.2367.15.camel@localhost.localdomain \
--to=marcel.a@redhat.com \
--cc=afaerber@suse.de \
--cc=aliguori@amazon.com \
--cc=armbru@redhat.com \
--cc=blauwirbel@gmail.com \
--cc=chouteau@adacore.com \
--cc=edgar.iglesias@gmail.com \
--cc=kraxel@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--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 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).