cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
218e99
From 6e011e90a93e9301c2a23a71a13f2a1664b4be2b Mon Sep 17 00:00:00 2001
218e99
From: Max Reitz <mreitz@redhat.com>
218e99
Date: Thu, 7 Nov 2013 13:12:58 +0100
218e99
Subject: [PATCH 73/87] vmdk: Implement .bdrv_has_zero_init
218e99
218e99
RH-Author: Max Reitz <mreitz@redhat.com>
218e99
Message-id: <1383756824-6921-8-git-send-email-mreitz@redhat.com>
218e99
Patchwork-id: 55562
218e99
O-Subject: [RHEL-7.0 qemu-kvm PATCH v2 07/21] vmdk: Implement .bdrv_has_zero_init
218e99
Bugzilla: 980771
218e99
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
218e99
RH-Acked-by: Fam Zheng <famz@redhat.com>
218e99
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
218e99
218e99
From: Fam Zheng <famz@redhat.com>
218e99
218e99
BZ: 980771
218e99
218e99
Depending on the subformat, has_zero_init queries underlying storage for
218e99
flat extent. If it has a flat extent and its underlying storage doesn't
218e99
have zero init, return 0. Otherwise return 1.
218e99
218e99
Aligns the operator assignments.
218e99
218e99
Signed-off-by: Fam Zheng <famz@redhat.com>
218e99
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
218e99
(cherry picked from commit da7a50f938516d0f2302965eeb82940c32028ed8)
218e99
218e99
Signed-off-by: Max Reitz <mreitz@redhat.com>
218e99
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
218e99
---
218e99
 block/vmdk.c |   48 +++++++++++++++++++++++++++++++++---------------
218e99
 1 files changed, 33 insertions(+), 15 deletions(-)
218e99
218e99
diff --git a/block/vmdk.c b/block/vmdk.c
218e99
index 213901f..bd1dd62 100644
218e99
--- a/block/vmdk.c
218e99
+++ b/block/vmdk.c
218e99
@@ -1797,6 +1797,23 @@ static int64_t vmdk_get_allocated_file_size(BlockDriverState *bs)
218e99
     return ret;
218e99
 }
218e99
 
218e99
+static int vmdk_has_zero_init(BlockDriverState *bs)
218e99
+{
218e99
+    int i;
218e99
+    BDRVVmdkState *s = bs->opaque;
218e99
+
218e99
+    /* If has a flat extent and its underlying storage doesn't have zero init,
218e99
+     * return 0. */
218e99
+    for (i = 0; i < s->num_extents; i++) {
218e99
+        if (s->extents[i].flat) {
218e99
+            if (!bdrv_has_zero_init(s->extents[i].file)) {
218e99
+                return 0;
218e99
+            }
218e99
+        }
218e99
+    }
218e99
+    return 1;
218e99
+}
218e99
+
218e99
 static QEMUOptionParameter vmdk_create_options[] = {
218e99
     {
218e99
         .name = BLOCK_OPT_SIZE,
218e99
@@ -1835,21 +1852,22 @@ static QEMUOptionParameter vmdk_create_options[] = {
218e99
 };
218e99
 
218e99
 static BlockDriver bdrv_vmdk = {
218e99
-    .format_name    = "vmdk",
218e99
-    .instance_size  = sizeof(BDRVVmdkState),
218e99
-    .bdrv_probe     = vmdk_probe,
218e99
-    .bdrv_open      = vmdk_open,
218e99
-    .bdrv_reopen_prepare = vmdk_reopen_prepare,
218e99
-    .bdrv_read      = vmdk_co_read,
218e99
-    .bdrv_write     = vmdk_co_write,
218e99
-    .bdrv_co_write_zeroes = vmdk_co_write_zeroes,
218e99
-    .bdrv_close     = vmdk_close,
218e99
-    .bdrv_create    = vmdk_create,
218e99
-    .bdrv_co_flush_to_disk  = vmdk_co_flush,
218e99
-    .bdrv_co_get_block_status = vmdk_co_get_block_status,
218e99
-    .bdrv_get_allocated_file_size  = vmdk_get_allocated_file_size,
218e99
-
218e99
-    .create_options = vmdk_create_options,
218e99
+    .format_name                  = "vmdk",
218e99
+    .instance_size                = sizeof(BDRVVmdkState),
218e99
+    .bdrv_probe                   = vmdk_probe,
218e99
+    .bdrv_open                    = vmdk_open,
218e99
+    .bdrv_reopen_prepare          = vmdk_reopen_prepare,
218e99
+    .bdrv_read                    = vmdk_co_read,
218e99
+    .bdrv_write                   = vmdk_co_write,
218e99
+    .bdrv_co_write_zeroes         = vmdk_co_write_zeroes,
218e99
+    .bdrv_close                   = vmdk_close,
218e99
+    .bdrv_create                  = vmdk_create,
218e99
+    .bdrv_co_flush_to_disk        = vmdk_co_flush,
218e99
+    .bdrv_co_get_block_status     = vmdk_co_get_block_status,
218e99
+    .bdrv_get_allocated_file_size = vmdk_get_allocated_file_size,
218e99
+    .bdrv_has_zero_init           = vmdk_has_zero_init,
218e99
+
218e99
+    .create_options               = vmdk_create_options,
218e99
 };
218e99
 
218e99
 static void bdrv_vmdk_init(void)
218e99
-- 
218e99
1.7.1
218e99