From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mq2Hc-0004ET-Ad for qemu-devel@nongnu.org; Tue, 22 Sep 2009 06:07:40 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mq2HX-0004Cq-1E for qemu-devel@nongnu.org; Tue, 22 Sep 2009 06:07:39 -0400 Received: from [199.232.76.173] (port=42322 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mq2HW-0004Cn-RY for qemu-devel@nongnu.org; Tue, 22 Sep 2009 06:07:34 -0400 Received: from tx2ehsobe005.messaging.microsoft.com ([65.55.88.15]:19895 helo=TX2EHSOBE010.bigfish.com) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_ARCFOUR_MD5:16) (Exim 4.60) (envelope-from ) id 1Mq2HW-00018d-E6 for qemu-devel@nongnu.org; Tue, 22 Sep 2009 06:07:34 -0400 From: Christoph Egger Subject: Re: [Qemu-devel] [PATCH 09/13] Add exit callback to DeviceInfo. Date: Tue, 22 Sep 2009 12:06:22 +0200 References: <1253611767-6483-1-git-send-email-kraxel@redhat.com> <1253611767-6483-10-git-send-email-kraxel@redhat.com> In-Reply-To: <1253611767-6483-10-git-send-email-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-ID: <200909221206.22716.Christoph.Egger@amd.com> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann On Tuesday 22 September 2009 11:29:23 Gerd Hoffmann wrote: > This adds a exit callback for device destruction to DeviceInfo, so > we can hook cleanups into qdev device destruction. This is not enough. You need a childexit to allow devices to cleanup their children in the device tree first. Christoph > > Followup patches will put that into use. > > Signed-off-by: Gerd Hoffmann > --- > hw/qdev.c | 2 ++ > hw/qdev.h | 2 ++ > 2 files changed, 4 insertions(+), 0 deletions(-) > > diff --git a/hw/qdev.c b/hw/qdev.c > index 4931da1..a25245a 100644 > --- a/hw/qdev.c > +++ b/hw/qdev.c > @@ -245,6 +245,8 @@ void qdev_free(DeviceState *dev) > #endif > if (dev->info->reset) > qemu_unregister_reset(dev->info->reset, dev); > + if (dev->info->exit) > + dev->info->exit(dev); > } > QLIST_REMOVE(dev, sibling); > qemu_free(dev); > diff --git a/hw/qdev.h b/hw/qdev.h > index c036aff..0db2d32 100644 > --- a/hw/qdev.h > +++ b/hw/qdev.h > @@ -107,6 +107,7 @@ BusState *qdev_get_child_bus(DeviceState *dev, const > char *name); /*** Device API. ***/ > > typedef int (*qdev_initfn)(DeviceState *dev, DeviceInfo *info); > +typedef int (*qdev_exitfn)(DeviceState *dev); > > struct DeviceInfo { > const char *name; > @@ -124,6 +125,7 @@ struct DeviceInfo { > > /* Private to qdev / bus. */ > qdev_initfn init; > + qdev_exitfn exit; > BusInfo *bus_info; > struct DeviceInfo *next; > }; -- ---to satisfy European Law for business letters: Advanced Micro Devices GmbH Karl-Hammerschmidt-Str. 34, 85609 Dornach b. Muenchen Geschaeftsfuehrer: Andrew Bowd, Thomas M. McCoy, Giuliano Meroni Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632