block: Add blk_set_allow_aio_context_change()
authorKevin Wolf <kwolf@redhat.com>
Mon, 6 May 2019 17:18:02 +0000 (19:18 +0200)
committerKevin Wolf <kwolf@redhat.com>
Mon, 20 May 2019 15:08:56 +0000 (17:08 +0200)
Some users (like block jobs) can tolerate an AioContext change for their
BlockBackend. Add a function that tells the BlockBackend that it can
allow changes.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/block-backend.c
include/sysemu/block-backend.h

index 0e75fc88496a54be5ff0c8259eca3f41576bd698..4c0a8ef88d4757cf4c68c5872a487985a60366c5 100644 (file)
@@ -71,6 +71,7 @@ struct BlockBackend {
     uint64_t shared_perm;
     bool disable_perm;
 
+    bool allow_aio_context_change;
     bool allow_write_beyond_eof;
 
     NotifierList remove_bs_notifiers, insert_bs_notifiers;
@@ -1092,6 +1093,11 @@ void blk_set_allow_write_beyond_eof(BlockBackend *blk, bool allow)
     blk->allow_write_beyond_eof = allow;
 }
 
+void blk_set_allow_aio_context_change(BlockBackend *blk, bool allow)
+{
+    blk->allow_aio_context_change = allow;
+}
+
 static int blk_check_byte_request(BlockBackend *blk, int64_t offset,
                                   size_t size)
 {
@@ -1891,6 +1897,10 @@ static bool blk_root_can_set_aio_ctx(BdrvChild *child, AioContext *ctx,
 {
     BlockBackend *blk = child->opaque;
 
+    if (blk->allow_aio_context_change) {
+        return true;
+    }
+
     /* Only manually created BlockBackends that are not attached to anything
      * can change their AioContext without updating their user. */
     if (!blk->name || blk->dev) {
index 5be622422622e5c26d9cb6201c9f8d5b775fdea3..938de34fe9ed924137a52ba4a30a0822b87c2cc8 100644 (file)
@@ -103,6 +103,7 @@ int blk_set_perm(BlockBackend *blk, uint64_t perm, uint64_t shared_perm,
 void blk_get_perm(BlockBackend *blk, uint64_t *perm, uint64_t *shared_perm);
 
 void blk_set_allow_write_beyond_eof(BlockBackend *blk, bool allow);
+void blk_set_allow_aio_context_change(BlockBackend *blk, bool allow);
 void blk_iostatus_enable(BlockBackend *blk);
 bool blk_iostatus_is_enabled(const BlockBackend *blk);
 BlockDeviceIoStatus blk_iostatus(const BlockBackend *blk);