@samitouri / QOSamiQemu / commits / 5a1f41c66a

hw/nvme: set CQE.sq_id earlier in nvme_process_sq

Instead of filling req->cqe.sq_id in nvme_post_cqes, let's set it earlier in nvme_process_sq. This shouldn't cause any issues, because req->cqe.sq_id never changes during lifetime of req. This will help us for migration support. Reviewed-by: Klaus Jensen <k.jensen@samsung.com> Acked-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@futurfusion.io> Signed-off-by: Klaus Jensen <k.jensen@samsung.com>

Alexander Mikhalitsyn committed Jun 11, 2026 at 20:08 UTC 5a1f41c66ad713b5abe5a8ebb2d32d8b2e0a3ec6
1 file changed +1 -1
hw/nvme/ctrl.c
+1 -1
@@ -1535,7 +1535,6 @@ static void nvme_post_cqes(void *opaque)
1535
1536 sq = req->sq;
1537 req->cqe.status = cpu_to_le16((req->status << 1) | cq->phase);
1538 - req->cqe.sq_id = cpu_to_le16(sq->sqid);
1538 req->cqe.sq_head = cpu_to_le16(sq->head);
1539 addr = cq->dma_addr + (cq->tail << NVME_CQES);
1540 ret = pci_dma_write(PCI_DEVICE(n), addr, (void *)&req->cqe,
@@ -7875,6 +7874,7 @@ static void nvme_process_sq(void *opaque)
7874 QTAILQ_REMOVE(&sq->req_list, req, entry);
7875 QTAILQ_INSERT_TAIL(&sq->out_req_list, req, entry);
7876 nvme_req_clear(req);
7877 + req->cqe.sq_id = cpu_to_le16(sq->sqid);
7878 req->cqe.cid = cmd.cid;
7879 memcpy(&req->cmd, &cmd, sizeof(NvmeCmd));
7880