From nobody Wed Nov 5 09:54:34 2025 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.zohomail.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 1499705114342261.08402693232847; Mon, 10 Jul 2017 09:45:14 -0700 (PDT) Received: from localhost ([::1]:42019 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUbo6-0003ef-Es for importer@patchew.org; Mon, 10 Jul 2017 12:45:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47108) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUba5-0000fF-W5 for qemu-devel@nongnu.org; Mon, 10 Jul 2017 12:30:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dUba3-0001Oz-GP for qemu-devel@nongnu.org; Mon, 10 Jul 2017 12:30:41 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:9229 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 1dUba2-0001Ma-Vt; Mon, 10 Jul 2017 12:30:39 -0400 Received: from kvm.sw.ru (msk-vpn.virtuozzo.com [195.214.232.6]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id v6AGUTIr031112; Mon, 10 Jul 2017 19:30:33 +0300 (MSK) From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org, qemu-devel@nongnu.org Date: Mon, 10 Jul 2017 19:30:28 +0300 Message-Id: <20170710163029.129912-16-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.11.1 In-Reply-To: <20170710163029.129912-1-vsementsov@virtuozzo.com> References: <20170710163029.129912-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 v7 15/16] iotests: add dirty bitmap migration test 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, peter.maydell@linaro.org, vsementsov@virtuozzo.com, famz@redhat.com, lirans@il.ibm.com, quintela@redhat.com, jsnow@redhat.com, armbru@redhat.com, mreitz@redhat.com, stefanha@redhat.com, den@openvz.org, amit.shah@redhat.com, pbonzini@redhat.com, dgilbert@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" The test starts two vms (vm_a, vm_b), create dirty bitmap in the first one, do several writes to corresponding device and then migrate vm_a to vm_b with dirty bitmaps. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- tests/qemu-iotests/169 | 86 ++++++++++++++++++++++++++++++++++++++++++= ++++ tests/qemu-iotests/169.out | 5 +++ tests/qemu-iotests/group | 1 + 3 files changed, 92 insertions(+) create mode 100755 tests/qemu-iotests/169 create mode 100644 tests/qemu-iotests/169.out diff --git a/tests/qemu-iotests/169 b/tests/qemu-iotests/169 new file mode 100755 index 0000000000..ec6cd46a4d --- /dev/null +++ b/tests/qemu-iotests/169 @@ -0,0 +1,86 @@ +#!/usr/bin/env python +# +# Tests for dirty bitmaps migration. +# +# Copyright (C) Vladimir Sementsov-Ogievskiy 2015-2016 +# +# 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_a =3D os.path.join(iotests.test_dir, 'disk_a') +disk_b =3D os.path.join(iotests.test_dir, 'disk_b') +fifo =3D os.path.join(iotests.test_dir, 'mig_fifo') + +class TestDirtyBitmapMigration(iotests.QMPTestCase): + + def setUp(self): + size =3D 0x400000000 # 1G + os.mkfifo(fifo) + qemu_img('create', '-f', iotests.imgfmt, disk_a, str(size)) + qemu_img('create', '-f', iotests.imgfmt, disk_b, str(size)) + self.vm_a =3D iotests.VM(path_suffix=3D'a').add_drive(disk_a) + self.vm_b =3D iotests.VM(path_suffix=3D'b').add_drive(disk_b) + self.vm_b.add_incoming_migration("exec: cat '" + fifo + "'") + self.vm_a.launch() + self.vm_b.launch() + + def tearDown(self): + self.vm_a.shutdown() + self.vm_b.shutdown() + os.remove(disk_a) + os.remove(disk_b) + os.remove(fifo) + + def test_migration(self): + granularity =3D 512 + regions =3D [ + { 'start': 0, 'count': 0x100000 }, + { 'start': 0x100000000, 'count': 0x200000 }, + { 'start': 0x399900000, 'count': 0x100000 } + ] + + result =3D self.vm_a.qmp('block-dirty-bitmap-add', node=3D'drive0', + name=3D'bitmap', granularity=3Dgranularity) + self.assert_qmp(result, 'return', {}); + + for r in regions: + self.vm_a.hmp_qemu_io('drive0', + 'write %d %d' % (r['start'], r['count'])) + + result =3D self.vm_a.qmp('x-debug-block-dirty-bitmap-sha256', + node=3D'drive0', name=3D'bitmap') + sha256 =3D result['return']['sha256'] + + result =3D self.vm_a.qmp('migrate-set-capabilities', + capabilities=3D[{'capability': 'dirty-bitma= ps', + 'state': True}]) + self.assert_qmp(result, 'return', {}) + + result =3D self.vm_a.qmp('migrate', uri=3D'exec:cat>' + fifo) + self.assertNotEqual(self.vm_a.event_wait("STOP"), None) + self.assertNotEqual(self.vm_b.event_wait("RESUME"), None) + time.sleep(2) + + result =3D self.vm_b.qmp('x-debug-block-dirty-bitmap-sha256', + node=3D'drive0', name=3D'bitmap') + self.assert_qmp(result, 'return/sha256', sha256); + + +if __name__ =3D=3D '__main__': + iotests.main() diff --git a/tests/qemu-iotests/169.out b/tests/qemu-iotests/169.out new file mode 100644 index 0000000000..ae1213e6f8 --- /dev/null +++ b/tests/qemu-iotests/169.out @@ -0,0 +1,5 @@ +. +---------------------------------------------------------------------- +Ran 1 tests + +OK diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 40bef995fe..a0b7972879 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -165,6 +165,7 @@ 160 rw auto quick 162 auto quick 165 rw auto quick +169 rw auto quick 170 rw auto quick 171 rw auto quick 172 auto --=20 2.11.1