summary refs log tree commit diff stats
path: root/hw/nvme/subsys.c
diff options
context:
space:
mode:
authorKlaus Jensen <k.jensen@samsung.com>2022-04-29 10:33:32 +0200
committerKlaus Jensen <k.jensen@samsung.com>2022-06-03 21:48:24 +0200
commita859eb9f8f64e116671048a43a07d87bc6527a55 (patch)
treec9418bf0eb09c343f86b0bd8bc7c7c37fae77c1f /hw/nvme/subsys.c
parent9235a72a5df0fae1ede89f02717b597ef91cf6ad (diff)
downloadfocaccia-qemu-a859eb9f8f64e116671048a43a07d87bc6527a55.tar.gz
focaccia-qemu-a859eb9f8f64e116671048a43a07d87bc6527a55.zip
hw/nvme: enforce common serial per subsystem
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>
Diffstat (limited to 'hw/nvme/subsys.c')
-rw-r--r--hw/nvme/subsys.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/hw/nvme/subsys.c b/hw/nvme/subsys.c
index fb58d63950..691a90d209 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++) {