qemu

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

161 (3914B)


      1 #!/usr/bin/env bash
      2 # group: rw auto quick
      3 #
      4 # Test reopening a backing image after block-stream and block-commit
      5 #
      6 # Copyright (C) 2018 Igalia, S.L.
      7 #
      8 # This program is free software; you can redistribute it and/or modify
      9 # it under the terms of the GNU General Public License as published by
     10 # the Free Software Foundation; either version 2 of the License, or
     11 # (at your option) any later version.
     12 #
     13 # This program is distributed in the hope that it will be useful,
     14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 # GNU General Public License for more details.
     17 #
     18 # You should have received a copy of the GNU General Public License
     19 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
     20 #
     21 
     22 # creator
     23 owner=berto@igalia.com
     24 
     25 seq=`basename $0`
     26 echo "QA output created by $seq"
     27 
     28 here=`pwd`
     29 status=1	# failure is the default!
     30 
     31 _cleanup()
     32 {
     33     _cleanup_test_img
     34     _rm_test_img "$TEST_IMG.base"
     35     _rm_test_img "$TEST_IMG.int"
     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 # Any format implementing BlockDriver.bdrv_change_backing_file
     45 _supported_fmt qcow2 qed
     46 _supported_proto file fuse
     47 _supported_os Linux
     48 
     49 IMG_SIZE=1M
     50 
     51 # Create the images
     52 TEST_IMG="$TEST_IMG.base" _make_test_img $IMG_SIZE
     53 TEST_IMG="$TEST_IMG.int" _make_test_img -b "$TEST_IMG.base" -F $IMGFMT
     54 _make_test_img -b "$TEST_IMG.int" -F $IMGFMT -F $IMGFMT
     55 
     56 # First test: reopen $TEST.IMG changing the detect-zeroes option on
     57 # its backing file ($TEST_IMG.int).
     58 echo
     59 echo "*** Change an option on the backing file"
     60 echo
     61 _launch_qemu -drive if=none,file="${TEST_IMG}"
     62 _send_qemu_cmd $QEMU_HANDLE \
     63     "{ 'execute': 'qmp_capabilities' }" \
     64     'return'
     65 
     66 _send_qemu_cmd $QEMU_HANDLE \
     67     "{ 'execute': 'human-monitor-command',
     68        'arguments': { 'command-line':
     69                       'qemu-io none0 \"reopen -o backing.detect-zeroes=on\"' } }" \
     70     "return"
     71 
     72 _cleanup_qemu
     73 
     74 # Second test: stream $TEST_IMG.base into $TEST_IMG.int and then
     75 # reopen $TEST.IMG changing the detect-zeroes option on its new
     76 # backing file ($TEST_IMG.base).
     77 echo
     78 echo "*** Stream and then change an option on the backing file"
     79 echo
     80 _launch_qemu -drive if=none,file="${TEST_IMG}"
     81 _send_qemu_cmd $QEMU_HANDLE \
     82     "{ 'execute': 'qmp_capabilities' }" \
     83     'return'
     84 
     85 _send_qemu_cmd $QEMU_HANDLE \
     86     "{ 'execute': 'block-stream', \
     87        'arguments': { 'device': 'none0',
     88                       'base': '${TEST_IMG}.base' } }" \
     89     'return'
     90 
     91 # Wait for block-stream to finish
     92 sleep 0.5
     93 
     94 _send_qemu_cmd $QEMU_HANDLE \
     95     "{ 'execute': 'human-monitor-command',
     96        'arguments': { 'command-line':
     97                       'qemu-io none0 \"reopen -o backing.detect-zeroes=on\"' } }" \
     98     "return"
     99 
    100 _cleanup_qemu
    101 
    102 # Third test: commit $TEST_IMG.int into $TEST_IMG.base and then reopen
    103 # $TEST.IMG changing the detect-zeroes option on its new backing file
    104 # ($TEST_IMG.base).
    105 echo
    106 echo "*** Commit and then change an option on the backing file"
    107 echo
    108 # Create the images again
    109 TEST_IMG="$TEST_IMG.base" _make_test_img $IMG_SIZE
    110 TEST_IMG="$TEST_IMG.int" _make_test_img -b "$TEST_IMG.base" -F $IMGFMT
    111 _make_test_img -b "$TEST_IMG.int" -F $IMGFMT
    112 
    113 _launch_qemu -drive if=none,file="${TEST_IMG}"
    114 _send_qemu_cmd $QEMU_HANDLE \
    115     "{ 'execute': 'qmp_capabilities' }" \
    116     'return'
    117 
    118 _send_qemu_cmd $QEMU_HANDLE \
    119     "{ 'execute': 'block-commit', \
    120        'arguments': { 'device': 'none0',
    121                       'top': '${TEST_IMG}.int' } }" \
    122     'return'
    123 
    124 # Wait for block-commit to finish
    125 sleep 0.5
    126 
    127 _send_qemu_cmd $QEMU_HANDLE \
    128     "{ 'execute': 'human-monitor-command',
    129        'arguments': { 'command-line':
    130                       'qemu-io none0 \"reopen -o backing.detect-zeroes=on\"' } }" \
    131     "return"
    132 
    133 _cleanup_qemu
    134 
    135 # success, all done
    136 echo "*** done"
    137 rm -f $seq.full
    138 status=0