qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: "Kevin Wolf" <kwolf@redhat.com>,
	"Anthony Liguori" <aliguori@us.ibm.com>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	"Stefan Hajnoczi" <stefanha@gmail.com>,
	qemu-devel@nongnu.org, "Luiz Capitulino" <lcapitulino@redhat.com>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	laine@redhat.com, "Paolo Bonzini" <pbonzini@redhat.com>,
	"Andreas Färber" <afaerber@suse.de>
Subject: Re: [Qemu-devel] [PATCH] qdev: DEVICE_DELETED event
Date: Thu, 7 Mar 2013 22:29:46 +0200	[thread overview]
Message-ID: <20130307202946.GA13243@redhat.com> (raw)
In-Reply-To: <877gljvu8n.fsf@blackfin.pond.sub.org>

On Thu, Mar 07, 2013 at 09:18:48PM +0100, Markus Armbruster wrote:
> "Michael S. Tsirkin" <mst@redhat.com> writes:
> 
> > On Thu, Mar 07, 2013 at 06:23:46PM +0100, Markus Armbruster wrote:
> >> "Michael S. Tsirkin" <mst@redhat.com> writes:
> >> 
> >> > On Thu, Mar 07, 2013 at 03:14:15PM +0100, Markus Armbruster wrote:
> >> >> Andreas Färber <afaerber@suse.de> writes:
> >> >> 
> >> >> > Am 07.03.2013 11:07, schrieb Michael S. Tsirkin:
> >> >> >> On Thu, Mar 07, 2013 at 10:55:23AM +0100, Markus Armbruster wrote:
> >> >> >>> "Michael S. Tsirkin" <mst@redhat.com> writes:
> >> >> >>>
> >> >> >>>> On Wed, Mar 06, 2013 at 02:57:22PM +0100, Andreas Färber wrote:
> >> >> >>>>> Am 06.03.2013 14:00, schrieb Michael S. Tsirkin:
> >> >> >>>>>> libvirt has a long-standing bug: when removing the device,
> >> >> >>>>>> it can request removal but does not know when does the
> >> >> >>>>>> removal complete. Add an event so we can fix this in a robust way.
> >> >> >>>>>>
> >> >> >>>>>> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> >> >> >>>>>
> >> >> >>>>> Sounds like a good idea to me. :)
> >> >> >>>>>
> >> >> >>>>> [...]
> >> >> >>>>>> diff --git a/hw/qdev.c b/hw/qdev.c
> >> >> >>>>>> index 689cd54..f30d251 100644
> >> >> >>>>>> --- a/hw/qdev.c
> >> >> >>>>>> +++ b/hw/qdev.c
> >> >> >>>>>> @@ -29,6 +29,7 @@
> >> >> >>>>>>  #include "sysemu/sysemu.h"
> >> >> >>>>>>  #include "qapi/error.h"
> >> >> >>>>>>  #include "qapi/visitor.h"
> >> >> >>>>>> +#include "qapi/qmp/qjson.h"
> >> >> >>>>>>  
> >> >> >>>>>>  int qdev_hotplug = 0;
> >> >> >>>>>>  static bool qdev_hot_added = false;
> >> >> >>>>>> @@ -267,6 +268,11 @@ void qdev_init_nofail(DeviceState *dev)
> >> >> >>>>>>  /* Unlink device from bus and free the structure.  */
> >> >> >>>>>>  void qdev_free(DeviceState *dev)
> >> >> >>>>>>  {
> >> >> >>>>>> +    if (dev->id) {
> >> >> >>>>>> +        QObject *data = qobject_from_jsonf("{ 'device': %s }", dev->id);
> >> >> >>>>>> +        monitor_protocol_event(QEVENT_DEVICE_DELETED, data);
> >> >> >>>>>> +        qobject_decref(data);
> >> >> >>>>>> +    }
> >> >> >>>>>>      object_unparent(OBJECT(dev));
> >> >> >>>>>>  }
> >> >> >>>>>>  
> >> >> >>>>>
> >> >> >>>>> I'm pretty sure this is the wrong place to fire the notification. We
> >> >> >>>>> should rather do this when the device is actually deleted - which
> >> >> >>>>> qdev_free() does *not* actually guarantee, as criticized in the s390x
> >> >> >>>>> and unref'ing contexts.
> >> >> >>>>> I would suggest to place your code into device_unparent() instead.
> >> >> >>>>>
> >> >> >>>>> Another thing to consider is what data to pass to the event: Not all
> >> >> >>>>> devices have an ID.
> >> >> >>>>
> >> >> >>>> If they don't they were not created by management so management is
> >> >> >>>> probably not interested in them being removed.
> >> >> >>>>
> >> >> >>>> We could always add a 'path' key later if this assumption
> >> >> >>>> proves incorrect.
> >> >> >>>
> >> >> >>> In old qdev, ID was all we had, because paths were busted.  Thus,
> >> >> >>> management had no choice but use IDs.
> >> >> >>>
> >> >> >>> If I understand modern qdev correctly, we got a canonical path.  Old
> >> >> >>> APIs like device_del still accept only ID.  Should new APIs still be
> >> >> >>> designed that way?  Or should they always accept / provide
> >> >> >>> the canonical
> >> >> >>> path, plus optional ID for convenience?
> >> >> >> 
> >> >> >> What are advantages of exposing the path to users in this way?
> >> >> 
> >> >> The path is the device's canonical name.  Canonical means path:device is
> >> >> 1:1.  Path always works.  Qdev ID only works when the user assigned one.
> >> >> 
> >> >> Funny case: board creates a hot-pluggable device by default (thus no
> >> >> qdev ID), guest ejects it, what do you put into the event?  Your code
> >> >> simply doesn't emit one.
> >> >> 
> >> >> You could blame the user; after all he could've used -nodefaults, and
> >> >> added the device himself, with an ID.
> >> >> 
> >> >> I blame your design instead, which needlessly complicates the event's
> >> >> semantics: it gets emitted only for devices with a qdev ID.  Which you
> >> >> neglected to document clearly, by the way.
> >> >
> >> > Good point, I'll document this.
> >> >
> >> >> If you put the path into the event, you can emit it always, which is
> >> >> simpler.  Feel free to throw in the qdev ID.
> >> >
> >> > I don't blame anyone.  User not assigning an id is a clear indication
> >> > that user does not care about the lifetime of this device.
> >> >
> >> >> >> Looks like maintainance hassle without real benefits?
> >> >> 
> >> >> I can't see path being a greater maintenance hassle than ID.
> >> >
> >> > Sure, the less events we emit the less we need to support.
> >> > You want to expose all kind of internal events,
> >> > then management will come to depend on it and
> >> > we'll have to maintain them forever.
> >> 
> >> Misunderstanding.  I'm *not* asking for more events.  I'm asking for the
> >> DEVICE_DELETED event to carry the device's canonical name: its QOM path.
> >> 
> >> >> > Anthony had rejected earlier QOM patches by Paolo related to qdev id,
> >> >> > saying it was deprecated in favor of those QOM paths.
> >> >> 
> >> >> More reason to put the path into the event, not just the qdev ID.
> >> >
> >> > libvirt does not seems to want it there. We'll always be able to
> >> > add info but will never be able to remove info, keep it minimal.
> >> 
> >> Yes, adding members to an event is easy.  Doesn't mean we should do it
> >> just for the heck of it.  If we don't need a member now, and we think
> >> there's a chance we won't need in the future, then we probably shouldn't
> >> add it now.
> >> 
> >> I believe the chance of not needing the QOM path is effectively zero.
> >> 
> >> Moreover, we'd add not just a member in this case, we'd add a *trigger*.
> >> 
> >> Before: the event gets emitted only for devices with a qdev ID.
> >> 
> >> After: the event gets emitted for all devices.
> >> 
> >> I very much prefer the latter, because it's simpler.
> >> 
> >> [...]
> >
> > I still don't see why it's useful for anyone.  For now I hear from the
> > libvirt guys that this patch does exactly what they need so I'll keep it
> > simple.
> 
> You're keeping it simple only in the sense of keeping it as it is.  I
> think it's not as simple as it easily could be.  Specifically, I want
> you to simplify the event's trigger, and add a path member.  I'm
> convinced we'll have to do this anyway, so why not do it right right
> away, and simplify the future.
> 
> This is based on my limited understanding of qdev and QOM.  If the QOM
> folks tell me that we shouldn't use QOM paths to name the device, I'll
> gladly admit to be wrong, and retract my request.
> 
> >          You are welcome to send a follow-up patch adding a path
> > and more triggers, I won't object.
> 
> The usual protocol for patch submission is maintainer (that would be me,
> until Luiz is back) reviews, submitter (that would be you) addresses
> review comments, within reason.
> 
> I believe my request is well within reason.  As a patch submitter, I've
> jumped through hoops I found less reasonable (to put it charitably) many
> times.
> 
> You, as a maintainer, should know that asking the maintainer to address
> his review comments himself doesn't scale.
> 
> If you think I'm an unreasonable maintainer, feel free to ignore me and
> try again when Luiz is back.

I think it's a reasonable request, just not sure it's the right thing
to do and don't see why it should block this patch when we can
add functionality in a follow-up patch.

-- 
MST

  reply	other threads:[~2013-03-07 20:29 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-06 13:00 [Qemu-devel] [PATCH] qdev: DEVICE_DELETED event Michael S. Tsirkin
2013-03-06 13:57 ` Andreas Färber
2013-03-06 14:13   ` Michael S. Tsirkin
2013-03-07  9:55     ` Markus Armbruster
2013-03-07 10:07       ` Michael S. Tsirkin
2013-03-07 13:11         ` Andreas Färber
2013-03-07 14:14           ` Markus Armbruster
2013-03-07 16:35             ` Michael S. Tsirkin
2013-03-07 17:23               ` Markus Armbruster
2013-03-07 18:12                 ` Michael S. Tsirkin
2013-03-07 19:00                   ` Andreas Färber
2013-03-07 19:15                     ` Michael S. Tsirkin
2013-03-08  7:09                       ` Osier Yang
2013-03-08  8:50                         ` Markus Armbruster
2013-03-08  9:25                           ` Jiri Denemark
2013-03-08 10:37                             ` Osier Yang
2013-03-08 10:56                           ` Osier Yang
2013-03-08 11:58                             ` Markus Armbruster
2013-03-07 20:18                   ` Markus Armbruster
2013-03-07 20:29                     ` Michael S. Tsirkin [this message]
2013-03-06 14:44 ` Eric Blake
2013-03-06 14:50   ` Michael S. Tsirkin
2013-03-06 14:52   ` Paolo Bonzini
2013-03-06 15:41     ` Eric Blake
2013-03-07  9:38       ` 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=20130307202946.GA13243@redhat.com \
    --to=mst@redhat.com \
    --cc=afaerber@suse.de \
    --cc=aliguori@us.ibm.com \
    --cc=armbru@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=laine@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.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).