| 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 |
| 24 | owner=fam@euphon.net |
| 25 | |
| 26 | seq=`basename $0` |
| 27 | echo "QA output created by $seq" |
| 28 | |
| 29 | status=1 # failure is the default! |
| 30 | |
| 31 | _cleanup() |
| 32 | { |
| 33 | _cleanup_qemu |
| 34 | _cleanup_test_img |
| 35 | rm -f "$SOCK_DIR/nbd" |
| 36 | } |
| 37 | trap "_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 | _require_hmp |
| 47 | |
| 48 | if [ "$QEMU_DEFAULT_MACHINE" != "pc" ]; then |
| 49 | _notrun "Requires a PC machine" |
| 50 | fi |
| 51 | |
| 52 | size=64M |
| 53 | _make_test_img $size |
| 54 | |
| 55 | if test "$IMGOPTSSYNTAX" = "true" |
| 56 | then |
| 57 | DRIVE_ARG=if=ide,id=drive0,$TEST_IMG |
| 58 | else |
| 59 | DRIVE_ARG=if=ide,id=drive0,format=$IMGFMT,file=$TEST_IMG |
| 60 | fi |
| 61 | |
| 62 | qemu_comm_method="monitor" |
| 63 | _launch_qemu -drive $DRIVE_ARG -incoming defer |
| 64 | h=$QEMU_HANDLE |
| 65 | if [ "${VALGRIND_QEMU}" == "y" ]; then |
| 66 | QEMU_COMM_TIMEOUT=7 |
| 67 | else |
| 68 | QEMU_COMM_TIMEOUT=1 |
| 69 | fi |
| 70 | |
| 71 | _send_qemu_cmd $h "nbd_server_start unix:$SOCK_DIR/nbd" "(qemu)" |
| 72 | _send_qemu_cmd $h "nbd_server_add -w drive0" "(qemu)" |
| 73 | _send_qemu_cmd $h "q" "(qemu)" |
| 74 | |
| 75 | # success, all done |
| 76 | echo "*** done" |
| 77 | rm -f $seq.full |
| 78 | status=0 |