From 10bcb0d996634aec642b000f05a72c93b652b2e6 Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Tue, 5 Dec 2023 13:19:59 -0500 Subject: scsi: assert that callbacks run in the correct AioContext Since the removal of AioContext locking, the correctness of the code relies on running requests from a single AioContext at any given time. Add assertions that verify that callbacks are invoked in the correct AioContext. Signed-off-by: Stefan Hajnoczi Message-ID: <20231205182011.1976568-3-stefanha@redhat.com> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- system/dma-helpers.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'system') diff --git a/system/dma-helpers.c b/system/dma-helpers.c index 528117f..9b221cf 100644 --- a/system/dma-helpers.c +++ b/system/dma-helpers.c @@ -119,6 +119,9 @@ static void dma_blk_cb(void *opaque, int ret) trace_dma_blk_cb(dbs, ret); + /* DMAAIOCB is not thread-safe and must be accessed only from dbs->ctx */ + assert(ctx == qemu_get_current_aio_context()); + dbs->acb = NULL; dbs->offset += dbs->iov.size; -- cgit v1.1