2010-04-26 09:44:05 +00:00
|
|
|
#!/bin/bash
|
2009-06-22 16:29:05 +00: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 17:26:54 +00:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2009-06-22 16:29:05 +00:00
|
|
|
#
|
|
|
|
#
|
|
|
|
# standard filters
|
|
|
|
#
|
|
|
|
|
|
|
|
# ctime(3) dates
|
|
|
|
#
|
|
|
|
_filter_date()
|
|
|
|
{
|
|
|
|
sed \
|
2013-09-04 11:16:04 +00: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 16:29:05 +00:00
|
|
|
}
|
|
|
|
|
2015-10-12 23:36:50 +00:00
|
|
|
_filter_generated_node_ids()
|
|
|
|
{
|
|
|
|
sed -re 's/\#block[0-9]{3,}/NODE_NAME/'
|
|
|
|
}
|
|
|
|
|
2010-11-24 16:12:21 +00:00
|
|
|
# replace occurrences of the actual TEST_DIR value with TEST_DIR
|
2009-06-22 16:29:05 +00:00
|
|
|
_filter_testdir()
|
|
|
|
{
|
2016-12-16 05:47:23 +00:00
|
|
|
sed -e "s#$TEST_DIR/#TEST_DIR/#g"
|
2009-06-22 16:29:05 +00:00
|
|
|
}
|
|
|
|
|
2010-11-24 16:12:21 +00:00
|
|
|
# replace occurrences of the actual IMGFMT value with IMGFMT
|
|
|
|
_filter_imgfmt()
|
|
|
|
{
|
|
|
|
sed -e "s#$IMGFMT#IMGFMT#g"
|
|
|
|
}
|
|
|
|
|
2016-08-10 02:43:12 +00:00
|
|
|
# Replace error message when the format is not supported and delete
|
|
|
|
# the output lines after the first one
|
|
|
|
_filter_qemu_img_check()
|
|
|
|
{
|
|
|
|
sed -e '/allocated.*fragmented.*compressed clusters/d' \
|
|
|
|
-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 13:30:25 +00:00
|
|
|
# Removes \r from messages
|
|
|
|
_filter_win32()
|
|
|
|
{
|
|
|
|
sed -e 's/\r//g'
|
|
|
|
}
|
|
|
|
|
2009-06-22 16:29:05 +00:00
|
|
|
# sanitize qemu-io output
|
|
|
|
_filter_qemu_io()
|
|
|
|
{
|
2013-11-18 07:13:01 +00: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 09:48:11 +00:00
|
|
|
-e "s/: line [0-9][0-9]*: *[0-9][0-9]*\( Aborted\| Killed\)/:\1/" \
|
2013-11-18 07:13:01 +00:00
|
|
|
-e "s/qemu-io> //g"
|
2009-06-22 16:29:05 +00:00
|
|
|
}
|
|
|
|
|
2013-04-15 08:15:17 +00:00
|
|
|
# replace occurrences of QEMU_PROG with "qemu"
|
|
|
|
_filter_qemu()
|
|
|
|
{
|
2013-08-05 12:40:34 +00:00
|
|
|
sed -e "s#\\(^\\|(qemu) \\)$(basename $QEMU_PROG):#\1QEMU_PROG:#" \
|
2013-11-14 14:24:58 +00:00
|
|
|
-e 's#^QEMU [0-9]\+\.[0-9]\+\.[0-9]\+ monitor#QEMU X.Y.Z monitor#' \
|
2014-12-19 16:17:06 +00:00
|
|
|
-e '/main-loop: WARNING: I\/O thread spun for [0-9]\+ iterations/d' \
|
2013-11-14 14:24:58 +00:00
|
|
|
-e $'s#\r##' # QEMU monitor uses \r\n line endings
|
2013-04-15 08:15:17 +00:00
|
|
|
}
|
|
|
|
|
2013-09-18 14:47:41 +00:00
|
|
|
# replace problematic QMP output like timestamps
|
|
|
|
_filter_qmp()
|
|
|
|
{
|
|
|
|
_filter_win32 | \
|
|
|
|
sed -e 's#\("\(micro\)\?seconds": \)[0-9]\+#\1 TIMESTAMP#g' \
|
2014-11-17 12:31:05 +00:00
|
|
|
-e 's#^{"QMP":.*}$#QMP_VERSION#' \
|
|
|
|
-e '/^ "QMP": {\s*$/, /^ }\s*$/ c\' \
|
|
|
|
-e ' QMP_VERSION'
|
2013-09-18 14:47:41 +00:00
|
|
|
}
|
|
|
|
|
2017-04-13 17:19:51 +00:00
|
|
|
# readline makes HMP command strings so long that git complains
|
|
|
|
_filter_hmp()
|
|
|
|
{
|
|
|
|
sed -e $'s/^\\((qemu) \\)\\?.*\e\\[D/\\1/g' \
|
|
|
|
-e $'s/\e\\[K//g'
|
|
|
|
}
|
|
|
|
|
2016-08-03 12:56:45 +00:00
|
|
|
# replace block job offset
|
|
|
|
_filter_block_job_offset()
|
|
|
|
{
|
|
|
|
sed -e 's/, "offset": [0-9]\+,/, "offset": OFFSET,/'
|
|
|
|
}
|
|
|
|
|
2017-04-20 00:54:28 +00:00
|
|
|
# replace block job len
|
|
|
|
_filter_block_job_len()
|
|
|
|
{
|
|
|
|
sed -e 's/, "len": [0-9]\+,/, "len": LEN,/g'
|
|
|
|
}
|
|
|
|
|
2017-10-09 16:34:55 +00:00
|
|
|
# replace actual image size (depends on the host filesystem)
|
|
|
|
_filter_actual_image_size()
|
|
|
|
{
|
|
|
|
sed -s 's/\("actual-size":\s*\)[0-9]\+/\1SIZE/g'
|
|
|
|
}
|
|
|
|
|
2014-08-19 17:28:58 +00:00
|
|
|
# replace driver-specific options in the "Formatting..." line
|
|
|
|
_filter_img_create()
|
|
|
|
{
|
|
|
|
sed -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \
|
|
|
|
-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 19:02:48 +00:00
|
|
|
-e 's#nbd:127.0.0.1:10810#TEST_DIR/t.IMGFMT#g' \
|
2014-08-19 17:28:58 +00:00
|
|
|
-e "s# encryption=off##g" \
|
|
|
|
-e "s# cluster_size=[0-9]\\+##g" \
|
|
|
|
-e "s# table_size=[0-9]\\+##g" \
|
2015-07-07 14:42:10 +00:00
|
|
|
-e "s# compat=[^ ]*##g" \
|
2014-08-19 17:28:58 +00:00
|
|
|
-e "s# compat6=\\(on\\|off\\)##g" \
|
|
|
|
-e "s# static=\\(on\\|off\\)##g" \
|
|
|
|
-e "s# zeroed_grain=\\(on\\|off\\)##g" \
|
|
|
|
-e "s# subformat='[^']*'##g" \
|
|
|
|
-e "s# adapter_type='[^']*'##g" \
|
2016-05-03 09:43:30 +00:00
|
|
|
-e "s# hwversion=[^ ]*##g" \
|
2014-08-19 17:28:58 +00: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 16:11:28 +00:00
|
|
|
-e "s# refcount_bits=[0-9]\\+##g" \
|
2017-06-26 12:35:08 +00:00
|
|
|
-e "s# key-secret=[a-zA-Z0-9]\\+##g" \
|
2017-12-05 01:08:20 +00:00
|
|
|
-e "s# iter-time=[0-9]\\+##g" \
|
|
|
|
-e "s# force_size=\\(on\\|off\\)##g"
|
2014-08-19 17:28:58 +00:00
|
|
|
}
|
|
|
|
|
2014-09-10 09:05:45 +00:00
|
|
|
_filter_img_info()
|
|
|
|
{
|
2017-11-23 02:08:21 +00: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": \{'
|
2014-09-10 09:05:45 +00:00
|
|
|
sed -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \
|
|
|
|
-e "s#$TEST_DIR#TEST_DIR#g" \
|
|
|
|
-e "s#$IMGFMT#IMGFMT#g" \
|
2015-01-27 02:02:58 +00:00
|
|
|
-e 's#nbd://127.0.0.1:10810$#TEST_DIR/t.IMGFMT#g' \
|
2017-04-04 03:48:09 +00:00
|
|
|
-e 's#json.*vdisk-id.*vxhs"}}#TEST_DIR/t.IMGFMT#' \
|
2014-09-10 09:05:45 +00: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" \
|
|
|
|
-e "/static: \\(on\\|off\\)/d" \
|
|
|
|
-e "/zeroed_grain: \\(on\\|off\\)/d" \
|
|
|
|
-e "/subformat: '[^']*'/d" \
|
|
|
|
-e "/adapter_type: '[^']*'/d" \
|
2016-05-03 09:43:30 +00:00
|
|
|
-e "/hwversion: '[^']*'/d" \
|
2014-09-10 09:05:45 +00:00
|
|
|
-e "/lazy_refcounts: \\(on\\|off\\)/d" \
|
|
|
|
-e "/block_size: [0-9]\\+/d" \
|
|
|
|
-e "/block_state_zero: \\(on\\|off\\)/d" \
|
2017-11-17 11:29:13 +00:00
|
|
|
-e "/log_size: [0-9]\\+/d" \
|
|
|
|
-e "s/iters: [0-9]\\+/iters: 1024/" \
|
2017-11-23 02:08:21 +00: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 09:05:45 +00: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 00:05:48 +00:00
|
|
|
# filter out offsets and file names from qemu-img map; good for both
|
|
|
|
# human and json output
|
2014-10-24 13:57:41 +00:00
|
|
|
_filter_qemu_img_map()
|
|
|
|
{
|
|
|
|
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 00:05:48 +00:00
|
|
|
-e 's/"offset": [0-9]\+/"offset": OFFSET/g' \
|
2014-10-24 13:57:41 +00:00
|
|
|
-e 's/Mapped to *//' | _filter_testdir | _filter_imgfmt
|
|
|
|
}
|
|
|
|
|
2016-01-25 18:41:11 +00: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.
|
2016-01-25 18:41:12 +00:00
|
|
|
sed -e '/nbd\/.*\.c:/d' \
|
2017-08-29 12:27:45 +00:00
|
|
|
-e 's#127\.0\.0\.1:[0-9]*#127.0.0.1:PORT#g' \
|
2016-01-25 18:41:13 +00:00
|
|
|
-e "s#?socket=$TEST_DIR#?socket=TEST_DIR#g" \
|
2017-08-29 12:27:45 +00:00
|
|
|
-e 's#\(foo\|PORT/\?\|.sock\): Failed to .*$#\1#'
|
2016-01-25 18:41:11 +00:00
|
|
|
}
|
|
|
|
|
2009-06-22 16:29:05 +00:00
|
|
|
# make sure this script returns success
|
2015-01-04 01:53:48 +00:00
|
|
|
true
|