xref: /qemu/tests/qemu-iotests/tests/qsd-jobs (revision a9fdde40)
1e2157770SKevin Wolf#!/usr/bin/env bash
2e2157770SKevin Wolf# group: rw auto quick qsd
3e2157770SKevin Wolf#
4e2157770SKevin Wolf# Job tests related specifically to qemu-storage-daemon
5e2157770SKevin Wolf#
6e2157770SKevin Wolf# Copyright (C) 2021 Red Hat, Inc.
7e2157770SKevin Wolf#
8e2157770SKevin Wolf# This program is free software; you can redistribute it and/or modify
9e2157770SKevin Wolf# it under the terms of the GNU General Public License as published by
10e2157770SKevin Wolf# the Free Software Foundation; either version 2 of the License, or
11e2157770SKevin Wolf# (at your option) any later version.
12e2157770SKevin Wolf#
13e2157770SKevin Wolf# This program is distributed in the hope that it will be useful,
14e2157770SKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of
15e2157770SKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16e2157770SKevin Wolf# GNU General Public License for more details.
17e2157770SKevin Wolf#
18e2157770SKevin Wolf# You should have received a copy of the GNU General Public License
19e2157770SKevin Wolf# along with this program.  If not, see <http://www.gnu.org/licenses/>.
20e2157770SKevin Wolf#
21e2157770SKevin Wolf
22e2157770SKevin Wolf# creator
23e2157770SKevin Wolfowner=kwolf@redhat.com
24e2157770SKevin Wolf
25e2157770SKevin Wolfseq="$(basename $0)"
26e2157770SKevin Wolfecho "QA output created by $seq"
27e2157770SKevin Wolf
28e2157770SKevin Wolfstatus=1	# failure is the default!
29e2157770SKevin Wolf
30e2157770SKevin Wolf_cleanup()
31e2157770SKevin Wolf{
32e2157770SKevin Wolf    _cleanup_test_img
331bf26076SKevin Wolf    rm -f "$SOCK_DIR/nbd.sock"
34e2157770SKevin Wolf}
35e2157770SKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15
36e2157770SKevin Wolf
37e2157770SKevin Wolf# get standard environment, filters and checks
38e2157770SKevin Wolfcd ..
39e2157770SKevin Wolf. ./common.rc
40e2157770SKevin Wolf. ./common.filter
41e2157770SKevin Wolf
42e2157770SKevin Wolf_supported_fmt qcow2
43*a9fdde40SThomas Huth_supported_proto file
44e2157770SKevin Wolf
45e2157770SKevin Wolfsize=128M
46e2157770SKevin Wolf
47e2157770SKevin WolfTEST_IMG="$TEST_IMG.base" _make_test_img $size
48e2157770SKevin Wolf_make_test_img -b "$TEST_IMG.base" -F $IMGFMT
49e2157770SKevin Wolf
50e2157770SKevin Wolfecho
51e2157770SKevin Wolfecho "=== Job still present at shutdown ==="
52e2157770SKevin Wolfecho
53e2157770SKevin Wolf
54e2157770SKevin Wolf# Just make sure that this doesn't crash
5566f18320SMax Reitz# (Filter job status and READY events, because their order may differ
5666f18320SMax Reitz# between runs, particularly around when 'quit' is issued)
57e2157770SKevin Wolf$QSD --chardev stdio,id=stdio --monitor chardev=stdio \
58e2157770SKevin Wolf    --blockdev node-name=file0,driver=file,filename="$TEST_IMG" \
5966f18320SMax Reitz    --blockdev node-name=fmt0,driver=qcow2,file=file0 <<EOF \
6066f18320SMax Reitz    | _filter_qmp | grep -v JOB_STATUS_CHANGE | grep -v BLOCK_JOB_READY
61e2157770SKevin Wolf{"execute":"qmp_capabilities"}
62e2157770SKevin Wolf{"execute": "block-commit", "arguments": {"device": "fmt0", "job-id": "job0"}}
63e2157770SKevin Wolf{"execute": "quit"}
64e2157770SKevin WolfEOF
65e2157770SKevin Wolf
661bf26076SKevin Wolfecho
671bf26076SKevin Wolfecho "=== Streaming can't get permission on base node ==="
681bf26076SKevin Wolfecho
691bf26076SKevin Wolf
701bf26076SKevin Wolf# Just make sure that this doesn't crash
711bf26076SKevin Wolf$QSD --chardev stdio,id=stdio --monitor chardev=stdio \
721bf26076SKevin Wolf    --blockdev node-name=file_base,driver=file,filename="$TEST_IMG.base" \
731bf26076SKevin Wolf    --blockdev node-name=fmt_base,driver=qcow2,file=file_base \
741bf26076SKevin Wolf    --blockdev node-name=file_overlay,driver=file,filename="$TEST_IMG" \
751bf26076SKevin Wolf    --blockdev node-name=fmt_overlay,driver=qcow2,file=file_overlay,backing=fmt_base \
761bf26076SKevin Wolf    --nbd-server addr.type=unix,addr.path="$SOCK_DIR/nbd.sock" \
771bf26076SKevin Wolf    --export type=nbd,id=export1,node-name=fmt_base,writable=on,name=export1 \
781bf26076SKevin Wolf    <<EOF | _filter_qmp
791bf26076SKevin Wolf{"execute": "qmp_capabilities"}
801bf26076SKevin Wolf{"execute": "block-stream",
811bf26076SKevin Wolf  "arguments": {"device": "fmt_overlay", "job-id": "job0"}}
821bf26076SKevin Wolf{"execute": "quit"}
831bf26076SKevin WolfEOF
841bf26076SKevin Wolf
85e2157770SKevin Wolf# success, all done
86e2157770SKevin Wolfecho "*** done"
87e2157770SKevin Wolfrm -f $seq.full
88e2157770SKevin Wolfstatus=0
89e2157770SKevin Wolf
90