From: Klaus Jensen <its@irrelevant.dk>
To: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Cc: "Eduardo Habkost" <ehabkost@redhat.com>,
qemu-block@nongnu.org, "Klaus Jensen" <k.jensen@samsung.com>,
"Klaus Jensen" <its@irrelevant.dk>,
"Hannes Reinecke" <hare@suse.de>,
"Keith Busch" <kbusch@kernel.org>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: [PULL for-6.2 1/3] hw/nvme: reattach subsystem namespaces on hotplug
Date: Fri, 19 Nov 2021 09:09:52 +0100 [thread overview]
Message-ID: <20211119080954.211927-2-its@irrelevant.dk> (raw)
In-Reply-To: <20211119080954.211927-1-its@irrelevant.dk>
From: Hannes Reinecke <hare@suse.de>
With commit 5ffbaeed16 ("hw/nvme: fix controller hot unplugging")
namespaces get moved from the controller to the subsystem if one
is specified.
That keeps the namespaces alive after a controller hot-unplug, but
after a controller hotplug we have to reconnect the namespaces
from the subsystem to the controller.
Fixes: 5ffbaeed16 ("hw/nvme: fix controller hot unplugging")
Cc: Klaus Jensen <k.jensen@samsung.com>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Hannes Reinecke <hare@suse.de>
[k.jensen: only attach to shared and non-detached namespaces]
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
---
hw/nvme/subsys.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/hw/nvme/subsys.c b/hw/nvme/subsys.c
index 495dcff5ebb8..fb58d639504e 100644
--- a/hw/nvme/subsys.c
+++ b/hw/nvme/subsys.c
@@ -14,7 +14,7 @@
int nvme_subsys_register_ctrl(NvmeCtrl *n, Error **errp)
{
NvmeSubsystem *subsys = n->subsys;
- int cntlid;
+ int cntlid, nsid;
for (cntlid = 0; cntlid < ARRAY_SIZE(subsys->ctrls); cntlid++) {
if (!subsys->ctrls[cntlid]) {
@@ -29,12 +29,20 @@ int nvme_subsys_register_ctrl(NvmeCtrl *n, Error **errp)
subsys->ctrls[cntlid] = n;
+ for (nsid = 1; nsid < ARRAY_SIZE(subsys->namespaces); nsid++) {
+ NvmeNamespace *ns = subsys->namespaces[nsid];
+ if (ns && ns->params.shared && !ns->params.detached) {
+ nvme_attach_ns(n, ns);
+ }
+ }
+
return cntlid;
}
void nvme_subsys_unregister_ctrl(NvmeSubsystem *subsys, NvmeCtrl *n)
{
subsys->ctrls[n->cntlid] = NULL;
+ n->cntlid = -1;
}
static void nvme_subsys_setup(NvmeSubsystem *subsys)
--
2.34.0
next prev parent reply other threads:[~2021-11-19 8:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-19 8:09 [PULL for-6.2 0/3] hw/nvme fixes Klaus Jensen
2021-11-19 8:09 ` Klaus Jensen [this message]
2021-11-19 8:09 ` [PULL for-6.2 2/3] hw/nvme: change nvme-ns 'shared' default Klaus Jensen
2021-11-19 8:09 ` [PULL for-6.2 3/3] hw/nvme: fix buffer overrun in nvme_changed_nslist (CVE-2021-3947) Klaus Jensen
2021-11-19 11:19 ` [PULL for-6.2 0/3] hw/nvme fixes Richard Henderson
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=20211119080954.211927-2-its@irrelevant.dk \
--to=its@irrelevant.dk \
--cc=ehabkost@redhat.com \
--cc=hare@suse.de \
--cc=k.jensen@samsung.com \
--cc=kbusch@kernel.org \
--cc=peter.maydell@linaro.org \
--cc=philmd@redhat.com \
--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).