|
|
383d26 |
From a213535d2d03296c7b2f31845160757dbb959ca6 Mon Sep 17 00:00:00 2001
|
|
|
383d26 |
From: John Snow <jsnow@redhat.com>
|
|
|
383d26 |
Date: Tue, 24 Jul 2018 13:06:13 +0200
|
|
|
383d26 |
Subject: [PATCH 86/89] iotests: New test 223 for exporting dirty bitmap over
|
|
|
383d26 |
NBD
|
|
|
383d26 |
|
|
|
383d26 |
RH-Author: John Snow <jsnow@redhat.com>
|
|
|
383d26 |
Message-id: <20180718225511.14878-36-jsnow@redhat.com>
|
|
|
383d26 |
Patchwork-id: 81424
|
|
|
383d26 |
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 35/35] iotests: New test 223 for exporting dirty bitmap over NBD
|
|
|
383d26 |
Bugzilla: 1207657
|
|
|
383d26 |
RH-Acked-by: Eric Blake <eblake@redhat.com>
|
|
|
383d26 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
383d26 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
383d26 |
|
|
|
383d26 |
From: Eric Blake <eblake@redhat.com>
|
|
|
383d26 |
|
|
|
383d26 |
Although this test is NOT a full test of image fleecing (as it
|
|
|
383d26 |
intentionally uses just a single block device directly exported
|
|
|
383d26 |
over NBD, rather than trying to set up a blockdev-backup job with
|
|
|
383d26 |
multiple BDS involved), it DOES prove that qemu as a server is
|
|
|
383d26 |
able to properly expose a dirty bitmap over NBD.
|
|
|
383d26 |
|
|
|
383d26 |
When coupled with image fleecing, it is then possible for a
|
|
|
383d26 |
third-party client to do an incremental backup by using
|
|
|
383d26 |
qemu-img map with the x-dirty-bitmap option to learn which parts
|
|
|
383d26 |
of the file are dirty (perhaps confusingly, they are the portions
|
|
|
383d26 |
mapped as "data":false - which is part of the reason this is
|
|
|
383d26 |
still in the x- experimental namespace), along with another
|
|
|
383d26 |
normal client (perhaps 'qemu-nbd -c' to expose the server over
|
|
|
383d26 |
/dev/nbd0 and then just use normal I/O on that block device) to
|
|
|
383d26 |
read the dirty sections.
|
|
|
383d26 |
|
|
|
383d26 |
Signed-off-by: Eric Blake <eblake@redhat.com>
|
|
|
383d26 |
Message-Id: <20180702191458.28741-3-eblake@redhat.com>
|
|
|
383d26 |
Tested-by: John Snow <jsnow@redhat.com>
|
|
|
383d26 |
Reviewed-by: John Snow <jsnow@redhat.com>
|
|
|
383d26 |
(cherry picked from commit a1532a225a183c9fa60b9c1e8ac8a00c7771f64d)
|
|
|
383d26 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
383d26 |
---
|
|
|
383d26 |
tests/qemu-iotests/223 | 138 +++++++++++++++++++++++++++++++++++++++++++++
|
|
|
383d26 |
tests/qemu-iotests/223.out | 49 ++++++++++++++++
|
|
|
383d26 |
tests/qemu-iotests/group | 1 +
|
|
|
383d26 |
3 files changed, 188 insertions(+)
|
|
|
383d26 |
create mode 100644 tests/qemu-iotests/223
|
|
|
383d26 |
create mode 100644 tests/qemu-iotests/223.out
|
|
|
383d26 |
|
|
|
383d26 |
diff --git a/tests/qemu-iotests/223 b/tests/qemu-iotests/223
|
|
|
383d26 |
new file mode 100644
|
|
|
383d26 |
index 0000000..b63b7a4
|
|
|
383d26 |
--- /dev/null
|
|
|
383d26 |
+++ b/tests/qemu-iotests/223
|
|
|
383d26 |
@@ -0,0 +1,138 @@
|
|
|
383d26 |
+#!/bin/bash
|
|
|
383d26 |
+#
|
|
|
383d26 |
+# Test reading dirty bitmap over NBD
|
|
|
383d26 |
+#
|
|
|
383d26 |
+# Copyright (C) 2018 Red Hat, Inc.
|
|
|
383d26 |
+#
|
|
|
383d26 |
+# This program is free software; you can redistribute it and/or modify
|
|
|
383d26 |
+# it under the terms of the GNU General Public License as published by
|
|
|
383d26 |
+# the Free Software Foundation; either version 2 of the License, or
|
|
|
383d26 |
+# (at your option) any later version.
|
|
|
383d26 |
+#
|
|
|
383d26 |
+# This program is distributed in the hope that it will be useful,
|
|
|
383d26 |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
383d26 |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
383d26 |
+# GNU General Public License for more details.
|
|
|
383d26 |
+#
|
|
|
383d26 |
+# You should have received a copy of the GNU General Public License
|
|
|
383d26 |
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
383d26 |
+#
|
|
|
383d26 |
+
|
|
|
383d26 |
+seq="$(basename $0)"
|
|
|
383d26 |
+echo "QA output created by $seq"
|
|
|
383d26 |
+
|
|
|
383d26 |
+here="$PWD"
|
|
|
383d26 |
+status=1 # failure is the default!
|
|
|
383d26 |
+
|
|
|
383d26 |
+_cleanup()
|
|
|
383d26 |
+{
|
|
|
383d26 |
+ _cleanup_test_img
|
|
|
383d26 |
+ _cleanup_qemu
|
|
|
383d26 |
+ rm -f "$TEST_DIR/nbd"
|
|
|
383d26 |
+}
|
|
|
383d26 |
+trap "_cleanup; exit \$status" 0 1 2 3 15
|
|
|
383d26 |
+
|
|
|
383d26 |
+# get standard environment, filters and checks
|
|
|
383d26 |
+. ./common.rc
|
|
|
383d26 |
+. ./common.filter
|
|
|
383d26 |
+. ./common.qemu
|
|
|
383d26 |
+
|
|
|
383d26 |
+_supported_fmt qcow2
|
|
|
383d26 |
+_supported_proto file # uses NBD as well
|
|
|
383d26 |
+_supported_os Linux
|
|
|
383d26 |
+
|
|
|
383d26 |
+function do_run_qemu()
|
|
|
383d26 |
+{
|
|
|
383d26 |
+ echo Testing: "$@"
|
|
|
383d26 |
+ $QEMU -nographic -qmp stdio -serial none "$@"
|
|
|
383d26 |
+ echo
|
|
|
383d26 |
+}
|
|
|
383d26 |
+
|
|
|
383d26 |
+function run_qemu()
|
|
|
383d26 |
+{
|
|
|
383d26 |
+ do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp \
|
|
|
383d26 |
+ | _filter_qemu | _filter_imgfmt \
|
|
|
383d26 |
+ | _filter_actual_image_size
|
|
|
383d26 |
+}
|
|
|
383d26 |
+
|
|
|
383d26 |
+echo
|
|
|
383d26 |
+echo "=== Create partially sparse image, then add dirty bitmap ==="
|
|
|
383d26 |
+echo
|
|
|
383d26 |
+
|
|
|
383d26 |
+_make_test_img 4M
|
|
|
383d26 |
+$QEMU_IO -c 'w -P 0x11 1M 2M' "$TEST_IMG" | _filter_qemu_io
|
|
|
383d26 |
+run_qemu <
|
|
|
383d26 |
+{ "execute": "qmp_capabilities" }
|
|
|
383d26 |
+{ "execute": "blockdev-add",
|
|
|
383d26 |
+ "arguments": {
|
|
|
383d26 |
+ "driver": "$IMGFMT",
|
|
|
383d26 |
+ "node-name": "n",
|
|
|
383d26 |
+ "file": {
|
|
|
383d26 |
+ "driver": "file",
|
|
|
383d26 |
+ "filename": "$TEST_IMG"
|
|
|
383d26 |
+ }
|
|
|
383d26 |
+ }
|
|
|
383d26 |
+}
|
|
|
383d26 |
+{ "execute": "block-dirty-bitmap-add",
|
|
|
383d26 |
+ "arguments": {
|
|
|
383d26 |
+ "node": "n",
|
|
|
383d26 |
+ "name": "b",
|
|
|
383d26 |
+ "persistent": true
|
|
|
383d26 |
+ }
|
|
|
383d26 |
+}
|
|
|
383d26 |
+{ "execute": "quit" }
|
|
|
383d26 |
+EOF
|
|
|
383d26 |
+
|
|
|
383d26 |
+echo
|
|
|
383d26 |
+echo "=== Write part of the file under active bitmap ==="
|
|
|
383d26 |
+echo
|
|
|
383d26 |
+
|
|
|
383d26 |
+$QEMU_IO -c 'w -P 0x22 2M 2M' "$TEST_IMG" | _filter_qemu_io
|
|
|
383d26 |
+
|
|
|
383d26 |
+echo
|
|
|
383d26 |
+echo "=== End dirty bitmap, and start serving image over NBD ==="
|
|
|
383d26 |
+echo
|
|
|
383d26 |
+
|
|
|
383d26 |
+_launch_qemu 2> >(_filter_nbd)
|
|
|
383d26 |
+
|
|
|
383d26 |
+silent=
|
|
|
383d26 |
+_send_qemu_cmd $QEMU_HANDLE '{"execute":"qmp_capabilities"}' "return"
|
|
|
383d26 |
+_send_qemu_cmd $QEMU_HANDLE '{"execute":"blockdev-add",
|
|
|
383d26 |
+ "arguments":{"driver":"qcow2", "node-name":"n",
|
|
|
383d26 |
+ "file":{"driver":"file", "filename":"'"$TEST_IMG"'"}}}' "return"
|
|
|
383d26 |
+_send_qemu_cmd $QEMU_HANDLE '{"execute":"x-block-dirty-bitmap-disable",
|
|
|
383d26 |
+ "arguments":{"node":"n", "name":"b"}}' "return"
|
|
|
383d26 |
+_send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-start",
|
|
|
383d26 |
+ "arguments":{"addr":{"type":"unix",
|
|
|
383d26 |
+ "data":{"path":"'"$TEST_DIR/nbd"'"}}}}' "return"
|
|
|
383d26 |
+_send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-add",
|
|
|
383d26 |
+ "arguments":{"device":"n"}}' "return"
|
|
|
383d26 |
+_send_qemu_cmd $QEMU_HANDLE '{"execute":"x-nbd-server-add-bitmap",
|
|
|
383d26 |
+ "arguments":{"name":"n", "bitmap":"b"}}' "return"
|
|
|
383d26 |
+
|
|
|
383d26 |
+echo
|
|
|
383d26 |
+echo "=== Contrast normal status with dirty-bitmap status ==="
|
|
|
383d26 |
+echo
|
|
|
383d26 |
+
|
|
|
383d26 |
+QEMU_IO_OPTIONS=$QEMU_IO_OPTIONS_NO_FMT
|
|
|
383d26 |
+IMG="driver=nbd,export=n,server.type=unix,server.path=$TEST_DIR/nbd"
|
|
|
383d26 |
+$QEMU_IO -r -c 'r -P 0 0 1m' -c 'r -P 0x11 1m 1m' \
|
|
|
383d26 |
+ -c 'r -P 0x22 2m 2m' --image-opts "$IMG" | _filter_qemu_io
|
|
|
383d26 |
+$QEMU_IMG map --output=json --image-opts \
|
|
|
383d26 |
+ "$IMG" | _filter_qemu_img_map
|
|
|
383d26 |
+$QEMU_IMG map --output=json --image-opts \
|
|
|
383d26 |
+ "$IMG,x-dirty-bitmap=qemu:dirty-bitmap:b" | _filter_qemu_img_map
|
|
|
383d26 |
+
|
|
|
383d26 |
+echo
|
|
|
383d26 |
+echo "=== End NBD server ==="
|
|
|
383d26 |
+echo
|
|
|
383d26 |
+
|
|
|
383d26 |
+_send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-remove",
|
|
|
383d26 |
+ "arguments":{"name":"n"}}' "return"
|
|
|
383d26 |
+_send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-stop"}' "return"
|
|
|
383d26 |
+_send_qemu_cmd $QEMU_HANDLE '{"execute":"quit"}' "return"
|
|
|
383d26 |
+
|
|
|
383d26 |
+# success, all done
|
|
|
383d26 |
+echo '*** done'
|
|
|
383d26 |
+rm -f $seq.full
|
|
|
383d26 |
+status=0
|
|
|
383d26 |
diff --git a/tests/qemu-iotests/223.out b/tests/qemu-iotests/223.out
|
|
|
383d26 |
new file mode 100644
|
|
|
383d26 |
index 0000000..33021c8
|
|
|
383d26 |
--- /dev/null
|
|
|
383d26 |
+++ b/tests/qemu-iotests/223.out
|
|
|
383d26 |
@@ -0,0 +1,49 @@
|
|
|
383d26 |
+QA output created by 223
|
|
|
383d26 |
+
|
|
|
383d26 |
+=== Create partially sparse image, then add dirty bitmap ===
|
|
|
383d26 |
+
|
|
|
383d26 |
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4194304
|
|
|
383d26 |
+wrote 2097152/2097152 bytes at offset 1048576
|
|
|
383d26 |
+2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
|
383d26 |
+Testing:
|
|
|
383d26 |
+QMP_VERSION
|
|
|
383d26 |
+{"return": {}}
|
|
|
383d26 |
+{"return": {}}
|
|
|
383d26 |
+{"return": {}}
|
|
|
383d26 |
+{"return": {}}
|
|
|
383d26 |
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
|
|
|
383d26 |
+
|
|
|
383d26 |
+
|
|
|
383d26 |
+=== Write part of the file under active bitmap ===
|
|
|
383d26 |
+
|
|
|
383d26 |
+wrote 2097152/2097152 bytes at offset 2097152
|
|
|
383d26 |
+2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
|
383d26 |
+
|
|
|
383d26 |
+=== End dirty bitmap, and start serving image over NBD ===
|
|
|
383d26 |
+
|
|
|
383d26 |
+{"return": {}}
|
|
|
383d26 |
+{"return": {}}
|
|
|
383d26 |
+{"return": {}}
|
|
|
383d26 |
+{"return": {}}
|
|
|
383d26 |
+{"return": {}}
|
|
|
383d26 |
+{"return": {}}
|
|
|
383d26 |
+
|
|
|
383d26 |
+=== Contrast normal status with dirty-bitmap status ===
|
|
|
383d26 |
+
|
|
|
383d26 |
+read 1048576/1048576 bytes at offset 0
|
|
|
383d26 |
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
|
383d26 |
+read 1048576/1048576 bytes at offset 1048576
|
|
|
383d26 |
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
|
383d26 |
+read 2097152/2097152 bytes at offset 2097152
|
|
|
383d26 |
+2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
|
383d26 |
+[{ "start": 0, "length": 1048576, "depth": 0, "zero": true, "data": false},
|
|
|
383d26 |
+{ "start": 1048576, "length": 3145728, "depth": 0, "zero": false, "data": true}]
|
|
|
383d26 |
+[{ "start": 0, "length": 2097152, "depth": 0, "zero": false, "data": true},
|
|
|
383d26 |
+{ "start": 2097152, "length": 2097152, "depth": 0, "zero": false, "data": false}]
|
|
|
383d26 |
+
|
|
|
383d26 |
+=== End NBD server ===
|
|
|
383d26 |
+
|
|
|
383d26 |
+{"return": {}}
|
|
|
383d26 |
+{"return": {}}
|
|
|
383d26 |
+{"return": {}}
|
|
|
383d26 |
+*** done
|
|
|
383d26 |
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
|
|
|
383d26 |
index be55905..401258f 100644
|
|
|
383d26 |
--- a/tests/qemu-iotests/group
|
|
|
383d26 |
+++ b/tests/qemu-iotests/group
|
|
|
383d26 |
@@ -219,4 +219,5 @@
|
|
|
383d26 |
218 rw auto quick
|
|
|
383d26 |
219 rw auto
|
|
|
383d26 |
222 rw auto quick
|
|
|
383d26 |
+223 rw auto quick
|
|
|
383d26 |
226 auto quick
|
|
|
383d26 |
--
|
|
|
383d26 |
1.8.3.1
|
|
|
383d26 |
|