298 (c5ea91da443b458352c1b629b490ee6631775cb4) 298 (b6aed193e5ecca32bb07e062f58f0daca06e7009)
1#!/usr/bin/env python3
2#
3# Test for preallocate filter
4#
5# Copyright (c) 2020 Virtuozzo International GmbH.
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by

--- 66 unchanged lines hidden (view full) ---

75
76 def test_prealloc(self):
77 self.vm.hmp_qemu_io('drive0', 'write 0 1M')
78 self.check_big()
79
80 def test_external_snapshot(self):
81 self.test_prealloc()
82
1#!/usr/bin/env python3
2#
3# Test for preallocate filter
4#
5# Copyright (c) 2020 Virtuozzo International GmbH.
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by

--- 66 unchanged lines hidden (view full) ---

75
76 def test_prealloc(self):
77 self.vm.hmp_qemu_io('drive0', 'write 0 1M')
78 self.check_big()
79
80 def test_external_snapshot(self):
81 self.test_prealloc()
82
83 result = self.vm.qmp('blockdev-snapshot-sync', node_name='disk',
84 snapshot_file=overlay,
85 snapshot_node_name='overlay')
86 self.assert_qmp(result, 'return', {})
83 self.vm.cmd('blockdev-snapshot-sync', node_name='disk',
84 snapshot_file=overlay,
85 snapshot_node_name='overlay')
87
88 # on reopen to r-o base preallocation should be dropped
89 self.check_small()
90
91 self.vm.hmp_qemu_io('drive0', 'write 1M 1M')
92
86
87 # on reopen to r-o base preallocation should be dropped
88 self.check_small()
89
90 self.vm.hmp_qemu_io('drive0', 'write 1M 1M')
91
93 result = self.vm.qmp('block-commit', device='overlay')
94 self.assert_qmp(result, 'return', {})
92 self.vm.cmd('block-commit', device='overlay')
95 self.complete_and_wait()
96
97 # commit of new megabyte should trigger preallocation
98 self.check_big()
99
100 def test_reopen_opts(self):
93 self.complete_and_wait()
94
95 # commit of new megabyte should trigger preallocation
96 self.check_big()
97
98 def test_reopen_opts(self):
101 result = self.vm.qmp('blockdev-reopen', options=[{
99 self.vm.cmd('blockdev-reopen', options=[{
102 'node-name': 'disk',
103 'driver': iotests.imgfmt,
104 'file': {
105 'node-name': 'filter',
106 'driver': 'preallocate',
107 'prealloc-size': 20 * MiB,
108 'prealloc-align': 5 * MiB,
109 'file': {
110 'node-name': 'file',
111 'driver': 'file',
112 'filename': disk
113 }
114 }
115 }])
100 'node-name': 'disk',
101 'driver': iotests.imgfmt,
102 'file': {
103 'node-name': 'filter',
104 'driver': 'preallocate',
105 'prealloc-size': 20 * MiB,
106 'prealloc-align': 5 * MiB,
107 'file': {
108 'node-name': 'file',
109 'driver': 'file',
110 'filename': disk
111 }
112 }
113 }])
116 self.assert_qmp(result, 'return', {})
117
118 self.vm.hmp_qemu_io('drive0', 'write 0 1M')
119 self.assertTrue(os.path.getsize(disk) == 25 * MiB)
120
121
122class TestTruncate(iotests.QMPTestCase):
123 def setUp(self):
124 iotests.qemu_img_create('-f', iotests.imgfmt, disk, str(10 * MiB))

--- 59 unchanged lines hidden ---
114
115 self.vm.hmp_qemu_io('drive0', 'write 0 1M')
116 self.assertTrue(os.path.getsize(disk) == 25 * MiB)
117
118
119class TestTruncate(iotests.QMPTestCase):
120 def setUp(self):
121 iotests.qemu_img_create('-f', iotests.imgfmt, disk, str(10 * MiB))

--- 59 unchanged lines hidden ---