scsi: only access SCSIDevice->requests from one thread
commiteaad0fe26050c227dc5dad63205835bac4912a51
authorStefan Hajnoczi <stefanha@redhat.com>
Mon, 4 Dec 2023 16:42:56 +0000 (4 11:42 -0500)
committerKevin Wolf <kwolf@redhat.com>
Thu, 21 Dec 2023 21:49:27 +0000 (21 22:49 +0100)
tree6c954c0f7d9cebf9ee228a68b281483a9d4e9fe2
parentbb6e2511eb48539b7dcbcb5f47772e156b9c45d1
scsi: only access SCSIDevice->requests from one thread

Stop depending on the AioContext lock and instead access
SCSIDevice->requests from only one thread at a time:
- When the VM is running only the BlockBackend's AioContext may access
  the requests list.
- When the VM is stopped only the main loop may access the requests
  list.

These constraints protect the requests list without the need for locking
in the I/O code path.

Note that multiple IOThreads are not supported yet because the code
assumes all SCSIRequests are executed from a single AioContext. Leave
that as future work.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-ID: <20231204164259.1515217-2-stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
hw/scsi/scsi-bus.c
include/hw/scsi/scsi.h