From: Klaus Jensen <its@irrelevant.dk>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Kevin Wolf <kwolf@redhat.com>, Qemu-block <qemu-block@nongnu.org>,
Klaus Jensen <k.jensen@samsung.com>,
QEMU Developers <qemu-devel@nongnu.org>,
Max Reitz <mreitz@redhat.com>, Keith Busch <kbusch@kernel.org>
Subject: Re: [PATCH for-6.0 v2 2/2] hw/block/nvme: disable hotplugging for subsystem-linked controllers
Date: Fri, 23 Apr 2021 15:25:06 +0200 [thread overview]
Message-ID: <YILKsjz+WoXFiKUh@apples.localdomain> (raw)
In-Reply-To: <CAFEAcA8xS6Hoqd+Y96FxhrDabsotYURsHHvEeN9yDLDHzzVf+g@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2084 bytes --]
On Apr 23 14:21, Peter Maydell wrote:
>On Fri, 23 Apr 2021 at 06:21, Klaus Jensen <its@irrelevant.dk> wrote:
>>
>> From: Klaus Jensen <k.jensen@samsung.com>
>>
>> If a controller is linked to a subsystem, do not allow it to be
>> hotplugged since this will mess up the (possibly shared) namespaces.
>>
>> Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
>> ---
>> hw/block/nvme.c | 4 ++++
>> 1 file changed, 4 insertions(+)
>>
>> diff --git a/hw/block/nvme.c b/hw/block/nvme.c
>> index 5fe082ec34c5..7606b58a39b9 100644
>> --- a/hw/block/nvme.c
>> +++ b/hw/block/nvme.c
>> @@ -6140,12 +6140,16 @@ static void nvme_init_ctrl(NvmeCtrl *n, PCIDevice *pci_dev)
>>
>> static int nvme_init_subsys(NvmeCtrl *n, Error **errp)
>> {
>> + DeviceClass *dc;
>> int cntlid;
>>
>> if (!n->subsys) {
>> return 0;
>> }
>>
>> + dc = DEVICE_GET_CLASS(n);
>> + dc->hotpluggable = false;
>> +
>> cntlid = nvme_subsys_register_ctrl(n, errp);
>> if (cntlid < 0) {
>> return -1;
>
>I'm not sure this is right -- the DeviceClass is the
>class struct, which there's only one of for every instance
>of the device in the system. So this is saying "if this instance
>is linked to a subsystem, don't let any *future* instances ever
>be hotpluggable". I'm not even sure if it will do the right
>thing for the current device, because this function is called
>from the device's realize method, and the device_set_realized()
>function does the "forbid if dc->hotpluggable is false" check
>before calling the realize method.
>
>Possibly what you want to do here is to call the
>device_get_hotplugged() function and just make the realize
>method fail with a suitable error if the device is both (a) being
>hotplugged and (b) has a subsystem link; but I'm not an expert on
>hotplug, so I might be wrong.
>
Thanks Peter, this sounds exactly like what I want. I'll respin!
I have a "full" fix that actually makes the device hotpluggable in the
context of subsystems, but it is definitely not an -rc thing.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2021-04-23 13:28 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-23 5:21 [PATCH for-6.0 v2 0/2] hw/block/nvme: fix msix uninit Klaus Jensen
2021-04-23 5:21 ` [PATCH for-6.0 v2 1/2] hw/block/nvme: fix invalid msix exclusive uninit Klaus Jensen
2021-04-23 15:46 ` Peter Maydell
2021-04-26 4:40 ` Klaus Jensen
2021-04-26 9:27 ` Philippe Mathieu-Daudé
2021-04-26 9:39 ` Klaus Jensen
2021-04-26 13:08 ` Michael S. Tsirkin
2021-04-26 15:23 ` Peter Maydell
2021-04-23 5:21 ` [PATCH for-6.0 v2 2/2] hw/block/nvme: disable hotplugging for subsystem-linked controllers Klaus Jensen
2021-04-23 13:21 ` Peter Maydell
2021-04-23 13:25 ` Klaus Jensen [this message]
2021-04-23 13:25 ` Peter Maydell
2021-04-23 13:33 ` Klaus Jensen
2021-04-23 10:38 ` [PATCH for-6.0 v2 0/2] hw/block/nvme: fix msix uninit Klaus Jensen
2021-04-23 10:50 ` 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=YILKsjz+WoXFiKUh@apples.localdomain \
--to=its@irrelevant.dk \
--cc=k.jensen@samsung.com \
--cc=kbusch@kernel.org \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-block@nongnu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).