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