new file mode 100755
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+#
+# Test for qcow2 bitmap printed information
+#
+# Copyright (c) 2018 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
+import json
+from iotests import qemu_img_create, qemu_io, qemu_img_pipe, \
+ file_path, log
+
+disk = file_path('disk')
+chunk = 256
+
+def print_bitmap():
+ log('bitmap info dump:')
+ result = json.loads(qemu_img_pipe('info', '--force-share',
+ '--output=json', disk))
+ bitmaps = result['format-specific']['data']['bitmaps']
+ log(bitmaps, indent=2)
+
+def add_bitmap(bitmap_number):
+ num = bitmap_number
+ granularity = 2**(13 + num)
+ bitmap_name = 'bitmap-' + str(num)
+ vm = iotests.VM().add_drive(disk)
+ vm.launch()
+ vm.qmp_log('block-dirty-bitmap-add', node='drive0', name=bitmap_name,
+ granularity=granularity, persistent=True)
+ vm.shutdown()
+ write = 'write {} {}K'.format((num-1)*chunk, chunk)
+ qemu_io('-f', iotests.imgfmt, '-c', write, disk)
+
+iotests.verify_image_format(supported_fmts=['qcow2'])
+qemu_img_create('-f', iotests.imgfmt, disk, '1M')
+
+for num in range(1, 4):
+ add_bitmap(num)
+ print_bitmap()
+ log('')
+
+vm = iotests.VM().add_drive(disk)
+vm.launch()
+log('Check \"in-use\" flag')
+print_bitmap()
+vm.shutdown()
new file mode 100644
@@ -0,0 +1,88 @@
+{"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 16384, "name": "bitmap-1", "node": "drive0", "persistent": true}}
+{"return": {}}
+bitmap info dump:
+[
+ {
+ "flags": [
+ "auto"
+ ],
+ "granularity": 16384,
+ "name": "bitmap-1"
+ }
+]
+
+{"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 32768, "name": "bitmap-2", "node": "drive0", "persistent": true}}
+{"return": {}}
+bitmap info dump:
+[
+ {
+ "flags": [
+ "auto"
+ ],
+ "granularity": 16384,
+ "name": "bitmap-1"
+ },
+ {
+ "flags": [
+ "auto"
+ ],
+ "granularity": 32768,
+ "name": "bitmap-2"
+ }
+]
+
+{"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 65536, "name": "bitmap-3", "node": "drive0", "persistent": true}}
+{"return": {}}
+bitmap info dump:
+[
+ {
+ "flags": [
+ "auto"
+ ],
+ "granularity": 16384,
+ "name": "bitmap-1"
+ },
+ {
+ "flags": [
+ "auto"
+ ],
+ "granularity": 32768,
+ "name": "bitmap-2"
+ },
+ {
+ "flags": [
+ "auto"
+ ],
+ "granularity": 65536,
+ "name": "bitmap-3"
+ }
+]
+
+Check "in-use" flag
+bitmap info dump:
+[
+ {
+ "flags": [
+ "in-use",
+ "auto"
+ ],
+ "granularity": 16384,
+ "name": "bitmap-1"
+ },
+ {
+ "flags": [
+ "in-use",
+ "auto"
+ ],
+ "granularity": 32768,
+ "name": "bitmap-2"
+ },
+ {
+ "flags": [
+ "in-use",
+ "auto"
+ ],
+ "granularity": 65536,
+ "name": "bitmap-3"
+ }
+]
@@ -235,3 +235,4 @@
235 auto quick
236 auto quick
238 auto quick
+239 rw auto quick
A new test file 239 added to the qemu-iotests set. It checks the output format of 'qemu-img info' for bitmaps extension of qcow2 specific information. Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com> --- tests/qemu-iotests/239 | 60 +++++++++++++++++++++++++++++++ tests/qemu-iotests/239.out | 88 ++++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 149 insertions(+) create mode 100755 tests/qemu-iotests/239 create mode 100644 tests/qemu-iotests/239.out