|
|
7711c0 |
From 8b23ebef39aa3e2817db7d42c8143139697e0adc Mon Sep 17 00:00:00 2001
|
|
|
7711c0 |
From: John Snow <jsnow@redhat.com>
|
|
|
7711c0 |
Date: Mon, 6 May 2019 17:56:17 +0200
|
|
|
7711c0 |
Subject: [PATCH 07/53] iotests: Add 241 to test NBD on unaligned images
|
|
|
7711c0 |
|
|
|
7711c0 |
RH-Author: John Snow <jsnow@redhat.com>
|
|
|
7711c0 |
Message-id: <20190506175629.11079-8-jsnow@redhat.com>
|
|
|
7711c0 |
Patchwork-id: 87182
|
|
|
7711c0 |
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 07/19] iotests: Add 241 to test NBD on unaligned images
|
|
|
7711c0 |
Bugzilla: 1692018
|
|
|
7711c0 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
7711c0 |
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
|
|
|
7711c0 |
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
|
7711c0 |
|
|
|
7711c0 |
From: Eric Blake <eblake@redhat.com>
|
|
|
7711c0 |
|
|
|
7711c0 |
Add a test for the NBD client workaround in the previous patch. It's
|
|
|
7711c0 |
not really feasible for an iotest to assume a specific tracing engine,
|
|
|
7711c0 |
so we can't really probe trace_nbd_parse_blockstatus_compliance to see
|
|
|
7711c0 |
if the server was fixed vs. whether the client just worked around the
|
|
|
7711c0 |
server (other than by rearranging order between code patches and this
|
|
|
7711c0 |
test). But having a successful exchange sure beats the previous state
|
|
|
7711c0 |
of an error message. Since format probing can change alignment, we can
|
|
|
7711c0 |
use that as an easy way to test several configurations.
|
|
|
7711c0 |
|
|
|
7711c0 |
Not tested yet, but worth adding to this test in future patches: an
|
|
|
7711c0 |
NBD server that can advertise a non-sector-aligned size (such as
|
|
|
7711c0 |
nbdkit) causes qemu as the NBD client to misbehave when it rounds the
|
|
|
7711c0 |
size up and accesses beyond the advertised size. Qemu as NBD server
|
|
|
7711c0 |
never advertises a non-sector-aligned size (since bdrv_getlength()
|
|
|
7711c0 |
currently rounds up to sector boundaries); until qemu can act as such
|
|
|
7711c0 |
a server, testing that flaw will have to rely on external binaries.
|
|
|
7711c0 |
|
|
|
7711c0 |
Signed-off-by: Eric Blake <eblake@redhat.com>
|
|
|
7711c0 |
Message-Id: <20190329042750.14704-2-eblake@redhat.com>
|
|
|
7711c0 |
Tested-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
|
|
|
7711c0 |
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
|
|
|
7711c0 |
[eblake: add forced-512 alignment, and nbdkit reproducer comment]
|
|
|
7711c0 |
(cherry picked from commit e9dce9cb6eae57834cd80324ff43069299198bab)
|
|
|
7711c0 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
7711c0 |
|
|
|
7711c0 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
7711c0 |
---
|
|
|
7711c0 |
tests/qemu-iotests/241 | 100 +++++++++++++++++++++++++++++++++++++++++++++
|
|
|
7711c0 |
tests/qemu-iotests/241.out | 26 ++++++++++++
|
|
|
7711c0 |
tests/qemu-iotests/group | 1 +
|
|
|
7711c0 |
3 files changed, 127 insertions(+)
|
|
|
7711c0 |
create mode 100755 tests/qemu-iotests/241
|
|
|
7711c0 |
create mode 100644 tests/qemu-iotests/241.out
|
|
|
7711c0 |
|
|
|
7711c0 |
diff --git a/tests/qemu-iotests/241 b/tests/qemu-iotests/241
|
|
|
7711c0 |
new file mode 100755
|
|
|
7711c0 |
index 0000000..4b19685
|
|
|
7711c0 |
--- /dev/null
|
|
|
7711c0 |
+++ b/tests/qemu-iotests/241
|
|
|
7711c0 |
@@ -0,0 +1,100 @@
|
|
|
7711c0 |
+#!/bin/bash
|
|
|
7711c0 |
+#
|
|
|
7711c0 |
+# Test qemu-nbd vs. unaligned images
|
|
|
7711c0 |
+#
|
|
|
7711c0 |
+# Copyright (C) 2018-2019 Red Hat, Inc.
|
|
|
7711c0 |
+#
|
|
|
7711c0 |
+# This program is free software; you can redistribute it and/or modify
|
|
|
7711c0 |
+# it under the terms of the GNU General Public License as published by
|
|
|
7711c0 |
+# the Free Software Foundation; either version 2 of the License, or
|
|
|
7711c0 |
+# (at your option) any later version.
|
|
|
7711c0 |
+#
|
|
|
7711c0 |
+# This program is distributed in the hope that it will be useful,
|
|
|
7711c0 |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
7711c0 |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
7711c0 |
+# GNU General Public License for more details.
|
|
|
7711c0 |
+#
|
|
|
7711c0 |
+# You should have received a copy of the GNU General Public License
|
|
|
7711c0 |
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
7711c0 |
+#
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+seq="$(basename $0)"
|
|
|
7711c0 |
+echo "QA output created by $seq"
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+status=1 # failure is the default!
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+nbd_unix_socket=$TEST_DIR/test_qemu_nbd_socket
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+_cleanup()
|
|
|
7711c0 |
+{
|
|
|
7711c0 |
+ _cleanup_test_img
|
|
|
7711c0 |
+ nbd_server_stop
|
|
|
7711c0 |
+}
|
|
|
7711c0 |
+trap "_cleanup; exit \$status" 0 1 2 3 15
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+# get standard environment, filters and checks
|
|
|
7711c0 |
+. ./common.rc
|
|
|
7711c0 |
+. ./common.filter
|
|
|
7711c0 |
+. ./common.nbd
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+_supported_fmt raw
|
|
|
7711c0 |
+_supported_proto nbd
|
|
|
7711c0 |
+_supported_os Linux
|
|
|
7711c0 |
+_require_command QEMU_NBD
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+# can't use _make_test_img, because qemu-img rounds image size up,
|
|
|
7711c0 |
+# and because we want to use Unix socket rather than TCP port. Likewise,
|
|
|
7711c0 |
+# we have to redirect TEST_IMG to our server.
|
|
|
7711c0 |
+# This tests that we can deal with the hole at the end of an unaligned
|
|
|
7711c0 |
+# raw file (either because the server doesn't advertise alignment too
|
|
|
7711c0 |
+# large, or because the client ignores the server's noncompliance - even
|
|
|
7711c0 |
+# though we can't actually wire iotests into checking trace messages).
|
|
|
7711c0 |
+printf %01000d 0 > "$TEST_IMG_FILE"
|
|
|
7711c0 |
+TEST_IMG="nbd:unix:$nbd_unix_socket"
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+echo
|
|
|
7711c0 |
+echo "=== Exporting unaligned raw image, natural alignment ==="
|
|
|
7711c0 |
+echo
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+nbd_server_start_unix_socket -f $IMGFMT "$TEST_IMG_FILE"
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+$QEMU_NBD_PROG --list -k $nbd_unix_socket | grep '\(size\|min\)'
|
|
|
7711c0 |
+$QEMU_IMG map -f raw --output=json "$TEST_IMG" | _filter_qemu_img_map
|
|
|
7711c0 |
+$QEMU_IO -f raw -c map "$TEST_IMG"
|
|
|
7711c0 |
+nbd_server_stop
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+echo
|
|
|
7711c0 |
+echo "=== Exporting unaligned raw image, forced server sector alignment ==="
|
|
|
7711c0 |
+echo
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+# Intentionally omit '-f' to force image probing, which in turn forces
|
|
|
7711c0 |
+# sector alignment, here at the server.
|
|
|
7711c0 |
+nbd_server_start_unix_socket "$TEST_IMG_FILE"
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+$QEMU_NBD_PROG --list -k $nbd_unix_socket | grep '\(size\|min\)'
|
|
|
7711c0 |
+$QEMU_IMG map -f raw --output=json "$TEST_IMG" | _filter_qemu_img_map
|
|
|
7711c0 |
+$QEMU_IO -f raw -c map "$TEST_IMG"
|
|
|
7711c0 |
+nbd_server_stop
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+echo
|
|
|
7711c0 |
+echo "=== Exporting unaligned raw image, forced client sector alignment ==="
|
|
|
7711c0 |
+echo
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+# Now force sector alignment at the client.
|
|
|
7711c0 |
+nbd_server_start_unix_socket -f $IMGFMT "$TEST_IMG_FILE"
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+$QEMU_NBD_PROG --list -k $nbd_unix_socket | grep '\(size\|min\)'
|
|
|
7711c0 |
+$QEMU_IMG map --output=json "$TEST_IMG" | _filter_qemu_img_map
|
|
|
7711c0 |
+$QEMU_IO -c map "$TEST_IMG"
|
|
|
7711c0 |
+nbd_server_stop
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+# Not tested yet: we also want to ensure that qemu as NBD client does
|
|
|
7711c0 |
+# not access beyond the end of a server's advertised unaligned size:
|
|
|
7711c0 |
+# nbdkit -U - memory size=513 --run 'qemu-io -f raw -c "r 512 512" $nbd'
|
|
|
7711c0 |
+# However, since qemu as server always rounds up to a sector alignment,
|
|
|
7711c0 |
+# we would have to use nbdkit to provoke the current client failures.
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+# success, all done
|
|
|
7711c0 |
+echo '*** done'
|
|
|
7711c0 |
+rm -f $seq.full
|
|
|
7711c0 |
+status=0
|
|
|
7711c0 |
diff --git a/tests/qemu-iotests/241.out b/tests/qemu-iotests/241.out
|
|
|
7711c0 |
new file mode 100644
|
|
|
7711c0 |
index 0000000..b76a623
|
|
|
7711c0 |
--- /dev/null
|
|
|
7711c0 |
+++ b/tests/qemu-iotests/241.out
|
|
|
7711c0 |
@@ -0,0 +1,26 @@
|
|
|
7711c0 |
+QA output created by 241
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+=== Exporting unaligned raw image, natural alignment ===
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+ size: 1024
|
|
|
7711c0 |
+ min block: 512
|
|
|
7711c0 |
+[{ "start": 0, "length": 1024, "depth": 0, "zero": false, "data": true}]
|
|
|
7711c0 |
+1 KiB (0x400) bytes allocated at offset 0 bytes (0x0)
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+=== Exporting unaligned raw image, forced server sector alignment ===
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+WARNING: Image format was not specified for '/home/eblake/qemu/tests/qemu-iotests/scratch/t.raw' and probing guessed raw.
|
|
|
7711c0 |
+ Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
|
|
|
7711c0 |
+ Specify the 'raw' format explicitly to remove the restrictions.
|
|
|
7711c0 |
+ size: 1024
|
|
|
7711c0 |
+ min block: 512
|
|
|
7711c0 |
+[{ "start": 0, "length": 1024, "depth": 0, "zero": false, "data": true}]
|
|
|
7711c0 |
+1 KiB (0x400) bytes allocated at offset 0 bytes (0x0)
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+=== Exporting unaligned raw image, forced client sector alignment ===
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+ size: 1024
|
|
|
7711c0 |
+ min block: 512
|
|
|
7711c0 |
+[{ "start": 0, "length": 1024, "depth": 0, "zero": false, "data": true}]
|
|
|
7711c0 |
+1 KiB (0x400) bytes allocated at offset 0 bytes (0x0)
|
|
|
7711c0 |
+*** done
|
|
|
7711c0 |
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
|
|
|
7711c0 |
index 7da1334..882ff66 100644
|
|
|
7711c0 |
--- a/tests/qemu-iotests/group
|
|
|
7711c0 |
+++ b/tests/qemu-iotests/group
|
|
|
7711c0 |
@@ -229,5 +229,6 @@
|
|
|
7711c0 |
233 auto quick
|
|
|
7711c0 |
234 auto quick migration
|
|
|
7711c0 |
236 auto quick
|
|
|
7711c0 |
+241 rw auto quick
|
|
|
7711c0 |
242 rw auto quick
|
|
|
7711c0 |
246 rw auto quick
|
|
|
7711c0 |
--
|
|
|
7711c0 |
1.8.3.1
|
|
|
7711c0 |
|