1#!/usr/bin/env bash 2# group: rw auto quick qsd 3# 4# Job tests related specifically to qemu-storage-daemon 5# 6# Copyright (C) 2021 Red Hat, Inc. 7# 8# This program is free software; you can redistribute it and/or modify 9# it under the terms of the GNU General Public License as published by 10# the Free Software Foundation; either version 2 of the License, or 11# (at your option) any later version. 12# 13# This program is distributed in the hope that it will be useful, 14# but WITHOUT ANY WARRANTY; without even the implied warranty of 15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16# GNU General Public License for more details. 17# 18# You should have received a copy of the GNU General Public License 19# along with this program. If not, see <http://www.gnu.org/licenses/>. 20# 21 22# creator 23owner=kwolf@redhat.com 24 25seq="$(basename $0)" 26echo "QA output created by $seq" 27 28status=1 # failure is the default! 29 30_cleanup() 31{ 32 _cleanup_test_img 33 rm -f "$SOCK_DIR/nbd.sock" 34} 35trap "_cleanup; exit \$status" 0 1 2 3 15 36 37# get standard environment, filters and checks 38cd .. 39. ./common.rc 40. ./common.filter 41 42_supported_fmt qcow2 43_supported_proto generic 44 45size=128M 46 47TEST_IMG="$TEST_IMG.base" _make_test_img $size 48_make_test_img -b "$TEST_IMG.base" -F $IMGFMT 49 50echo 51echo "=== Job still present at shutdown ===" 52echo 53 54# Just make sure that this doesn't crash 55# (Filter job status and READY events, because their order may differ 56# between runs, particularly around when 'quit' is issued) 57$QSD --chardev stdio,id=stdio --monitor chardev=stdio \ 58 --blockdev node-name=file0,driver=file,filename="$TEST_IMG" \ 59 --blockdev node-name=fmt0,driver=qcow2,file=file0 <<EOF \ 60 | _filter_qmp | grep -v JOB_STATUS_CHANGE | grep -v BLOCK_JOB_READY 61{"execute":"qmp_capabilities"} 62{"execute": "block-commit", "arguments": {"device": "fmt0", "job-id": "job0"}} 63{"execute": "quit"} 64EOF 65 66echo 67echo "=== Streaming can't get permission on base node ===" 68echo 69 70# Just make sure that this doesn't crash 71$QSD --chardev stdio,id=stdio --monitor chardev=stdio \ 72 --blockdev node-name=file_base,driver=file,filename="$TEST_IMG.base" \ 73 --blockdev node-name=fmt_base,driver=qcow2,file=file_base \ 74 --blockdev node-name=file_overlay,driver=file,filename="$TEST_IMG" \ 75 --blockdev node-name=fmt_overlay,driver=qcow2,file=file_overlay,backing=fmt_base \ 76 --nbd-server addr.type=unix,addr.path="$SOCK_DIR/nbd.sock" \ 77 --export type=nbd,id=export1,node-name=fmt_base,writable=on,name=export1 \ 78 <<EOF | _filter_qmp 79{"execute": "qmp_capabilities"} 80{"execute": "block-stream", 81 "arguments": {"device": "fmt_overlay", "job-id": "job0"}} 82{"execute": "quit"} 83EOF 84 85# success, all done 86echo "*** done" 87rm -f $seq.full 88status=0 89 90