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