new file mode 100644
@@ -0,0 +1,62 @@
+#!/usr/bin/env python
+#
+# Tests for persistent dirty bitmap
+#
+# Copyright (C) 2016 Red Hat, Inc.
+#
+# 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 os
+import iotests
+from iotests import qemu_img, qemu_io
+
+test_img = os.path.join(iotests.test_dir, 'test.img')
+
+class TestPersistentDirtyBitmap(iotests.QMPTestCase):
+ image_len = 64 * 1024 * 1024 # MB
+ def setUp(self):
+ # Write data to the image so we can compare later
+ qemu_img('create', '-f', iotests.imgfmt, test_img, str(self.image_len))
+ self.vm = iotests.VM().add_drive(test_img)
+ self.vm.launch()
+
+ def tearDown(self):
+ self.vm.shutdown()
+ os.remove(test_img)
+
+ def do_test_create(self, n):
+ def make_range(k):
+ return (k * 65536, 512)
+ r = range(n)
+ for i in r:
+ result = self.vm.qmp('block-dirty-bitmap-add', node='drive0',
+ name='bitmap-%d' % i,
+ persistent=True)
+ self.assert_qmp(result, 'return', {})
+ self.vm.hmp_qemu_io('drive0', 'write -P %d %d %d' % ((i % 255,) + make_range(i)))
+ for i in r:
+ result = self.vm.qmp('block-dirty-bitmap-set-persistent',
+ node='drive0', name='bitmap-%d' % i,
+ persistent=False)
+ self.assert_qmp(result, 'return', {})
+
+ def test_simple_one(self):
+ self.do_test_create(1)
+
+ def test_simple_multiple(self):
+ self.do_test_create(10)
+
+if __name__ == '__main__':
+ iotests.main(supported_fmts=['qbm'])
new file mode 100644
@@ -0,0 +1,5 @@
+..
+----------------------------------------------------------------------
+Ran 2 tests
+
+OK
@@ -142,4 +142,5 @@
138 rw auto quick
139 rw auto quick
140 rw auto quick
+141 rw auto quick
142 auto
For now it merely invokes block-dirty-bitmap-{add,set-persistent}. Verification of the bitmap data and user data to be added in the future. Signed-off-by: Fam Zheng <famz@redhat.com> --- tests/qemu-iotests/141 | 62 ++++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/141.out | 5 ++++ tests/qemu-iotests/group | 1 + 3 files changed, 68 insertions(+) create mode 100644 tests/qemu-iotests/141 create mode 100644 tests/qemu-iotests/141.out