Expand allocated namespace list (subsys->namespaces) to have 256 entries which is a value lager than at least NVME_MAX_NAMESPACES which is for attached namespace list in a controller. Allocated namespace list should at least larger than attached namespace list. n->num_namespaces = NVME_MAX_NAMESPACES; The above line will set the NN field by id->nn so that the subsystem should also prepare at least this number of namespace list entries. Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com> Reviewed-by: Keith Busch <kbusch@kernel.org> Reviewed-by: Klaus Jensen <k.jensen@samsung.com> Tested-by: Klaus Jensen <k.jensen@samsung.com> Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
38 lines
963 B
C
38 lines
963 B
C
/*
|
|
* QEMU NVM Express Subsystem: nvme-subsys
|
|
*
|
|
* Copyright (c) 2021 Minwoo Im <minwoo.im.dev@gmail.com>
|
|
*
|
|
* This code is licensed under the GNU GPL v2. Refer COPYING.
|
|
*/
|
|
|
|
#ifndef NVME_SUBSYS_H
|
|
#define NVME_SUBSYS_H
|
|
|
|
#define TYPE_NVME_SUBSYS "nvme-subsys"
|
|
#define NVME_SUBSYS(obj) \
|
|
OBJECT_CHECK(NvmeSubsystem, (obj), TYPE_NVME_SUBSYS)
|
|
|
|
#define NVME_SUBSYS_MAX_CTRLS 32
|
|
#define NVME_SUBSYS_MAX_NAMESPACES 256
|
|
|
|
typedef struct NvmeCtrl NvmeCtrl;
|
|
typedef struct NvmeNamespace NvmeNamespace;
|
|
typedef struct NvmeSubsystem {
|
|
DeviceState parent_obj;
|
|
uint8_t subnqn[256];
|
|
|
|
NvmeCtrl *ctrls[NVME_SUBSYS_MAX_CTRLS];
|
|
/* Allocated namespaces for this subsystem */
|
|
NvmeNamespace *namespaces[NVME_SUBSYS_MAX_NAMESPACES + 1];
|
|
|
|
struct {
|
|
char *nqn;
|
|
} params;
|
|
} NvmeSubsystem;
|
|
|
|
int nvme_subsys_register_ctrl(NvmeCtrl *n, Error **errp);
|
|
int nvme_subsys_register_ns(NvmeNamespace *ns, Error **errp);
|
|
|
|
#endif /* NVME_SUBSYS_H */
|