1312758e2SKevin Wolf#!/bin/bash 2312758e2SKevin Wolf# 3312758e2SKevin Wolf# Test postcopy live migration with shared storage 4312758e2SKevin Wolf# 5312758e2SKevin Wolf# Copyright (C) 2017 Red Hat, Inc. 6312758e2SKevin Wolf# 7312758e2SKevin Wolf# This program is free software; you can redistribute it and/or modify 8312758e2SKevin Wolf# it under the terms of the GNU General Public License as published by 9312758e2SKevin Wolf# the Free Software Foundation; either version 2 of the License, or 10312758e2SKevin Wolf# (at your option) any later version. 11312758e2SKevin Wolf# 12312758e2SKevin Wolf# This program is distributed in the hope that it will be useful, 13312758e2SKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of 14312758e2SKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15312758e2SKevin Wolf# GNU General Public License for more details. 16312758e2SKevin Wolf# 17312758e2SKevin Wolf# You should have received a copy of the GNU General Public License 18312758e2SKevin Wolf# along with this program. If not, see <http://www.gnu.org/licenses/>. 19312758e2SKevin Wolf# 20312758e2SKevin Wolf 21312758e2SKevin Wolf# creator 22312758e2SKevin Wolfowner=kwolf@redhat.com 23312758e2SKevin Wolf 24312758e2SKevin Wolfseq=`basename $0` 25312758e2SKevin Wolfecho "QA output created by $seq" 26312758e2SKevin Wolf 27312758e2SKevin Wolfhere=`pwd` 28312758e2SKevin Wolfstatus=1 # failure is the default! 29312758e2SKevin Wolf 30312758e2SKevin WolfMIG_SOCKET="${TEST_DIR}/migrate" 31312758e2SKevin Wolf 32312758e2SKevin Wolf_cleanup() 33312758e2SKevin Wolf{ 34312758e2SKevin Wolf rm -f "${MIG_SOCKET}" 35312758e2SKevin Wolf _cleanup_test_img 36312758e2SKevin Wolf _cleanup_qemu 37312758e2SKevin Wolf} 38312758e2SKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15 39312758e2SKevin Wolf 40312758e2SKevin Wolf# get standard environment, filters and checks 41312758e2SKevin Wolf. ./common.rc 42312758e2SKevin Wolf. ./common.filter 43312758e2SKevin Wolf. ./common.qemu 44312758e2SKevin Wolf 45312758e2SKevin Wolf_supported_fmt generic 46a9ed6a91SMax Reitz# Formats that do not support live migration 47a9ed6a91SMax Reitz_unsupported_fmt qcow vdi vhdx vmdk vpc vvfat 48312758e2SKevin Wolf_supported_proto generic 49312758e2SKevin Wolf_supported_os Linux 50312758e2SKevin Wolf 51312758e2SKevin Wolfsize=64M 52312758e2SKevin Wolf_make_test_img $size 53312758e2SKevin Wolf 54312758e2SKevin Wolfecho 55312758e2SKevin Wolfecho === Starting VMs === 56312758e2SKevin Wolfecho 57312758e2SKevin Wolf 58312758e2SKevin Wolfqemu_comm_method="monitor" 59312758e2SKevin Wolf 60*13a1d4a7SDaniel P. Berrangeif [ "$IMGOPTSSYNTAX" = "true" ]; then 61*13a1d4a7SDaniel P. Berrange _launch_qemu \ 62*13a1d4a7SDaniel P. Berrange -drive "${TEST_IMG}",cache=${CACHEMODE},id=disk 63*13a1d4a7SDaniel P. Berrangeelse 64312758e2SKevin Wolf _launch_qemu \ 65312758e2SKevin Wolf -drive file="${TEST_IMG}",cache=${CACHEMODE},driver=$IMGFMT,id=disk 66*13a1d4a7SDaniel P. Berrangefi 67312758e2SKevin Wolfsrc=$QEMU_HANDLE 68312758e2SKevin Wolf 69*13a1d4a7SDaniel P. Berrangeif [ "$IMGOPTSSYNTAX" = "true" ]; then 70*13a1d4a7SDaniel P. Berrange _launch_qemu \ 71*13a1d4a7SDaniel P. Berrange -drive "${TEST_IMG}",cache=${CACHEMODE},id=disk \ 72*13a1d4a7SDaniel P. Berrange -incoming "unix:${MIG_SOCKET}" 73*13a1d4a7SDaniel P. Berrangeelse 74312758e2SKevin Wolf _launch_qemu \ 75312758e2SKevin Wolf -drive file="${TEST_IMG}",cache=${CACHEMODE},driver=$IMGFMT,id=disk \ 76312758e2SKevin Wolf -incoming "unix:${MIG_SOCKET}" 77*13a1d4a7SDaniel P. Berrangefi 78312758e2SKevin Wolfdest=$QEMU_HANDLE 79312758e2SKevin Wolf 80312758e2SKevin Wolfecho 81312758e2SKevin Wolfecho === Write something on the source === 82312758e2SKevin Wolfecho 83312758e2SKevin Wolf 84312758e2SKevin Wolfsilent= 85312758e2SKevin Wolf_send_qemu_cmd $src 'qemu-io disk "write -P 0x55 0 64k"' "(qemu)" 86312758e2SKevin Wolf_send_qemu_cmd $src "" "ops/sec" 87312758e2SKevin Wolf_send_qemu_cmd $src 'qemu-io disk "read -P 0x55 0 64k"' "(qemu)" 88312758e2SKevin Wolf_send_qemu_cmd $src "" "ops/sec" 89312758e2SKevin Wolf 90312758e2SKevin Wolfecho 91312758e2SKevin Wolfecho === Do postcopy migration to destination === 92312758e2SKevin Wolfecho 93312758e2SKevin Wolf 94312758e2SKevin Wolf# Slow down migration so much that it definitely won't finish before we can 95312758e2SKevin Wolf# switch to postcopy 96312758e2SKevin Wolfsilent=yes 97312758e2SKevin Wolf_send_qemu_cmd $src 'migrate_set_speed 4k' "(qemu)" 98312758e2SKevin Wolf_send_qemu_cmd $src 'migrate_set_capability postcopy-ram on' "(qemu)" 99312758e2SKevin Wolf_send_qemu_cmd $src "migrate -d unix:${MIG_SOCKET}" "(qemu)" 100312758e2SKevin Wolf_send_qemu_cmd $src 'migrate_start_postcopy' "(qemu)" 101312758e2SKevin Wolf 102312758e2SKevin WolfQEMU_COMM_TIMEOUT=1 qemu_cmd_repeat=10 silent=yes \ 103312758e2SKevin Wolf _send_qemu_cmd $src "info migrate" "completed\|failed" 104312758e2SKevin Wolfsilent=yes _send_qemu_cmd $src "" "(qemu)" 105312758e2SKevin Wolf 106312758e2SKevin Wolfecho 107312758e2SKevin Wolfecho === Do some I/O on the destination === 108312758e2SKevin Wolfecho 109312758e2SKevin Wolf 110312758e2SKevin Wolf# It is important that we use the BlockBackend of the guest device here instead 111312758e2SKevin Wolf# of the node name, which would create a new BlockBackend and not test whether 112312758e2SKevin Wolf# the guest has the necessary permissions to access the image now 113312758e2SKevin Wolfsilent= 114312758e2SKevin Wolf_send_qemu_cmd $dest 'qemu-io disk "read -P 0x55 0 64k"' "(qemu)" 115312758e2SKevin Wolf_send_qemu_cmd $dest "" "ops/sec" 116312758e2SKevin Wolf_send_qemu_cmd $dest 'qemu-io disk "write -P 0x66 1M 64k"' "(qemu)" 117312758e2SKevin Wolf_send_qemu_cmd $dest "" "ops/sec" 118312758e2SKevin Wolf 119312758e2SKevin Wolfecho 120312758e2SKevin Wolfecho === Shut down and check image === 121312758e2SKevin Wolfecho 122312758e2SKevin Wolf 123312758e2SKevin Wolf_send_qemu_cmd $src 'quit' "" 124312758e2SKevin Wolf_send_qemu_cmd $dest 'quit' "" 125312758e2SKevin Wolfwait=1 _cleanup_qemu 126312758e2SKevin Wolf 127312758e2SKevin Wolf_check_test_img 128312758e2SKevin Wolf 129312758e2SKevin Wolf# success, all done 130312758e2SKevin Wolfecho "*** done" 131312758e2SKevin Wolfrm -f $seq.full 132312758e2SKevin Wolfstatus=0 133