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