|
| 1 | +#!/usr/bin/env python3 |
| 2 | +# group: rw quick |
| 3 | +# |
| 4 | +# Copyright (C) 2023 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: Kevin Wolf <[email protected]> |
| 20 | + |
| 21 | +import asyncio |
| 22 | +import iotests |
| 23 | + |
| 24 | +iotests.script_initialize(supported_fmts=['qcow2', 'qcow', 'qed', 'vdi', |
| 25 | + 'vmdk', 'parallels']) |
| 26 | +iotests.verify_virtio_scsi_pci_or_ccw() |
| 27 | + |
| 28 | +with iotests.FilePath('disk.img') as img_path, \ |
| 29 | + iotests.VM() as vm: |
| 30 | + |
| 31 | + iotests.qemu_img_create('-f', 'raw', img_path, '0') |
| 32 | + |
| 33 | + vm.add_object('iothread,id=iothread0') |
| 34 | + vm.add_blockdev(f'file,node-name=img-file,read-only=on,' |
| 35 | + f'filename={img_path}') |
| 36 | + vm.add_device('virtio-scsi,iothread=iothread0') |
| 37 | + vm.add_device('scsi-hd,drive=img-file,share-rw=on') |
| 38 | + |
| 39 | + vm.launch() |
| 40 | + |
| 41 | + iotests.log(vm.qmp( |
| 42 | + 'blockdev-reopen', |
| 43 | + options=[{ |
| 44 | + 'driver': 'file', |
| 45 | + 'filename': img_path, |
| 46 | + 'node-name': 'img-file', |
| 47 | + 'read-only': False, |
| 48 | + }], |
| 49 | + )) |
| 50 | + iotests.log(vm.qmp( |
| 51 | + 'blockdev-create', |
| 52 | + job_id='job0', |
| 53 | + options={ |
| 54 | + 'driver': iotests.imgfmt, |
| 55 | + 'file': 'img-file', |
| 56 | + 'size': 1024 * 1024, |
| 57 | + }, |
| 58 | + )) |
| 59 | + |
| 60 | + # Should succeed and not time out |
| 61 | + try: |
| 62 | + vm.run_job('job0', wait=5.0) |
| 63 | + vm.shutdown() |
| 64 | + except asyncio.TimeoutError: |
| 65 | + # VM may be stuck, kill it |
| 66 | + vm.kill() |
| 67 | + raise |
0 commit comments