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