]> git.proxmox.com Git - mirror_qemu.git/commitdiff
hw/nvme: enforce common serial per subsystem
authorKlaus Jensen <k.jensen@samsung.com>
Fri, 29 Apr 2022 08:33:32 +0000 (10:33 +0200)
committerKlaus Jensen <k.jensen@samsung.com>
Fri, 3 Jun 2022 19:48:24 +0000 (21:48 +0200)
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
hw/nvme/subsys.c

index 677381932569e919a08a21b1c4885348de14fa28..e41771604f598ed279016018d11f52e80e0b5278 100644 (file)
@@ -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];
index fb58d639504e9fc80f45e3e40b6c936585f24423..691a90d20947663b5db0815d6cded336302a079a 100644 (file)
@@ -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++) {