Docs/RCU: Correct sample code of qatomic_rcu_set
[qemu/ar7.git] / tests / qemu-iotests / 304
blobaaf9e1461728034b7e02bfc6ef6e32002454108d
1 #!/usr/bin/env python3
3 # Tests dirty-bitmap backup with unaligned bitmap granularity
5 # Copyright (c) 2020 Proxmox Server Solutions
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 # owner=s.reiter@proxmox.com
22 import iotests
23 from iotests import qemu_img_create, qemu_img_log, file_path
25 iotests.script_initialize(supported_fmts=['qcow2'],
26                           supported_protocols=['file'])
28 test_img = file_path('test.qcow2')
29 target_img = file_path('target.qcow2')
31 # unaligned by one byte
32 image_len = 4097
33 bitmap_granularity = 4096
35 qemu_img_create('-f', iotests.imgfmt, test_img, str(image_len))
37 # create VM
38 vm = iotests.VM().add_drive(test_img)
39 vm.launch()
41 # write to the entire image
42 vm.hmp_qemu_io('drive0', 'write -P0x16 0 4096');
43 vm.hmp_qemu_io('drive0', 'write -P0x17 4096 1');
45 # do backup and wait for completion
46 vm.qmp('drive-backup', **{
47     'device': 'drive0',
48     'sync': 'full',
49     'target': target_img
52 event = vm.event_wait(name='BLOCK_JOB_COMPLETED',
53                       match={'data': {'device': 'drive0'}},
54                       timeout=5.0)
56 # shutdown to sync images
57 vm.shutdown()
59 # backup succeeded, check if image is correct
60 qemu_img_log('compare', test_img, target_img)