From patchwork Sat Jan 30 10:56:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 575945 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4A576140C02 for ; Sat, 30 Jan 2016 21:57:39 +1100 (AEDT) Received: from localhost ([::1]:38245 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aPTDl-00036x-4O for incoming@patchwork.ozlabs.org; Sat, 30 Jan 2016 05:57:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51587) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aPTDC-00020X-Mp for qemu-devel@nongnu.org; Sat, 30 Jan 2016 05:57:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aPTD9-0002Wc-ES for qemu-devel@nongnu.org; Sat, 30 Jan 2016 05:57:02 -0500 Received: from mailhub.sw.ru ([195.214.232.25]:48797 helo=relay.sw.ru) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aPTD9-0002VF-2L for qemu-devel@nongnu.org; Sat, 30 Jan 2016 05:56:59 -0500 Received: from kvm.sw.ru. ([10.28.8.145]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id u0TKtNex009503; Fri, 29 Jan 2016 23:55:32 +0300 (MSK) From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Date: Sat, 30 Jan 2016 13:56:31 +0300 Message-Id: <1454151394-52320-4-git-send-email-vsementsov@virtuozzo.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1454151394-52320-1-git-send-email-vsementsov@virtuozzo.com> References: <1454151394-52320-1-git-send-email-vsementsov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: OpenBSD 3.x X-Received-From: 195.214.232.25 Cc: kwolf@redhat.com, Vladimir Sementsov-Ogievskiy , famz@redhat.com, den@virtuozzo.com, armbru@redhat.com, jsnow@redhat.com Subject: [Qemu-devel] [PATCH 3/6] iotests: test query-block-dirty-bitmap-ranges X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Add test for QMP command query-block-dirty-bitmap-ranges. Signed-off-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/150 | 88 ++++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/150.out | 21 +++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 110 insertions(+) create mode 100755 tests/qemu-iotests/150 create mode 100644 tests/qemu-iotests/150.out diff --git a/tests/qemu-iotests/150 b/tests/qemu-iotests/150 new file mode 100755 index 0000000..f208050 --- /dev/null +++ b/tests/qemu-iotests/150 @@ -0,0 +1,88 @@ +#!/usr/bin/env python +# +# Test qmp command query-block-dirty-bitmap-ranges +# +# (C) Vladimir Sementsov-Ogievskiy 2015 +# +# 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 . +# + +import os +import iotests +import time +from iotests import qemu_img + +disk = os.path.join(iotests.test_dir, 'disk') + +size = 0x40000000 # 1G +sector_size = 512 +granularity = 0x10000 +regions = [ + { 'start': 0, 'count': 0x100000 }, + { 'start': 0x10000000, 'count': 0x20000 }, + { 'start': 0x39990000, 'count': 0x10000 } + ] + +class TestQueryDirtyBitmap(iotests.QMPTestCase): + + def setUp(self): + qemu_img('create', '-f', iotests.imgfmt, disk, str(size)) + self.vm = iotests.VM().add_drive(disk) + self.vm.launch() + + def tearDown(self): + self.vm.shutdown() + os.remove(disk) + + def printRange(self, begin, end): + print self.vm.qmp('query-block-dirty-bitmap-ranges', node='drive0', + name='bitmap', start=begin, count=(end - begin), + max_ranges=100); + + def printWhole(self, max_ranges=100): + print self.vm.qmp('query-block-dirty-bitmap-ranges', node='drive0', + name='bitmap', max_ranges=max_ranges); + + def test_query_bitmap(self): + result = self.vm.qmp('block-dirty-bitmap-add', node='drive0', + name='bitmap', granularity=granularity) + self.assert_qmp(result, 'return', {}); + + for r in regions: + self.vm.hmp_qemu_io('drive0', + 'write %d %d' % (r['start'], r['count'])) + + self.printWhole() + self.printWhole(2) + self.printRange(100, 200) + self.printRange(0x100000 - 10, 0x10000000 + 10) + print + + self.printRange(0x100000 - 10, 0x10000000 + 1) + self.printRange(0x100000 - 10, 0x10000000) + self.printRange(0x100000 - 10, 0x10000000 - 1) + print + + self.printRange(0x100000 + 1, 0x10000000 - 1) + self.printRange(0x100000 + 1, 0x10000000) + self.printRange(0x100000 + 1, 0x10000000 + 1) + print + + self.printRange(0x100000, 0x10000000 - 1) + self.printRange(0x100000, 0x10000000) + self.printRange(0x100000, 0x10000000 + 1) + + +if __name__ == '__main__': + iotests.main() diff --git a/tests/qemu-iotests/150.out b/tests/qemu-iotests/150.out new file mode 100644 index 0000000..c137925 --- /dev/null +++ b/tests/qemu-iotests/150.out @@ -0,0 +1,21 @@ +. +---------------------------------------------------------------------- +Ran 1 tests + +OK +{u'return': [{u'count': 1048576, u'start': 0}, {u'count': 131072, u'start': 268435456}, {u'count': 65536, u'start': 966328320}]} +{u'return': [{u'count': 1048576, u'start': 0}, {u'count': 131072, u'start': 268435456}]} +{u'return': [{u'count': 100, u'start': 100}]} +{u'return': [{u'count': 10, u'start': 1048566}, {u'count': 10, u'start': 268435456}]} + +{u'return': [{u'count': 10, u'start': 1048566}, {u'count': 1, u'start': 268435456}]} +{u'return': [{u'count': 10, u'start': 1048566}]} +{u'return': [{u'count': 10, u'start': 1048566}]} + +{u'return': []} +{u'return': []} +{u'return': [{u'count': 1, u'start': 268435456}]} + +{u'return': []} +{u'return': []} +{u'return': [{u'count': 1, u'start': 268435456}]} diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index d6e9219..84db670 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -142,3 +142,4 @@ 138 rw auto quick 139 rw auto quick 142 auto +150 auto