[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 19/29] qcow2: Fix src_offset in copy offloading
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 19/29] qcow2: Fix src_offset in copy offloading |
Date: |
Fri, 29 Jun 2018 16:09:49 +0200 |
From: Fam Zheng <address@hidden>
Not updating src_offset will result in wrong data being written to dst
image.
Reported-by: Max Reitz <address@hidden>
Signed-off-by: Fam Zheng <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/qcow2.c | 1 +
tests/qemu-iotests/063 | 9 +++++++++
tests/qemu-iotests/063.out | 12 ++++++++++++
3 files changed, 22 insertions(+)
diff --git a/block/qcow2.c b/block/qcow2.c
index 286640c0e3..2f9e58e0c4 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -3387,6 +3387,7 @@ qcow2_co_copy_range_to(BlockDriverState *bs,
}
bytes -= cur_bytes;
+ src_offset += cur_bytes;
dst_offset += cur_bytes;
}
ret = 0;
diff --git a/tests/qemu-iotests/063 b/tests/qemu-iotests/063
index e4f6ea9385..adc037c1f5 100755
--- a/tests/qemu-iotests/063
+++ b/tests/qemu-iotests/063
@@ -91,6 +91,15 @@ if $QEMU_IMG convert -f $IMGFMT -O $IMGFMT -n
"$TEST_IMG.orig" "$TEST_IMG" >/dev
exit 1
fi
+echo "== Regression testing for copy offloading bug =="
+
+_make_test_img 1M
+TEST_IMG="$TEST_IMG.target" _make_test_img 1M
+$QEMU_IO -c 'write -P 1 0 512k' -c 'write -P 2 512k 512k' "$TEST_IMG" |
_filter_qemu_io
+$QEMU_IO -c 'write -P 4 512k 512k' -c 'write -P 3 0 512k' "$TEST_IMG.target" |
_filter_qemu_io
+$QEMU_IMG convert -n -O $IMGFMT "$TEST_IMG" "$TEST_IMG.target"
+$QEMU_IMG compare "$TEST_IMG" "$TEST_IMG.target"
+
echo "*** done"
rm -f $seq.full
status=0
diff --git a/tests/qemu-iotests/063.out b/tests/qemu-iotests/063.out
index de1c99afd8..7b691b2c9e 100644
--- a/tests/qemu-iotests/063.out
+++ b/tests/qemu-iotests/063.out
@@ -7,4 +7,16 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4194304
No errors were found on the image.
== Testing conversion to a smaller file fails ==
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2097152
+== Regression testing for copy offloading bug ==
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
+Formatting 'TEST_DIR/t.IMGFMT.target', fmt=IMGFMT size=1048576
+wrote 524288/524288 bytes at offset 0
+512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 524288/524288 bytes at offset 524288
+512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 524288/524288 bytes at offset 524288
+512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 524288/524288 bytes at offset 0
+512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+Images are identical.
*** done
--
2.13.6
- [Qemu-block] [PULL 14/29] block/crypto: Simplify block_crypto_{open, create}_opts_init(), (continued)
- [Qemu-block] [PULL 14/29] block/crypto: Simplify block_crypto_{open, create}_opts_init(), Kevin Wolf, 2018/06/29
- [Qemu-block] [PULL 16/29] qcow2: Free allocated clusters on write error, Kevin Wolf, 2018/06/29
- [Qemu-block] [PULL 17/29] qemu-iotests: Test qcow2 not leaking clusters on write error, Kevin Wolf, 2018/06/29
- [Qemu-block] [PULL 18/29] file-posix: Implement co versions of discard/flush, Kevin Wolf, 2018/06/29
- [Qemu-block] [PULL 15/29] qemu-iotests: Update 026.out.nocache reference output, Kevin Wolf, 2018/06/29
- [Qemu-block] [PULL 24/29] qcow: Switch qcow_co_readv to byte-based calls, Kevin Wolf, 2018/06/29
- [Qemu-block] [PULL 21/29] file-posix: Fix EINTR handling, Kevin Wolf, 2018/06/29
- [Qemu-block] [PULL 20/29] iscsi: Don't blindly use designator length in response for memcpy, Kevin Wolf, 2018/06/29
- [Qemu-block] [PULL 22/29] parallels: Switch to byte-based calls, Kevin Wolf, 2018/06/29
- [Qemu-block] [PULL 23/29] qcow: Switch get_cluster_offset to be byte-based, Kevin Wolf, 2018/06/29
- [Qemu-block] [PULL 19/29] qcow2: Fix src_offset in copy offloading,
Kevin Wolf <=
- [Qemu-block] [PULL 26/29] qcow: Switch to a byte-based driver, Kevin Wolf, 2018/06/29
- [Qemu-block] [PULL 25/29] qcow: Switch qcow_co_writev to byte-based calls, Kevin Wolf, 2018/06/29
- [Qemu-block] [PULL 27/29] replication: Switch to byte-based calls, Kevin Wolf, 2018/06/29
- [Qemu-block] [PULL 28/29] vhdx: Switch to byte-based calls, Kevin Wolf, 2018/06/29
- [Qemu-block] [PULL 29/29] block: Remove unused sector-based vectored I/O, Kevin Wolf, 2018/06/29
- Re: [Qemu-block] [PULL 00/29] Block layer patches, Peter Maydell, 2018/06/30