From: Hannes Reinecke <hare@suse.de>
To: Klaus Jensen <k.jensen@samsung.com>
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org,
Hannes Reinecke <hare@suse.de>
Subject: [PATCH] hw/nvme: reattach subsystem namespaces on hotplug
Date: Thu, 9 Sep 2021 11:43:08 +0200 [thread overview]
Message-ID: <20210909094308.122038-1-hare@suse.de> (raw)
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>
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
hw/nvme/subsys.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/hw/nvme/subsys.c b/hw/nvme/subsys.c
index 93c35950d6..a9404f2b5e 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,18 @@ int nvme_subsys_register_ctrl(NvmeCtrl *n, Error **errp)
subsys->ctrls[cntlid] = n;
+ for (nsid = 0; nsid < ARRAY_SIZE(subsys->namespaces); nsid++) {
+ if (subsys->namespaces[nsid]) {
+ nvme_attach_ns(n, subsys->namespaces[nsid]);
+ }
+ }
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.26.2
next reply other threads:[~2021-09-09 9:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-09 9:43 Hannes Reinecke [this message]
2021-09-09 10:47 ` [PATCH] hw/nvme: reattach subsystem namespaces on hotplug Klaus Jensen
2021-09-09 11:37 ` Hannes Reinecke
2021-09-23 20:09 ` Klaus Jensen
2021-09-24 6:05 ` Hannes Reinecke
2021-09-24 7:29 ` Klaus Jensen
-- strict thread matches above, loose matches on Subject: below --
2021-09-09 9:39 Hannes Reinecke
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=20210909094308.122038-1-hare@suse.de \
--to=hare@suse.de \
--cc=k.jensen@samsung.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).