[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 18/21] qemu-img: rebase: Reuse in-chain BlockDriverSt
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PULL 18/21] qemu-img: rebase: Reuse in-chain BlockDriverState |
Date: |
Tue, 28 May 2019 21:28:44 +0200 |
From: Sam Eiderman <address@hidden>
If a chain was detected, don't open a new BlockBackend from the target
backing file which will create a new BlockDriverState. Instead, create
an empty BlockBackend and attach the already open BlockDriverState.
Permissions for blk_new() were copied from blk_new_open() when
flags = 0.
Reviewed-by: Karl Heubaum <address@hidden>
Reviewed-by: Eyal Moscovici <address@hidden>
Signed-off-by: Sagi Amit <address@hidden>
Co-developed-by: Sagi Amit <address@hidden>
Signed-off-by: Sam Eiderman <address@hidden>
Message-id: address@hidden
Signed-off-by: Max Reitz <address@hidden>
---
qemu-img.c | 33 +++++++++++++++++++++++----------
1 file changed, 23 insertions(+), 10 deletions(-)
diff --git a/qemu-img.c b/qemu-img.c
index 2d96a491e2..b0535919b1 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -3358,16 +3358,29 @@ static int img_rebase(int argc, char **argv)
* in its chain.
*/
prefix_chain_bs = bdrv_find_backing_image(bs, out_real_path);
-
- blk_new_backing = blk_new_open(out_real_path, NULL,
- options, src_flags, &local_err);
- g_free(out_real_path);
- if (!blk_new_backing) {
- error_reportf_err(local_err,
- "Could not open new backing file '%s': ",
- out_baseimg);
- ret = -1;
- goto out;
+ if (prefix_chain_bs) {
+ g_free(out_real_path);
+ blk_new_backing = blk_new(BLK_PERM_CONSISTENT_READ,
+ BLK_PERM_ALL);
+ ret = blk_insert_bs(blk_new_backing, prefix_chain_bs,
+ &local_err);
+ if (ret < 0) {
+ error_reportf_err(local_err,
+ "Could not reuse backing file '%s': ",
+ out_baseimg);
+ goto out;
+ }
+ } else {
+ blk_new_backing = blk_new_open(out_real_path, NULL,
+ options, src_flags, &local_err);
+ g_free(out_real_path);
+ if (!blk_new_backing) {
+ error_reportf_err(local_err,
+ "Could not open new backing file '%s': ",
+ out_baseimg);
+ ret = -1;
+ goto out;
+ }
}
}
}
--
2.21.0
- [Qemu-devel] [PULL 16/21] qemu-img: rebase: Reuse parent BlockDriverState, (continued)
- [Qemu-devel] [PULL 16/21] qemu-img: rebase: Reuse parent BlockDriverState, Max Reitz, 2019/05/28
- [Qemu-devel] [PULL 13/21] block/backup: refactor: split out backup_calculate_cluster_size, Max Reitz, 2019/05/28
- [Qemu-devel] [PULL 07/21] qcow2: bdrv_co_pwritev: move encryption code out of the lock, Max Reitz, 2019/05/28
- [Qemu-devel] [PULL 06/21] qcow2: qcow2_co_preadv: improve locking, Max Reitz, 2019/05/28
- [Qemu-devel] [PULL 14/21] block: Use bdrv_unref_child() for all children in bdrv_close(), Max Reitz, 2019/05/28
- [Qemu-devel] [PULL 09/21] block/backup: simplify backup_incremental_init_copy_bitmap, Max Reitz, 2019/05/28
- [Qemu-devel] [PULL 15/21] block: Make bdrv_root_attach_child() unref child_bs on failure, Max Reitz, 2019/05/28
- [Qemu-devel] [PULL 08/21] qcow2: do encryption in threads, Max Reitz, 2019/05/28
- [Qemu-devel] [PULL 10/21] block/backup: move to copy_bitmap with granularity, Max Reitz, 2019/05/28
- [Qemu-devel] [PULL 21/21] blockdev: loosen restrictions on drive-backup source node, Max Reitz, 2019/05/28
- [Qemu-devel] [PULL 18/21] qemu-img: rebase: Reuse in-chain BlockDriverState,
Max Reitz <=
- [Qemu-devel] [PULL 17/21] qemu-img: rebase: Reduce reads on in-chain rebase, Max Reitz, 2019/05/28
- [Qemu-devel] [PULL 11/21] block/backup: refactor and tolerate unallocated cluster skipping, Max Reitz, 2019/05/28
- [Qemu-devel] [PULL 12/21] block/backup: unify different modes code path, Max Reitz, 2019/05/28
- [Qemu-devel] [PULL 20/21] qcow2-bitmap: initialize bitmap directory alignment, Max Reitz, 2019/05/28
- [Qemu-devel] [PULL 19/21] qcow2: skip writing zero buffers to empty COW areas, Max Reitz, 2019/05/28
- Re: [Qemu-devel] [PULL 00/21] Block patches, Peter Maydell, 2019/05/30