aboutsummaryrefslogtreecommitdiff
path: root/tests/qemu-iotests/304
blob: 198f2820871e26fb7e7d39f2f716c7abb30aa3cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python3
# group: rw quick
#
# Tests dirty-bitmap backup with unaligned bitmap granularity
#
# Copyright (c) 2020 Proxmox Server Solutions
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# owner=s.reiter@proxmox.com

import iotests
from iotests import qemu_img_create, qemu_img_log, file_path

iotests.script_initialize(supported_fmts=['qcow2'],
                          supported_protocols=['file'])

test_img = file_path('test.qcow2')
target_img = file_path('target.qcow2')

# unaligned by one byte
image_len = 4097
bitmap_granularity = 4096

qemu_img_create('-f', iotests.imgfmt, test_img, str(image_len))

# create VM
vm = iotests.VM().add_drive(test_img)
vm.launch()

# write to the entire image
vm.hmp_qemu_io('drive0', 'write -P0x16 0 4096');
vm.hmp_qemu_io('drive0', 'write -P0x17 4096 1');

# do backup and wait for completion
vm.qmp('drive-backup', **{
    'device': 'drive0',
    'sync': 'full',
    'target': target_img
})

event = vm.event_wait(name='BLOCK_JOB_COMPLETED',
                      match={'data': {'device': 'drive0'}},
                      timeout=5.0)

# shutdown to sync images
vm.shutdown()

# backup succeeded, check if image is correct
qemu_img_log('compare', test_img, target_img)