Skip to content

Commit 9592fe4

Browse files
committed
iotests: Add test for failing mirror complete
Signed-off-by: Max Reitz <[email protected]> Reviewed-by: Vladimir Sementsov-Ogievskiy <[email protected]> Tested-by: Vladimir Sementsov-Ogievskiy <[email protected]> Reviewed-by: John Snow <[email protected]> Message-id: [email protected] Signed-off-by: Max Reitz <[email protected]>
1 parent 216656f commit 9592fe4

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

tests/qemu-iotests/041

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,6 +1121,50 @@ class TestOrphanedSource(iotests.QMPTestCase):
11211121
target='dest-ro')
11221122
self.assert_qmp(result, 'error/class', 'GenericError')
11231123

1124+
def test_failing_permission_in_complete(self):
1125+
self.assert_no_active_block_jobs()
1126+
1127+
# Unshare consistent-read on the target
1128+
# (The mirror job does not care)
1129+
result = self.vm.qmp('blockdev-add',
1130+
driver='blkdebug',
1131+
node_name='dest-perm',
1132+
image='dest',
1133+
unshare_child_perms=['consistent-read'])
1134+
self.assert_qmp(result, 'return', {})
1135+
1136+
result = self.vm.qmp('blockdev-mirror', job_id='job', device='src',
1137+
sync='full', target='dest',
1138+
filter_node_name='mirror-filter')
1139+
self.assert_qmp(result, 'return', {})
1140+
1141+
# Require consistent-read on the source
1142+
# (We can only add this node once the job has started, or it
1143+
# will complain that it does not want to run on non-root nodes)
1144+
result = self.vm.qmp('blockdev-add',
1145+
driver='blkdebug',
1146+
node_name='src-perm',
1147+
image='src',
1148+
take_child_perms=['consistent-read'])
1149+
self.assert_qmp(result, 'return', {})
1150+
1151+
# While completing, mirror will attempt to replace src by
1152+
# dest, which must fail because src-perm requires
1153+
# consistent-read but dest-perm does not share it; thus
1154+
# aborting the job when it is supposed to complete
1155+
self.complete_and_wait('job',
1156+
completion_error='Operation not permitted')
1157+
1158+
# Assert that all of our nodes are still there (except for the
1159+
# mirror filter, which should be gone despite the failure)
1160+
nodes = self.vm.qmp('query-named-block-nodes')['return']
1161+
nodes = [node['node-name'] for node in nodes]
1162+
1163+
for expect in ('src', 'src-perm', 'dest', 'dest-perm'):
1164+
self.assertTrue(expect in nodes, '%s disappeared' % expect)
1165+
self.assertFalse('mirror-filter' in nodes,
1166+
'Mirror filter node did not disappear')
1167+
11241168
if __name__ == '__main__':
11251169
iotests.main(supported_fmts=['qcow2', 'qed'],
11261170
supported_protocols=['file'])

tests/qemu-iotests/041.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
..........................................................................................
1+
...........................................................................................
22
----------------------------------------------------------------------
3-
Ran 90 tests
3+
Ran 91 tests
44

55
OK

0 commit comments

Comments
 (0)