mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
hw/nvme: fix namespace attachment
Commit6ccca4b6bb("hw/nvme: rework csi handling") introduced a bug in Namespace Attachment, causing it to a) not allow a controller to attach namespaces to other controllers b) assert if a valid non-attached namespace is detached This fixes both issues. Fixes:6ccca4b6bb("hw/nvme: rework csi handling") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2976 Reviewed-by: Jesper Wendel Devantier <foss@defmacro.it> Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
This commit is contained in:
+6
-2
@@ -6816,7 +6816,7 @@ static uint16_t nvme_ns_attachment(NvmeCtrl *n, NvmeRequest *req)
|
||||
|
||||
switch (sel) {
|
||||
case NVME_NS_ATTACHMENT_ATTACH:
|
||||
if (nvme_ns(n, nsid)) {
|
||||
if (nvme_ns(ctrl, nsid)) {
|
||||
return NVME_NS_ALREADY_ATTACHED | NVME_DNR;
|
||||
}
|
||||
|
||||
@@ -6824,7 +6824,7 @@ static uint16_t nvme_ns_attachment(NvmeCtrl *n, NvmeRequest *req)
|
||||
return NVME_NS_PRIVATE | NVME_DNR;
|
||||
}
|
||||
|
||||
if (!nvme_csi_supported(n, ns->csi)) {
|
||||
if (!nvme_csi_supported(ctrl, ns->csi)) {
|
||||
return NVME_IOCS_NOT_SUPPORTED | NVME_DNR;
|
||||
}
|
||||
|
||||
@@ -6834,6 +6834,10 @@ static uint16_t nvme_ns_attachment(NvmeCtrl *n, NvmeRequest *req)
|
||||
break;
|
||||
|
||||
case NVME_NS_ATTACHMENT_DETACH:
|
||||
if (!nvme_ns(ctrl, nsid)) {
|
||||
return NVME_NS_NOT_ATTACHED | NVME_DNR;
|
||||
}
|
||||
|
||||
nvme_detach_ns(ctrl, ns);
|
||||
nvme_update_dsm_limits(ctrl, NULL);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user