1*11a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env 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 Codystatus=1 # failure is the default! 30d975301dSJeff Cody 31d975301dSJeff Cody_cleanup() 32d975301dSJeff Cody{ 33d975301dSJeff Cody _cleanup_qemu 34d975301dSJeff Cody rm -f "${TEST_IMG}" "${BACKING_IMG}" 35d975301dSJeff Cody} 36d975301dSJeff Codytrap "_cleanup; exit \$status" 0 1 2 3 15 37d975301dSJeff Cody 38d975301dSJeff Cody# get standard environment, filters and checks 39d975301dSJeff Cody. ./common.rc 40d975301dSJeff Cody. ./common.filter 41d975301dSJeff Cody. ./common.qemu 42d975301dSJeff Cody 43d975301dSJeff Cody_supported_fmt qcow2 qed 44d975301dSJeff Cody_supported_proto file 45d975301dSJeff Cody_supported_os Linux 46d975301dSJeff Cody 47d975301dSJeff CodyBACKING_IMG="${TEST_DIR}/backing.img" 48d975301dSJeff CodyTEST_IMG="${TEST_DIR}/test.img" 49d975301dSJeff Cody 50d975301dSJeff Cody${QEMU_IMG} create -f $IMGFMT "${BACKING_IMG}" 512M | _filter_img_create 51d975301dSJeff Cody${QEMU_IMG} create -f $IMGFMT -F $IMGFMT "${TEST_IMG}" -b "${BACKING_IMG}" 512M | _filter_img_create 52d975301dSJeff Cody 53d975301dSJeff Cody${QEMU_IO} -c "write -P 0xa5 512 300M" "${BACKING_IMG}" | _filter_qemu_io 54d975301dSJeff Cody 55d975301dSJeff Codyecho 56d975301dSJeff Codyecho === Starting QEMU VM === 57d975301dSJeff Codyecho 58d975301dSJeff Codyqemu_comm_method="qmp" 59d975301dSJeff Cody_launch_qemu -device pci-bridge,id=bridge1,chassis_nr=1,bus=pci.0 \ 60d975301dSJeff Cody -object iothread,id=iothread0 \ 61d975301dSJeff Cody -device virtio-scsi-pci,bus=bridge1,addr=0x1f,id=scsi0,iothread=iothread0 \ 6245a79646SMax Reitz -drive file="${TEST_IMG}",media=disk,if=none,cache=$CACHEMODE,id=drive_sysdisk,format=$IMGFMT \ 63d975301dSJeff Cody -device scsi-hd,drive=drive_sysdisk,bus=scsi0.0,id=sysdisk,bootindex=0 64d975301dSJeff Codyh1=$QEMU_HANDLE 65d975301dSJeff Cody 66d975301dSJeff Cody_send_qemu_cmd $h1 "{ 'execute': 'qmp_capabilities' }" 'return' 67d975301dSJeff Cody 68d975301dSJeff Codyecho 69d975301dSJeff Codyecho === Sending stream/cancel, checking for SIGSEGV only === 70d975301dSJeff Codyecho 71d975301dSJeff Codyfor (( i=1;i<500;i++ )) 72d975301dSJeff Codydo 73d975301dSJeff Cody mismatch_only='y' qemu_error_no_exit='n' _send_qemu_cmd $h1 \ 74d975301dSJeff Cody "{ 75d975301dSJeff Cody 'execute': 'block-stream', 76d975301dSJeff Cody 'arguments': { 77d975301dSJeff Cody 'device': 'drive_sysdisk', 78d975301dSJeff Cody 'speed': 10000000, 79d975301dSJeff Cody 'on-error': 'report', 80d975301dSJeff Cody 'job-id': 'job-$i' 81d975301dSJeff Cody } 82d975301dSJeff Cody } 83d975301dSJeff Cody { 84d975301dSJeff Cody 'execute': 'block-job-cancel', 85d975301dSJeff Cody 'arguments': { 86d975301dSJeff Cody 'device': 'job-$i' 87d975301dSJeff Cody } 88d975301dSJeff Cody }" \ 89d975301dSJeff Cody "{.*{.*}.*}" # should match all well-formed QMP responses 90d975301dSJeff Codydone 91d975301dSJeff Cody 92d975301dSJeff Codysilent='y' _send_qemu_cmd $h1 "{ 'execute': 'quit' }" 'return' 93d975301dSJeff Cody 94d975301dSJeff Codyecho "$i iterations performed" 95d975301dSJeff Cody 96d975301dSJeff Codyecho "*** done" 97d975301dSJeff Codyrm -f $seq.full 98d975301dSJeff Codystatus=0 99