]> xenbits.xensource.com Git - qemu-xen.git/commit
xen-bus/block: explicitly assign event channels to an AioContext
authorPaul Durrant <pdurrant@amazon.com>
Mon, 16 Dec 2019 14:34:51 +0000 (14:34 +0000)
committerAnthony PERARD <anthony.perard@citrix.com>
Tue, 14 Apr 2020 17:38:05 +0000 (18:38 +0100)
commit2c38e9982f671e367e139a723b4bd9f3993fc61f
treec745d9746e3fe002d3b18fc3e98d7ddddf5033cf
parent2865b67da41570c5acbb0e0761535b0401a8a54a
xen-bus/block: explicitly assign event channels to an AioContext

It is not safe to close an event channel from the QEMU main thread when
that channel's poller is running in IOThread context.

This patch adds a new xen_device_set_event_channel_context() function
to explicitly assign the channel AioContext, and modifies
xen_device_bind_event_channel() to initially assign the channel's poller
to the QEMU main thread context. The code in xen-block's dataplane is
then modified to assign the channel to IOThread context during
xen_block_dataplane_start() and de-assign it during in
xen_block_dataplane_stop(), such that the channel is always assigned
back to main thread context before it is closed. aio_set_fd_handler()
already deals with all the necessary synchronization when moving an fd
between AioContext-s so no extra code is needed to manage this.

Reported-by: Julien Grall <jgrall@amazon.com>
Signed-off-by: Paul Durrant <pdurrant@amazon.com>
Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
Message-Id: <20191216143451.19024-1-pdurrant@amazon.com>
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
(cherry picked from commit 32d0b7be68216f130dc962533c6fc2f9ad848a8b)
hw/block/dataplane/xen-block.c
hw/xen/xen-bus.c
include/hw/xen/xen-bus.h