Skip to content

Commit

Permalink
hw/nvme: enforce common serial per subsystem
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
birkelund authored and taylorsimpson committed Jun 6, 2022
1 parent d772a01 commit add0903
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions hw/nvme/nvme.h
Expand Up @@ -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];
Expand Down
7 changes: 7 additions & 0 deletions hw/nvme/subsys.c
Expand Up @@ -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++) {
Expand Down

0 comments on commit add0903

Please sign in to comment.