mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-21 17:11:57 -06:00
iotests: add test for backup-top failure on permission activation
This test checks that bug is really fixed by previous commit. Cc: qemu-stable@nongnu.org # v4.2.0 Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Message-id: 20200121142802.21467-3-vsementsov@virtuozzo.com Signed-off-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
parent
0df62f45c1
commit
a541fcc27c
3 changed files with 101 additions and 0 deletions
92
tests/qemu-iotests/283
Normal file
92
tests/qemu-iotests/283
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
#
|
||||||
|
# Test for backup-top filter permission activation failure
|
||||||
|
#
|
||||||
|
# Copyright (c) 2019 Virtuozzo International GmbH.
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# The test is unrelated to formats, restrict it to qcow2 to avoid extra runs
|
||||||
|
iotests.verify_image_format(supported_fmts=['qcow2'])
|
||||||
|
|
||||||
|
size = 1024 * 1024
|
||||||
|
|
||||||
|
""" Test description
|
||||||
|
|
||||||
|
When performing a backup, all writes on the source subtree must go through the
|
||||||
|
backup-top filter so it can copy all data to the target before it is changed.
|
||||||
|
backup-top filter is appended above source node, to achieve this thing, so all
|
||||||
|
parents of source node are handled. A configuration with side parents of source
|
||||||
|
sub-tree with write permission is unsupported (we'd have append several
|
||||||
|
backup-top filter like nodes to handle such parents). The test create an
|
||||||
|
example of such configuration and checks that a backup is then not allowed
|
||||||
|
(blockdev-backup command should fail).
|
||||||
|
|
||||||
|
The configuration:
|
||||||
|
|
||||||
|
┌────────┐ target ┌─────────────┐
|
||||||
|
│ target │ ◀─────── │ backup_top │
|
||||||
|
└────────┘ └─────────────┘
|
||||||
|
│
|
||||||
|
│ backing
|
||||||
|
▼
|
||||||
|
┌─────────────┐
|
||||||
|
│ source │
|
||||||
|
└─────────────┘
|
||||||
|
│
|
||||||
|
│ file
|
||||||
|
▼
|
||||||
|
┌─────────────┐ write perm ┌───────┐
|
||||||
|
│ base │ ◀──────────── │ other │
|
||||||
|
└─────────────┘ └───────┘
|
||||||
|
|
||||||
|
On activation (see .active field of backup-top state in block/backup-top.c),
|
||||||
|
backup-top is going to unshare write permission on its source child. Write
|
||||||
|
unsharing will be propagated to the "source->base" link and will conflict with
|
||||||
|
other node write permission. So permission update will fail and backup job will
|
||||||
|
not be started.
|
||||||
|
|
||||||
|
Note, that the only thing which prevents backup of running on such
|
||||||
|
configuration is default permission propagation scheme. It may be altered by
|
||||||
|
different block drivers, so backup will run in invalid configuration. But
|
||||||
|
something is better than nothing. Also, before the previous commit (commit
|
||||||
|
preceding this test creation), starting backup on such configuration led to
|
||||||
|
crash, so current "something" is a lot better, and this test actual goal is
|
||||||
|
to check that crash is fixed :)
|
||||||
|
"""
|
||||||
|
|
||||||
|
vm = iotests.VM()
|
||||||
|
vm.launch()
|
||||||
|
|
||||||
|
vm.qmp_log('blockdev-add', **{'node-name': 'target', 'driver': 'null-co'})
|
||||||
|
|
||||||
|
vm.qmp_log('blockdev-add', **{
|
||||||
|
'node-name': 'source',
|
||||||
|
'driver': 'blkdebug',
|
||||||
|
'image': {'node-name': 'base', 'driver': 'null-co', 'size': size}
|
||||||
|
})
|
||||||
|
|
||||||
|
vm.qmp_log('blockdev-add', **{
|
||||||
|
'node-name': 'other',
|
||||||
|
'driver': 'blkdebug',
|
||||||
|
'image': 'base',
|
||||||
|
'take-child-perms': ['write']
|
||||||
|
})
|
||||||
|
|
||||||
|
vm.qmp_log('blockdev-backup', sync='full', device='source', target='target')
|
||||||
|
|
||||||
|
vm.shutdown()
|
8
tests/qemu-iotests/283.out
Normal file
8
tests/qemu-iotests/283.out
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{"execute": "blockdev-add", "arguments": {"driver": "null-co", "node-name": "target"}}
|
||||||
|
{"return": {}}
|
||||||
|
{"execute": "blockdev-add", "arguments": {"driver": "blkdebug", "image": {"driver": "null-co", "node-name": "base", "size": 1048576}, "node-name": "source"}}
|
||||||
|
{"return": {}}
|
||||||
|
{"execute": "blockdev-add", "arguments": {"driver": "blkdebug", "image": "base", "node-name": "other", "take-child-perms": ["write"]}}
|
||||||
|
{"return": {}}
|
||||||
|
{"execute": "blockdev-backup", "arguments": {"device": "source", "sync": "full", "target": "target"}}
|
||||||
|
{"error": {"class": "GenericError", "desc": "Cannot set permissions for backup-top filter: Conflicts with use by other as 'image', which uses 'write' on base"}}
|
|
@ -289,3 +289,4 @@
|
||||||
279 rw backing quick
|
279 rw backing quick
|
||||||
280 rw migration quick
|
280 rw migration quick
|
||||||
281 rw quick
|
281 rw quick
|
||||||
|
283 auto quick
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue