cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-vmdk-Fix-calculation-of-block-status-s-offset.patch

34b321
From 0cdb7038a7027cbb63c820e60bb34abd191ac85f Mon Sep 17 00:00:00 2001
34b321
From: Fam Zheng <famz@redhat.com>
34b321
Date: Mon, 15 Feb 2016 09:28:31 +0100
34b321
Subject: [PATCH 18/18] vmdk: Fix calculation of block status's offset
34b321
34b321
RH-Author: Fam Zheng <famz@redhat.com>
34b321
Message-id: <1455528511-9357-19-git-send-email-famz@redhat.com>
34b321
Patchwork-id: 69184
34b321
O-Subject: [RHEL-7.3 qemu-kvm PATCH 18/18] vmdk: Fix calculation of block status's offset
34b321
Bugzilla: 1299116
34b321
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
34b321
RH-Acked-by: Max Reitz <mreitz@redhat.com>
34b321
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
34b321
34b321
"offset" is the offset of cluster and sector_num doesn't necessarily
34b321
refer to the start of it, it should add index_in_cluster.
34b321
34b321
Signed-off-by: Fam Zheng <famz@redhat.com>
34b321
Message-id: 1453780743-16806-12-git-send-email-famz@redhat.com
34b321
Reviewed-by: Max Reitz <mreitz@redhat.com>
34b321
Signed-off-by: Max Reitz <mreitz@redhat.com>
34b321
(cherry picked from commit d0a18f10251f515c86dcaec5bdf979a4e07fafc5)
34b321
Signed-off-by: Fam Zheng <famz@redhat.com>
34b321
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
34b321
---
34b321
 block/vmdk.c | 6 ++++--
34b321
 1 file changed, 4 insertions(+), 2 deletions(-)
34b321
34b321
diff --git a/block/vmdk.c b/block/vmdk.c
34b321
index b0c312b..b4f0d44 100644
34b321
--- a/block/vmdk.c
34b321
+++ b/block/vmdk.c
34b321
@@ -1275,6 +1275,7 @@ static int64_t coroutine_fn vmdk_co_get_block_status(BlockDriverState *bs,
34b321
                              0, 0);
34b321
     qemu_co_mutex_unlock(&s->lock);
34b321
 
34b321
+    index_in_cluster = vmdk_find_index_in_cluster(extent, sector_num);
34b321
     switch (ret) {
34b321
     case VMDK_ERROR:
34b321
         ret = -EIO;
34b321
@@ -1288,13 +1289,14 @@ static int64_t coroutine_fn vmdk_co_get_block_status(BlockDriverState *bs,
34b321
     case VMDK_OK:
34b321
         ret = BDRV_BLOCK_DATA;
34b321
         if (extent->file == bs->file && !extent->compressed) {
34b321
-            ret |= BDRV_BLOCK_OFFSET_VALID | offset;
34b321
+            ret |= BDRV_BLOCK_OFFSET_VALID;
34b321
+            ret |= (offset + (index_in_cluster << BDRV_SECTOR_BITS))
34b321
+                    & BDRV_BLOCK_OFFSET_MASK;
34b321
         }
34b321
 
34b321
         break;
34b321
     }
34b321
 
34b321
-    index_in_cluster = vmdk_find_index_in_cluster(extent, sector_num);
34b321
     n = extent->cluster_sectors - index_in_cluster;
34b321
     if (n > nb_sectors) {
34b321
         n = nb_sectors;
34b321
-- 
34b321
1.8.3.1
34b321