From nobody Sun Feb 8 21:29:34 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1486138811418103.75065055596326; Fri, 3 Feb 2017 08:20:11 -0800 (PST) Received: from localhost ([::1]:35575 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZgam-0001Jg-TO for importer@patchew.org; Fri, 03 Feb 2017 11:20:08 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36782) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZg5p-0007pX-3x for qemu-devel@nongnu.org; Fri, 03 Feb 2017 10:48:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZg5j-00082z-VJ for qemu-devel@nongnu.org; Fri, 03 Feb 2017 10:48:09 -0500 Received: from mailhub.sw.ru ([195.214.232.25]:8881 helo=relay.sw.ru) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cZg5j-00080P-Du for qemu-devel@nongnu.org; Fri, 03 Feb 2017 10:48:03 -0500 Received: from kvm.qa.sw.ru. (msk-vpn.virtuozzo.com [195.214.232.6]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id v13Flv7v011039; Fri, 3 Feb 2017 18:47:58 +0300 (MSK) From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org, qemu-devel@nongnu.org Date: Fri, 3 Feb 2017 18:47:55 +0300 Message-Id: <20170203154757.36140-17-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170203154757.36140-1-vsementsov@virtuozzo.com> References: <20170203154757.36140-1-vsementsov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: OpenBSD 3.x [fuzzy] X-Received-From: 195.214.232.25 Subject: [Qemu-devel] [PATCH 16/18] iotests: add test for nbd dirty bitmap export X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, famz@redhat.com, den@virtuozzo.com, armbru@redhat.com, mreitz@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/180 | 133 +++++++++++++++++++++++++++++++++++++++++= ++++ tests/qemu-iotests/180.out | 5 ++ tests/qemu-iotests/group | 1 + 3 files changed, 139 insertions(+) create mode 100755 tests/qemu-iotests/180 create mode 100644 tests/qemu-iotests/180.out diff --git a/tests/qemu-iotests/180 b/tests/qemu-iotests/180 new file mode 100755 index 0000000000..e8238a064a --- /dev/null +++ b/tests/qemu-iotests/180 @@ -0,0 +1,133 @@ +#!/usr/bin/env python +# +# Test case for NBD's bitmap export +# Copyright (C) 2017 Virtuozzo. +# +# derived from io test 147, original copyright: +# 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 . +# + +import os +import socket +import stat +import time +import iotests +from iotests import cachemode, imgfmt, qemu_img, qemu_nbd + +NBD_PORT =3D 10811 + +test_img =3D os.path.join(iotests.test_dir, 'test.img') +unix_socket =3D os.path.join(iotests.test_dir, 'nbd.socket') + +class NBDBlockdevAddBase(iotests.QMPTestCase): + def blockdev_add_options(self, address, export=3DNone): + options =3D { 'node-name': 'nbd-blockdev', + 'driver': 'raw', + 'file': { + 'driver': 'nbd', + 'server': address, + 'bitmap': 'mega' + } } + if export is not None: + options['file']['export'] =3D export + return options + + def client_test(self, filename, address, sha256, export=3DNone): + bao =3D self.blockdev_add_options(address, export) + result =3D self.vm.qmp('blockdev-add', **bao) + self.assert_qmp(result, 'return', {}) + + result =3D self.vm.qmp('query-named-block-nodes') + for node in result['return']: + if node['node-name'] =3D=3D 'nbd-blockdev': + if isinstance(filename, str): + self.assert_qmp(node, 'image/filename', filename) + else: + self.assert_json_filename_equal(node['image']['filenam= e'], + filename) + break + + result =3D self.vm.qmp('block-dirty-bitmap-load', + node=3D'nbd-blockdev', name=3D'mega') + self.assert_qmp(result, 'return', {}) + + result =3D self.vm.qmp('x-debug-block-dirty-bitmap-sha256', + node=3D'nbd-blockdev', name=3D'mega') + self.assert_qmp(result, 'return/sha256', sha256); + + def setUp(self): + qemu_img('create', '-f', iotests.imgfmt, test_img, '0x400000000') + self.vm =3D iotests.VM() + self.vm.launch() + + self.server =3D iotests.VM('.server') + self.server.add_drive_raw('if=3Dnone,id=3Dnbd-export,' + + 'file=3D%s,' % test_img + + 'format=3D%s,' % imgfmt + + 'cache=3D%s' % cachemode) + self.server.launch() + + def tearDown(self): + self.vm.shutdown() + self.server.shutdown() + os.remove(test_img) + + def _server_up(self, address): + result =3D self.server.qmp('nbd-server-start', addr=3Daddress) + self.assert_qmp(result, 'return', {}) + + result =3D self.server.qmp('nbd-server-add', device=3D'nbd-export') + self.assert_qmp(result, 'return', {}) + + def _server_down(self): + result =3D self.server.qmp('nbd-server-stop') + self.assert_qmp(result, 'return', {}) + + def test_export_bitmap(self): + address =3D { 'type': 'inet', + 'data': { + 'host': 'localhost', + 'port': str(NBD_PORT) + } } + + granularity =3D 65536 + regions =3D [ + { 'start': 0, 'count': 0x100000 }, + { 'start': 0x100000000, 'count': 0x200000 }, + { 'start': 0x399900000, 'count': 0x100000 } + ] + + result =3D self.server.qmp('block-dirty-bitmap-add', node=3D'nbd-e= xport', + name=3D'mega', granularity=3Dgranularity) + self.assert_qmp(result, 'return', {}); + + for r in regions: + self.server.hmp_qemu_io('nbd-export', + 'write %d %d' % (r['start'], r['count'= ])) + + result =3D self.server.qmp('x-debug-block-dirty-bitmap-sha256', + node=3D'nbd-export', name=3D'mega') + sha256 =3D result['return']['sha256'] + + self._server_up(address) + self.client_test('nbd://localhost:%i/nbd-export' % NBD_PORT, + address, sha256, 'nbd-export') + #self._server_down() + +if __name__ =3D=3D '__main__': + # Need to support image creation + iotests.main(supported_fmts=3D['vpc', 'parallels', 'qcow', 'vdi', 'qco= w2', + 'vmdk', 'raw', 'vhdx', 'qed']) diff --git a/tests/qemu-iotests/180.out b/tests/qemu-iotests/180.out new file mode 100644 index 0000000000..ae1213e6f8 --- /dev/null +++ b/tests/qemu-iotests/180.out @@ -0,0 +1,5 @@ +. +---------------------------------------------------------------------- +Ran 1 tests + +OK diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 866c1a032d..9d06d3f862 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -165,3 +165,4 @@ 170 rw auto quick 171 rw auto quick 172 auto +180 auto --=20 2.11.0