]> Git Repo - qemu.git/blob - tests/qemu-iotests/304
tests/docker: Remove old Debian 9 containers
[qemu.git] / tests / qemu-iotests / 304
1 #!/usr/bin/env python3
2 #
3 # Tests dirty-bitmap backup with unaligned bitmap granularity
4 #
5 # Copyright (c) 2020 Proxmox Server Solutions
6 #
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.
11 #
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.
16 #
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/>.
19 #
20[email protected]
21
22 import iotests
23 from iotests import qemu_img_create, qemu_img_log, file_path
24
25 iotests.script_initialize(supported_fmts=['qcow2'],
26                           supported_protocols=['file'])
27
28 test_img = file_path('test.qcow2')
29 target_img = file_path('target.qcow2')
30
31 # unaligned by one byte
32 image_len = 4097
33 bitmap_granularity = 4096
34
35 qemu_img_create('-f', iotests.imgfmt, test_img, str(image_len))
36
37 # create VM
38 vm = iotests.VM().add_drive(test_img)
39 vm.launch()
40
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');
44
45 # do backup and wait for completion
46 vm.qmp('drive-backup', **{
47     'device': 'drive0',
48     'sync': 'full',
49     'target': target_img
50 })
51
52 event = vm.event_wait(name='BLOCK_JOB_COMPLETED',
53                       match={'data': {'device': 'drive0'}},
54                       timeout=5.0)
55
56 # shutdown to sync images
57 vm.shutdown()
58
59 # backup succeeded, check if image is correct
60 qemu_img_log('compare', test_img, target_img)
This page took 0.026564 seconds and 4 git commands to generate.