qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

iotests: Test quitting with job on throttled node

When qemu quits, all throttling should be ignored. That means, if there
is a mirror job running from a throttled node, it should be cancelled
immediately and qemu close without blocking.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>

authored by

Max Reitz and committed by
Kevin Wolf
49278ec0 e6f0ac4d

+57 -2
+53 -2
tests/qemu-iotests/218
··· 27 27 # Creator/Owner: Max Reitz <mreitz@redhat.com> 28 28 29 29 import iotests 30 - from iotests import log 30 + from iotests import log, qemu_img, qemu_io_silent 31 31 32 - iotests.verify_platform(['linux']) 32 + iotests.verify_image_format(supported_fmts=['qcow2', 'raw']) 33 33 34 34 35 35 # Launches the VM, adds two null-co nodes (source and target), and ··· 136 136 137 137 log(vm.event_wait('BLOCK_JOB_CANCELLED'), 138 138 filters=[iotests.filter_qmp_event]) 139 + 140 + log('') 141 + log('=== Cancel mirror job from throttled node by quitting ===') 142 + log('') 143 + 144 + with iotests.VM() as vm, \ 145 + iotests.FilePath('src.img') as src_img_path: 146 + 147 + assert qemu_img('create', '-f', iotests.imgfmt, src_img_path, '64M') == 0 148 + assert qemu_io_silent('-f', iotests.imgfmt, src_img_path, 149 + '-c', 'write -P 42 0M 64M') == 0 150 + 151 + vm.launch() 152 + 153 + ret = vm.qmp('object-add', qom_type='throttle-group', id='tg', 154 + props={'x-bps-read': 4096}) 155 + assert ret['return'] == {} 156 + 157 + ret = vm.qmp('blockdev-add', 158 + node_name='source', 159 + driver=iotests.imgfmt, 160 + file={ 161 + 'driver': 'file', 162 + 'filename': src_img_path 163 + }) 164 + assert ret['return'] == {} 165 + 166 + ret = vm.qmp('blockdev-add', 167 + node_name='throttled-source', 168 + driver='throttle', 169 + throttle_group='tg', 170 + file='source') 171 + assert ret['return'] == {} 172 + 173 + ret = vm.qmp('blockdev-add', 174 + node_name='target', 175 + driver='null-co', 176 + size=(64 * 1048576)) 177 + assert ret['return'] == {} 178 + 179 + ret = vm.qmp('blockdev-mirror', 180 + job_id='mirror', 181 + device='throttled-source', 182 + target='target', 183 + sync='full') 184 + assert ret['return'] == {} 185 + 186 + log(vm.qmp('quit')) 187 + 188 + with iotests.Timeout(5, 'Timeout waiting for VM to quit'): 189 + vm.shutdown(has_quit=True)
+4
tests/qemu-iotests/218.out
··· 28 28 Cancelling job 29 29 {"return": {}} 30 30 {"data": {"device": "mirror", "len": 1048576, "offset": 1048576, "speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_CANCELLED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} 31 + 32 + === Cancel mirror job from throttled node by quitting === 33 + 34 + {"return": {}}