@@ -315,6 +315,12 @@ BlockDriverState *bdrv_new(const char *device_name)
return bs;
}
+void bdrv_set_aio_context(BlockDriverState *bs, AioContext *ctx)
+{
+ assert(ctx);
+ bs->ctx = ctx;
+}
+
void bdrv_add_close_notifier(BlockDriverState *bs, Notifier *notify)
{
notifier_list_add(&bs->close_notifiers, notify);
@@ -378,6 +378,7 @@ void virtio_blk_data_plane_start(VirtIOBlockDataPlane *s)
}
s->ctx = aio_context_new();
+ bdrv_set_aio_context(s->bs, s->ctx);
/* Set up guest notifier (irq) */
if (k->set_guest_notifiers(qbus->parent, 1, true) != 0) {
@@ -128,6 +128,7 @@ int bdrv_create(BlockDriver *drv, const char* filename,
QEMUOptionParameter *options);
int bdrv_create_file(const char* filename, QEMUOptionParameter *options);
BlockDriverState *bdrv_new(const char *device_name);
+void bdrv_set_aio_context(BlockDriverState *bs, AioContext *ctx);
void bdrv_make_anon(BlockDriverState *bs);
void bdrv_swap(BlockDriverState *bs_new, BlockDriverState *bs_old);
void bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top);
@@ -299,6 +299,7 @@ struct BlockDriverState {
QLIST_HEAD(, BdrvTrackedRequest) tracked_requests;
+ AioContext *ctx;
/* long-running background operation */
BlockJob *job;
The default aio for BDS is qemu_aio_context, while for data plane, it will has its own ctx. Relating BDS with AioContext can help block layer to determine its running environment. Some stuff like timers need such info, so that they can run in the correct environment. Signed-off-by: Liu Ping Fan <pingfank@linux.vnet.ibm.com> --- block.c | 6 ++++++ hw/block/dataplane/virtio-blk.c | 1 + include/block/block.h | 1 + include/block/block_int.h | 1 + 4 files changed, 9 insertions(+)