qemu

FORK: QEMU emulator
git clone https://git.neptards.moe/neptards/qemu.git
Log | Files | Refs | Submodules | LICENSE

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 
     23 seq=`basename $0`
     24 echo "QA output created by $seq"
     25 
     26 status=1	# failure is the default!
     27 
     28 MIG_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 }
     41 trap "_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 
     51 size=64M
     52 _make_test_img $size
     53 
     54 echo
     55 echo === Starting VMs ===
     56 echo
     57 
     58 qemu_comm_method="monitor"
     59 
     60 if [ "$IMGOPTSSYNTAX" = "true" ]; then
     61     _launch_qemu \
     62         -drive "${TEST_IMG}",cache=${CACHEMODE},aio=$AIOMODE,id=disk
     63 else
     64     _launch_qemu \
     65         -drive file="${TEST_IMG}",cache=${CACHEMODE},aio=$AIOMODE,driver=$IMGFMT,id=disk
     66 fi
     67 src=$QEMU_HANDLE
     68 
     69 if [ "$IMGOPTSSYNTAX" = "true" ]; then
     70     _launch_qemu \
     71         -drive "${TEST_IMG}",cache=${CACHEMODE},aio=$AIOMODE,id=disk \
     72         -incoming "unix:${MIG_SOCKET}"
     73 else
     74     _launch_qemu \
     75         -drive file="${TEST_IMG}",cache=${CACHEMODE},aio=$AIOMODE,driver=$IMGFMT,id=disk \
     76         -incoming "unix:${MIG_SOCKET}"
     77 fi
     78 dest=$QEMU_HANDLE
     79 
     80 echo
     81 echo === Set \'migrate_set_capability postcopy-ram on\' and migrate ===
     82 echo
     83 
     84 silent=yes
     85 _send_qemu_cmd $dest 'migrate_set_capability postcopy-ram on' "(qemu)"
     86 
     87 qemu_error_no_exit=yes success_or_failure=yes \
     88     _send_qemu_cmd $dest '' "(qemu)" "Postcopy is not supported"
     89 if [ ${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'
     97 fi
     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 
    102 QEMU_COMM_TIMEOUT=1 qemu_cmd_repeat=10 silent=yes \
    103     _send_qemu_cmd $src "info migrate" "completed\|failed"
    104 silent=yes _send_qemu_cmd $src "" "(qemu)"
    105 
    106 echo
    107 echo === Check if migration was successful ===
    108 echo
    109 
    110 QEMU_COMM_TIMEOUT=1 silent=yes \
    111     _send_qemu_cmd $src "info migrate" "completed"
    112 silent=yes _send_qemu_cmd $src "" "(qemu)"
    113 
    114 echo
    115 echo === On destination, execute savevm and loadvm ===
    116 echo
    117 
    118 silent=
    119 _send_qemu_cmd $dest 'savevm state1' "(qemu)"
    120 _send_qemu_cmd $dest 'loadvm state1' "(qemu)"
    121 
    122 echo
    123 echo === Shut down and check image ===
    124 echo
    125 
    126 _send_qemu_cmd $src 'quit' ""
    127 _send_qemu_cmd $dest 'quit' ""
    128 wait=1 _cleanup_qemu
    129 
    130 _check_test_img
    131 
    132 # success, all done
    133 echo "*** done"
    134 status=0