qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: "Michael S. Tsirkin" <mst@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, Markus Armbruster <armbru@redhat.com>,
	Gerd Hoffmann <kraxel@redhat.com>,
	laine@redhat.com, Paolo Bonzini <pbonzini@redhat.com>,
	Luiz Capitulino <lcapitulino@redhat.com>
Subject: Re: [Qemu-devel] [PATCHv2] qdev: DEVICE_DELETED event
Date: Wed, 06 Mar 2013 18:03:37 +0100	[thread overview]
Message-ID: <513776E9.20901@suse.de> (raw)
In-Reply-To: <20130306165521.GA429@redhat.com>

Am 06.03.2013 17:55, schrieb Michael S. Tsirkin:
> On Wed, Mar 06, 2013 at 05:52:05PM +0100, Paolo Bonzini wrote:
>> Il 06/03/2013 17:49, Michael S. Tsirkin ha scritto:
>>> libvirt has a long-standing bug: when removing the device,
>>> it can request removal but does not know when the
>>> removal completes. Add an event so we can fix this in a robust way.
>>>
>>> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
>>> ---
>>>
>>> Changes from v1:
>>>     - move to device_unparent
>>>     - address comments by Andreas and Eric
>>>
>>> Andreas also suggested a more generic object-deleted event,
>>> I'm not sure how useful that is so let's add what we already need, for
>>> devices with an id and wait and see what's necessary for non-device
>>> objects?

Fine with me, just wanted to bring that up for consideration since it
impacts not only where we call it but also what data we can provide.

>>> diff --git a/hw/qdev.c b/hw/qdev.c
>>> index 689cd54..d603f4f 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;
>>> @@ -761,6 +762,12 @@ static void device_unparent(Object *obj)
>>>      DeviceClass *dc = DEVICE_GET_CLASS(dev);
>>>      BusState *bus;
>>>  
>>> +    if (dev->id) {
>>> +        QObject *data = qobject_from_jsonf("{ 'device': %s }", dev->id);
>>> +        monitor_protocol_event(QEVENT_DEVICE_DELETED, data);
>>> +        qobject_decref(data);
>>> +    }
>>
>> Do this at the end of device_unparent, so that parents are reported
>> after their children.
>>
>> Paolo
> 
> Hmm yes it seems cleaner, though we'd need to copy the
> id as the device can go away.
> 
> Doing this after
>     while (dev->num_child_bus) {
>         bus = QLIST_FIRST(&dev->child_bus);
>         qbus_free(bus); 
>     }
> would be enough, isn't it?

I had implicitly suggested after dev->realized and before
dev->parent_bus. The reason being that what is inside the if
(dev->realized) {} block actually still needs to be moved into an
unrealize function, and realized = false might still do device-specific
cleanups that could consume time. I'll try to cook something up tonight,
shouldn't collide with your change.

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

      parent reply	other threads:[~2013-03-06 17:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-06 16:49 [Qemu-devel] [PATCHv2] qdev: DEVICE_DELETED event Michael S. Tsirkin
2013-03-06 16:52 ` Paolo Bonzini
2013-03-06 16:55   ` Michael S. Tsirkin
2013-03-06 16:57     ` Paolo Bonzini
2013-03-06 17:03     ` Andreas Färber [this message]

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=513776E9.20901@suse.de \
    --to=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=mst@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).