201 (3480B)
1#!/usr/bin/env bash 2# group: rw migration quick 3# 4# Test savevm and loadvm after live migration with postcopy flag 5# 6# Copyright (C) 2017, IBM Corporation. 7# 8# This file is derived from tests/qemu-iotests/181 by Kevin Wolf 9# 10# This program is free software; you can redistribute it and/or modify 11# it under the terms of the GNU General Public License as published by 12# the Free Software Foundation; either version 2 of the License, or 13# (at your option) any later version. 14# 15# This program is distributed in the hope that it will be useful, 16# but WITHOUT ANY WARRANTY; without even the implied warranty of 17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18# GNU General Public License for more details. 19# 20# You should have received a copy of the GNU General Public License 21# along with this program. If not, see <http://www.gnu.org/licenses/>. 22 23seq=`basename $0` 24echo "QA output created by $seq" 25 26status=1 # failure is the default! 27 28MIG_SOCKET="${SOCK_DIR}/migrate" 29 30# get standard environment, filters and checks 31. ./common.rc 32. ./common.filter 33. ./common.qemu 34 35_cleanup() 36{ 37 rm -f "${MIG_SOCKET}" 38 _cleanup_test_img 39 _cleanup_qemu 40} 41trap "_cleanup; exit \$status" 0 1 2 3 15 42 43_supported_fmt qcow2 44_supported_proto generic 45_supported_os Linux 46 47# Internal snapshots are (currently) impossible with refcount_bits=1, 48# and generally impossible with external data files 49_unsupported_imgopts 'refcount_bits=1[^0-9]' data_file 50 51size=64M 52_make_test_img $size 53 54echo 55echo === Starting VMs === 56echo 57 58qemu_comm_method="monitor" 59 60if [ "$IMGOPTSSYNTAX" = "true" ]; then 61 _launch_qemu \ 62 -drive "${TEST_IMG}",cache=${CACHEMODE},aio=$AIOMODE,id=disk 63else 64 _launch_qemu \ 65 -drive file="${TEST_IMG}",cache=${CACHEMODE},aio=$AIOMODE,driver=$IMGFMT,id=disk 66fi 67src=$QEMU_HANDLE 68 69if [ "$IMGOPTSSYNTAX" = "true" ]; then 70 _launch_qemu \ 71 -drive "${TEST_IMG}",cache=${CACHEMODE},aio=$AIOMODE,id=disk \ 72 -incoming "unix:${MIG_SOCKET}" 73else 74 _launch_qemu \ 75 -drive file="${TEST_IMG}",cache=${CACHEMODE},aio=$AIOMODE,driver=$IMGFMT,id=disk \ 76 -incoming "unix:${MIG_SOCKET}" 77fi 78dest=$QEMU_HANDLE 79 80echo 81echo === Set \'migrate_set_capability postcopy-ram on\' and migrate === 82echo 83 84silent=yes 85_send_qemu_cmd $dest 'migrate_set_capability postcopy-ram on' "(qemu)" 86 87qemu_error_no_exit=yes success_or_failure=yes \ 88 _send_qemu_cmd $dest '' "(qemu)" "Postcopy is not supported" 89if [ ${QEMU_STATUS[$dest]} -lt 0 ]; then 90 _send_qemu_cmd $dest '' "(qemu)" 91 92 _send_qemu_cmd $src 'quit' "" 93 _send_qemu_cmd $dest 'quit' "" 94 wait=1 _cleanup_qemu 95 96 _notrun 'Postcopy is not supported' 97fi 98 99_send_qemu_cmd $src 'migrate_set_capability postcopy-ram on' "(qemu)" 100_send_qemu_cmd $src "migrate -d unix:${MIG_SOCKET}" "(qemu)" 101 102QEMU_COMM_TIMEOUT=1 qemu_cmd_repeat=10 silent=yes \ 103 _send_qemu_cmd $src "info migrate" "completed\|failed" 104silent=yes _send_qemu_cmd $src "" "(qemu)" 105 106echo 107echo === Check if migration was successful === 108echo 109 110QEMU_COMM_TIMEOUT=1 silent=yes \ 111 _send_qemu_cmd $src "info migrate" "completed" 112silent=yes _send_qemu_cmd $src "" "(qemu)" 113 114echo 115echo === On destination, execute savevm and loadvm === 116echo 117 118silent= 119_send_qemu_cmd $dest 'savevm state1' "(qemu)" 120_send_qemu_cmd $dest 'loadvm state1' "(qemu)" 121 122echo 123echo === Shut down and check image === 124echo 125 126_send_qemu_cmd $src 'quit' "" 127_send_qemu_cmd $dest 'quit' "" 128wait=1 _cleanup_qemu 129 130_check_test_img 131 132# success, all done 133echo "*** done" 134status=0