xref: /openbmc/qemu/tests/qemu-iotests/192 (revision d525f73f)
1#!/usr/bin/env bash
2# group: rw auto quick
3#
4# Test NBD export with -incoming (non-shared storage migration use case from
5# libvirt)
6#
7# Copyright (C) 2017 Red Hat, Inc.
8#
9# This program is free software; you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation; either version 2 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program.  If not, see <http://www.gnu.org/licenses/>.
21#
22
23# creator
24owner=fam@euphon.net
25
26seq=`basename $0`
27echo "QA output created by $seq"
28
29status=1	# failure is the default!
30
31_cleanup()
32{
33    _cleanup_qemu
34    _cleanup_test_img
35    rm -f "$SOCK_DIR/nbd"
36}
37trap "_cleanup; exit \$status" 0 1 2 3 15
38
39# get standard environment, filters and checks
40. ./common.rc
41. ./common.filter
42. ./common.qemu
43
44_supported_fmt generic
45_supported_proto file
46
47if [ "$QEMU_DEFAULT_MACHINE" != "pc" ]; then
48    _notrun "Requires a PC machine"
49fi
50
51size=64M
52_make_test_img $size
53
54if test "$IMGOPTSSYNTAX" = "true"
55then
56    DRIVE_ARG=if=ide,id=drive0,$TEST_IMG
57else
58    DRIVE_ARG=if=ide,id=drive0,format=$IMGFMT,file=$TEST_IMG
59fi
60
61qemu_comm_method="monitor"
62_launch_qemu -drive $DRIVE_ARG -incoming defer
63h=$QEMU_HANDLE
64if [ "${VALGRIND_QEMU}" == "y" ]; then
65    QEMU_COMM_TIMEOUT=7
66else
67    QEMU_COMM_TIMEOUT=1
68fi
69
70_send_qemu_cmd $h "nbd_server_start unix:$SOCK_DIR/nbd" "(qemu)"
71_send_qemu_cmd $h "nbd_server_add -w drive0" "(qemu)"
72_send_qemu_cmd $h "q" "(qemu)"
73
74# success, all done
75echo "*** done"
76rm -f $seq.full
77status=0
78