cachepc-qemu

Fork of AMDESE/qemu with changes for cachepc side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-qemu
Log | Files | Refs | Submodules | LICENSE | sfeed.txt

203 (2603B)


      1#!/usr/bin/env python3
      2# group: rw auto migration 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 'migrate' with multiple drives on a single IOThread completes
     22# successfully.  This particular command triggered a hang in the source QEMU
     23# process due to recursive AioContext locking in bdrv_invalidate_all() and
     24# BDRV_POLL_WHILE().
     25
     26import iotests
     27
     28iotests.script_initialize(supported_fmts=['qcow2'],
     29                          supported_platforms=['linux'])
     30
     31with iotests.FilePath('disk0.img') as disk0_img_path, \
     32     iotests.FilePath('disk1.img') as disk1_img_path, \
     33     iotests.VM() as vm:
     34
     35    img_size = '10M'
     36    iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, disk0_img_path, img_size)
     37    iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, disk1_img_path, img_size)
     38
     39    iotests.log('Launching VM...')
     40    (vm.add_object('iothread,id=iothread0')
     41       .add_drive(disk0_img_path, 'node-name=drive0-node', interface='none')
     42       .add_drive(disk1_img_path, 'node-name=drive1-node', interface='none')
     43       .launch())
     44
     45    iotests.log('Setting IOThreads...')
     46    iotests.log(vm.qmp('x-blockdev-set-iothread',
     47                       node_name='drive0-node', iothread='iothread0',
     48                       force=True))
     49    iotests.log(vm.qmp('x-blockdev-set-iothread',
     50                       node_name='drive1-node', iothread='iothread0',
     51                       force=True))
     52
     53    iotests.log('Enabling migration QMP events...')
     54    iotests.log(vm.qmp('migrate-set-capabilities', capabilities=[
     55        {
     56            'capability': 'events',
     57            'state': True
     58        }
     59    ]))
     60
     61    iotests.log('Starting migration...')
     62    iotests.log(vm.qmp('migrate', uri='exec:cat >/dev/null'))
     63    while True:
     64        event = vm.event_wait('MIGRATION')
     65        iotests.log(event, filters=[iotests.filter_qmp_event])
     66        if event['data']['status'] == 'completed':
     67            break