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