2019-03-07 15:58:38 +01:00
|
|
|
#!/usr/bin/env bash
|
2009-06-22 18:29:05 +02:00
|
|
|
#
|
|
|
|
# Copyright (C) 2009 Red Hat, Inc.
|
|
|
|
# Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License as
|
|
|
|
# published by the Free Software Foundation.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it would be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
2009-07-16 19:26:54 +02:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2009-06-22 18:29:05 +02:00
|
|
|
#
|
|
|
|
#
|
|
|
|
# standard filters
|
|
|
|
#
|
|
|
|
|
|
|
|
# ctime(3) dates
|
|
|
|
#
|
|
|
|
_filter_date()
|
|
|
|
{
|
2019-03-07 15:58:39 +01:00
|
|
|
$SED \
|
2013-09-04 13:16:04 +02:00
|
|
|
-e 's/[A-Z][a-z][a-z] [A-z][a-z][a-z] *[0-9][0-9]* [0-9][0-9]:[0-9][0-9]:[0-9][0-9] [0-9][0-9][0-9][0-9]$/DATE/'
|
2009-06-22 18:29:05 +02:00
|
|
|
}
|
|
|
|
|
2015-10-13 01:36:50 +02:00
|
|
|
_filter_generated_node_ids()
|
|
|
|
{
|
2019-03-07 15:58:39 +01:00
|
|
|
$SED -re 's/\#block[0-9]{3,}/NODE_NAME/'
|
2015-10-13 01:36:50 +02:00
|
|
|
}
|
|
|
|
|
2018-03-22 15:45:51 +01:00
|
|
|
_filter_qom_path()
|
|
|
|
{
|
2019-03-07 15:58:39 +01:00
|
|
|
$SED -e 's#\(Attached to: *\) /.*#\1 PATH#'
|
2018-03-22 15:45:51 +01:00
|
|
|
}
|
|
|
|
|
2010-11-24 17:12:21 +01:00
|
|
|
# replace occurrences of the actual TEST_DIR value with TEST_DIR
|
2009-06-22 18:29:05 +02:00
|
|
|
_filter_testdir()
|
|
|
|
{
|
2019-03-07 15:58:39 +01:00
|
|
|
$SED -e "s#$TEST_DIR/#TEST_DIR/#g"
|
2009-06-22 18:29:05 +02:00
|
|
|
}
|
|
|
|
|
2010-11-24 17:12:21 +01:00
|
|
|
# replace occurrences of the actual IMGFMT value with IMGFMT
|
|
|
|
_filter_imgfmt()
|
|
|
|
{
|
2019-03-07 15:58:39 +01:00
|
|
|
$SED -e "s#$IMGFMT#IMGFMT#g"
|
2010-11-24 17:12:21 +01:00
|
|
|
}
|
|
|
|
|
2016-08-10 04:43:12 +02:00
|
|
|
# Replace error message when the format is not supported and delete
|
|
|
|
# the output lines after the first one
|
|
|
|
_filter_qemu_img_check()
|
|
|
|
{
|
2019-03-07 15:58:39 +01:00
|
|
|
$SED -e '/allocated.*fragmented.*compressed clusters/d' \
|
2016-08-10 04:43:12 +02:00
|
|
|
-e 's/qemu-img: This image format does not support checks/No errors were found on the image./' \
|
|
|
|
-e '/Image end offset: [0-9]\+/d'
|
|
|
|
}
|
|
|
|
|
2011-04-29 15:30:25 +02:00
|
|
|
# Removes \r from messages
|
|
|
|
_filter_win32()
|
|
|
|
{
|
2019-03-07 15:58:39 +01:00
|
|
|
$SED -e 's/\r//g'
|
2011-04-29 15:30:25 +02:00
|
|
|
}
|
|
|
|
|
2009-06-22 18:29:05 +02:00
|
|
|
# sanitize qemu-io output
|
|
|
|
_filter_qemu_io()
|
|
|
|
{
|
2019-03-07 15:58:39 +01:00
|
|
|
_filter_win32 | $SED -e "s/[0-9]* ops\; [0-9/:. sec]* ([0-9/.inf]* [EPTGMKiBbytes]*\/sec and [0-9/.inf]* ops\/sec)/X ops\; XX:XX:XX.X (XXX YYY\/sec and XXX ops\/sec)/" \
|
2014-12-08 10:48:11 +01:00
|
|
|
-e "s/: line [0-9][0-9]*: *[0-9][0-9]*\( Aborted\| Killed\)/:\1/" \
|
2013-11-18 08:13:01 +01:00
|
|
|
-e "s/qemu-io> //g"
|
2009-06-22 18:29:05 +02:00
|
|
|
}
|
|
|
|
|
2013-04-15 10:15:17 +02:00
|
|
|
# replace occurrences of QEMU_PROG with "qemu"
|
|
|
|
_filter_qemu()
|
|
|
|
{
|
2019-03-07 15:58:39 +01:00
|
|
|
$SED -e "s#\\(^\\|(qemu) \\)$(basename $QEMU_PROG):#\1QEMU_PROG:#" \
|
2013-11-14 15:24:58 +01:00
|
|
|
-e 's#^QEMU [0-9]\+\.[0-9]\+\.[0-9]\+ monitor#QEMU X.Y.Z monitor#' \
|
|
|
|
-e $'s#\r##' # QEMU monitor uses \r\n line endings
|
2013-04-15 10:15:17 +02:00
|
|
|
}
|
|
|
|
|
2013-09-18 16:47:41 +02:00
|
|
|
# replace problematic QMP output like timestamps
|
|
|
|
_filter_qmp()
|
|
|
|
{
|
|
|
|
_filter_win32 | \
|
2019-03-07 15:58:39 +01:00
|
|
|
$SED -e 's#\("\(micro\)\?seconds": \)[0-9]\+#\1 TIMESTAMP#g' \
|
2014-11-17 13:31:05 +01:00
|
|
|
-e 's#^{"QMP":.*}$#QMP_VERSION#' \
|
|
|
|
-e '/^ "QMP": {\s*$/, /^ }\s*$/ c\' \
|
|
|
|
-e ' QMP_VERSION'
|
2013-09-18 16:47:41 +02:00
|
|
|
}
|
|
|
|
|
2017-04-13 19:19:51 +02:00
|
|
|
# readline makes HMP command strings so long that git complains
|
|
|
|
_filter_hmp()
|
|
|
|
{
|
2019-03-07 15:58:39 +01:00
|
|
|
$SED -e $'s/^\\((qemu) \\)\\?.*\e\\[D/\\1/g' \
|
2017-04-13 19:19:51 +02:00
|
|
|
-e $'s/\e\\[K//g'
|
|
|
|
}
|
|
|
|
|
2016-08-03 14:56:45 +02:00
|
|
|
# replace block job offset
|
|
|
|
_filter_block_job_offset()
|
|
|
|
{
|
2019-03-07 15:58:39 +01:00
|
|
|
$SED -e 's/, "offset": [0-9]\+,/, "offset": OFFSET,/'
|
2016-08-03 14:56:45 +02:00
|
|
|
}
|
|
|
|
|
2017-04-20 02:54:28 +02:00
|
|
|
# replace block job len
|
|
|
|
_filter_block_job_len()
|
|
|
|
{
|
2019-03-07 15:58:39 +01:00
|
|
|
$SED -e 's/, "len": [0-9]\+,/, "len": LEN,/g'
|
2017-04-20 02:54:28 +02:00
|
|
|
}
|
|
|
|
|
2017-10-09 18:34:55 +02:00
|
|
|
# replace actual image size (depends on the host filesystem)
|
|
|
|
_filter_actual_image_size()
|
|
|
|
{
|
2019-03-07 15:58:39 +01:00
|
|
|
$SED -s 's/\("actual-size":\s*\)[0-9]\+/\1SIZE/g'
|
2017-10-09 18:34:55 +02:00
|
|
|
}
|
|
|
|
|
2014-08-19 19:28:58 +02:00
|
|
|
# replace driver-specific options in the "Formatting..." line
|
|
|
|
_filter_img_create()
|
|
|
|
{
|
2019-03-07 15:58:39 +01:00
|
|
|
$SED -e "s#$REMOTE_TEST_DIR#TEST_DIR#g" \
|
2018-05-17 18:33:52 +02:00
|
|
|
-e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \
|
2014-08-19 19:28:58 +02:00
|
|
|
-e "s#$TEST_DIR#TEST_DIR#g" \
|
|
|
|
-e "s#$IMGFMT#IMGFMT#g" \
|
iotests: Add test 197 for covering copy-on-read
Add a test for qcow2 copy-on-read behavior, including exposure
for the just-fixed bugs.
The copy-on-read behavior is always to a qcow2 image, but the
test is careful to allow running with most image protocol/format
combos as the backing file being copied from (luks being the
exception, as it is harder to pass the right secret to all the
right places). In fact, for './check nbd', this appears to be
the first time we've had a qcow2 image wrapping NBD, requiring
an additional line in _filter_img_create to match the similar
line in _filter_img_info.
Invoking blkdebug to prove we don't write too much took some
effort to get working; and it requires that $TEST_WRAP (based
on $TEST_DIR) not be subject to word splitting. We may decide
later to have the entire iotests suite use relative rather than
absolute names, to avoid problems inherited by the absolute
name of $PWD or $TEST_DIR, at which point the sanity check in
this commit could be simplified.
This test requires at least 2G of consecutive memory to succeed;
as such, it is prone to spurious failures, particularly on
32-bit machines under load. This situation is detected and
triggers an early exit to skip the test, rather than a failure.
To manually provoke this setup on a beefier machine, I used:
$ (ulimit -S -v 1000000; ./check -qcow2 197)
Signed-off-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2017-10-05 21:02:48 +02:00
|
|
|
-e 's#nbd:127.0.0.1:10810#TEST_DIR/t.IMGFMT#g' \
|
2014-08-19 19:28:58 +02:00
|
|
|
-e "s# encryption=off##g" \
|
|
|
|
-e "s# cluster_size=[0-9]\\+##g" \
|
|
|
|
-e "s# table_size=[0-9]\\+##g" \
|
2015-07-07 16:42:10 +02:00
|
|
|
-e "s# compat=[^ ]*##g" \
|
2014-08-19 19:28:58 +02:00
|
|
|
-e "s# compat6=\\(on\\|off\\)##g" \
|
|
|
|
-e "s# static=\\(on\\|off\\)##g" \
|
|
|
|
-e "s# zeroed_grain=\\(on\\|off\\)##g" \
|
2019-08-15 17:36:32 +02:00
|
|
|
-e "s# subformat=[^ ]*##g" \
|
|
|
|
-e "s# adapter_type=[^ ]*##g" \
|
2016-05-03 11:43:30 +02:00
|
|
|
-e "s# hwversion=[^ ]*##g" \
|
2014-08-19 19:28:58 +02:00
|
|
|
-e "s# lazy_refcounts=\\(on\\|off\\)##g" \
|
|
|
|
-e "s# block_size=[0-9]\\+##g" \
|
|
|
|
-e "s# block_state_zero=\\(on\\|off\\)##g" \
|
|
|
|
-e "s# log_size=[0-9]\\+##g" \
|
2016-05-10 18:11:28 +02:00
|
|
|
-e "s# refcount_bits=[0-9]\\+##g" \
|
2017-06-26 14:35:08 +02:00
|
|
|
-e "s# key-secret=[a-zA-Z0-9]\\+##g" \
|
2017-12-05 02:08:20 +01:00
|
|
|
-e "s# iter-time=[0-9]\\+##g" \
|
|
|
|
-e "s# force_size=\\(on\\|off\\)##g"
|
2014-08-19 19:28:58 +02:00
|
|
|
}
|
|
|
|
|
2014-09-10 11:05:45 +02:00
|
|
|
_filter_img_info()
|
|
|
|
{
|
2017-11-23 03:08:21 +01:00
|
|
|
if [[ "$1" == "--format-specific" ]]; then
|
|
|
|
local format_specific=1
|
|
|
|
shift
|
|
|
|
else
|
|
|
|
local format_specific=0
|
|
|
|
fi
|
|
|
|
|
|
|
|
discard=0
|
|
|
|
regex_json_spec_start='^ *"format-specific": \{'
|
2019-03-07 15:58:39 +01:00
|
|
|
$SED -e "s#$REMOTE_TEST_DIR#TEST_DIR#g" \
|
2018-05-17 18:33:52 +02:00
|
|
|
-e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \
|
2014-09-10 11:05:45 +02:00
|
|
|
-e "s#$TEST_DIR#TEST_DIR#g" \
|
|
|
|
-e "s#$IMGFMT#IMGFMT#g" \
|
2015-01-27 03:02:58 +01:00
|
|
|
-e 's#nbd://127.0.0.1:10810$#TEST_DIR/t.IMGFMT#g' \
|
2017-04-04 05:48:09 +02:00
|
|
|
-e 's#json.*vdisk-id.*vxhs"}}#TEST_DIR/t.IMGFMT#' \
|
2014-09-10 11:05:45 +02:00
|
|
|
-e "/encrypted: yes/d" \
|
|
|
|
-e "/cluster_size: [0-9]\\+/d" \
|
|
|
|
-e "/table_size: [0-9]\\+/d" \
|
|
|
|
-e "/compat: '[^']*'/d" \
|
|
|
|
-e "/compat6: \\(on\\|off\\)/d" \
|
2018-05-15 17:36:33 +02:00
|
|
|
-e "s/cid: [0-9]\+/cid: XXXXXXXXXX/" \
|
2014-09-10 11:05:45 +02:00
|
|
|
-e "/static: \\(on\\|off\\)/d" \
|
|
|
|
-e "/zeroed_grain: \\(on\\|off\\)/d" \
|
|
|
|
-e "/subformat: '[^']*'/d" \
|
|
|
|
-e "/adapter_type: '[^']*'/d" \
|
2016-05-03 11:43:30 +02:00
|
|
|
-e "/hwversion: '[^']*'/d" \
|
2014-09-10 11:05:45 +02:00
|
|
|
-e "/lazy_refcounts: \\(on\\|off\\)/d" \
|
|
|
|
-e "/block_size: [0-9]\\+/d" \
|
|
|
|
-e "/block_state_zero: \\(on\\|off\\)/d" \
|
2017-11-17 12:29:13 +01:00
|
|
|
-e "/log_size: [0-9]\\+/d" \
|
|
|
|
-e "s/iters: [0-9]\\+/iters: 1024/" \
|
2017-11-23 03:08:21 +01:00
|
|
|
-e "s/uuid: [-a-f0-9]\\+/uuid: 00000000-0000-0000-0000-000000000000/" | \
|
|
|
|
while IFS='' read -r line; do
|
|
|
|
if [[ $format_specific == 1 ]]; then
|
|
|
|
discard=0
|
|
|
|
elif [[ $line == "Format specific information:" ]]; then
|
|
|
|
discard=1
|
|
|
|
elif [[ $line =~ $regex_json_spec_start ]]; then
|
|
|
|
discard=2
|
|
|
|
regex_json_spec_end="^${line%%[^ ]*}\\},? *$"
|
|
|
|
fi
|
|
|
|
if [[ $discard == 0 ]]; then
|
|
|
|
echo "$line"
|
|
|
|
elif [[ $discard == 1 && ! $line ]]; then
|
|
|
|
echo
|
|
|
|
discard=0
|
|
|
|
elif [[ $discard == 2 && $line =~ $regex_json_spec_end ]]; then
|
|
|
|
discard=0
|
|
|
|
fi
|
|
|
|
done
|
2014-09-10 11:05:45 +02:00
|
|
|
}
|
|
|
|
|
iotests: Improve _filter_qemu_img_map
Although _filter_qemu_img_map documents that it scrubs offsets, it
was only doing so for human mode. Of the existing tests using the
filter (97, 122, 150, 154, 176), two of them are affected, but it
does not hurt the validity of the tests to not require particular
mappings (another test, 66, uses offsets but intentionally does not
pass through _filter_qemu_img_map, because it checks that offsets
are unchanged before and after an operation).
Another justification for this patch is that it will allow a future
patch to utilize 'qemu-img map --output=json' to check the status of
preallocated zero clusters without regards to the mapping (since
the qcow2 mapping can be very sensitive to the chosen cluster size,
when preallocation is not in use).
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-id: 20170507000552.20847-9-eblake@redhat.com
Signed-off-by: Max Reitz <mreitz@redhat.com>
2017-05-07 02:05:48 +02:00
|
|
|
# filter out offsets and file names from qemu-img map; good for both
|
|
|
|
# human and json output
|
2014-10-24 15:57:41 +02:00
|
|
|
_filter_qemu_img_map()
|
|
|
|
{
|
2019-03-07 15:58:39 +01:00
|
|
|
$SED -e 's/\([0-9a-fx]* *[0-9a-fx]* *\)[0-9a-fx]* */\1/g' \
|
iotests: Improve _filter_qemu_img_map
Although _filter_qemu_img_map documents that it scrubs offsets, it
was only doing so for human mode. Of the existing tests using the
filter (97, 122, 150, 154, 176), two of them are affected, but it
does not hurt the validity of the tests to not require particular
mappings (another test, 66, uses offsets but intentionally does not
pass through _filter_qemu_img_map, because it checks that offsets
are unchanged before and after an operation).
Another justification for this patch is that it will allow a future
patch to utilize 'qemu-img map --output=json' to check the status of
preallocated zero clusters without regards to the mapping (since
the qcow2 mapping can be very sensitive to the chosen cluster size,
when preallocation is not in use).
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-id: 20170507000552.20847-9-eblake@redhat.com
Signed-off-by: Max Reitz <mreitz@redhat.com>
2017-05-07 02:05:48 +02:00
|
|
|
-e 's/"offset": [0-9]\+/"offset": OFFSET/g' \
|
2014-10-24 15:57:41 +02:00
|
|
|
-e 's/Mapped to *//' | _filter_testdir | _filter_imgfmt
|
|
|
|
}
|
|
|
|
|
2016-01-25 19:41:11 +01:00
|
|
|
_filter_nbd()
|
|
|
|
{
|
|
|
|
# nbd.c error messages contain function names and line numbers that are
|
|
|
|
# prone to change. Message ordering depends on timing between send and
|
|
|
|
# receive callbacks sometimes, making them unreliable.
|
|
|
|
#
|
|
|
|
# Filter out the TCP port number since this changes between runs.
|
2019-03-07 15:58:39 +01:00
|
|
|
$SED -e '/nbd\/.*\.c:/d' \
|
2017-08-29 14:27:45 +02:00
|
|
|
-e 's#127\.0\.0\.1:[0-9]*#127.0.0.1:PORT#g' \
|
2016-01-25 19:41:13 +01:00
|
|
|
-e "s#?socket=$TEST_DIR#?socket=TEST_DIR#g" \
|
2017-08-29 14:27:45 +02:00
|
|
|
-e 's#\(foo\|PORT/\?\|.sock\): Failed to .*$#\1#'
|
2016-01-25 19:41:11 +01:00
|
|
|
}
|
|
|
|
|
2019-08-09 20:52:53 +02:00
|
|
|
_filter_qmp_empty_return()
|
|
|
|
{
|
|
|
|
grep -v '{"return": {}}'
|
|
|
|
}
|
|
|
|
|
2009-06-22 18:29:05 +02:00
|
|
|
# make sure this script returns success
|
2015-01-04 02:53:48 +01:00
|
|
|
true
|