include/standard-headers: add pvrdma related headers
[qemu.git] / tests / qemu-iotests / 140
bloba8fc95145c4fac39a81bebd3df927b38d8826cf5
1 #!/bin/bash
3 # Test case for ejecting a BlockBackend with an NBD server attached to it
5 # Verify that the NBD server stops offering the drive when ejecting a
6 # BlockDriverState tree from a BlockBackend (that is, a medium from a
7 # drive) exposed via an NBD server.
9 # Copyright (C) 2016 Red Hat, Inc.
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2 of the License, or
14 # (at your option) any later version.
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program. If not, see <http://www.gnu.org/licenses/>.
25 # creator
26 owner=mreitz@redhat.com
28 seq="$(basename $0)"
29 echo "QA output created by $seq"
31 here="$PWD"
32 status=1 # failure is the default!
34 _cleanup()
36 _cleanup_qemu
37 _cleanup_test_img
38 rm -f "$TEST_DIR/nbd"
40 trap "_cleanup; exit \$status" 0 1 2 3 15
42 # get standard environment, filters and checks
43 . ./common.rc
44 . ./common.filter
45 . ./common.qemu
47 _supported_fmt generic
48 _supported_proto file
49 _supported_os Linux
51 _make_test_img 64k
53 $QEMU_IO -c 'write -P 42 0 64k' "$TEST_IMG" | _filter_qemu_io
55 if test "$IMGOPTSSYNTAX" = "true"
56 then
57 SYSEMU_DRIVE_ARG=if=none,media=cdrom,id=drv,"$TEST_IMG"
58 else
59 SYSEMU_DRIVE_ARG=if=none,media=cdrom,id=drv,file="$TEST_IMG",driver=$IMGFMT
62 keep_stderr=y \
63 _launch_qemu -drive $SYSEMU_DRIVE_ARG \
64 2> >(_filter_nbd)
66 _send_qemu_cmd $QEMU_HANDLE \
67 "{ 'execute': 'qmp_capabilities' }" \
68 'return'
70 _send_qemu_cmd $QEMU_HANDLE \
71 "{ 'execute': 'nbd-server-start',
72 'arguments': { 'addr': { 'type': 'unix',
73 'data': { 'path': '$TEST_DIR/nbd' }}}}" \
74 'return'
76 _send_qemu_cmd $QEMU_HANDLE \
77 "{ 'execute': 'nbd-server-add',
78 'arguments': { 'device': 'drv' }}" \
79 'return'
81 $QEMU_IO_PROG -f raw -r -c 'read -P 42 0 64k' \
82 "nbd+unix:///drv?socket=$TEST_DIR/nbd" 2>&1 \
83 | _filter_qemu_io | _filter_nbd
85 _send_qemu_cmd $QEMU_HANDLE \
86 "{ 'execute': 'eject',
87 'arguments': { 'device': 'drv' }}" \
88 'return'
90 $QEMU_IO_PROG -f raw -r -c close \
91 "nbd+unix:///drv?socket=$TEST_DIR/nbd" 2>&1 \
92 | _filter_qemu_io | _filter_nbd
94 _send_qemu_cmd $QEMU_HANDLE \
95 "{ 'execute': 'quit' }" \
96 'return'
98 wait=1 _cleanup_qemu
100 # success, all done
101 echo '*** done'
102 rm -f $seq.full
103 status=0