qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC 7/8] block: associate BlockDriverState with AioContext


From: Liu Ping Fan
Subject: [Qemu-devel] [RFC 7/8] block: associate BlockDriverState with AioContext
Date: Sun, 21 Jul 2013 16:43:04 +0800

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 <address@hidden>
---
 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(+)

diff --git a/block.c b/block.c
index daf5717..c6b7b6c 100644
--- a/block.c
+++ b/block.c
@@ -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);
diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c
index 5fde06f..ec477b0 100644
--- a/hw/block/dataplane/virtio-blk.c
+++ b/hw/block/dataplane/virtio-blk.c
@@ -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) {
diff --git a/include/block/block.h b/include/block/block.h
index cb44f27..23e743d 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -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);
diff --git a/include/block/block_int.h b/include/block/block_int.h
index cd0e0a8..801d1c1 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -299,6 +299,7 @@ struct BlockDriverState {
 
     QLIST_HEAD(, BdrvTrackedRequest) tracked_requests;
 
+    AioContext *ctx;
     /* long-running background operation */
     BlockJob *job;
 
-- 
1.8.1.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]