2020-01-30 19:32:30 +03:00
|
|
|
#!/usr/bin/env python3
|
2021-01-16 16:44:19 +03:00
|
|
|
# group: rw backing quick
|
2019-05-29 02:33:31 +03:00
|
|
|
#
|
2019-07-29 23:35:54 +03:00
|
|
|
# Test external snapshot with bitmap copying and moving.
|
2019-05-29 02:33:31 +03:00
|
|
|
#
|
|
|
|
# Copyright (c) 2019 Virtuozzo International GmbH. All rights reserved.
|
|
|
|
#
|
|
|
|
# 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/>.
|
|
|
|
#
|
|
|
|
|
|
|
|
import iotests
|
|
|
|
from iotests import qemu_img_create, file_path, log
|
|
|
|
|
2021-12-23 19:01:28 +03:00
|
|
|
iotests.script_initialize(supported_fmts=['qcow2'],
|
|
|
|
unsupported_imgopts=['compat'])
|
2019-06-05 18:54:05 +03:00
|
|
|
|
2019-05-29 02:33:31 +03:00
|
|
|
disk, top = file_path('disk', 'top')
|
|
|
|
size = 1024 * 1024
|
|
|
|
|
|
|
|
qemu_img_create('-f', iotests.imgfmt, disk, str(size))
|
|
|
|
|
|
|
|
vm = iotests.VM().add_drive(disk, opts='node-name=base')
|
|
|
|
vm.launch()
|
|
|
|
|
|
|
|
vm.qmp_log('block-dirty-bitmap-add', node='drive0', name='bitmap0')
|
2019-07-29 23:35:54 +03:00
|
|
|
vm.qmp_log('block-dirty-bitmap-add', node='drive0', name='bitmap1',
|
|
|
|
persistent=True)
|
|
|
|
vm.qmp_log('block-dirty-bitmap-add', node='drive0', name='bitmap2',
|
|
|
|
persistent=True)
|
2019-05-29 02:33:31 +03:00
|
|
|
|
|
|
|
vm.hmp_qemu_io('drive0', 'write 0 512K')
|
|
|
|
|
|
|
|
vm.qmp_log('transaction', indent=2, actions=[
|
|
|
|
{'type': 'blockdev-snapshot-sync',
|
|
|
|
'data': {'device': 'drive0', 'snapshot-file': top,
|
|
|
|
'snapshot-node-name': 'snap'}},
|
2019-07-29 23:35:54 +03:00
|
|
|
|
|
|
|
# copy non-persistent bitmap0
|
2019-05-29 02:33:31 +03:00
|
|
|
{'type': 'block-dirty-bitmap-add',
|
|
|
|
'data': {'node': 'snap', 'name': 'bitmap0'}},
|
|
|
|
{'type': 'block-dirty-bitmap-merge',
|
|
|
|
'data': {'node': 'snap', 'target': 'bitmap0',
|
2019-07-29 23:35:54 +03:00
|
|
|
'bitmaps': [{'node': 'base', 'name': 'bitmap0'}]}},
|
|
|
|
|
|
|
|
# copy persistent bitmap1, original will be saved to base image
|
|
|
|
{'type': 'block-dirty-bitmap-add',
|
|
|
|
'data': {'node': 'snap', 'name': 'bitmap1', 'persistent': True}},
|
|
|
|
{'type': 'block-dirty-bitmap-merge',
|
|
|
|
'data': {'node': 'snap', 'target': 'bitmap1',
|
|
|
|
'bitmaps': [{'node': 'base', 'name': 'bitmap1'}]}},
|
|
|
|
|
|
|
|
# move persistent bitmap2, original will be removed and not saved
|
|
|
|
# to base image
|
|
|
|
{'type': 'block-dirty-bitmap-add',
|
|
|
|
'data': {'node': 'snap', 'name': 'bitmap2', 'persistent': True}},
|
|
|
|
{'type': 'block-dirty-bitmap-merge',
|
|
|
|
'data': {'node': 'snap', 'target': 'bitmap2',
|
|
|
|
'bitmaps': [{'node': 'base', 'name': 'bitmap2'}]}},
|
|
|
|
{'type': 'block-dirty-bitmap-remove',
|
|
|
|
'data': {'node': 'base', 'name': 'bitmap2'}}
|
2019-05-29 02:33:31 +03:00
|
|
|
], filters=[iotests.filter_qmp_testfiles])
|
|
|
|
|
|
|
|
result = vm.qmp('query-block')['return'][0]
|
|
|
|
log("query-block: device = {}, node-name = {}, dirty-bitmaps:".format(
|
|
|
|
result['device'], result['inserted']['node-name']))
|
2021-02-19 22:22:36 +03:00
|
|
|
log(result['inserted']['dirty-bitmaps'], indent=2)
|
2019-07-29 23:35:54 +03:00
|
|
|
log("\nbitmaps in backing image:")
|
|
|
|
log(result['inserted']['image']['backing-image']['format-specific'] \
|
|
|
|
['data']['bitmaps'], indent=2)
|
2019-05-29 02:33:31 +03:00
|
|
|
|
|
|
|
vm.shutdown()
|