9ae3a8
From ecaad218fdda71c1f64f557b3dff6a09a425b084 Mon Sep 17 00:00:00 2001
9ae3a8
Message-Id: <ecaad218fdda71c1f64f557b3dff6a09a425b084.1389014116.git.minovotn@redhat.com>
9ae3a8
In-Reply-To: <c8cc35838d42aa286242772d97e3a9be7bb786ba.1389014116.git.minovotn@redhat.com>
9ae3a8
References: <c8cc35838d42aa286242772d97e3a9be7bb786ba.1389014116.git.minovotn@redhat.com>
9ae3a8
From: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
Date: Mon, 9 Dec 2013 14:09:17 +0100
9ae3a8
Subject: [PATCH 29/50] vpc, vhdx: add get_info
9ae3a8
9ae3a8
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
Message-id: <1386598178-11845-32-git-send-email-pbonzini@redhat.com>
9ae3a8
Patchwork-id: 56068
9ae3a8
O-Subject: [RHEL 7.0 qemu-kvm PATCH 31/52] vpc, vhdx: add get_info
9ae3a8
Bugzilla: 1007815
9ae3a8
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
9ae3a8
RH-Acked-by: Fam Zheng <famz@redhat.com>
9ae3a8
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
9ae3a8
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
Reviewed-by: Peter Lieven <pl@kamp.de>
9ae3a8
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
(cherry picked from commit 97b00e285119e611f500686f32f9bccffbb9126a)
9ae3a8
9ae3a8
Conflicts:
9ae3a8
	block/vhdx.c [BlockDriver members]
9ae3a8
	block/vpc.c [VHDFooter vs. struct vhd_footer, BlockDriver members]
9ae3a8
---
9ae3a8
 block/vhdx.c | 10 ++++++++++
9ae3a8
 block/vpc.c  | 13 +++++++++++++
9ae3a8
 2 files changed, 23 insertions(+)
9ae3a8
9ae3a8
Signed-off-by: Michal Novotny <minovotn@redhat.com>
9ae3a8
---
9ae3a8
 block/vhdx.c | 10 ++++++++++
9ae3a8
 block/vpc.c  | 13 +++++++++++++
9ae3a8
 2 files changed, 23 insertions(+)
9ae3a8
9ae3a8
diff --git a/block/vhdx.c b/block/vhdx.c
9ae3a8
index 6cb0412..7285b95 100644
9ae3a8
--- a/block/vhdx.c
9ae3a8
+++ b/block/vhdx.c
9ae3a8
@@ -878,6 +878,15 @@ static void vhdx_block_translate(BDRVVHDXState *s, int64_t sector_num,
9ae3a8
 }
9ae3a8
 
9ae3a8
 
9ae3a8
+static int vhdx_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
9ae3a8
+{
9ae3a8
+    BDRVVHDXState *s = bs->opaque;
9ae3a8
+
9ae3a8
+    bdi->cluster_size = s->block_size;
9ae3a8
+
9ae3a8
+    return 0;
9ae3a8
+}
9ae3a8
+
9ae3a8
 
9ae3a8
 static coroutine_fn int vhdx_co_readv(BlockDriverState *bs, int64_t sector_num,
9ae3a8
                                       int nb_sectors, QEMUIOVector *qiov)
9ae3a8
@@ -973,6 +982,7 @@ static BlockDriver bdrv_vhdx = {
9ae3a8
     .bdrv_reopen_prepare    = vhdx_reopen_prepare,
9ae3a8
     .bdrv_co_readv          = vhdx_co_readv,
9ae3a8
     .bdrv_co_writev         = vhdx_co_writev,
9ae3a8
+    .bdrv_get_info          = vhdx_get_info,
9ae3a8
 };
9ae3a8
 
9ae3a8
 static void bdrv_vhdx_init(void)
9ae3a8
diff --git a/block/vpc.c b/block/vpc.c
9ae3a8
index 5d65756..49520c1 100644
9ae3a8
--- a/block/vpc.c
9ae3a8
+++ b/block/vpc.c
9ae3a8
@@ -439,6 +439,18 @@ fail:
9ae3a8
     return -1;
9ae3a8
 }
9ae3a8
 
9ae3a8
+static int vpc_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
9ae3a8
+{
9ae3a8
+    BDRVVPCState *s = (BDRVVPCState *)bs->opaque;
9ae3a8
+    struct vhd_footer *footer = (struct vhd_footer *) s->footer_buf;
9ae3a8
+
9ae3a8
+    if (cpu_to_be32(footer->type) != VHD_FIXED) {
9ae3a8
+        bdi->cluster_size = s->block_size;
9ae3a8
+    }
9ae3a8
+
9ae3a8
+    return 0;
9ae3a8
+}
9ae3a8
+
9ae3a8
 static int vpc_read(BlockDriverState *bs, int64_t sector_num,
9ae3a8
                     uint8_t *buf, int nb_sectors)
9ae3a8
 {
9ae3a8
@@ -830,6 +842,7 @@ static BlockDriver bdrv_vpc = {
9ae3a8
     .bdrv_write             = vpc_co_write,
9ae3a8
 
9ae3a8
     .create_options = vpc_create_options,
9ae3a8
+    .bdrv_get_info  = vpc_get_info,
9ae3a8
 };
9ae3a8
 
9ae3a8
 static void bdrv_vpc_init(void)
9ae3a8
-- 
9ae3a8
1.7.11.7
9ae3a8