]> git.proxmox.com Git - mirror_qemu.git/blame - tests/qemu-iotests/140
build: Remove --enable-gprof
[mirror_qemu.git] / tests / qemu-iotests / 140
CommitLineData
11a82d14 1#!/usr/bin/env bash
9dd003a9 2# group: rw auto quick
16dee418 3#
43e15ed4
SS
4# Test case for ejecting a BlockBackend with an NBD server attached to it
5#
6# Verify that the NBD server stops offering the drive when ejecting a
7# BlockDriverState tree from a BlockBackend (that is, a medium from a
8# drive) exposed via an NBD server.
16dee418
HR
9#
10# Copyright (C) 2016 Red Hat, Inc.
11#
12# This program is free software; you can redistribute it and/or modify
13# it under the terms of the GNU General Public License as published by
14# the Free Software Foundation; either version 2 of the License, or
15# (at your option) any later version.
16#
17# This program is distributed in the hope that it will be useful,
18# but WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20# GNU General Public License for more details.
21#
22# You should have received a copy of the GNU General Public License
23# along with this program. If not, see <http://www.gnu.org/licenses/>.
24#
25
26# creator
42a5009d 27owner=hreitz@redhat.com
16dee418
HR
28
29seq="$(basename $0)"
30echo "QA output created by $seq"
31
16dee418
HR
32status=1 # failure is the default!
33
34_cleanup()
35{
ecfa1854 36 _cleanup_qemu
16dee418 37 _cleanup_test_img
46cabce6 38 rm -f "$SOCK_DIR/nbd"
16dee418
HR
39}
40trap "_cleanup; exit \$status" 0 1 2 3 15
41
42# get standard environment, filters and checks
43. ./common.rc
44. ./common.filter
45. ./common.qemu
46
47_supported_fmt generic
57284d2a 48_supported_proto file fuse
16dee418
HR
49_supported_os Linux
50
51_make_test_img 64k
52
53$QEMU_IO -c 'write -P 42 0 64k' "$TEST_IMG" | _filter_qemu_io
54
13a1d4a7
DB
55if test "$IMGOPTSSYNTAX" = "true"
56then
57 SYSEMU_DRIVE_ARG=if=none,media=cdrom,id=drv,"$TEST_IMG"
58else
59 SYSEMU_DRIVE_ARG=if=none,media=cdrom,id=drv,file="$TEST_IMG",driver=$IMGFMT
60fi
61
16dee418 62keep_stderr=y \
13a1d4a7 63_launch_qemu -drive $SYSEMU_DRIVE_ARG \
16dee418
HR
64 2> >(_filter_nbd)
65
66_send_qemu_cmd $QEMU_HANDLE \
67 "{ 'execute': 'qmp_capabilities' }" \
68 'return'
69
70_send_qemu_cmd $QEMU_HANDLE \
71 "{ 'execute': 'nbd-server-start',
72 'arguments': { 'addr': { 'type': 'unix',
46cabce6 73 'data': { 'path': '$SOCK_DIR/nbd' }}}}" \
16dee418
HR
74 'return'
75
76_send_qemu_cmd $QEMU_HANDLE \
77 "{ 'execute': 'nbd-server-add',
78 'arguments': { 'device': 'drv' }}" \
79 'return'
80
1104d83c 81$QEMU_IO_PROG -f raw -r -c 'read -P 42 0 64k' \
46cabce6 82 "nbd+unix:///drv?socket=$SOCK_DIR/nbd" 2>&1 \
16dee418
HR
83 | _filter_qemu_io | _filter_nbd
84
1a9f7a80
KW
85# The order of 'return' and the BLOCK_EXPORT_DELETED event is undefined. Just
86# wait until we've twice seen one of them. Filter the 'return' line out so that
87# the output is defined.
16dee418
HR
88_send_qemu_cmd $QEMU_HANDLE \
89 "{ 'execute': 'eject',
90 'arguments': { 'device': 'drv' }}" \
1a9f7a80
KW
91 'return\|BLOCK_EXPORT_DELETED' |
92 grep -v 'return'
93
94_send_qemu_cmd $QEMU_HANDLE '' 'return\|BLOCK_EXPORT_DELETED' |
95 grep -v 'return'
16dee418 96
1104d83c 97$QEMU_IO_PROG -f raw -r -c close \
46cabce6 98 "nbd+unix:///drv?socket=$SOCK_DIR/nbd" 2>&1 \
16dee418
HR
99 | _filter_qemu_io | _filter_nbd
100
101_send_qemu_cmd $QEMU_HANDLE \
102 "{ 'execute': 'quit' }" \
103 'return'
104
105wait=1 _cleanup_qemu
106
107# success, all done
108echo '*** done'
109rm -f $seq.full
110status=0