|
|
ae23c9 |
From a36dfa1ce0b98a3144be892ef6ada29deaf9dcf8 Mon Sep 17 00:00:00 2001
|
|
|
ae23c9 |
From: Fam Zheng <famz@redhat.com>
|
|
|
ae23c9 |
Date: Fri, 29 Jun 2018 06:11:51 +0200
|
|
|
ae23c9 |
Subject: [PATCH 177/268] qcow2: Fix src_offset in copy offloading
|
|
|
ae23c9 |
|
|
|
ae23c9 |
RH-Author: Fam Zheng <famz@redhat.com>
|
|
|
ae23c9 |
Message-id: <20180629061153.12687-12-famz@redhat.com>
|
|
|
ae23c9 |
Patchwork-id: 81163
|
|
|
ae23c9 |
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH v2 11/13] qcow2: Fix src_offset in copy offloading
|
|
|
ae23c9 |
Bugzilla: 1482537
|
|
|
ae23c9 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Not updating src_offset will result in wrong data being written to dst
|
|
|
ae23c9 |
image.
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Reported-by: Max Reitz <mreitz@redhat.com>
|
|
|
ae23c9 |
Signed-off-by: Fam Zheng <famz@redhat.com>
|
|
|
ae23c9 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
ae23c9 |
---
|
|
|
ae23c9 |
block/qcow2.c | 1 +
|
|
|
ae23c9 |
tests/qemu-iotests/063 | 9 +++++++++
|
|
|
ae23c9 |
tests/qemu-iotests/063.out | 12 ++++++++++++
|
|
|
ae23c9 |
3 files changed, 22 insertions(+)
|
|
|
ae23c9 |
|
|
|
ae23c9 |
diff --git a/block/qcow2.c b/block/qcow2.c
|
|
|
ae23c9 |
index c85ebcb..4404dc7 100644
|
|
|
ae23c9 |
--- a/block/qcow2.c
|
|
|
ae23c9 |
+++ b/block/qcow2.c
|
|
|
ae23c9 |
@@ -3416,6 +3416,7 @@ qcow2_co_copy_range_to(BlockDriverState *bs,
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
bytes -= cur_bytes;
|
|
|
ae23c9 |
+ src_offset += cur_bytes;
|
|
|
ae23c9 |
dst_offset += cur_bytes;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
ret = 0;
|
|
|
ae23c9 |
diff --git a/tests/qemu-iotests/063 b/tests/qemu-iotests/063
|
|
|
ae23c9 |
index e4f6ea9..adc037c 100755
|
|
|
ae23c9 |
--- a/tests/qemu-iotests/063
|
|
|
ae23c9 |
+++ b/tests/qemu-iotests/063
|
|
|
ae23c9 |
@@ -91,6 +91,15 @@ if $QEMU_IMG convert -f $IMGFMT -O $IMGFMT -n "$TEST_IMG.orig" "$TEST_IMG" >/dev
|
|
|
ae23c9 |
exit 1
|
|
|
ae23c9 |
fi
|
|
|
ae23c9 |
|
|
|
ae23c9 |
+echo "== Regression testing for copy offloading bug =="
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+_make_test_img 1M
|
|
|
ae23c9 |
+TEST_IMG="$TEST_IMG.target" _make_test_img 1M
|
|
|
ae23c9 |
+$QEMU_IO -c 'write -P 1 0 512k' -c 'write -P 2 512k 512k' "$TEST_IMG" | _filter_qemu_io
|
|
|
ae23c9 |
+$QEMU_IO -c 'write -P 4 512k 512k' -c 'write -P 3 0 512k' "$TEST_IMG.target" | _filter_qemu_io
|
|
|
ae23c9 |
+$QEMU_IMG convert -n -O $IMGFMT "$TEST_IMG" "$TEST_IMG.target"
|
|
|
ae23c9 |
+$QEMU_IMG compare "$TEST_IMG" "$TEST_IMG.target"
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
echo "*** done"
|
|
|
ae23c9 |
rm -f $seq.full
|
|
|
ae23c9 |
status=0
|
|
|
ae23c9 |
diff --git a/tests/qemu-iotests/063.out b/tests/qemu-iotests/063.out
|
|
|
ae23c9 |
index de1c99a..7b691b2 100644
|
|
|
ae23c9 |
--- a/tests/qemu-iotests/063.out
|
|
|
ae23c9 |
+++ b/tests/qemu-iotests/063.out
|
|
|
ae23c9 |
@@ -7,4 +7,16 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4194304
|
|
|
ae23c9 |
No errors were found on the image.
|
|
|
ae23c9 |
== Testing conversion to a smaller file fails ==
|
|
|
ae23c9 |
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2097152
|
|
|
ae23c9 |
+== Regression testing for copy offloading bug ==
|
|
|
ae23c9 |
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
|
|
|
ae23c9 |
+Formatting 'TEST_DIR/t.IMGFMT.target', fmt=IMGFMT size=1048576
|
|
|
ae23c9 |
+wrote 524288/524288 bytes at offset 0
|
|
|
ae23c9 |
+512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
|
ae23c9 |
+wrote 524288/524288 bytes at offset 524288
|
|
|
ae23c9 |
+512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
|
ae23c9 |
+wrote 524288/524288 bytes at offset 524288
|
|
|
ae23c9 |
+512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
|
ae23c9 |
+wrote 524288/524288 bytes at offset 0
|
|
|
ae23c9 |
+512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
|
ae23c9 |
+Images are identical.
|
|
|
ae23c9 |
*** done
|
|
|
ae23c9 |
--
|
|
|
ae23c9 |
1.8.3.1
|
|
|
ae23c9 |
|