[v3,01/25] block/mirror: Small absolute-paths simplification
diff mbox

Message ID 20161130011851.24696-2-mreitz@redhat.com
State New
Headers show

Commit Message

Max Reitz Nov. 30, 2016, 1:18 a.m. UTC
When invoking drive-mirror in absolute-paths mode, the target's backing
BDS is assigned to it in mirror_complete(). The current logic only does
so if the target does not have that backing BDS already; but it actually
cannot have a backing BDS at all (the BDS is opened with O_NO_BACKING in
qmp_drive_mirror()), so just assert that and assign the new backing BDS
unconditionally.

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 block/mirror.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Alberto Garcia Dec. 15, 2016, 4:14 p.m. UTC | #1
On Wed 30 Nov 2016 02:18:27 AM CET, Max Reitz wrote:
> When invoking drive-mirror in absolute-paths mode, the target's backing
> BDS is assigned to it in mirror_complete(). The current logic only does
> so if the target does not have that backing BDS already; but it actually
> cannot have a backing BDS at all (the BDS is opened with O_NO_BACKING in
> qmp_drive_mirror()), so just assert that and assign the new backing BDS
> unconditionally.
>
> Signed-off-by: Max Reitz <mreitz@redhat.com>

Reviewed-by: Alberto Garcia <berto@igalia.com>

Berto

Patch
diff mbox

diff --git a/block/mirror.c b/block/mirror.c
index 301ba92..4ece624 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -888,9 +888,9 @@  static void mirror_complete(BlockJob *job, Error **errp)
 
     if (s->backing_mode == MIRROR_SOURCE_BACKING_CHAIN) {
         BlockDriverState *backing = s->is_none_mode ? src : s->base;
-        if (backing_bs(target) != backing) {
-            bdrv_set_backing_hd(target, backing);
-        }
+
+        assert(!target->backing);
+        bdrv_set_backing_hd(target, backing);
     }
 
     s->should_complete = true;