]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
block: introduce blk_replace_bs
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Tue, 24 Aug 2021 08:38:24 +0000 (11:38 +0300)
committerHanna Reitz <hreitz@redhat.com>
Wed, 1 Sep 2021 10:57:31 +0000 (12:57 +0200)
Add function to change bs inside blk.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20210824083856.17408-3-vsementsov@virtuozzo.com>
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
block/block-backend.c
include/sysemu/block-backend.h

index deb55c272ead88648c9c66ebf2e42fa24af6ff09..6140d133e275eb98d09e4ab4cf9efb472f6f473a 100644 (file)
@@ -869,6 +869,14 @@ int blk_insert_bs(BlockBackend *blk, BlockDriverState *bs, Error **errp)
     return 0;
 }
 
+/*
+ * Change BlockDriverState associated with @blk.
+ */
+int blk_replace_bs(BlockBackend *blk, BlockDriverState *new_bs, Error **errp)
+{
+    return bdrv_replace_child_bs(blk->root, new_bs, errp);
+}
+
 /*
  * Sets the permission bitmasks that the user of the BlockBackend needs.
  */
index 9ac5f7bbd3a17d87d8a59abb3a6565eb0b6e6471..29d4fdbf63fabbd2081781ba30f68e6eacc44a99 100644 (file)
@@ -102,6 +102,7 @@ BlockBackend *blk_by_public(BlockBackendPublic *public);
 BlockDriverState *blk_bs(BlockBackend *blk);
 void blk_remove_bs(BlockBackend *blk);
 int blk_insert_bs(BlockBackend *blk, BlockDriverState *bs, Error **errp);
+int blk_replace_bs(BlockBackend *blk, BlockDriverState *new_bs, Error **errp);
 bool bdrv_has_blk(BlockDriverState *bs);
 bool bdrv_is_root_node(BlockDriverState *bs);
 int blk_set_perm(BlockBackend *blk, uint64_t perm, uint64_t shared_perm,