From: Paolo Bonzini <pbonzini@redhat.com>
To: Markus Armbruster <armbru@redhat.com>,
Alistair Francis <alistair.francis@xilinx.com>
Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org,
crosthwaitepeter@gmail.com, cov@codeaurora.org,
"Andreas Färber" <afaerber@suse.de>,
lig.fnst@cn.fujitsu.com
Subject: Re: [Qemu-devel] [PATCH v1 1/2] qdev-monitor.c: Register reset function if the device has one
Date: Thu, 18 Feb 2016 22:47:57 +0100 [thread overview]
Message-ID: <56C63C0D.8030501@redhat.com> (raw)
In-Reply-To: <87lh6ijqa2.fsf@blackfin.pond.sub.org>
On 18/02/2016 10:56, Markus Armbruster wrote:
> Alistair Francis <alistair.francis@xilinx.com> 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 <alistair.francis@xilinx.com>
>> ---
>>
>> 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.
There is no bus here, see the "if" above the one that's being added.
However, what devices have done so far is to register/unregister the
reset in the realize/unrealize methods, and I suggest doing the same.
If you really want to add the magic qemu_register_reset, you should at
least do one of the following:
* add a matching unregister (no idea where)
* assert that the device is not hot-unpluggable, otherwise hot-unplug
would leave a dangling pointer.
Paolo
> Propagating the reset signal to all the devices is a qdev problem.
> Copying Andreas for further insight.
next prev parent reply other threads:[~2016-02-18 21:48 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-17 21:04 [Qemu-devel] [PATCH v1 0/2] Add a generic loader Alistair Francis
2016-02-17 21:04 ` [Qemu-devel] [PATCH v1 1/2] qdev-monitor.c: Register reset function if the device has one Alistair Francis
2016-02-18 9:56 ` Markus Armbruster
2016-02-18 18:47 ` Alistair Francis
2016-02-18 21:47 ` Paolo Bonzini [this message]
2016-02-18 23:07 ` Peter Crosthwaite
2016-02-19 0:02 ` Alistair Francis
2016-02-19 9:33 ` Paolo Bonzini
2016-02-19 10:55 ` Peter Maydell
2016-02-19 17:17 ` Paolo Bonzini
2016-02-19 9:58 ` Markus Armbruster
2016-02-19 17:15 ` Andreas Färber
2016-02-19 18:53 ` Alistair Francis
2016-02-17 21:04 ` [Qemu-devel] [PATCH v1 2/2] generic-loader: Add a generic loader Alistair Francis
2016-02-17 21:41 ` Eric Blake
2016-02-18 0:03 ` Alistair Francis
2016-02-18 0:11 ` Eric Blake
2016-02-18 0:17 ` Alistair Francis
2016-02-18 18:23 ` Hollis Blanchard
2016-02-18 18:49 ` Alistair Francis
2016-02-18 18:58 ` Hollis Blanchard
2016-02-18 19:34 ` Alistair Francis
2016-02-18 18:27 ` [Qemu-devel] [PATCH v1 0/2] " Hollis Blanchard
2016-02-18 19:02 ` Alistair Francis
2016-02-18 20:01 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56C63C0D.8030501@redhat.com \
--to=pbonzini@redhat.com \
--cc=afaerber@suse.de \
--cc=alistair.francis@xilinx.com \
--cc=armbru@redhat.com \
--cc=cov@codeaurora.org \
--cc=crosthwaitepeter@gmail.com \
--cc=lig.fnst@cn.fujitsu.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.