111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash
26bf19c94SChristoph Hellwig#
343074635SEric Blake# Copyright Red Hat
46bf19c94SChristoph Hellwig# Copyright (c) 2000-2001 Silicon Graphics, Inc.  All Rights Reserved.
56bf19c94SChristoph Hellwig#
66bf19c94SChristoph Hellwig# This program is free software; you can redistribute it and/or
76bf19c94SChristoph Hellwig# modify it under the terms of the GNU General Public License as
86bf19c94SChristoph Hellwig# published by the Free Software Foundation.
96bf19c94SChristoph Hellwig#
106bf19c94SChristoph Hellwig# This program is distributed in the hope that it would be useful,
116bf19c94SChristoph Hellwig# but WITHOUT ANY WARRANTY; without even the implied warranty of
126bf19c94SChristoph Hellwig# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
136bf19c94SChristoph Hellwig# GNU General Public License for more details.
146bf19c94SChristoph Hellwig#
156bf19c94SChristoph Hellwig# You should have received a copy of the GNU General Public License
16e8c212d6SChristoph Hellwig# along with this program.  If not, see <http://www.gnu.org/licenses/>.
176bf19c94SChristoph Hellwig#
186bf19c94SChristoph Hellwig#
196bf19c94SChristoph Hellwig# standard filters
206bf19c94SChristoph Hellwig#
216bf19c94SChristoph Hellwig
226bf19c94SChristoph Hellwig_filter_date()
236bf19c94SChristoph Hellwig{
249086c763SThomas Huth    sed -Ee 's/[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/yyyy-mm-dd hh:mm:ss/'
2592b22e7bSKevin Wolf}
2692b22e7bSKevin Wolf
2792b22e7bSKevin Wolf_filter_vmstate_size()
2892b22e7bSKevin Wolf{
299086c763SThomas Huth    sed -E -e 's/[0-9. ]{5} [KMGT]iB/     SIZE/' \
3092b22e7bSKevin Wolf           -e 's/[0-9. ]{5} B/   SIZE/'
316bf19c94SChristoph Hellwig}
326bf19c94SChristoph Hellwig
3315489c76SJeff Cody_filter_generated_node_ids()
3415489c76SJeff Cody{
359086c763SThomas Huth    sed -Ee 's/\#block[0-9]{3,}/NODE_NAME/'
3615489c76SJeff Cody}
3715489c76SJeff Cody
38627f607eSAlberto Garcia_filter_qom_path()
39627f607eSAlberto Garcia{
409086c763SThomas Huth    gsed -e '/Attached to:/s/\device[[0-9]\+\]/device[N]/g'
41627f607eSAlberto Garcia}
42627f607eSAlberto Garcia
4362284d17SStefan Hajnoczi# replace occurrences of the actual TEST_DIR value with TEST_DIR
446bf19c94SChristoph Hellwig_filter_testdir()
456bf19c94SChristoph Hellwig{
469086c763SThomas Huth    sed -e "s#$TEST_DIR/#TEST_DIR/#g" \
47f96ac06bSMax Reitz        -e "s#$SOCK_DIR/#SOCK_DIR/#g" \
48f96ac06bSMax Reitz        -e "s#SOCK_DIR/fuse-#TEST_DIR/#g"
496bf19c94SChristoph Hellwig}
506bf19c94SChristoph Hellwig
5162284d17SStefan Hajnoczi# replace occurrences of the actual IMGFMT value with IMGFMT
5262284d17SStefan Hajnoczi_filter_imgfmt()
5362284d17SStefan Hajnoczi{
549086c763SThomas Huth    sed -e "s#$IMGFMT#IMGFMT#g"
5562284d17SStefan Hajnoczi}
5662284d17SStefan Hajnoczi
5786ce1f6eSReda Sallahi# Replace error message when the format is not supported and delete
5886ce1f6eSReda Sallahi# the output lines after the first one
5986ce1f6eSReda Sallahi_filter_qemu_img_check()
6086ce1f6eSReda Sallahi{
619086c763SThomas Huth    gsed -e '/allocated.*fragmented.*compressed clusters/d' \
6286ce1f6eSReda Sallahi        -e 's/qemu-img: This image format does not support checks/No errors were found on the image./' \
6386ce1f6eSReda Sallahi        -e '/Image end offset: [0-9]\+/d'
6486ce1f6eSReda Sallahi}
6586ce1f6eSReda Sallahi
66a06d5cc2SKevin Wolf# Removes \r from messages
67a06d5cc2SKevin Wolf_filter_win32()
68a06d5cc2SKevin Wolf{
699086c763SThomas Huth    gsed -e 's/\r//g'
70a06d5cc2SKevin Wolf}
71a06d5cc2SKevin Wolf
726bf19c94SChristoph Hellwig# sanitize qemu-io output
736bf19c94SChristoph Hellwig_filter_qemu_io()
746bf19c94SChristoph Hellwig{
759086c763SThomas Huth    _filter_win32 | \
769086c763SThomas Huth    gsed -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)/" \
779e0c3e8dSMax Reitz        -e "s/: line [0-9][0-9]*:  *[0-9][0-9]*\( Aborted\| Killed\)/:\1/" \
78c34b8012SFam Zheng        -e "s/qemu-io> //g"
796bf19c94SChristoph Hellwig}
806bf19c94SChristoph Hellwig
81c09b437bSStefan Hajnoczi# replace occurrences of QEMU_PROG with "qemu"
82c09b437bSStefan Hajnoczi_filter_qemu()
83c09b437bSStefan Hajnoczi{
849086c763SThomas Huth    gsed -e "s#\\(^\\|(qemu) \\)$(basename $QEMU_PROG):#\1QEMU_PROG:#" \
85ac9524dcSStefan Hajnoczi        -e 's#^QEMU [0-9]\+\.[0-9]\+\.[0-9]\+ monitor#QEMU X.Y.Z monitor#' \
86ac9524dcSStefan Hajnoczi        -e $'s#\r##' # QEMU monitor uses \r\n line endings
87c09b437bSStefan Hajnoczi}
88c09b437bSStefan Hajnoczi
89a9b43397SKevin Wolf# replace problematic QMP output like timestamps
90a9b43397SKevin Wolf_filter_qmp()
91a9b43397SKevin Wolf{
92a9b43397SKevin Wolf    _filter_win32 | \
939086c763SThomas Huth    gsed -e 's#\("\(micro\)\?seconds": \)[0-9]\+#\1 TIMESTAMP#g' \
94cc20b07aSMax Reitz        -e 's#^{"QMP":.*}$#QMP_VERSION#' \
95cc20b07aSMax Reitz        -e '/^    "QMP": {\s*$/, /^    }\s*$/ c\' \
96cc20b07aSMax Reitz        -e '    QMP_VERSION'
97a9b43397SKevin Wolf}
98a9b43397SKevin Wolf
9969404d9eSKevin Wolf# readline makes HMP command strings so long that git complains
10069404d9eSKevin Wolf_filter_hmp()
10169404d9eSKevin Wolf{
1029086c763SThomas Huth    gsed -e $'s/^\\((qemu) \\)\\?.*\e\\[D/\\1/g' \
10369404d9eSKevin Wolf        -e $'s/\e\\[K//g'
10469404d9eSKevin Wolf}
10569404d9eSKevin Wolf
106a752e478SVladimir Sementsov-Ogievskiy# replace block job offset
107a752e478SVladimir Sementsov-Ogievskiy_filter_block_job_offset()
108a752e478SVladimir Sementsov-Ogievskiy{
109ab101297SThomas Huth    gsed -e 's/, "offset": [0-9]\+,/, "offset": OFFSET,/'
110a752e478SVladimir Sementsov-Ogievskiy}
111a752e478SVladimir Sementsov-Ogievskiy
11224dfdfd0SFam Zheng# replace block job len
11324dfdfd0SFam Zheng_filter_block_job_len()
11424dfdfd0SFam Zheng{
115ab101297SThomas Huth    gsed -e 's/, "len": [0-9]\+,/, "len": LEN,/g'
11624dfdfd0SFam Zheng}
11724dfdfd0SFam Zheng
11844673a0bSMax Reitz# replace actual image size (depends on the host filesystem)
11944673a0bSMax Reitz_filter_actual_image_size()
12044673a0bSMax Reitz{
1219086c763SThomas Huth    gsed -s 's/\("actual-size":\s*\)[0-9]\+/\1SIZE/g'
12244673a0bSMax Reitz}
12344673a0bSMax Reitz
1244b196cd1SMax Reitz# Filename filters for qemu-img create
1254b196cd1SMax Reitz_filter_img_create_filenames()
1264b196cd1SMax Reitz{
1279086c763SThomas Huth    sed \
1284b196cd1SMax Reitz        -e "s#$REMOTE_TEST_DIR#TEST_DIR#g" \
1294b196cd1SMax Reitz        -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \
1304b196cd1SMax Reitz        -e "s#$TEST_DIR#TEST_DIR#g" \
1314b196cd1SMax Reitz        -e "s#$SOCK_DIR#SOCK_DIR#g" \
132f96ac06bSMax Reitz        -e 's#SOCK_DIR/fuse-#TEST_DIR/#g' \
1334b196cd1SMax Reitz        -e "s#$IMGFMT#IMGFMT#g" \
1344b196cd1SMax Reitz        -e 's#nbd+unix:///\??socket=SOCK_DIR/nbd#TEST_DIR/t.IMGFMT#g'
1354b196cd1SMax Reitz}
1364b196cd1SMax Reitz
1376ffb4cb6SKevin Wolf# replace driver-specific options in the "Formatting..." line
1384b196cd1SMax Reitz_do_filter_img_create()
1396ffb4cb6SKevin Wolf{
14057ee95edSMax Reitz    # Split the line into the pre-options part ($filename_part, which
14157ee95edSMax Reitz    # precedes ", fmt=") and the options part ($options, which starts
14257ee95edSMax Reitz    # with "fmt=")
14357ee95edSMax Reitz    # (And just echo everything before the first "^Formatting")
1449086c763SThomas Huth    readarray formatting_line < <(gsed -e 's/, fmt=/\n/')
14557ee95edSMax Reitz
1464b196cd1SMax Reitz    filename_part=${formatting_line[0]}
1474b196cd1SMax Reitz    unset formatting_line[0]
14857ee95edSMax Reitz
14957ee95edSMax Reitz    options="fmt=${formatting_line[@]}"
15057ee95edSMax Reitz
15157ee95edSMax Reitz    # Set grep_data_file to '\|data_file' to keep it; make it empty
15257ee95edSMax Reitz    # to drop it.
15357ee95edSMax Reitz    # We want to drop it if it is part of the global $IMGOPTS, and we
15457ee95edSMax Reitz    # want to keep it otherwise (if the test specifically wants to
15557ee95edSMax Reitz    # test data files).
15657ee95edSMax Reitz    grep_data_file=(-e data_file)
15757ee95edSMax Reitz    if _get_data_file "$TEST_IMG" > /dev/null; then
15857ee95edSMax Reitz        grep_data_file=()
1591b35b85aSMax Reitz    fi
1601b35b85aSMax Reitz
1614b196cd1SMax Reitz    filename_part=$(echo "$filename_part" | _filter_img_create_filenames)
16257ee95edSMax Reitz
16357ee95edSMax Reitz    # Break the option line before each option (preserving pre-existing
16457ee95edSMax Reitz    # line breaks by replacing them by \0 and restoring them at the end),
16557ee95edSMax Reitz    # then filter out the options we want to keep and sort them according
16657ee95edSMax Reitz    # to some order that all block drivers used at the time of writing
16757ee95edSMax Reitz    # this function.
16857ee95edSMax Reitz    options=$(
16957ee95edSMax Reitz        echo "$options" \
17057ee95edSMax Reitz        | tr '\n' '\0' \
1719086c763SThomas Huth        | gsed -e 's/ \([a-z0-9_.-]*\)=/\n\1=/g' \
17257ee95edSMax Reitz        | grep -a -e '^fmt' -e '^size' -e '^backing' -e '^preallocation' \
173cbb32e79SMaxim Levitsky                  -e '^encryption' "${grep_data_file[@]}" \
1744b196cd1SMax Reitz        | _filter_img_create_filenames \
1759086c763SThomas Huth        | sed \
17657ee95edSMax Reitz            -e 's/^\(fmt\)/0-\1/' \
17757ee95edSMax Reitz            -e 's/^\(size\)/1-\1/' \
17857ee95edSMax Reitz            -e 's/^\(backing\)/2-\1/' \
17957ee95edSMax Reitz            -e 's/^\(data_file\)/3-\1/' \
18057ee95edSMax Reitz            -e 's/^\(encryption\)/4-\1/' \
18157ee95edSMax Reitz            -e 's/^\(preallocation\)/8-\1/' \
1824a40f561SMax Reitz        | LC_ALL=C sort \
1839086c763SThomas Huth        | sed -e 's/^[0-9]-//' \
18457ee95edSMax Reitz        | tr '\n\0' ' \n' \
1859086c763SThomas Huth        | sed -e 's/^ *$//' -e 's/ *$//'
18657ee95edSMax Reitz    )
18757ee95edSMax Reitz
18857ee95edSMax Reitz    if [ -n "$options" ]; then
18957ee95edSMax Reitz        echo "$filename_part, $options"
19057ee95edSMax Reitz    elif [ -n "$filename_part" ]; then
19157ee95edSMax Reitz        echo "$filename_part"
19257ee95edSMax Reitz    fi
19357ee95edSMax Reitz}
19457ee95edSMax Reitz
1954b196cd1SMax Reitz# Filter qemu-img create output:
1964b196cd1SMax Reitz# Pipe all ^Formatting lines through _do_filter_img_create, and all
1974b196cd1SMax Reitz# other lines through _filter_img_create_filenames
1984b196cd1SMax Reitz_filter_img_create()
19957ee95edSMax Reitz{
20057ee95edSMax Reitz    while read -r line; do
20157ee95edSMax Reitz        if echo "$line" | grep -q '^Formatting'; then
2024b196cd1SMax Reitz            echo "$line" | _do_filter_img_create
20357ee95edSMax Reitz        else
2044b196cd1SMax Reitz            echo "$line" | _filter_img_create_filenames
20557ee95edSMax Reitz        fi
20657ee95edSMax Reitz    done
2076ffb4cb6SKevin Wolf}
2086ffb4cb6SKevin Wolf
209ffa41a62SKevin Wolf_filter_img_create_size()
210ffa41a62SKevin Wolf{
2119086c763SThomas Huth    gsed -e "s# size=[0-9]\\+# size=SIZE#g"
212ffa41a62SKevin Wolf}
213ffa41a62SKevin Wolf
214c2eb918eSHu Tao_filter_img_info()
215c2eb918eSHu Tao{
2161cc6169bSMax Reitz    if [[ "$1" == "--format-specific" ]]; then
2171cc6169bSMax Reitz        local format_specific=1
2181cc6169bSMax Reitz        shift
2191cc6169bSMax Reitz    else
2201cc6169bSMax Reitz        local format_specific=0
2211cc6169bSMax Reitz    fi
2221cc6169bSMax Reitz
2231cc6169bSMax Reitz    discard=0
2241cc6169bSMax Reitz    regex_json_spec_start='^ *"format-specific": \{'
225bcc6777aSHanna Reitz    regex_json_child_start='^ *"children": \['
2269086c763SThomas Huth    gsed -e "s#$REMOTE_TEST_DIR#TEST_DIR#g" \
2278908b253SKevin Wolf        -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \
228c2eb918eSHu Tao        -e "s#$TEST_DIR#TEST_DIR#g" \
229dc48bfdfSMax Reitz        -e "s#$SOCK_DIR#SOCK_DIR#g" \
230c2eb918eSHu Tao        -e "s#$IMGFMT#IMGFMT#g" \
231f3923a72SEric Blake        -e 's#nbd+unix:///\??socket=SOCK_DIR/nbd#TEST_DIR/t.IMGFMT#g' \
232f96ac06bSMax Reitz        -e 's#SOCK_DIR/fuse-#TEST_DIR/#g' \
233c2eb918eSHu Tao        -e "/encrypted: yes/d" \
234c2eb918eSHu Tao        -e "/cluster_size: [0-9]\\+/d" \
235c2eb918eSHu Tao        -e "/table_size: [0-9]\\+/d" \
236c2eb918eSHu Tao        -e "/compat: '[^']*'/d" \
237c2eb918eSHu Tao        -e "/compat6: \\(on\\|off\\)/d" \
238bab4feb2SFam Zheng        -e "s/cid: [0-9]\+/cid: XXXXXXXXXX/" \
239c2eb918eSHu Tao        -e "/static: \\(on\\|off\\)/d" \
240c2eb918eSHu Tao        -e "/zeroed_grain: \\(on\\|off\\)/d" \
241c2eb918eSHu Tao        -e "/subformat: '[^']*'/d" \
242c2eb918eSHu Tao        -e "/adapter_type: '[^']*'/d" \
243f249924eSJanne Karhunen        -e "/hwversion: '[^']*'/d" \
244c2eb918eSHu Tao        -e "/lazy_refcounts: \\(on\\|off\\)/d" \
2457be20252SAlberto Garcia        -e "/extended_l2=\\(on\\|off\\)/d" \
246c2eb918eSHu Tao        -e "/block_size: [0-9]\\+/d" \
247c2eb918eSHu Tao        -e "/block_state_zero: \\(on\\|off\\)/d" \
248f0603329SDaniel P. Berrange        -e "/log_size: [0-9]\\+/d" \
249f0603329SDaniel P. Berrange        -e "s/iters: [0-9]\\+/iters: 1024/" \
250dba5aee4SVladimir Sementsov-Ogievskiy        -e 's/\(compression type: \)\(zlib\|zstd\)/\1COMPRESSION_TYPE/' \
2511cc6169bSMax Reitz        -e "s/uuid: [-a-f0-9]\\+/uuid: 00000000-0000-0000-0000-000000000000/" | \
2521cc6169bSMax Reitz    while IFS='' read -r line; do
253bcc6777aSHanna Reitz        if [[ $discard == 0 ]]; then
254bcc6777aSHanna Reitz            if [[ $format_specific == 0 && $line == "Format specific information:" ]]; then
255bcc6777aSHanna Reitz                discard=1
256bcc6777aSHanna Reitz            elif [[ $line =~ "Child node '/" ]]; then
2571cc6169bSMax Reitz                discard=1
2581cc6169bSMax Reitz            elif [[ $line =~ $regex_json_spec_start ]]; then
2591cc6169bSMax Reitz                discard=2
260bcc6777aSHanna Reitz                regex_json_end="^${line%%[^ ]*}\\},? *$"
261bcc6777aSHanna Reitz            elif [[ $line =~ $regex_json_child_start ]]; then
262bcc6777aSHanna Reitz                discard=2
263bcc6777aSHanna Reitz                regex_json_end="^${line%%[^ ]*}\\],? *$"
264bcc6777aSHanna Reitz            fi
2651cc6169bSMax Reitz        fi
2661cc6169bSMax Reitz        if [[ $discard == 0 ]]; then
2671cc6169bSMax Reitz            echo "$line"
2681cc6169bSMax Reitz        elif [[ $discard == 1 && ! $line ]]; then
2691cc6169bSMax Reitz            echo
2701cc6169bSMax Reitz            discard=0
271bcc6777aSHanna Reitz        elif [[ $discard == 2 && $line =~ $regex_json_end ]]; then
2721cc6169bSMax Reitz            discard=0
2731cc6169bSMax Reitz        fi
2741cc6169bSMax Reitz    done
275c2eb918eSHu Tao}
276c2eb918eSHu Tao
277d9ca2214SEric Blake# filter out offsets and file names from qemu-img map; good for both
278d9ca2214SEric Blake# human and json output
279f67ac71eSMax Reitz_filter_qemu_img_map()
280f67ac71eSMax Reitz{
2811b35b85aSMax Reitz    # Assuming the data_file value in $IMGOPTS contains a '$TEST_IMG',
2821b35b85aSMax Reitz    # create a filter that replaces the data file name by $TEST_IMG.
2831b35b85aSMax Reitz    # Example:
2841b35b85aSMax Reitz    #   In $IMGOPTS: 'data_file=$TEST_IMG.data_file'
2851b35b85aSMax Reitz    #   Then data_file_pattern == '\(.*\).data_file'
2861b35b85aSMax Reitz    #   And  data_file_filter  == -e 's#\(.*\).data_file#\1#
2871b35b85aSMax Reitz    data_file_filter=()
2881b35b85aSMax Reitz    if data_file_pattern=$(_get_data_file '\\(.*\\)'); then
2891b35b85aSMax Reitz        data_file_filter=(-e "s#$data_file_pattern#\\1#")
2901b35b85aSMax Reitz    fi
2911b35b85aSMax Reitz
2929086c763SThomas Huth    sed -e 's/\([0-9a-fx]* *[0-9a-fx]* *\)[0-9a-fx]* */\1/g' \
293d9ca2214SEric Blake        -e 's/"offset": [0-9]\+/"offset": OFFSET/g' \
2941b35b85aSMax Reitz        -e 's/Mapped to *//' \
2951b35b85aSMax Reitz        "${data_file_filter[@]}" \
2961b35b85aSMax Reitz        | _filter_testdir | _filter_imgfmt
297f67ac71eSMax Reitz}
298f67ac71eSMax Reitz
29960d44688SMax Reitz_filter_nbd()
30060d44688SMax Reitz{
30160d44688SMax Reitz    # nbd.c error messages contain function names and line numbers that are
30260d44688SMax Reitz    # prone to change.  Message ordering depends on timing between send and
30360d44688SMax Reitz    # receive callbacks sometimes, making them unreliable.
30460d44688SMax Reitz    #
30560d44688SMax Reitz    # Filter out the TCP port number since this changes between runs.
3069086c763SThomas Huth    sed -e '/nbd\/.*\.c:/d' \
30702d2d860SStefan Hajnoczi        -e 's#127\.0\.0\.1:[0-9]*#127.0.0.1:PORT#g' \
3087470bf87SDaniel P. Berrangé        -e 's#localhost:[0-9]*#localhost:PORT#g' \
3097470bf87SDaniel P. Berrangé        -e 's#host=127\.0\.0\.1,port=[0-9]*#host=127.0.0.1,port=PORT#g' \
3107470bf87SDaniel P. Berrangé        -e 's#host=localhost,port=[0-9]*#host=localhost,port=PORT#g' \
3117470bf87SDaniel P. Berrangé        -e "s#path=$SOCK_DIR#path=SOCK_DIR#g" \
312dc48bfdfSMax Reitz        -e "s#?socket=$SOCK_DIR#?socket=SOCK_DIR#g" \
31302d2d860SStefan Hajnoczi        -e 's#\(foo\|PORT/\?\|.sock\): Failed to .*$#\1#'
31460d44688SMax Reitz}
31560d44688SMax Reitz
3169960fda9SDaniel P. Berrangé_filter_qemu_nbd_exports()
3179960fda9SDaniel P. Berrangé{
3189960fda9SDaniel P. Berrangé    grep '\(exports available\|export\|size\|min block\|qemu-nbd\):'
3199960fda9SDaniel P. Berrangé}
3209960fda9SDaniel P. Berrangé
3219c46f4a0SMax Reitz_filter_qmp_empty_return()
3229c46f4a0SMax Reitz{
3239c46f4a0SMax Reitz    grep -v '{"return": {}}'
3249c46f4a0SMax Reitz}
3259c46f4a0SMax Reitz
326a75b7b57SMax Reitz_filter_json_filename()
327a75b7b57SMax Reitz{
328a75b7b57SMax Reitz    $PYTHON -c 'import sys
329a75b7b57SMax Reitzresult, *fnames = sys.stdin.read().split("json:{")
330a75b7b57SMax Reitzdepth = 0
331a75b7b57SMax Reitzfor fname in fnames:
332a75b7b57SMax Reitz    depth += 1 # For the opening brace in the split separator
333a75b7b57SMax Reitz    for chr_i, chr in enumerate(fname):
334a75b7b57SMax Reitz        if chr == "{":
335a75b7b57SMax Reitz            depth += 1
336a75b7b57SMax Reitz        elif chr == "}":
337a75b7b57SMax Reitz            depth -= 1
338a75b7b57SMax Reitz            if depth == 0:
339a75b7b57SMax Reitz                break
340a75b7b57SMax Reitz
341a75b7b57SMax Reitz    # json:{} filenames may be nested; filter out everything from
342a75b7b57SMax Reitz    # inside the outermost one
343a75b7b57SMax Reitz    if depth == 0:
344a75b7b57SMax Reitz        chr_i += 1 # First character past the filename
345a75b7b57SMax Reitz        result += "json:{ /* filtered */ }" + fname[chr_i:]
346a75b7b57SMax Reitz
347a75b7b57SMax Reitzsys.stdout.write(result)'
348a75b7b57SMax Reitz}
349a75b7b57SMax Reitz
350a6d2bb25SDaniel P. Berrangé_filter_authz_check_tls()
351a6d2bb25SDaniel P. Berrangé{
3529086c763SThomas Huth    sed -e 's/TLS x509 authz check for .* is denied/TLS x509 authz check for DISTINGUISHED-NAME is denied/'
353a6d2bb25SDaniel P. Berrangé}
354a6d2bb25SDaniel P. Berrangé
355dba5aee4SVladimir Sementsov-Ogievskiy_filter_qcow2_compression_type_bit()
356dba5aee4SVladimir Sementsov-Ogievskiy{
3579086c763SThomas Huth    gsed -e 's/\(incompatible_features\s\+\)\[3\(, \)\?/\1[/' \
358dba5aee4SVladimir Sementsov-Ogievskiy        -e 's/\(incompatible_features.*\), 3\]/\1]/' \
359dba5aee4SVladimir Sementsov-Ogievskiy        -e 's/\(incompatible_features.*\), 3\(,.*\)/\1\2/'
360dba5aee4SVladimir Sementsov-Ogievskiy}
361dba5aee4SVladimir Sementsov-Ogievskiy
362*bf1695c2SJuan Quintela# filter warnings caused for block migration deprecation
363*bf1695c2SJuan Quintela_filter_migration_block_deprecated()
364*bf1695c2SJuan Quintela{
365*bf1695c2SJuan Quintela    gsed -e '/warning: parameter .blk. is deprecated; use blockdev-mirror with NBD instead/d' \
366*bf1695c2SJuan Quintela         -e '/warning: block migration is deprecated; use blockdev-mirror with NBD instead/d'
367*bf1695c2SJuan Quintela}
368*bf1695c2SJuan Quintela
3696bf19c94SChristoph Hellwig# make sure this script returns success
370a2d9c0c4SFam Zhengtrue
371