[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 13/29] block: Split bdrv_move_feature_fields()
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 13/29] block: Split bdrv_move_feature_fields() |
Date: |
Fri, 16 Oct 2015 17:05:58 +0200 |
After bdrv_swap(), some fields must be moved back to their original BDS
to compensate for the effects that a swap of the contents of the objects
has while keeping the old addresses. Other fields must be moved back
because they should logically be moved and must stay on top
When replacing bdrv_swap() with operations changing the pointers in the
parents, we only need the latter and must avoid swapping the former.
Split the function accordingly.
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
Reviewed-by: Fam Zheng <address@hidden>
Reviewed-by: Alberto Garcia <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
---
block.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/block.c b/block.c
index a9c7ea6..a2d6238 100644
--- a/block.c
+++ b/block.c
@@ -1985,6 +1985,8 @@ static void bdrv_rebind(BlockDriverState *bs)
}
}
+/* Fields that need to stay with the top-level BDS, no matter whether the
+ * address of the top-level BDS stays the same or not. */
static void bdrv_move_feature_fields(BlockDriverState *bs_dest,
BlockDriverState *bs_src)
{
@@ -2020,7 +2022,13 @@ static void bdrv_move_feature_fields(BlockDriverState
*bs_dest,
/* dirty bitmap */
bs_dest->dirty_bitmaps = bs_src->dirty_bitmaps;
+}
+/* Fields that only need to be swapped if the contents of BDSes is swapped
+ * rather than pointers being changed in the parents. */
+static void bdrv_move_reference_fields(BlockDriverState *bs_dest,
+ BlockDriverState *bs_src)
+{
/* reference count */
bs_dest->refcnt = bs_src->refcnt;
@@ -2091,6 +2099,10 @@ void bdrv_swap(BlockDriverState *bs_new,
BlockDriverState *bs_old)
bdrv_move_feature_fields(bs_old, bs_new);
bdrv_move_feature_fields(bs_new, &tmp);
+ bdrv_move_reference_fields(&tmp, bs_old);
+ bdrv_move_reference_fields(bs_old, bs_new);
+ bdrv_move_reference_fields(bs_new, &tmp);
+
/* bs_new must remain unattached */
assert(!bs_new->blk);
--
1.8.3.1
- [Qemu-devel] [PULL 00/29] Block layer patches, Kevin Wolf, 2015/10/16
- [Qemu-devel] [PULL 01/29] iotests: disable core dumps in test 061, Kevin Wolf, 2015/10/16
- [Qemu-devel] [PULL 02/29] throttle: test that snapshots move the throttling configuration, Kevin Wolf, 2015/10/16
- [Qemu-devel] [PULL 03/29] qmp-commands.hx: Update the supported 'transaction' operations, Kevin Wolf, 2015/10/16
- [Qemu-devel] [PULL 05/29] block: Introduce BDS.file_child, Kevin Wolf, 2015/10/16
- [Qemu-devel] [PULL 06/29] vmdk: Use BdrvChild instead of BDS for references to extents, Kevin Wolf, 2015/10/16
- [Qemu-devel] [PULL 04/29] block: qemu-iotests - fix vmdk test 059.out, Kevin Wolf, 2015/10/16
- [Qemu-devel] [PULL 07/29] blkverify: Convert s->test_file to BdrvChild, Kevin Wolf, 2015/10/16
- [Qemu-devel] [PULL 10/29] block: Remove bdrv_open_image(), Kevin Wolf, 2015/10/16
- [Qemu-devel] [PULL 13/29] block: Split bdrv_move_feature_fields(),
Kevin Wolf <=
- [Qemu-devel] [PULL 08/29] quorum: Convert to BdrvChild, Kevin Wolf, 2015/10/16
- [Qemu-devel] [PULL 14/29] block/io: Make bdrv_requests_pending() public, Kevin Wolf, 2015/10/16
- [Qemu-devel] [PULL 16/29] block: Introduce parents list, Kevin Wolf, 2015/10/16
- [Qemu-devel] [PULL 18/29] blockjob: Store device name at job creation, Kevin Wolf, 2015/10/16
- [Qemu-devel] [PULL 11/29] block: Convert bs->backing_hd to BdrvChild, Kevin Wolf, 2015/10/16
- [Qemu-devel] [PULL 15/29] block-backend: Add blk_set_bs(), Kevin Wolf, 2015/10/16
- [Qemu-devel] [PULL 17/29] block: Implement bdrv_append() without bdrv_swap(), Kevin Wolf, 2015/10/16
- [Qemu-devel] [PULL 12/29] block: Manage backing file references in bdrv_set_backing_hd(), Kevin Wolf, 2015/10/16
- [Qemu-devel] [PULL 21/29] block: Allow bdrv_unref_child(bs, NULL), Kevin Wolf, 2015/10/16
- [Qemu-devel] [PULL 20/29] block: Remove bdrv_swap(), Kevin Wolf, 2015/10/16