aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>2020-03-12 11:19:49 +0300
committerMichael Roth <mdroth@linux.vnet.ibm.com>2020-06-03 19:58:05 -0500
commit8fc4aa4822c55c9dbf7061a6fa4d9b3b8471800d (patch)
treeb686746a38a154311e039fe1492ed46bf4675c4c /block
parent4a9486a02d17e81a54bc4b631fec7112a1850a9d (diff)
downloadqemu-8fc4aa4822c55c9dbf7061a6fa4d9b3b8471800d.zip
qemu-8fc4aa4822c55c9dbf7061a6fa4d9b3b8471800d.tar.gz
qemu-8fc4aa4822c55c9dbf7061a6fa4d9b3b8471800d.tar.bz2
block/io: fix bdrv_co_do_copy_on_readv
Prior to 1143ec5ebf4 it was OK to qemu_iovec_from_buf() from aligned-up buffer to original qiov, as qemu_iovec_from_buf() will stop at qiov end anyway. But after 1143ec5ebf4 we assume that bdrv_co_do_copy_on_readv works on part of original qiov, defined by qiov_offset and bytes. So we must not touch qiov behind qiov_offset+bytes bound. Fix it. Cc: qemu-stable@nongnu.org # v4.2 Fixes: 1143ec5ebf4 Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: John Snow <jsnow@redhat.com> Message-id: 20200312081949.5350-1-vsementsov@virtuozzo.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> (cherry picked from commit 4ab78b19189a81038e744728ed949d09aa477550) Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Diffstat (limited to 'block')
-rw-r--r--block/io.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/block/io.c b/block/io.c
index f75777f..949932d 100644
--- a/block/io.c
+++ b/block/io.c
@@ -1395,7 +1395,7 @@ static int coroutine_fn bdrv_co_do_copy_on_readv(BdrvChild *child,
if (!(flags & BDRV_REQ_PREFETCH)) {
qemu_iovec_from_buf(qiov, qiov_offset + progress,
bounce_buffer + skip_bytes,
- pnum - skip_bytes);
+ MIN(pnum - skip_bytes, bytes - progress));
}
} else if (!(flags & BDRV_REQ_PREFETCH)) {
/* Read directly into the destination */