xref: /openbmc/qemu/tests/qemu-iotests/202 (revision 3d53818f)
17c477526SPhilippe Mathieu-Daudé#!/usr/bin/env python3
29dd003a9SVladimir Sementsov-Ogievskiy# group: rw quick
36dd64919SStefan Hajnoczi#
46dd64919SStefan Hajnoczi# Copyright (C) 2017 Red Hat, Inc.
56dd64919SStefan Hajnoczi#
66dd64919SStefan Hajnoczi# This program is free software; you can redistribute it and/or modify
76dd64919SStefan Hajnoczi# it under the terms of the GNU General Public License as published by
86dd64919SStefan Hajnoczi# the Free Software Foundation; either version 2 of the License, or
96dd64919SStefan Hajnoczi# (at your option) any later version.
106dd64919SStefan Hajnoczi#
116dd64919SStefan Hajnoczi# This program is distributed in the hope that it will be useful,
126dd64919SStefan Hajnoczi# but WITHOUT ANY WARRANTY; without even the implied warranty of
136dd64919SStefan Hajnoczi# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
146dd64919SStefan Hajnoczi# GNU General Public License for more details.
156dd64919SStefan Hajnoczi#
166dd64919SStefan Hajnoczi# You should have received a copy of the GNU General Public License
176dd64919SStefan Hajnoczi# along with this program.  If not, see <http://www.gnu.org/licenses/>.
186dd64919SStefan Hajnoczi#
196dd64919SStefan Hajnoczi# Creator/Owner: Stefan Hajnoczi <stefanha@redhat.com>
206dd64919SStefan Hajnoczi#
216dd64919SStefan Hajnoczi# Check that QMP 'transaction' blockdev-snapshot-sync with multiple drives on a
226dd64919SStefan Hajnoczi# single IOThread completes successfully.  This particular command triggered a
236dd64919SStefan Hajnoczi# hang due to recursive AioContext locking and BDRV_POLL_WHILE().  Protect
246dd64919SStefan Hajnoczi# against regressions.
256dd64919SStefan Hajnoczi
266dd64919SStefan Hajnocziimport iotests
276dd64919SStefan Hajnoczi
287d814059SJohn Snowiotests.script_initialize(supported_fmts=['qcow2'],
297d814059SJohn Snow                          supported_platforms=['linux'])
306dd64919SStefan Hajnoczi
316dd64919SStefan Hajnocziwith iotests.FilePath('disk0.img') as disk0_img_path, \
326dd64919SStefan Hajnoczi     iotests.FilePath('disk1.img') as disk1_img_path, \
336dd64919SStefan Hajnoczi     iotests.FilePath('disk0-snap.img') as disk0_snap_img_path, \
346dd64919SStefan Hajnoczi     iotests.FilePath('disk1-snap.img') as disk1_snap_img_path, \
356dd64919SStefan Hajnoczi     iotests.VM() as vm:
366dd64919SStefan Hajnoczi
376dd64919SStefan Hajnoczi    img_size = '10M'
38*3d53818fSJohn Snow    iotests.qemu_img_create('-f', iotests.imgfmt, disk0_img_path, img_size)
39*3d53818fSJohn Snow    iotests.qemu_img_create('-f', iotests.imgfmt, disk1_img_path, img_size)
406dd64919SStefan Hajnoczi
416dd64919SStefan Hajnoczi    iotests.log('Launching VM...')
426dd64919SStefan Hajnoczi    vm.launch()
436dd64919SStefan Hajnoczi
446dd64919SStefan Hajnoczi    iotests.log('Adding IOThread...')
456dd64919SStefan Hajnoczi    iotests.log(vm.qmp('object-add',
466dd64919SStefan Hajnoczi                       qom_type='iothread',
476dd64919SStefan Hajnoczi                       id='iothread0'))
486dd64919SStefan Hajnoczi
496dd64919SStefan Hajnoczi    iotests.log('Adding blockdevs...')
506dd64919SStefan Hajnoczi    iotests.log(vm.qmp('blockdev-add',
516dd64919SStefan Hajnoczi                       driver=iotests.imgfmt,
526dd64919SStefan Hajnoczi                       node_name='disk0',
536dd64919SStefan Hajnoczi                       file={
546dd64919SStefan Hajnoczi                           'driver': 'file',
556dd64919SStefan Hajnoczi                           'filename': disk0_img_path,
566dd64919SStefan Hajnoczi                       }))
576dd64919SStefan Hajnoczi    iotests.log(vm.qmp('blockdev-add',
586dd64919SStefan Hajnoczi                       driver=iotests.imgfmt,
596dd64919SStefan Hajnoczi                       node_name='disk1',
606dd64919SStefan Hajnoczi                       file={
616dd64919SStefan Hajnoczi                           'driver': 'file',
626dd64919SStefan Hajnoczi                           'filename': disk1_img_path,
636dd64919SStefan Hajnoczi                       }))
646dd64919SStefan Hajnoczi
656dd64919SStefan Hajnoczi    iotests.log('Setting iothread...')
666dd64919SStefan Hajnoczi    iotests.log(vm.qmp('x-blockdev-set-iothread',
676dd64919SStefan Hajnoczi                       node_name='disk0',
686dd64919SStefan Hajnoczi                       iothread='iothread0'))
696dd64919SStefan Hajnoczi    iotests.log(vm.qmp('x-blockdev-set-iothread',
706dd64919SStefan Hajnoczi                       node_name='disk1',
716dd64919SStefan Hajnoczi                       iothread='iothread0'))
726dd64919SStefan Hajnoczi
736dd64919SStefan Hajnoczi    iotests.log('Creating external snapshots...')
746dd64919SStefan Hajnoczi    iotests.log(vm.qmp(
756dd64919SStefan Hajnoczi                  'transaction',
766dd64919SStefan Hajnoczi                  actions=[
776dd64919SStefan Hajnoczi                      {
786dd64919SStefan Hajnoczi                          'data': {
796dd64919SStefan Hajnoczi                              'node-name': 'disk0',
806dd64919SStefan Hajnoczi                              'snapshot-file': disk0_snap_img_path,
816dd64919SStefan Hajnoczi                              'snapshot-node-name': 'disk0-snap',
826dd64919SStefan Hajnoczi                              'mode': 'absolute-paths',
836dd64919SStefan Hajnoczi                              'format': iotests.imgfmt,
846dd64919SStefan Hajnoczi                          },
856dd64919SStefan Hajnoczi                          'type': 'blockdev-snapshot-sync'
866dd64919SStefan Hajnoczi                      }, {
876dd64919SStefan Hajnoczi                          'data': {
886dd64919SStefan Hajnoczi                              'node-name': 'disk1',
896dd64919SStefan Hajnoczi                              'snapshot-file': disk1_snap_img_path,
906dd64919SStefan Hajnoczi                              'snapshot-node-name': 'disk1-snap',
916dd64919SStefan Hajnoczi                              'mode': 'absolute-paths',
926dd64919SStefan Hajnoczi                              'format': iotests.imgfmt
936dd64919SStefan Hajnoczi                          },
946dd64919SStefan Hajnoczi                          'type': 'blockdev-snapshot-sync'
956dd64919SStefan Hajnoczi                      }
966dd64919SStefan Hajnoczi                  ]))
97