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