xref: /openbmc/qemu/tests/qemu-iotests/200 (revision 42a5009d)
111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash
29dd003a9SVladimir Sementsov-Ogievskiy# group: rw
3d975301dSJeff Cody#
4d975301dSJeff Cody# Block job co-routine race condition test.
5d975301dSJeff Cody#
6d975301dSJeff Cody# See: https://bugzilla.redhat.com/show_bug.cgi?id=1508708
7d975301dSJeff Cody#
8d975301dSJeff Cody# Copyright (C) 2017 Red Hat, Inc.
9d975301dSJeff Cody#
10d975301dSJeff Cody# This program is free software; you can redistribute it and/or modify
11d975301dSJeff Cody# it under the terms of the GNU General Public License as published by
12d975301dSJeff Cody# the Free Software Foundation; either version 2 of the License, or
13d975301dSJeff Cody# (at your option) any later version.
14d975301dSJeff Cody#
15d975301dSJeff Cody# This program is distributed in the hope that it will be useful,
16d975301dSJeff Cody# but WITHOUT ANY WARRANTY; without even the implied warranty of
17d975301dSJeff Cody# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18d975301dSJeff Cody# GNU General Public License for more details.
19d975301dSJeff Cody#
20d975301dSJeff Cody# You should have received a copy of the GNU General Public License
21d975301dSJeff Cody# along with this program.  If not, see <http://www.gnu.org/licenses/>.
22d975301dSJeff Cody#
23d975301dSJeff Cody
24d975301dSJeff Cody# creator
25*42a5009dSJohn Snowowner=codyprime@gmail.com
26d975301dSJeff Cody
27d975301dSJeff Codyseq=`basename $0`
28d975301dSJeff Codyecho "QA output created by $seq"
29d975301dSJeff Cody
30d975301dSJeff Codystatus=1    # failure is the default!
31d975301dSJeff Cody
32d975301dSJeff Cody_cleanup()
33d975301dSJeff Cody{
34d975301dSJeff Cody    _cleanup_qemu
35f91ecbd7SMax Reitz    _rm_test_img "${TEST_IMG}"
36f91ecbd7SMax Reitz    _rm_test_img "${BACKING_IMG}"
37d975301dSJeff Cody}
38d975301dSJeff Codytrap "_cleanup; exit \$status" 0 1 2 3 15
39d975301dSJeff Cody
40d975301dSJeff Cody# get standard environment, filters and checks
41d975301dSJeff Cody. ./common.rc
42d975301dSJeff Cody. ./common.filter
43d975301dSJeff Cody. ./common.qemu
44d975301dSJeff Cody
45d975301dSJeff Cody_supported_fmt qcow2 qed
4657284d2aSMax Reitz_supported_proto file fuse
47d975301dSJeff Cody
484c36f030SMax ReitzBACKING_IMG="$TEST_IMG.base"
49d975301dSJeff Cody
5052a97b5aSMax ReitzTEST_IMG="$BACKING_IMG" _make_test_img 512M
5152a97b5aSMax Reitz_make_test_img -F $IMGFMT -b "$BACKING_IMG" 512M
52d975301dSJeff Cody
53d975301dSJeff Cody${QEMU_IO} -c "write -P 0xa5 512 300M" "${BACKING_IMG}" | _filter_qemu_io
54d975301dSJeff Cody
55e0a59749SThomas Huthcase "$QEMU_DEFAULT_MACHINE" in
56e0a59749SThomas Huth  s390-ccw-virtio)
57e0a59749SThomas Huth      virtio_scsi="-device virtio-scsi-ccw,id=scsi0,iothread=iothread0"
58e0a59749SThomas Huth      ;;
59e0a59749SThomas Huth  *)
60e0a59749SThomas Huth      virtio_scsi="-device pci-bridge,id=bridge1,chassis_nr=1,bus=pci.0
61e0a59749SThomas Huth          -device virtio-scsi-pci,bus=bridge1,addr=0x1f,id=scsi0,iothread=iothread0"
62e0a59749SThomas Huth      ;;
63e0a59749SThomas Huthesac
64e0a59749SThomas Huth
65d975301dSJeff Codyecho
66d975301dSJeff Codyecho === Starting QEMU VM ===
67d975301dSJeff Codyecho
68d975301dSJeff Codyqemu_comm_method="qmp"
69e0a59749SThomas Huth_launch_qemu -object iothread,id=iothread0 $virtio_scsi \
708dff69b9SAarushi Mehta             -drive file="${TEST_IMG}",media=disk,if=none,cache=$CACHEMODE,aio=$AIOMODE,id=drive_sysdisk,format=$IMGFMT \
71d975301dSJeff Cody             -device scsi-hd,drive=drive_sysdisk,bus=scsi0.0,id=sysdisk,bootindex=0
72d975301dSJeff Codyh1=$QEMU_HANDLE
73d975301dSJeff Cody
74d975301dSJeff Cody_send_qemu_cmd $h1 "{ 'execute': 'qmp_capabilities' }" 'return'
75d975301dSJeff Cody
76d975301dSJeff Codyecho
77d975301dSJeff Codyecho === Sending stream/cancel, checking for SIGSEGV only  ===
78d975301dSJeff Codyecho
79d975301dSJeff Codyfor (( i=1;i<500;i++ ))
80d975301dSJeff Codydo
81d975301dSJeff Cody    mismatch_only='y' qemu_error_no_exit='n' _send_qemu_cmd $h1 \
82d975301dSJeff Cody                       "{
83d975301dSJeff Cody                            'execute': 'block-stream',
84d975301dSJeff Cody                            'arguments': {
85d975301dSJeff Cody                                'device': 'drive_sysdisk',
86d975301dSJeff Cody                                'speed': 10000000,
87d975301dSJeff Cody                                'on-error': 'report',
88d975301dSJeff Cody                                'job-id': 'job-$i'
89d975301dSJeff Cody                             }
90d975301dSJeff Cody                        }
91d975301dSJeff Cody                        {
92d975301dSJeff Cody                            'execute': 'block-job-cancel',
93d975301dSJeff Cody                            'arguments': {
94d975301dSJeff Cody                                'device': 'job-$i'
95d975301dSJeff Cody                             }
96d975301dSJeff Cody                        }" \
97d975301dSJeff Cody                       "{.*{.*}.*}"  # should match all well-formed QMP responses
98d975301dSJeff Codydone
99d975301dSJeff Cody
100d975301dSJeff Codysilent='y' _send_qemu_cmd $h1  "{ 'execute': 'quit' }" 'return'
101d975301dSJeff Cody
102d975301dSJeff Codyecho "$i iterations performed"
103d975301dSJeff Cody
104d975301dSJeff Codyecho "*** done"
105d975301dSJeff Codyrm -f $seq.full
106d975301dSJeff Codystatus=0
107