From nobody Sun Feb 8 18:29:28 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1558626780; cv=none; d=zoho.com; s=zohoarc; b=mAlfq1UN+ih+PnBsV75wnavBN353RDXxdlvKvDCO06oBTody3ZTfmwMYHikrCS7oG57FDx7zCChKDEVAnARGSV0pIdc6gyD9v6Ht/Dc+3EQaMscWCapVxHjxzaK5Le8/xbaU0Wth0XJM10SqdOdEo2n4wsAscvudDFqVGf/l26o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558626780; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=8l7wExIp+e2wubAlsaL5po4uRlkZpxAXmIfqTZuQQQw=; b=SrO7me9bpA1YvjzGYOvuoHZp4sEhtOD+zPGbslp8Lxv8adB+/XbSjpJdR/J4yuNkYn9mfHx9xHlLjQ9pV2ZIGh4OgBjpyoqdFXnrSzd0/GnVE8I7gPaPsDvsh/YhCw9MHhRU7Gc2VvXAoBhVN8eBKnnBWqMdmJMBBxK2yf8nIes= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1558626780385384.88205262794986; Thu, 23 May 2019 08:53:00 -0700 (PDT) Received: from localhost ([127.0.0.1]:39362 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTq1T-0006NU-3c for importer@patchew.org; Thu, 23 May 2019 11:52:51 -0400 Received: from eggs.gnu.org ([209.51.188.92]:53835) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTpwU-0003AB-PY for qemu-devel@nongnu.org; Thu, 23 May 2019 11:47:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hTpwT-0007vz-9s for qemu-devel@nongnu.org; Thu, 23 May 2019 11:47:42 -0400 Received: from relay.sw.ru ([185.231.240.75]:34906) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hTpwS-0007u4-QL; Thu, 23 May 2019 11:47:41 -0400 Received: from [10.94.3.0] (helo=kvm.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1hTpwL-0002xl-Mv; Thu, 23 May 2019 18:47:33 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Thu, 23 May 2019 18:47:31 +0300 Message-Id: <20190523154733.54944-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190523154733.54944-1-vsementsov@virtuozzo.com> References: <20190523154733.54944-1-vsementsov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 Subject: [Qemu-devel] [PATCH 1/3] iotests: add test 255 to check bitmap life after snapshot + commit 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: fam@euphon.net, kwolf@redhat.com, vsementsov@virtuozzo.com, mreitz@redhat.com, den@openvz.org, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Two testcases with persistent bitmaps are not added here, as there are bugs to be fixed soon. Signed-off-by: Vladimir Sementsov-Ogievskiy --- python/qemu/__init__.py | 4 +- tests/qemu-iotests/255 | 81 ++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/255.out | 17 ++++++++ tests/qemu-iotests/group | 1 + 4 files changed, 102 insertions(+), 1 deletion(-) create mode 100755 tests/qemu-iotests/255 create mode 100644 tests/qemu-iotests/255.out diff --git a/python/qemu/__init__.py b/python/qemu/__init__.py index 81d9657ec0..4c4317a55e 100644 --- a/python/qemu/__init__.py +++ b/python/qemu/__init__.py @@ -402,7 +402,7 @@ class QEMUMachine(object): self._qmp.clear_events() return events =20 - def event_wait(self, name, timeout=3D60.0, match=3DNone): + def event_wait(self, name, timeout=3D60.0, match=3DNone, fail_on=3DNon= e): """ Wait for specified timeout on named event in QMP; optionally filter results by match. @@ -430,6 +430,7 @@ class QEMUMachine(object): =20 # Search cached events for event in self._events: + assert event['event'] !=3D fail_on if (event['event'] =3D=3D name) and event_match(event, match): self._events.remove(event) return event @@ -437,6 +438,7 @@ class QEMUMachine(object): # Poll for new events while True: event =3D self._qmp.pull_event(wait=3Dtimeout) + assert event['event'] !=3D fail_on if (event['event'] =3D=3D name) and event_match(event, match): return event self._events.append(event) diff --git a/tests/qemu-iotests/255 b/tests/qemu-iotests/255 new file mode 100755 index 0000000000..36712689d3 --- /dev/null +++ b/tests/qemu-iotests/255 @@ -0,0 +1,81 @@ +#!/usr/bin/env python +# +# Tests for temporary external snapshot when we have bitmaps. +# +# Copyright (c) 2019 Virtuozzo International GmbH. All rights reserved. +# +# 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 iotests +from iotests import qemu_img_create, file_path, log + +iotests.verify_image_format(supported_fmts=3D['qcow2']) + +base, top =3D file_path('base', 'top') +size =3D 64 * 1024 * 3 + + +def print_bitmap(msg, vm): + result =3D vm.qmp('query-block')['return'][0] + if 'dirty-bitmaps' in result: + bitmap =3D result['dirty-bitmaps'][0] + log('{}: name=3D{} dirty-clusters=3D{}'.format(msg, bitmap['name'], + bitmap['count'] // 64 // 1024)) + else: + log(msg + ': not found') + + +def test(persistent, restart): + assert persistent or not restart + log("\nTestcase {}persistent {} restart\n".format( + '' if persistent else 'non-', 'with' if restart else 'without'= )) + + qemu_img_create('-f', iotests.imgfmt, base, str(size)) + + vm =3D iotests.VM().add_drive(base) + vm.launch() + + vm.qmp_log('block-dirty-bitmap-add', node=3D'drive0', name=3D'bitmap0', + persistent=3Dpersistent) + vm.hmp_qemu_io('drive0', 'write 0 64K') + print_bitmap('initial bitmap', vm) + + vm.qmp_log('blockdev-snapshot-sync', device=3D'drive0', snapshot_file= =3Dtop, + format=3Diotests.imgfmt, filters=3D[iotests.filter_qmp_test= files]) + vm.hmp_qemu_io('drive0', 'write 64K 512') + print_bitmap('check, that no bitmaps in snapshot', vm) + + if restart: + log("... Restart ...") + vm.shutdown() + vm =3D iotests.VM().add_drive(top) + vm.launch() + + vm.qmp_log('block-commit', device=3D'drive0', top=3Dtop, + filters=3D[iotests.filter_qmp_testfiles]) + log(vm.event_wait('BLOCK_JOB_READY', fail_on=3D'BLOCK_JOB_COMPLETED'), + filters=3D[iotests.filter_qmp_event]) + vm.qmp_log('block-job-complete', device=3D'drive0') + log(vm.event_wait('BLOCK_JOB_COMPLETED'), + filters=3D[iotests.filter_qmp_event]) + print_bitmap('check merged bitmap', vm) + + vm.hmp_qemu_io('drive0', 'write 128K 64K') + print_bitmap('check updated bitmap', vm) + + vm.shutdown() + + +test(persistent=3DFalse, restart=3DFalse) diff --git a/tests/qemu-iotests/255.out b/tests/qemu-iotests/255.out new file mode 100644 index 0000000000..2bffb486d2 --- /dev/null +++ b/tests/qemu-iotests/255.out @@ -0,0 +1,17 @@ + +Testcase non-persistent without restart + +{"execute": "block-dirty-bitmap-add", "arguments": {"name": "bitmap0", "no= de": "drive0", "persistent": false}} +{"return": {}} +initial bitmap: name=3Dbitmap0 dirty-clusters=3D1 +{"execute": "blockdev-snapshot-sync", "arguments": {"device": "drive0", "f= ormat": "qcow2", "snapshot-file": "TEST_DIR/PID-top"}} +{"return": {}} +check, that no bitmaps in snapshot: not found +{"execute": "block-commit", "arguments": {"device": "drive0", "top": "TEST= _DIR/PID-top"}} +{"return": {}} +{"data": {"device": "drive0", "len": 65536, "offset": 65536, "speed": 0, "= type": "commit"}, "event": "BLOCK_JOB_READY", "timestamp": {"microseconds":= "USECS", "seconds": "SECS"}} +{"execute": "block-job-complete", "arguments": {"device": "drive0"}} +{"return": {}} +{"data": {"device": "drive0", "len": 65536, "offset": 65536, "speed": 0, "= type": "commit"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microsecon= ds": "USECS", "seconds": "SECS"}} +check merged bitmap: name=3Dbitmap0 dirty-clusters=3D2 +check updated bitmap: name=3Dbitmap0 dirty-clusters=3D3 diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 52b7c16e15..2758f48143 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -251,3 +251,4 @@ 249 rw auto quick 252 rw auto backing quick 253 rw auto quick +255 rw auto quick --=20 2.18.0