From: Pavel Butsykin <pbutsy...@virtuozzo.com>

The vmdk format has the extents and bs->file can be equal to the first
extension. Before start of the backup we do detach the old context on the
target drive at the bdrv_attach_aio_context. For the vmdk drive this means
a double detach of the same block driver state, because the detach occurs
for s->extents[0].file and bs->file.

To fix we  just skip the detach if s->extents[i].file and bs->file are the
same. This approach is already used in the vmdk_free_extents() and the
vmdk_get_allocated_file_size(), so it won't be some innovation :)

Signed-off-by: Pavel Butsykin <pbutsy...@virtuozzo.com>
Signed-off-by: Denis V. Lunev <d...@openvz.org>
CC: Jeff Cody <jc...@redhat.com>
CC: Markus Armbruster <arm...@redhat.com>
CC: Eric Blake <ebl...@redhat.com>
CC: John Snow <js...@redhat.com>
CC: Stefan Hajnoczi <stefa...@redhat.com>
CC: Kevin Wolf <kw...@redhat.com>
---
 block/vmdk.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/block/vmdk.c b/block/vmdk.c
index 9530b30..0550924 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -2305,7 +2305,10 @@ static void vmdk_detach_aio_context(BlockDriverState *bs)
     int i;
 
     for (i = 0; i < s->num_extents; i++) {
-        bdrv_detach_aio_context(s->extents[i].file->bs);
+        BdrvChild *file = s->extents[i].file;
+        if (file != bs->file) {
+            bdrv_detach_aio_context(file->bs);
+        }
     }
 }
 
-- 
2.1.4


Reply via email to