From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:57509) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ttfuc-0003BN-Ea for qemu-devel@nongnu.org; Fri, 11 Jan 2013 09:48:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ttfua-0005Tt-MZ for qemu-devel@nongnu.org; Fri, 11 Jan 2013 09:48:50 -0500 Received: from cantor2.suse.de ([195.135.220.15]:36451 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ttfua-0005TS-DM for qemu-devel@nongnu.org; Fri, 11 Jan 2013 09:48:48 -0500 Message-ID: <50F0264C.4070902@suse.de> Date: Fri, 11 Jan 2013 15:48:44 +0100 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1357913836-4560-1-git-send-email-aliguori@us.ibm.com> <1357913836-4560-2-git-send-email-aliguori@us.ibm.com> In-Reply-To: <1357913836-4560-2-git-send-email-aliguori@us.ibm.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 1/2] qdev: make reset propagation overrideable by subclasses List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Peter Maydell , Michael Tsirkin , qemu-devel@nongnu.org, Eduardo Habkost , Paolo Bonzini Am 11.01.2013 15:17, schrieb Anthony Liguori: > Signed-off-by: Anthony Liguori > --- > hw/qdev-core.h | 16 +++++++++++++++- > hw/qdev.c | 11 ++++++++++- > 2 files changed, 25 insertions(+), 2 deletions(-) >=20 > diff --git a/hw/qdev-core.h b/hw/qdev-core.h > index 853bd08..f40fd15 100644 > --- a/hw/qdev-core.h > +++ b/hw/qdev-core.h > @@ -36,9 +36,23 @@ typedef struct DeviceClass { > Property *props; > int no_user; > =20 > - /* callbacks */ > + /** > + * reset: > + * > + * Cold reset of a device. This function must be implemented by a = device's > + * that never have children busses. > + */ > void (*reset)(DeviceState *dev); > =20 > + /** > + * reset_all: > + * > + * Cold reset of a device with children. The default implementati= on of this > + * method will invoke DeviceClass::reset and then recursively call > + * qbus_reset_all() on each child in an arbitrary order. > + */ > + void (*reset_all)(DeviceState *dev); This documentation is bogus, it should go into DeviceClass as @reset and @reset_all since these are struct fields, not standalone functions. This also happens to conflict with the realize/unrealize callbacks being added, v3 adding DeviceClass documentation on Eduardo's request. Can you please apply mine first? No objections to adding such a second reset callback. Maybe add a DeviceReset typedef to facilitate overriding these in subclasses? Regards, Andreas > + > /* device state */ > const struct VMStateDescription *vmsd; > =20 > diff --git a/hw/qdev.c b/hw/qdev.c > index 1b68d02..e02b5be 100644 > --- a/hw/qdev.c > +++ b/hw/qdev.c > @@ -223,11 +223,17 @@ static int qbus_reset_one(BusState *bus, void *op= aque) > return 0; > } > =20 > -void qdev_reset_all(DeviceState *dev) > +static void qdev_reset_children(DeviceState *dev) > { > qdev_walk_children(dev, qdev_reset_one, qbus_reset_one, NULL); > } > =20 > +void qdev_reset_all(DeviceState *dev) > +{ > + DeviceClass *dc =3D DEVICE_GET_CLASS(dev); > + dc->reset_all(dev); > +} > + > void qbus_reset_all(BusState *bus) > { > qbus_walk_children(bus, qdev_reset_one, qbus_reset_one, NULL); > @@ -714,7 +720,10 @@ static void device_unparent(Object *obj) > =20 > static void device_class_init(ObjectClass *class, void *data) > { > + DeviceClass *dc =3D DEVICE_CLASS(class); > + > class->unparent =3D device_unparent; > + dc->reset_all =3D qdev_reset_children; > } > =20 > void device_reset(DeviceState *dev) --=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