From patchwork Thu Dec 20 02:29:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 10738499 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E6529746 for ; Thu, 20 Dec 2018 02:32:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CFEE828908 for ; Thu, 20 Dec 2018 02:32:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD13F2890B; Thu, 20 Dec 2018 02:32:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D2EDB28908 for ; Thu, 20 Dec 2018 02:32:47 +0000 (UTC) Received: from localhost ([::1]:34999 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZo8k-00060K-U3 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 19 Dec 2018 21:32:47 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45411) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZo6r-0004Vc-FS for qemu-devel@nongnu.org; Wed, 19 Dec 2018 21:30:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZo6p-00087D-OK for qemu-devel@nongnu.org; Wed, 19 Dec 2018 21:30:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60186) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gZo6j-00080T-Sb; Wed, 19 Dec 2018 21:30:43 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B227A88E54; Thu, 20 Dec 2018 02:30:39 +0000 (UTC) Received: from probe.bos.redhat.com (dhcp-17-232.bos.redhat.com [10.18.17.232]) by smtp.corp.redhat.com (Postfix) with ESMTP id A99222D35F; Thu, 20 Dec 2018 02:30:38 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Wed, 19 Dec 2018 21:29:52 -0500 Message-Id: <20181220022952.20493-12-jsnow@redhat.com> In-Reply-To: <20181220022952.20493-1-jsnow@redhat.com> References: <20181220022952.20493-1-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 20 Dec 2018 02:30:39 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v5 11/11] iotests: add iotest 236 for testing bitmap merge 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: Kevin Wolf , Fam Zheng , vsementsov@virtuozzo.com, Markus Armbruster , Max Reitz , John Snow Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP New interface, new smoke test. Signed-off-by: John Snow Reviewed-by: Eric Blake Reviewed-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/236 | 161 +++++++++++++++++ tests/qemu-iotests/236.out | 351 +++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 513 insertions(+) create mode 100755 tests/qemu-iotests/236 create mode 100644 tests/qemu-iotests/236.out diff --git a/tests/qemu-iotests/236 b/tests/qemu-iotests/236 new file mode 100755 index 0000000000..42b93da3ad --- /dev/null +++ b/tests/qemu-iotests/236 @@ -0,0 +1,161 @@ +#!/usr/bin/env python +# +# Test bitmap merges. +# +# Copyright (c) 2018 John Snow for 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 . +# +# owner=jsnow@redhat.com + +import iotests +from iotests import log + +iotests.verify_image_format(supported_fmts=['generic']) +size = 64 * 1024 * 1024 +granularity = 64 * 1024 + +patterns = [("0x5d", "0", "64k"), + ("0xd5", "1M", "64k"), + ("0xdc", "32M", "64k"), + ("0xcd", "0x3ff0000", "64k")] # 64M - 64K + +overwrite = [("0xab", "0", "64k"), # Full overwrite + ("0xad", "0x00f8000", "64k"), # Partial-left (1M-32K) + ("0x1d", "0x2008000", "64k"), # Partial-right (32M+32K) + ("0xea", "0x3fe0000", "64k")] # Adjacent-left (64M - 128K) + +def query_bitmaps(vm): + res = vm.qmp("query-block") + return { "bitmaps": { device['device']: device.get('dirty-bitmaps', []) for + device in res['return'] } } + +with iotests.FilePath('img') as img_path, \ + iotests.VM() as vm: + + log('--- Preparing image & VM ---\n') + iotests.qemu_img_create('-f', iotests.imgfmt, img_path, str(size)) + vm.add_drive(img_path) + vm.launch() + + log('\n--- Adding preliminary bitmaps A & B ---\n') + vm.qmp_log("block-dirty-bitmap-add", node="drive0", + name="bitmapA", granularity=granularity) + vm.qmp_log("block-dirty-bitmap-add", node="drive0", + name="bitmapB", granularity=granularity) + + # Dirties 4 clusters. count=262144 + log('\n--- Emulating writes ---\n') + for p in patterns: + cmd = "write -P%s %s %s" % p + log(cmd) + log(vm.hmp_qemu_io("drive0", cmd)) + + log(query_bitmaps(vm), indent=2) + + log('\n--- Submitting Bad Transaction ---\n') + vm.qmp_log("transaction", indent=2, actions=[ + { "type": "block-dirty-bitmap-disable", + "data": { "node": "drive0", "name": "bitmapB" }}, + { "type": "block-dirty-bitmap-add", + "data": { "node": "drive0", "name": "bitmapC", + "granularity": granularity }}, + { "type": "block-dirty-bitmap-clear", + "data": { "node": "drive0", "name": "bitmapA" }}, + { "type": "abort", "data": {}} + ]) + log(query_bitmaps(vm), indent=2) + + log('\n--- Disabling B & Adding C ---\n') + vm.qmp_log("transaction", indent=2, actions=[ + { "type": "block-dirty-bitmap-disable", + "data": { "node": "drive0", "name": "bitmapB" }}, + { "type": "block-dirty-bitmap-add", + "data": { "node": "drive0", "name": "bitmapC", + "granularity": granularity }}, + # Purely extraneous, but test that it works: + { "type": "block-dirty-bitmap-disable", + "data": { "node": "drive0", "name": "bitmapC" }}, + { "type": "block-dirty-bitmap-enable", + "data": { "node": "drive0", "name": "bitmapC" }}, + ]) + + log('\n--- Emulating further writes ---\n') + # Dirties 6 clusters, 3 of which are new in contrast to "A". + # A = 64 * 1024 * (4 + 3) = 458752 + # C = 64 * 1024 * 6 = 393216 + for p in overwrite: + cmd = "write -P%s %s %s" % p + log(cmd) + log(vm.hmp_qemu_io("drive0", cmd)) + + log('\n--- Disabling A & C ---\n') + vm.qmp_log("transaction", indent=2, actions=[ + { "type": "block-dirty-bitmap-disable", + "data": { "node": "drive0", "name": "bitmapA" }}, + { "type": "block-dirty-bitmap-disable", + "data": { "node": "drive0", "name": "bitmapC" }} + ]) + + # A: 7 clusters + # B: 4 clusters + # C: 6 clusters + log(query_bitmaps(vm), indent=2) + + log('\n--- Submitting Bad Merge ---\n') + vm.qmp_log("transaction", indent=2, actions=[ + { "type": "block-dirty-bitmap-add", + "data": { "node": "drive0", "name": "bitmapD", + "disabled": True, "granularity": granularity }}, + { "type": "block-dirty-bitmap-merge", + "data": { "node": "drive0", "target": "bitmapD", + "bitmaps": ["bitmapB", "bitmapC"] }}, + { "type": "abort", "data": {}} + ]) + log(query_bitmaps(vm), indent=2) + + log('\n--- Creating D as a merge of B & C ---\n') + # Good hygiene: create a disabled bitmap as a merge target. + vm.qmp_log("transaction", indent=2, actions=[ + { "type": "block-dirty-bitmap-add", + "data": { "node": "drive0", "name": "bitmapD", + "disabled": True, "granularity": granularity }}, + { "type": "block-dirty-bitmap-merge", + "data": { "node": "drive0", "target": "bitmapD", + "bitmaps": ["bitmapB", "bitmapC"] }} + ]) + + # A and D should now both have 7 clusters apiece. + # B and C remain unchanged with 4 and 6 respectively. + log(query_bitmaps(vm), indent=2) + + # A and D should be equivalent. + # Some formats round the size of the disk, so don't print the checksums. + check_a = vm.qmp('x-debug-block-dirty-bitmap-sha256', + node="drive0", name="bitmapA")['return']['sha256'] + check_b = vm.qmp('x-debug-block-dirty-bitmap-sha256', + node="drive0", name="bitmapD")['return']['sha256'] + assert(check_a == check_b) + + log('\n--- Removing bitmaps A, B, C, and D ---\n') + vm.qmp_log("block-dirty-bitmap-remove", node="drive0", name="bitmapA") + vm.qmp_log("block-dirty-bitmap-remove", node="drive0", name="bitmapB") + vm.qmp_log("block-dirty-bitmap-remove", node="drive0", name="bitmapC") + vm.qmp_log("block-dirty-bitmap-remove", node="drive0", name="bitmapD") + + log('\n--- Final Query ---\n') + log(query_bitmaps(vm), indent=2) + + log('\n--- Done ---\n') + vm.shutdown() diff --git a/tests/qemu-iotests/236.out b/tests/qemu-iotests/236.out new file mode 100644 index 0000000000..1934035795 --- /dev/null +++ b/tests/qemu-iotests/236.out @@ -0,0 +1,351 @@ +--- Preparing image & VM --- + + +--- Adding preliminary bitmaps A & B --- + +{"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 65536, "name": "bitmapA", "node": "drive0"}} +{"return": {}} +{"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 65536, "name": "bitmapB", "node": "drive0"}} +{"return": {}} + +--- Emulating writes --- + +write -P0x5d 0 64k +{"return": ""} +write -P0xd5 1M 64k +{"return": ""} +write -P0xdc 32M 64k +{"return": ""} +write -P0xcd 0x3ff0000 64k +{"return": ""} +{ + "bitmaps": { + "drive0": [ + { + "count": 262144, + "granularity": 65536, + "name": "bitmapB", + "status": "active" + }, + { + "count": 262144, + "granularity": 65536, + "name": "bitmapA", + "status": "active" + } + ] + } +} + +--- Submitting Bad Transaction --- + +{ + "execute": "transaction", + "arguments": { + "actions": [ + { + "data": { + "node": "drive0", + "name": "bitmapB" + }, + "type": "block-dirty-bitmap-disable" + }, + { + "data": { + "node": "drive0", + "name": "bitmapC", + "granularity": 65536 + }, + "type": "block-dirty-bitmap-add" + }, + { + "data": { + "node": "drive0", + "name": "bitmapA" + }, + "type": "block-dirty-bitmap-clear" + }, + { + "data": {}, + "type": "abort" + } + ] + } +} +{ + "error": { + "class": "GenericError", + "desc": "Transaction aborted using Abort action" + } +} +{ + "bitmaps": { + "drive0": [ + { + "count": 262144, + "granularity": 65536, + "name": "bitmapB", + "status": "active" + }, + { + "count": 262144, + "granularity": 65536, + "name": "bitmapA", + "status": "active" + } + ] + } +} + +--- Disabling B & Adding C --- + +{ + "execute": "transaction", + "arguments": { + "actions": [ + { + "data": { + "node": "drive0", + "name": "bitmapB" + }, + "type": "block-dirty-bitmap-disable" + }, + { + "data": { + "node": "drive0", + "name": "bitmapC", + "granularity": 65536 + }, + "type": "block-dirty-bitmap-add" + }, + { + "data": { + "node": "drive0", + "name": "bitmapC" + }, + "type": "block-dirty-bitmap-disable" + }, + { + "data": { + "node": "drive0", + "name": "bitmapC" + }, + "type": "block-dirty-bitmap-enable" + } + ] + } +} +{ + "return": {} +} + +--- Emulating further writes --- + +write -P0xab 0 64k +{"return": ""} +write -P0xad 0x00f8000 64k +{"return": ""} +write -P0x1d 0x2008000 64k +{"return": ""} +write -P0xea 0x3fe0000 64k +{"return": ""} + +--- Disabling A & C --- + +{ + "execute": "transaction", + "arguments": { + "actions": [ + { + "data": { + "node": "drive0", + "name": "bitmapA" + }, + "type": "block-dirty-bitmap-disable" + }, + { + "data": { + "node": "drive0", + "name": "bitmapC" + }, + "type": "block-dirty-bitmap-disable" + } + ] + } +} +{ + "return": {} +} +{ + "bitmaps": { + "drive0": [ + { + "count": 393216, + "granularity": 65536, + "name": "bitmapC", + "status": "disabled" + }, + { + "count": 262144, + "granularity": 65536, + "name": "bitmapB", + "status": "disabled" + }, + { + "count": 458752, + "granularity": 65536, + "name": "bitmapA", + "status": "disabled" + } + ] + } +} + +--- Submitting Bad Merge --- + +{ + "execute": "transaction", + "arguments": { + "actions": [ + { + "data": { + "node": "drive0", + "disabled": true, + "name": "bitmapD", + "granularity": 65536 + }, + "type": "block-dirty-bitmap-add" + }, + { + "data": { + "node": "drive0", + "target": "bitmapD", + "bitmaps": [ + "bitmapB", + "bitmapC" + ] + }, + "type": "block-dirty-bitmap-merge" + }, + { + "data": {}, + "type": "abort" + } + ] + } +} +{ + "error": { + "class": "GenericError", + "desc": "Transaction aborted using Abort action" + } +} +{ + "bitmaps": { + "drive0": [ + { + "count": 393216, + "granularity": 65536, + "name": "bitmapC", + "status": "disabled" + }, + { + "count": 262144, + "granularity": 65536, + "name": "bitmapB", + "status": "disabled" + }, + { + "count": 458752, + "granularity": 65536, + "name": "bitmapA", + "status": "disabled" + } + ] + } +} + +--- Creating D as a merge of B & C --- + +{ + "execute": "transaction", + "arguments": { + "actions": [ + { + "data": { + "node": "drive0", + "disabled": true, + "name": "bitmapD", + "granularity": 65536 + }, + "type": "block-dirty-bitmap-add" + }, + { + "data": { + "node": "drive0", + "target": "bitmapD", + "bitmaps": [ + "bitmapB", + "bitmapC" + ] + }, + "type": "block-dirty-bitmap-merge" + } + ] + } +} +{ + "return": {} +} +{ + "bitmaps": { + "drive0": [ + { + "count": 458752, + "granularity": 65536, + "name": "bitmapD", + "status": "disabled" + }, + { + "count": 393216, + "granularity": 65536, + "name": "bitmapC", + "status": "disabled" + }, + { + "count": 262144, + "granularity": 65536, + "name": "bitmapB", + "status": "disabled" + }, + { + "count": 458752, + "granularity": 65536, + "name": "bitmapA", + "status": "disabled" + } + ] + } +} + +--- Removing bitmaps A, B, C, and D --- + +{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "bitmapA", "node": "drive0"}} +{"return": {}} +{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "bitmapB", "node": "drive0"}} +{"return": {}} +{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "bitmapC", "node": "drive0"}} +{"return": {}} +{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "bitmapD", "node": "drive0"}} +{"return": {}} + +--- Final Query --- + +{ + "bitmaps": { + "drive0": [] + } +} + +--- Done --- + diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 61a6d98ebd..f6b245917a 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -233,3 +233,4 @@ 233 auto quick 234 auto quick migration 235 auto quick +236 auto quick