From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:45910) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UDHlN-0003f9-1h for qemu-devel@nongnu.org; Wed, 06 Mar 2013 12:04:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UDHlL-0002hH-IX for qemu-devel@nongnu.org; Wed, 06 Mar 2013 12:04:20 -0500 Received: from cantor2.suse.de ([195.135.220.15]:50929 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UDHlL-0002W5-AQ for qemu-devel@nongnu.org; Wed, 06 Mar 2013 12:04:19 -0500 Message-ID: <513776E9.20901@suse.de> Date: Wed, 06 Mar 2013 18:03:37 +0100 From: =?ISO-8859-1?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <20130306164954.GA331@redhat.com> <51377435.3080100@redhat.com> <20130306165521.GA429@redhat.com> In-Reply-To: <20130306165521.GA429@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCHv2] qdev: DEVICE_DELETED event List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: Kevin Wolf , Anthony Liguori , Eduardo Habkost , Stefan Hajnoczi , qemu-devel@nongnu.org, Markus Armbruster , Gerd Hoffmann , laine@redhat.com, Paolo Bonzini , Luiz Capitulino 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 >>> --- >>> >>> 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, fo= r >>> 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" >>> =20 >>> int qdev_hotplug =3D 0; >>> static bool qdev_hot_added =3D false; >>> @@ -761,6 +762,12 @@ static void device_unparent(Object *obj) >>> DeviceClass *dc =3D DEVICE_GET_CLASS(dev); >>> BusState *bus; >>> =20 >>> + if (dev->id) { >>> + QObject *data =3D 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 >=20 > Hmm yes it seems cleaner, though we'd need to copy the > id as the device can go away. >=20 > Doing this after > while (dev->num_child_bus) { > bus =3D QLIST_FIRST(&dev->child_bus); > qbus_free(bus);=20 > } > 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 =3D 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 --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg