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: select first free NSID for legacy drive configuration
Date: Thu, 9 Sep 2021 11:51:59 +0200 [thread overview]
Message-ID: <20210909095159.122174-1-hare@suse.de> (raw)
If a legacy 'drive' argument is passed to the controller we cannot
assume that '1' will be a free NSID, as the subsys might already
have attached a namespace to this NSID. So select the first free
one.
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
hw/nvme/ctrl.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
index 757cdff038..2c69031ca9 100644
--- a/hw/nvme/ctrl.c
+++ b/hw/nvme/ctrl.c
@@ -6546,8 +6546,15 @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp)
/* setup a namespace if the controller drive property was given */
if (n->namespace.blkconf.blk) {
+ int i;
ns = &n->namespace;
- ns->params.nsid = 1;
+ for (i = 1; i <= NVME_MAX_NAMESPACES; i++) {
+ if (nvme_ns(n, i) || nvme_subsys_ns(n->subsys, i)) {
+ continue;
+ }
+ ns->params.nsid = i;
+ break;
+ }
if (nvme_ns_setup(ns, errp)) {
return;
--
2.26.2
next reply other threads:[~2021-09-09 9:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-09 9:51 Hannes Reinecke [this message]
2021-09-09 10:52 ` [PATCH] hw/nvme: select first free NSID for legacy drive configuration Klaus Jensen
2021-09-09 11:38 ` 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=20210909095159.122174-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).