Blame SOURCES/kvm-qemu-img-Fix-assert-when-mapping-unaligned-raw-file.patch

383d26
From bd6ce734563c0308b021c013f1e622ff185be60b Mon Sep 17 00:00:00 2001
383d26
From: Max Reitz <mreitz@redhat.com>
383d26
Date: Mon, 6 Aug 2018 16:35:52 +0200
383d26
Subject: [PATCH 03/13] qemu-img: Fix assert when mapping unaligned raw file
383d26
383d26
RH-Author: Max Reitz <mreitz@redhat.com>
383d26
Message-id: <20180806163553.13344-2-mreitz@redhat.com>
383d26
Patchwork-id: 81647
383d26
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH 1/2] qemu-img: Fix assert when mapping unaligned raw file
383d26
Bugzilla: 1601310
383d26
RH-Acked-by: Eric Blake <eblake@redhat.com>
383d26
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
383d26
RH-Acked-by: John Snow <jsnow@redhat.com>
383d26
383d26
From: Eric Blake <eblake@redhat.com>
383d26
383d26
Commit a290f085 exposed a latent bug in qemu-img map introduced
383d26
during the conversion of block status to be byte-based.  Earlier in
383d26
commit 5e344dd8, the internal interface get_block_status() switched
383d26
to take byte-based parameters, but still called a sector-based
383d26
block layer function; as such, rounding was added in the lone
383d26
caller to obey the contract.  However, commit 237d78f8 changed
383d26
get_block_status() to truly be byte-based, at which point rounding
383d26
to sector boundaries can result in calling bdrv_block_status() with
383d26
'bytes == 0' (a coding error) when the boundary between data and a
383d26
hole falls mid-sector (true for the past-EOF implicit hole present
383d26
in POSIX files).  Fix things by removing the rounding that is now
383d26
no longer necessary.
383d26
383d26
See also https://bugzilla.redhat.com/1589738
383d26
383d26
Fixes: 237d78f8
383d26
Reported-by: Dan Kenigsberg <danken@redhat.com>
383d26
Reported-by: Nir Soffer <nsoffer@redhat.com>
383d26
Reported-by: Maor Lipchuk <mlipchuk@redhat.com>
383d26
CC: qemu-stable@nongnu.org
383d26
Signed-off-by: Eric Blake <eblake@redhat.com>
383d26
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
383d26
(cherry picked from commit e0b371ed5e2db079051139136fd0478728b6a58f)
383d26
Signed-off-by: Max Reitz <mreitz@redhat.com>
383d26
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
383d26
---
383d26
 qemu-img.c | 2 +-
383d26
 1 file changed, 1 insertion(+), 1 deletion(-)
383d26
383d26
diff --git a/qemu-img.c b/qemu-img.c
383d26
index c9ccc1e..f42750a 100644
383d26
--- a/qemu-img.c
383d26
+++ b/qemu-img.c
383d26
@@ -2925,7 +2925,7 @@ static int img_map(int argc, char **argv)
383d26
         int64_t n;
383d26
 
383d26
         /* Probe up to 1 GiB at a time.  */
383d26
-        n = QEMU_ALIGN_DOWN(MIN(1 << 30, length - offset), BDRV_SECTOR_SIZE);
383d26
+        n = MIN(1 << 30, length - offset);
383d26
         ret = get_block_status(bs, offset, n, &next;;
383d26
 
383d26
         if (ret < 0) {
383d26
-- 
383d26
1.8.3.1
383d26