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

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

Commit Message

Max Reitz June 21, 2017, 12:50 p.m. UTC
When invoking drive-mirror in absolute-paths mode, the target's backing
BDS is assigned to it in mirror_exit(). 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 | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Alberto Garcia June 29, 2017, 1:17 p.m. UTC | #1
On Wed 21 Jun 2017 02:50:23 PM CEST, Max Reitz wrote:
> When invoking drive-mirror in absolute-paths mode, the target's backing
> BDS is assigned to it in mirror_exit(). 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 4618853..db57bee 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -529,12 +529,12 @@  static void mirror_exit(BlockJob *job, void *opaque)
                             &error_abort);
     if (s->backing_mode == MIRROR_SOURCE_BACKING_CHAIN) {
         BlockDriverState *backing = s->is_none_mode ? src : s->base;
-        if (backing_bs(target_bs) != backing) {
-            bdrv_set_backing_hd(target_bs, backing, &local_err);
-            if (local_err) {
-                error_report_err(local_err);
-                data->ret = -EPERM;
-            }
+
+        assert(!target_bs->backing);
+        bdrv_set_backing_hd(target_bs, backing, &local_err);
+        if (local_err) {
+            error_report_err(local_err);
+            data->ret = -EPERM;
         }
     }