From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:50365) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TtfU5-0001Oh-8R for qemu-devel@nongnu.org; Fri, 11 Jan 2013 09:21:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TtfTw-0006Br-AX for qemu-devel@nongnu.org; Fri, 11 Jan 2013 09:21:25 -0500 Received: from mx1.redhat.com ([209.132.183.28]:16364) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TtfTw-0006Bj-39 for qemu-devel@nongnu.org; Fri, 11 Jan 2013 09:21:16 -0500 Message-ID: <50F01FD6.6030408@redhat.com> Date: Fri, 11 Jan 2013 15:21:10 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1357913836-4560-1-git-send-email-aliguori@us.ibm.com> <1357913836-4560-3-git-send-email-aliguori@us.ibm.com> In-Reply-To: <1357913836-4560-3-git-send-email-aliguori@us.ibm.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 2/2] qbus: make bus reset overrideable by subclasses List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Peter Maydell , qemu-devel@nongnu.org, Michael Tsirkin Il 11/01/2013 15:17, Anthony Liguori ha scritto: > Signed-off-by: Anthony Liguori > --- > hw/qdev-core.h | 15 +++++++++++++++ > hw/qdev.c | 16 +++++++++++++++- > 2 files changed, 30 insertions(+), 1 deletion(-) > > diff --git a/hw/qdev-core.h b/hw/qdev-core.h > index f40fd15..453a061 100644 > --- a/hw/qdev-core.h > +++ b/hw/qdev-core.h > @@ -100,7 +100,22 @@ struct BusClass { > * bindings can be found at http://playground.sun.com/1275/bindings/. > */ > char *(*get_fw_dev_path)(DeviceState *dev); > + > + /** > + * reset: > + * > + * Cold reset of a bus. This only resets the controller state of the bus. > + */ > int (*reset)(BusState *bus); > + > + /** > + * reset_all: > + * > + * Cold reset of a bus with children. The default implementation of this > + * method will invoke BusState::reset and then recursively call > + * qdev_reset_all() on each child in an arbitrary order. > + */ > + void (*reset_all)(BusState *bus); > }; > > typedef struct BusChild { > diff --git a/hw/qdev.c b/hw/qdev.c > index e02b5be..db19b14 100644 > --- a/hw/qdev.c > +++ b/hw/qdev.c > @@ -234,11 +234,17 @@ void qdev_reset_all(DeviceState *dev) > dc->reset_all(dev); > } > > -void qbus_reset_all(BusState *bus) > +static void qbus_reset_children(BusState *bus) > { > qbus_walk_children(bus, qdev_reset_one, qbus_reset_one, NULL); > } > > +void qbus_reset_all(BusState *bus) > +{ > + BusClass *bc = BUS_GET_CLASS(bus); > + bc->reset_all(bus); > +} > + > void qbus_reset_all_fn(void *opaque) > { > BusState *bus = opaque; > @@ -758,6 +764,13 @@ static const TypeInfo device_type_info = { > .class_size = sizeof(DeviceClass), > }; > > +static void qbus_class_initfn(ObjectClass *klass, void *data) > +{ > + BusClass *bc = BUS_CLASS(klass); > + > + bc->reset_all = qbus_reset_children; > +} > + > static void qbus_initfn(Object *obj) > { > BusState *bus = BUS(obj); > @@ -789,6 +802,7 @@ static const TypeInfo bus_info = { > .parent = TYPE_OBJECT, > .instance_size = sizeof(BusState), > .abstract = true, > + .class_init = qbus_class_initfn, > .class_size = sizeof(BusClass), > .instance_init = qbus_initfn, > .instance_finalize = qbus_finalize, > Once you do this, the return value of bus->reset should become void, and classes that used to return 1 should instead override reset_all. Can you do that too? Paolo