thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-vmdk-Use-bdrv_nb_sectors-where-sectors-not-bytes-are.patch

9ae3a8
From 1d5ecdd5402c43fc20deefe64ee72172cd645486 Mon Sep 17 00:00:00 2001
9ae3a8
Message-Id: <1d5ecdd5402c43fc20deefe64ee72172cd645486.1418766606.git.jen@redhat.com>
9ae3a8
In-Reply-To: <6f81b4847eb68ebdf54a8f1a771e19d112d74152.1418766606.git.jen@redhat.com>
9ae3a8
References: <6f81b4847eb68ebdf54a8f1a771e19d112d74152.1418766606.git.jen@redhat.com>
9ae3a8
From: Fam Zheng <famz@redhat.com>
9ae3a8
Date: Thu, 4 Dec 2014 00:05:21 -0600
9ae3a8
Subject: [CHANGE 27/31] vmdk: Use bdrv_nb_sectors() where sectors, not bytes
9ae3a8
 are wanted
9ae3a8
MIME-Version: 1.0
9ae3a8
Content-Type: text/plain; charset=UTF-8
9ae3a8
Content-Transfer-Encoding: 8bit
9ae3a8
To: rhvirt-patches@redhat.com,
9ae3a8
    jen@redhat.com
9ae3a8
9ae3a8
RH-Author: Fam Zheng <famz@redhat.com>
9ae3a8
Message-id: <1417651524-18041-28-git-send-email-famz@redhat.com>
9ae3a8
Patchwork-id: 62700
9ae3a8
O-Subject: [RHEL-7.1 qemu-kvm PATCH v5 27/30] vmdk: Use bdrv_nb_sectors() where sectors, not bytes are wanted
9ae3a8
Bugzilla: 1002493
9ae3a8
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
9ae3a8
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
9ae3a8
RH-Acked-by: Max Reitz <mreitz@redhat.com>
9ae3a8
9ae3a8
From: Markus Armbruster <armbru@redhat.com>
9ae3a8
9ae3a8
Instead of bdrv_getlength().
9ae3a8
9ae3a8
Commit 57322b7 did this all over block, but one more bdrv_getlength()
9ae3a8
has crept in since.
9ae3a8
9ae3a8
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9ae3a8
Reviewed-by: Fam Zheng <famz@redhat.com>
9ae3a8
Reviewed-by: BenoƮt Canet <benoit.canet@nodalink.com>
9ae3a8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9ae3a8
(cherry picked from commit 0a156f7c750c4e4e1c5dfb2135debcf399e4e2a7)
9ae3a8
Signed-off-by: Fam Zheng <famz@redhat.com>
9ae3a8
Signed-off-by: Jeff E. Nelson <jen@redhat.com>
9ae3a8
---
9ae3a8
 block/vmdk.c | 11 +++++------
9ae3a8
 1 file changed, 5 insertions(+), 6 deletions(-)
9ae3a8
9ae3a8
diff --git a/block/vmdk.c b/block/vmdk.c
9ae3a8
index 560dd43..b9ab89b 100644
9ae3a8
--- a/block/vmdk.c
9ae3a8
+++ b/block/vmdk.c
9ae3a8
@@ -397,7 +397,7 @@ static int vmdk_add_extent(BlockDriverState *bs,
9ae3a8
 {
9ae3a8
     VmdkExtent *extent;
9ae3a8
     BDRVVmdkState *s = bs->opaque;
9ae3a8
-    int64_t length;
9ae3a8
+    int64_t nb_sectors;
9ae3a8
 
9ae3a8
     if (cluster_sectors > 0x200000) {
9ae3a8
         /* 0x200000 * 512Bytes = 1GB for one cluster is unrealistic */
9ae3a8
@@ -413,9 +413,9 @@ static int vmdk_add_extent(BlockDriverState *bs,
9ae3a8
         return -EFBIG;
9ae3a8
     }
9ae3a8
 
9ae3a8
-    length = bdrv_getlength(file);
9ae3a8
-    if (length < 0) {
9ae3a8
-        return length;
9ae3a8
+    nb_sectors = bdrv_nb_sectors(file);
9ae3a8
+    if (nb_sectors < 0) {
9ae3a8
+        return nb_sectors;
9ae3a8
     }
9ae3a8
 
9ae3a8
     s->extents = g_realloc(s->extents,
9ae3a8
@@ -433,8 +433,7 @@ static int vmdk_add_extent(BlockDriverState *bs,
9ae3a8
     extent->l1_entry_sectors = l2_size * cluster_sectors;
9ae3a8
     extent->l2_size = l2_size;
9ae3a8
     extent->cluster_sectors = flat ? sectors : cluster_sectors;
9ae3a8
-    extent->next_cluster_sector =
9ae3a8
-        ROUND_UP(DIV_ROUND_UP(length, BDRV_SECTOR_SIZE), cluster_sectors);
9ae3a8
+    extent->next_cluster_sector = ROUND_UP(nb_sectors, cluster_sectors);
9ae3a8
 
9ae3a8
     if (s->num_extents > 1) {
9ae3a8
         extent->end_sector = (*(extent - 1)).end_sector + extent->sectors;
9ae3a8
-- 
9ae3a8
2.1.0
9ae3a8