]>
Commit | Line | Data |
---|---|---|
7c477526 | 1 | #!/usr/bin/env python3 |
9dd003a9 | 2 | # group: rw backing quick |
403bb818 | 3 | # |
3f7b2fa8 | 4 | # Test external snapshot with bitmap copying and moving. |
403bb818 VSO |
5 | # |
6 | # Copyright (c) 2019 Virtuozzo International GmbH. All rights reserved. | |
7 | # | |
8 | # This program is free software; you can redistribute it and/or modify | |
9 | # it under the terms of the GNU General Public License as published by | |
10 | # the Free Software Foundation; either version 2 of the License, or | |
11 | # (at your option) any later version. | |
12 | # | |
13 | # This program is distributed in the hope that it will be useful, | |
14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | # GNU General Public License for more details. | |
17 | # | |
18 | # You should have received a copy of the GNU General Public License | |
19 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
20 | # | |
21 | ||
22 | import iotests | |
23 | from iotests import qemu_img_create, file_path, log | |
24 | ||
b30b8077 VSO |
25 | iotests.script_initialize(supported_fmts=['qcow2'], |
26 | unsupported_imgopts=['compat']) | |
549fb880 | 27 | |
403bb818 VSO |
28 | disk, top = file_path('disk', 'top') |
29 | size = 1024 * 1024 | |
30 | ||
31 | qemu_img_create('-f', iotests.imgfmt, disk, str(size)) | |
32 | ||
33 | vm = iotests.VM().add_drive(disk, opts='node-name=base') | |
34 | vm.launch() | |
35 | ||
36 | vm.qmp_log('block-dirty-bitmap-add', node='drive0', name='bitmap0') | |
3f7b2fa8 VSO |
37 | vm.qmp_log('block-dirty-bitmap-add', node='drive0', name='bitmap1', |
38 | persistent=True) | |
39 | vm.qmp_log('block-dirty-bitmap-add', node='drive0', name='bitmap2', | |
40 | persistent=True) | |
403bb818 VSO |
41 | |
42 | vm.hmp_qemu_io('drive0', 'write 0 512K') | |
43 | ||
44 | vm.qmp_log('transaction', indent=2, actions=[ | |
45 | {'type': 'blockdev-snapshot-sync', | |
46 | 'data': {'device': 'drive0', 'snapshot-file': top, | |
47 | 'snapshot-node-name': 'snap'}}, | |
3f7b2fa8 VSO |
48 | |
49 | # copy non-persistent bitmap0 | |
403bb818 VSO |
50 | {'type': 'block-dirty-bitmap-add', |
51 | 'data': {'node': 'snap', 'name': 'bitmap0'}}, | |
52 | {'type': 'block-dirty-bitmap-merge', | |
53 | 'data': {'node': 'snap', 'target': 'bitmap0', | |
3f7b2fa8 VSO |
54 | 'bitmaps': [{'node': 'base', 'name': 'bitmap0'}]}}, |
55 | ||
56 | # copy persistent bitmap1, original will be saved to base image | |
57 | {'type': 'block-dirty-bitmap-add', | |
58 | 'data': {'node': 'snap', 'name': 'bitmap1', 'persistent': True}}, | |
59 | {'type': 'block-dirty-bitmap-merge', | |
60 | 'data': {'node': 'snap', 'target': 'bitmap1', | |
61 | 'bitmaps': [{'node': 'base', 'name': 'bitmap1'}]}}, | |
62 | ||
63 | # move persistent bitmap2, original will be removed and not saved | |
64 | # to base image | |
65 | {'type': 'block-dirty-bitmap-add', | |
66 | 'data': {'node': 'snap', 'name': 'bitmap2', 'persistent': True}}, | |
67 | {'type': 'block-dirty-bitmap-merge', | |
68 | 'data': {'node': 'snap', 'target': 'bitmap2', | |
69 | 'bitmaps': [{'node': 'base', 'name': 'bitmap2'}]}}, | |
70 | {'type': 'block-dirty-bitmap-remove', | |
71 | 'data': {'node': 'base', 'name': 'bitmap2'}} | |
403bb818 VSO |
72 | ], filters=[iotests.filter_qmp_testfiles]) |
73 | ||
74 | result = vm.qmp('query-block')['return'][0] | |
75 | log("query-block: device = {}, node-name = {}, dirty-bitmaps:".format( | |
76 | result['device'], result['inserted']['node-name'])) | |
e67d8e29 | 77 | log(result['inserted']['dirty-bitmaps'], indent=2) |
3f7b2fa8 VSO |
78 | log("\nbitmaps in backing image:") |
79 | log(result['inserted']['image']['backing-image']['format-specific'] \ | |
80 | ['data']['bitmaps'], indent=2) | |
403bb818 VSO |
81 | |
82 | vm.shutdown() |