qemu

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

202 (3812B)


      1 #!/usr/bin/env python3
      2 # group: rw quick
      3 #
      4 # Copyright (C) 2017 Red Hat, Inc.
      5 #
      6 # This program is free software; you can redistribute it and/or modify
      7 # it under the terms of the GNU General Public License as published by
      8 # the Free Software Foundation; either version 2 of the License, or
      9 # (at your option) any later version.
     10 #
     11 # This program is distributed in the hope that it will be useful,
     12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14 # GNU General Public License for more details.
     15 #
     16 # You should have received a copy of the GNU General Public License
     17 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
     18 #
     19 # Creator/Owner: Stefan Hajnoczi <stefanha@redhat.com>
     20 #
     21 # Check that QMP 'transaction' blockdev-snapshot-sync with multiple drives on a
     22 # single IOThread completes successfully.  This particular command triggered a
     23 # hang due to recursive AioContext locking and BDRV_POLL_WHILE().  Protect
     24 # against regressions.
     25 
     26 import iotests
     27 
     28 iotests.script_initialize(supported_fmts=['qcow2'],
     29                           supported_platforms=['linux'])
     30 
     31 with iotests.FilePath('disk0.img') as disk0_img_path, \
     32      iotests.FilePath('disk1.img') as disk1_img_path, \
     33      iotests.FilePath('disk0-snap.img') as disk0_snap_img_path, \
     34      iotests.FilePath('disk1-snap.img') as disk1_snap_img_path, \
     35      iotests.VM() as vm:
     36 
     37     img_size = '10M'
     38     iotests.qemu_img_create('-f', iotests.imgfmt, disk0_img_path, img_size)
     39     iotests.qemu_img_create('-f', iotests.imgfmt, disk1_img_path, img_size)
     40 
     41     iotests.log('Launching VM...')
     42     vm.launch()
     43 
     44     iotests.log('Adding IOThread...')
     45     iotests.log(vm.qmp('object-add',
     46                        qom_type='iothread',
     47                        id='iothread0'))
     48 
     49     iotests.log('Adding blockdevs...')
     50     iotests.log(vm.qmp('blockdev-add',
     51                        driver=iotests.imgfmt,
     52                        node_name='disk0',
     53                        file={
     54                            'driver': 'file',
     55                            'filename': disk0_img_path,
     56                        }))
     57     iotests.log(vm.qmp('blockdev-add',
     58                        driver=iotests.imgfmt,
     59                        node_name='disk1',
     60                        file={
     61                            'driver': 'file',
     62                            'filename': disk1_img_path,
     63                        }))
     64 
     65     iotests.log('Setting iothread...')
     66     iotests.log(vm.qmp('x-blockdev-set-iothread',
     67                        node_name='disk0',
     68                        iothread='iothread0'))
     69     iotests.log(vm.qmp('x-blockdev-set-iothread',
     70                        node_name='disk1',
     71                        iothread='iothread0'))
     72 
     73     iotests.log('Creating external snapshots...')
     74     iotests.log(vm.qmp(
     75                   'transaction',
     76                   actions=[
     77                       {
     78                           'data': {
     79                               'node-name': 'disk0',
     80                               'snapshot-file': disk0_snap_img_path,
     81                               'snapshot-node-name': 'disk0-snap',
     82                               'mode': 'absolute-paths',
     83                               'format': iotests.imgfmt,
     84                           },
     85                           'type': 'blockdev-snapshot-sync'
     86                       }, {
     87                           'data': {
     88                               'node-name': 'disk1',
     89                               'snapshot-file': disk1_snap_img_path,
     90                               'snapshot-node-name': 'disk1-snap',
     91                               'mode': 'absolute-paths',
     92                               'format': iotests.imgfmt
     93                           },
     94                           'type': 'blockdev-snapshot-sync'
     95                       }
     96                   ]))