From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mqtap-00072T-Cj for qemu-devel@nongnu.org; Thu, 24 Sep 2009 15:03:03 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mqtak-0006w9-4U for qemu-devel@nongnu.org; Thu, 24 Sep 2009 15:03:02 -0400 Received: from [199.232.76.173] (port=54094 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mqtaj-0006vt-UR for qemu-devel@nongnu.org; Thu, 24 Sep 2009 15:02:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32293) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Mqtaj-0000N6-2S for qemu-devel@nongnu.org; Thu, 24 Sep 2009 15:02:57 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n8OJ2uEM023546 for ; Thu, 24 Sep 2009 15:02:56 -0400 Subject: Re: [Qemu-devel] [PATCH 09/13] Add exit callback to DeviceInfo. References: <1253611767-6483-1-git-send-email-kraxel@redhat.com> <1253611767-6483-10-git-send-email-kraxel@redhat.com> From: Markus Armbruster Date: Thu, 24 Sep 2009 21:02:53 +0200 In-Reply-To: <1253611767-6483-10-git-send-email-kraxel@redhat.com> (Gerd Hoffmann's message of "Tue\, 22 Sep 2009 11\:29\:23 +0200") Message-ID: <87d45gb1ya.fsf@pike.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: qemu-devel@nongnu.org Gerd Hoffmann writes: > This adds a exit callback for device destruction to DeviceInfo, so > we can hook cleanups into qdev device destruction. > > 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; > }; I don't like the name "exit". The buddy of init() is often called fini().