yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
26ba25
From 0ad5340a73448535ca73d6e551955e2339c9e110 Mon Sep 17 00:00:00 2001
26ba25
From: Max Reitz <mreitz@redhat.com>
26ba25
Date: Mon, 15 Oct 2018 17:44:45 +0100
26ba25
Subject: [PATCH 48/49] qemu-img: Fix assert when mapping unaligned raw file
26ba25
26ba25
RH-Author: Max Reitz <mreitz@redhat.com>
26ba25
Message-id: <20181015174446.31974-2-mreitz@redhat.com>
26ba25
Patchwork-id: 82706
26ba25
O-Subject: [RHEL-8 qemu-kvm PATCH v2 1/2] qemu-img: Fix assert when mapping unaligned raw file
26ba25
Bugzilla: 1639374
26ba25
RH-Acked-by: John Snow <jsnow@redhat.com>
26ba25
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
26ba25
RH-Acked-by: Thomas Huth <thuth@redhat.com>
26ba25
26ba25
From: Eric Blake <eblake@redhat.com>
26ba25
26ba25
Commit a290f085 exposed a latent bug in qemu-img map introduced
26ba25
during the conversion of block status to be byte-based.  Earlier in
26ba25
commit 5e344dd8, the internal interface get_block_status() switched
26ba25
to take byte-based parameters, but still called a sector-based
26ba25
block layer function; as such, rounding was added in the lone
26ba25
caller to obey the contract.  However, commit 237d78f8 changed
26ba25
get_block_status() to truly be byte-based, at which point rounding
26ba25
to sector boundaries can result in calling bdrv_block_status() with
26ba25
'bytes == 0' (a coding error) when the boundary between data and a
26ba25
hole falls mid-sector (true for the past-EOF implicit hole present
26ba25
in POSIX files).  Fix things by removing the rounding that is now
26ba25
no longer necessary.
26ba25
26ba25
See also https://bugzilla.redhat.com/1589738
26ba25
26ba25
Fixes: 237d78f8
26ba25
Reported-by: Dan Kenigsberg <danken@redhat.com>
26ba25
Reported-by: Nir Soffer <nsoffer@redhat.com>
26ba25
Reported-by: Maor Lipchuk <mlipchuk@redhat.com>
26ba25
CC: qemu-stable@nongnu.org
26ba25
Signed-off-by: Eric Blake <eblake@redhat.com>
26ba25
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
26ba25
(cherry picked from commit e0b371ed5e2db079051139136fd0478728b6a58f)
26ba25
Signed-off-by: Max Reitz <mreitz@redhat.com>
26ba25
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
26ba25
---
26ba25
 qemu-img.c | 2 +-
26ba25
 1 file changed, 1 insertion(+), 1 deletion(-)
26ba25
26ba25
diff --git a/qemu-img.c b/qemu-img.c
26ba25
index eaee6d6..b9bd401 100644
26ba25
--- a/qemu-img.c
26ba25
+++ b/qemu-img.c
26ba25
@@ -2912,7 +2912,7 @@ static int img_map(int argc, char **argv)
26ba25
         int64_t n;
26ba25
 
26ba25
         /* Probe up to 1 GiB at a time.  */
26ba25
-        n = QEMU_ALIGN_DOWN(MIN(1 << 30, length - offset), BDRV_SECTOR_SIZE);
26ba25
+        n = MIN(1 << 30, length - offset);
26ba25
         ret = get_block_status(bs, offset, n, &next;;
26ba25
 
26ba25
         if (ret < 0) {
26ba25
-- 
26ba25
1.8.3.1
26ba25