Received: from eggs.gnu.org ([2001:4830:134:3::10]:47775) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWLJl-0007WD-Uj for qemu-devel@nongnu.org; Thu, 18 Feb 2016 04:56:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aWLJi-0006xj-PE for qemu-devel@nongnu.org; Thu, 18 Feb 2016 04:56:13 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47901) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWLJi-0006xf-JZ for qemu-devel@nongnu.org; Thu, 18 Feb 2016 04:56:10 -0500 From: Markus Armbruster References: <4744c26fdfd911c44b58a9b6e1d0effc6cb39594.1455739133.git.alistair.francis@xilinx.com> Date: Thu, 18 Feb 2016 10:56:05 +0100 In-Reply-To: <4744c26fdfd911c44b58a9b6e1d0effc6cb39594.1455739133.git.alistair.francis@xilinx.com> (Alistair Francis's message of "Wed, 17 Feb 2016 13:04:09 -0800") Message-ID: <87lh6ijqa2.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v1 1/2] qdev-monitor.c: Register reset function if the device has one List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alistair Francis Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org, crosthwaitepeter@gmail.com, cov@codeaurora.org, pbonzini@redhat.com, =?utf-8?Q?Andreas_F=C3=A4rber?= , lig.fnst@cn.fujitsu.com Alistair Francis writes: > If the device being added when running qdev_device_add() has > a reset function, register it so that it can be called. > > Signed-off-by: Alistair Francis > --- > > qdev-monitor.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/qdev-monitor.c b/qdev-monitor.c > index 81e3ff3..0a99d01 100644 > --- a/qdev-monitor.c > +++ b/qdev-monitor.c > @@ -561,6 +561,8 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **errp) > > if (bus) { > qdev_set_parent_bus(dev, bus); > + } else if (dc->reset) { > + qemu_register_reset((void (*)(void *))dc->reset, dev); > } > > id = qemu_opts_id(opts); This looks wrong to me. You stuff all the device reset methods into the global reset_handlers list, where they get called in some semi-random order. This breaks when there are reset order dependencies between devices, e.g. between a device and the bus it plugs into. Propagating the reset signal to all the devices is a qdev problem. Copying Andreas for further insight.