diff options
author | Klaus Jensen <k.jensen@samsung.com> | 2021-07-06 10:51:36 +0200 |
---|---|---|
committer | Klaus Jensen <k.jensen@samsung.com> | 2021-07-26 21:09:38 +0200 |
commit | b0fde9e86133f66c054b31722fa29640f57e975c (patch) | |
tree | 98562c6b89b548167bf62b12d13a874a231bfaa4 | |
parent | cc6fb6bc506e6c47ed604fcb7b7413dff0b7d845 (diff) | |
download | qemu-b0fde9e86133f66c054b31722fa29640f57e975c.zip qemu-b0fde9e86133f66c054b31722fa29640f57e975c.tar.gz qemu-b0fde9e86133f66c054b31722fa29640f57e975c.tar.bz2 |
hw/nvme: unregister controller with subsystem at exit
Make sure the controller is unregistered from the subsystem when device
is removed.
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
-rw-r--r-- | hw/nvme/ctrl.c | 4 | ||||
-rw-r--r-- | hw/nvme/nvme.h | 1 | ||||
-rw-r--r-- | hw/nvme/subsys.c | 5 |
3 files changed, 10 insertions, 0 deletions
diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index dd18015..90e3ee2 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -6523,6 +6523,10 @@ static void nvme_exit(PCIDevice *pci_dev) nvme_ns_cleanup(ns); } + if (n->subsys) { + nvme_subsys_unregister_ctrl(n->subsys, n); + } + g_free(n->cq); g_free(n->sq); g_free(n->aer_reqs); diff --git a/hw/nvme/nvme.h b/hw/nvme/nvme.h index 0868359..c406546 100644 --- a/hw/nvme/nvme.h +++ b/hw/nvme/nvme.h @@ -50,6 +50,7 @@ typedef struct NvmeSubsystem { } NvmeSubsystem; int nvme_subsys_register_ctrl(NvmeCtrl *n, Error **errp); +void nvme_subsys_unregister_ctrl(NvmeSubsystem *subsys, NvmeCtrl *n); static inline NvmeCtrl *nvme_subsys_ctrl(NvmeSubsystem *subsys, uint32_t cntlid) diff --git a/hw/nvme/subsys.c b/hw/nvme/subsys.c index dc7a968..92caa60 100644 --- a/hw/nvme/subsys.c +++ b/hw/nvme/subsys.c @@ -32,6 +32,11 @@ int nvme_subsys_register_ctrl(NvmeCtrl *n, Error **errp) return cntlid; } +void nvme_subsys_unregister_ctrl(NvmeSubsystem *subsys, NvmeCtrl *n) +{ + subsys->ctrls[n->cntlid] = NULL; +} + static void nvme_subsys_setup(NvmeSubsystem *subsys) { const char *nqn = subsys->params.nqn ? |