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