cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
958e1b
From 0e4b156f5e4c928c2f98c21d029b0b1c361bd2a8 Mon Sep 17 00:00:00 2001
958e1b
From: Jeffrey Cody <jcody@redhat.com>
958e1b
Date: Tue, 16 Sep 2014 20:11:48 +0200
958e1b
Subject: [PATCH 10/20] vpc: Implement .bdrv_has_zero_init
958e1b
958e1b
Message-id: <f9375563af1f63122af308c2f924f154e54e47d4.1410897407.git.jcody@redhat.com>
958e1b
Patchwork-id: 61214
958e1b
O-Subject: [PATCH qemu-kvm-rhel RHEL7.1 09/15] vpc: Implement .bdrv_has_zero_init
958e1b
Bugzilla: 1098086
958e1b
RH-Acked-by: Fam Zheng <famz@redhat.com>
958e1b
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
958e1b
RH-Acked-by: Max Reitz <mreitz@redhat.com>
958e1b
958e1b
From: Kevin Wolf <kwolf@redhat.com>
958e1b
958e1b
Depending on the subformat, has_zero_init on VHD must behave like raw
958e1b
and query the underlying storage (fixed) or like other sparse formats
958e1b
that can always return 1 (dynamic, differencing).
958e1b
958e1b
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
958e1b
(cherry picked from commit 72c6cc94daa727f41ecfc2b2ff94aa6f0e459b7f)
958e1b
958e1b
Conflicts:
958e1b
	block/vpc.c
958e1b
958e1b
RHEL7 Notes: Conflict due to out of order commits
958e1b
958e1b
Signed-off-by: Jeff Cody <jcody@redhat.com>
958e1b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
958e1b
---
958e1b
 block/vpc.c |   28 +++++++++++++++++++++-------
958e1b
 1 files changed, 21 insertions(+), 7 deletions(-)
958e1b
958e1b
diff --git a/block/vpc.c b/block/vpc.c
958e1b
index 6e8fb33..2f3d4ac 100644
958e1b
--- a/block/vpc.c
958e1b
+++ b/block/vpc.c
958e1b
@@ -826,6 +826,18 @@ static int vpc_create(const char *filename, QEMUOptionParameter *options,
958e1b
     return ret;
958e1b
 }
958e1b
 
958e1b
+static int vpc_has_zero_init(BlockDriverState *bs)
958e1b
+{
958e1b
+    BDRVVPCState *s = bs->opaque;
958e1b
+    struct vhd_footer *footer =  (struct vhd_footer *) s->footer_buf;
958e1b
+
958e1b
+    if (cpu_to_be32(footer->type) == VHD_FIXED) {
958e1b
+        return bdrv_has_zero_init(bs->file);
958e1b
+    } else {
958e1b
+        return 1;
958e1b
+    }
958e1b
+}
958e1b
+
958e1b
 static void vpc_close(BlockDriverState *bs)
958e1b
 {
958e1b
     BDRVVPCState *s = bs->opaque;
958e1b
@@ -858,17 +870,19 @@ static BlockDriver bdrv_vpc = {
958e1b
     .format_name    = "vpc",
958e1b
     .instance_size  = sizeof(BDRVVPCState),
958e1b
 
958e1b
-    .bdrv_probe     = vpc_probe,
958e1b
-    .bdrv_open      = vpc_open,
958e1b
-    .bdrv_close     = vpc_close,
958e1b
-    .bdrv_reopen_prepare = vpc_reopen_prepare,
958e1b
-    .bdrv_create    = vpc_create,
958e1b
+    .bdrv_probe             = vpc_probe,
958e1b
+    .bdrv_open              = vpc_open,
958e1b
+    .bdrv_close             = vpc_close,
958e1b
+    .bdrv_reopen_prepare    = vpc_reopen_prepare,
958e1b
+    .bdrv_create            = vpc_create,
958e1b
 
958e1b
     .bdrv_read              = vpc_co_read,
958e1b
     .bdrv_write             = vpc_co_write,
958e1b
 
958e1b
-    .create_options = vpc_create_options,
958e1b
-    .bdrv_get_info  = vpc_get_info,
958e1b
+    .bdrv_get_info          = vpc_get_info,
958e1b
+
958e1b
+    .create_options         = vpc_create_options,
958e1b
+    .bdrv_has_zero_init     = vpc_has_zero_init,
958e1b
 };
958e1b
 
958e1b
 static void bdrv_vpc_init(void)
958e1b
-- 
958e1b
1.7.1
958e1b