From: Klaus Jensen <its@irrelevant.dk>
To: qemu-devel@nongnu.org
Cc: "Eduardo Habkost" <eduardo@habkost.net>,
qemu-block@nongnu.org, "Klaus Jensen" <k.jensen@samsung.com>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
"Yanan Wang" <wangyanan55@huawei.com>,
"Keith Busch" <kbusch@kernel.org>,
"Luis Chamberlain" <mcgrof@kernel.org>,
"Klaus Jensen" <its@irrelevant.dk>,
"Christoph Hellwig" <hch@lst.de>
Subject: [PATCH v2 1/5] hw/nvme: enforce common serial per subsystem
Date: Fri, 29 Apr 2022 10:33:32 +0200 [thread overview]
Message-ID: <20220429083336.2201286-2-its@irrelevant.dk> (raw)
In-Reply-To: <20220429083336.2201286-1-its@irrelevant.dk>
From: Klaus Jensen <k.jensen@samsung.com>
The Identify Controller Serial Number (SN) is the serial number for the
NVM subsystem and must be the same across all controller in the NVM
subsystem.
Enforce this.
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
---
hw/nvme/nvme.h | 1 +
hw/nvme/subsys.c | 7 +++++++
2 files changed, 8 insertions(+)
diff --git a/hw/nvme/nvme.h b/hw/nvme/nvme.h
index 739c8b8f7962..7f2e8f1b6491 100644
--- a/hw/nvme/nvme.h
+++ b/hw/nvme/nvme.h
@@ -48,6 +48,7 @@ typedef struct NvmeSubsystem {
DeviceState parent_obj;
NvmeBus bus;
uint8_t subnqn[256];
+ char *serial;
NvmeCtrl *ctrls[NVME_MAX_CONTROLLERS];
NvmeNamespace *namespaces[NVME_MAX_NAMESPACES + 1];
diff --git a/hw/nvme/subsys.c b/hw/nvme/subsys.c
index fb58d639504e..691a90d20947 100644
--- a/hw/nvme/subsys.c
+++ b/hw/nvme/subsys.c
@@ -27,6 +27,13 @@ int nvme_subsys_register_ctrl(NvmeCtrl *n, Error **errp)
return -1;
}
+ if (!subsys->serial) {
+ subsys->serial = g_strdup(n->params.serial);
+ } else if (strcmp(subsys->serial, n->params.serial)) {
+ error_setg(errp, "invalid controller serial");
+ return -1;
+ }
+
subsys->ctrls[cntlid] = n;
for (nsid = 1; nsid < ARRAY_SIZE(subsys->namespaces); nsid++) {
--
2.35.1
next prev parent reply other threads:[~2022-04-29 8:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-29 8:33 [PATCH v2 0/5] hw/nvme: fix namespace identifiers Klaus Jensen
2022-04-29 8:33 ` Klaus Jensen [this message]
2022-04-29 8:33 ` [PATCH v2 2/5] hw/nvme: do not auto-generate eui64 Klaus Jensen
2022-04-29 15:17 ` Christoph Hellwig
2022-04-29 8:33 ` [PATCH v2 3/5] hw/nvme: do not auto-generate uuid Klaus Jensen
2022-04-29 15:17 ` Christoph Hellwig
2022-04-29 8:33 ` [PATCH v2 4/5] hw/nvme: do not report null uuid Klaus Jensen
2022-04-29 8:33 ` [PATCH v2 5/5] hw/nvme: bump firmware revision Klaus Jensen
2022-05-12 9:27 ` [PATCH v2 0/5] hw/nvme: fix namespace identifiers Klaus Jensen
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=20220429083336.2201286-2-its@irrelevant.dk \
--to=its@irrelevant.dk \
--cc=eduardo@habkost.net \
--cc=f4bug@amsat.org \
--cc=hch@lst.de \
--cc=k.jensen@samsung.com \
--cc=kbusch@kernel.org \
--cc=mcgrof@kernel.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=wangyanan55@huawei.com \
/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).