3 # Test commit job graph modifications while requests are active
5 # Copyright (C) 2019 Red Hat, Inc.
7 # Creator/Owner: Kevin Wolf <kwolf@redhat.com>
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program. If not, see <http://www.gnu.org/licenses/>.
24 from iotests
import imgfmt
26 iotests
.verify_image_format(supported_fmts
=['qcow2'])
28 def blockdev_create(vm
, options
):
29 result
= vm
.qmp_log('blockdev-create',
30 filters
=[iotests
.filter_qmp_testfiles
],
31 job_id
='job0', options
=options
)
33 if 'return' in result
:
34 assert result
['return'] == {}
38 with iotests
.FilePath('t.qcow2') as disk_path
, \
39 iotests
.FilePath('t.qcow2.mid') as mid_path
, \
40 iotests
.FilePath('t.qcow2.base') as base_path
, \
43 iotests
.log("=== Create backing chain and start VM ===")
46 size
= 128 * 1024 * 1024
49 iotests
.create_image(base_path
, size
)
50 iotests
.qemu_img_log('create', '-f', iotests
.imgfmt
, mid_path
, size_str
)
51 iotests
.qemu_img_log('create', '-f', iotests
.imgfmt
, disk_path
, size_str
)
53 # Create a backing chain like this:
54 # base <- [throttled: bps-read=4096] <- mid <- overlay
56 vm
.add_object('throttle-group,x-bps-read=4096,id=throttle0')
57 vm
.add_blockdev('file,filename=%s,node-name=base' % (base_path
))
58 vm
.add_blockdev('throttle,throttle-group=throttle0,file=base,node-name=throttled')
59 vm
.add_blockdev('file,filename=%s,node-name=mid-file' % (mid_path
))
60 vm
.add_blockdev('qcow2,file=mid-file,node-name=mid,backing=throttled')
61 vm
.add_drive_raw('if=none,id=overlay,driver=qcow2,file=%s,backing=mid' % (disk_path
))
65 iotests
.log("=== Start background read requests ===")
69 vm
.hmp_qemu_io('overlay', 'aio_read 0 4k')
70 vm
.hmp_qemu_io('overlay', 'aio_read 0 4k')
74 iotests
.log("=== Run a commit job ===")
77 result
= vm
.qmp_log('block-commit', job_id
='job0', auto_finalize
=False,
78 device
='overlay', top_node
='mid')
80 vm
.run_job('job0', auto_finalize
=False, pre_finalize
=start_requests
,