VMDK: flush multiple extents
authorFam Zheng <famcool@gmail.com>
Tue, 12 Jul 2011 11:56:33 +0000 (19:56 +0800)
committerKevin Wolf <kwolf@redhat.com>
Tue, 19 Jul 2011 13:39:06 +0000 (15:39 +0200)
Flush all the file that referenced by the image.

Signed-off-by: Fam Zheng <famcool@gmail.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/vmdk.c

index 529ae90..f6d2986 100644 (file)
@@ -1072,7 +1072,17 @@ static void vmdk_close(BlockDriverState *bs)
 
 static int vmdk_flush(BlockDriverState *bs)
 {
-    return bdrv_flush(bs->file);
+    int i, ret, err;
+    BDRVVmdkState *s = bs->opaque;
+
+    ret = bdrv_flush(bs->file);
+    for (i = 0; i < s->num_extents; i++) {
+        err = bdrv_flush(s->extents[i].file);
+        if (err < 0) {
+            ret = err;
+        }
+    }
+    return ret;
 }