From nobody Sun Apr 13 18:12:56 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1614964447; cv=none; d=zohomail.com; s=zohoarc; b=VaEQxUUZvp/Yy/uWSeSecOnAYK4JqaC9iSYrN9QstBJLtsWJ6Wz7PXA4stwkBMhtgsd5LxP/C+CIOi1gY4Ud1tzB7ubjFB+YQK4Iao/U5UD+5ijKHT851TV97DCNrwQI7yQ/Xz/p2+SpbbY4PjDHKANBwsXlvaAeixPG39OBQbw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614964447; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cae2kkknNE/C4/3u4UBfwAIUtJ118zHDgw0ox10pAcE=; b=NBmhV47dfx/HhCxrDLS/6VU3bLjvEUKnTqtWl3fc7n1p/U+KWs0Oez2QSfZsJIIe08QGS7X2xl2lQawgVvv4NmXrRK5X6OL6UzaHJpH4ORBfAQzAjslBIwcxErCkpE7DtO6WMCj51B3ggxM+STgNQ0Xu+9MsSvucHZyhAo+IB4I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1614964447496294.2429396657702; Fri, 5 Mar 2021 09:14:07 -0800 (PST) Received: from localhost ([::1]:36318 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIE1e-0004Bw-AD for importer@patchew.org; Fri, 05 Mar 2021 12:14:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33210) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIDkZ-0007TC-Pf for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:27 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:21227) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lIDkB-0007Fj-BF for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:27 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-419-kmKxu0AUPqCgqbGBIRWt9Q-1; Fri, 05 Mar 2021 11:55:54 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8DE5310A2C73; Fri, 5 Mar 2021 16:55:47 +0000 (UTC) Received: from merkur.redhat.com (ovpn-112-36.phx2.redhat.com [10.3.112.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7E44C60BF3; Fri, 5 Mar 2021 16:55:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614963360; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cae2kkknNE/C4/3u4UBfwAIUtJ118zHDgw0ox10pAcE=; b=XBCWEaEU0Fg5crEZcjLd+ptGGz72qr+H1PqgbokCPWY69KTwtSX92fhlmHFzby+RRtrc4J 2DdgDilaLIJXxa87QGRq85ez2f6WmzRDVstTP6K3EnchqKvFeyY1V6lAINVUaLQj25W10B wJSJS8FqI+UcQ49NDVJY88OgFef5I6Q= X-MC-Unique: kmKxu0AUPqCgqbGBIRWt9Q-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 29/31] iotests: add parallels-read-bitmap test Date: Fri, 5 Mar 2021 17:54:52 +0100 Message-Id: <20210305165454.356840-30-kwolf@redhat.com> In-Reply-To: <20210305165454.356840-1-kwolf@redhat.com> References: <20210305165454.356840-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=216.205.24.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Test support for reading bitmap from parallels image format. parallels-with-bitmap.bz2 is generated on Virtuozzo by parallels-with-bitmap.sh Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20210224104707.88430-7-vsementsov@virtuozzo.com> Reviewed-by: Denis V. Lunev Signed-off-by: Kevin Wolf --- .../sample_images/parallels-with-bitmap.bz2 | Bin 0 -> 203 bytes .../sample_images/parallels-with-bitmap.sh | 51 ++++++++++++++++ .../qemu-iotests/tests/parallels-read-bitmap | 55 ++++++++++++++++++ .../tests/parallels-read-bitmap.out | 6 ++ 4 files changed, 112 insertions(+) create mode 100644 tests/qemu-iotests/sample_images/parallels-with-bitmap.= bz2 create mode 100755 tests/qemu-iotests/sample_images/parallels-with-bitmap.= sh create mode 100755 tests/qemu-iotests/tests/parallels-read-bitmap create mode 100644 tests/qemu-iotests/tests/parallels-read-bitmap.out diff --git a/tests/qemu-iotests/sample_images/parallels-with-bitmap.bz2 b/t= ests/qemu-iotests/sample_images/parallels-with-bitmap.bz2 new file mode 100644 index 0000000000000000000000000000000000000000..54892fd4d01bf743d395bd4f3d8= 96494146ab5a9 GIT binary patch literal 203 zcmV;+05tzXT4*^jL0KkKS@=3D;0bpT+Hf7|^?KmNPH-R Fx`3oHQ9u9y literal 0 HcmV?d00001 diff --git a/tests/qemu-iotests/sample_images/parallels-with-bitmap.sh b/te= sts/qemu-iotests/sample_images/parallels-with-bitmap.sh new file mode 100755 index 0000000000..30615aa6bd --- /dev/null +++ b/tests/qemu-iotests/sample_images/parallels-with-bitmap.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# +# Test parallels load bitmap +# +# Copyright (c) 2021 Virtuozzo International GmbH. +# +# 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 . +# + +CT=3Dparallels-with-bitmap-ct +DIR=3D$PWD/parallels-with-bitmap-dir +IMG=3D$DIR/root.hds +XML=3D$DIR/DiskDescriptor.xml +TARGET=3Dparallels-with-bitmap.bz2 + +rm -rf $DIR + +prlctl create $CT --vmtype ct +prlctl set $CT --device-add hdd --image $DIR --recreate --size 2G + +# cleanup the image +qemu-img create -f parallels $IMG 64G + +# create bitmap +prlctl backup $CT + +prlctl set $CT --device-del hdd1 +prlctl destroy $CT + +dev=3D$(ploop mount $XML | sed -n 's/^Adding delta dev=3D\(\/dev\/ploop[0-= 9]\+\).*/\1/p') +dd if=3D/dev/zero of=3D$dev bs=3D64K seek=3D5 count=3D2 oflag=3Ddirect +dd if=3D/dev/zero of=3D$dev bs=3D64K seek=3D30 count=3D1 oflag=3Ddirect +dd if=3D/dev/zero of=3D$dev bs=3D64K seek=3D10 count=3D3 oflag=3Ddirect +ploop umount $XML # bitmap name will be in the output + +bzip2 -z $IMG + +mv $IMG.bz2 $TARGET + +rm -rf $DIR diff --git a/tests/qemu-iotests/tests/parallels-read-bitmap b/tests/qemu-io= tests/tests/parallels-read-bitmap new file mode 100755 index 0000000000..af6b9c5db3 --- /dev/null +++ b/tests/qemu-iotests/tests/parallels-read-bitmap @@ -0,0 +1,55 @@ +#!/usr/bin/env python3 +# +# Test parallels load bitmap +# +# Copyright (c) 2021 Virtuozzo International GmbH. +# +# 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 json +import iotests +from iotests import qemu_nbd_popen, qemu_img_pipe, log, file_path + +iotests.script_initialize(supported_fmts=3D['parallels']) + +nbd_sock =3D file_path('nbd-sock', base_dir=3Diotests.sock_dir) +disk =3D iotests.file_path('disk') +bitmap =3D 'e4f2eed0-37fe-4539-b50b-85d2e7fd235f' +nbd_opts =3D f'driver=3Dnbd,server.type=3Dunix,server.path=3D{nbd_sock}' \ + f',x-dirty-bitmap=3Dqemu:dirty-bitmap:{bitmap}' + + +iotests.unarchive_sample_image('parallels-with-bitmap', disk) + + +with qemu_nbd_popen('--read-only', f'--socket=3D{nbd_sock}', + f'--bitmap=3D{bitmap}', '-f', iotests.imgfmt, disk): + out =3D qemu_img_pipe('map', '--output=3Djson', '--image-opts', nbd_op= ts) + chunks =3D json.loads(out) + cluster =3D 64 * 1024 + + log('dirty clusters (cluster size is 64K):') + for c in chunks: + assert c['start'] % cluster =3D=3D 0 + assert c['length'] % cluster =3D=3D 0 + if c['data']: + continue + + a =3D c['start'] // cluster + b =3D (c['start'] + c['length']) // cluster + if b - a > 1: + log(f'{a}-{b-1}') + else: + log(a) diff --git a/tests/qemu-iotests/tests/parallels-read-bitmap.out b/tests/qem= u-iotests/tests/parallels-read-bitmap.out new file mode 100644 index 0000000000..e8f6bc9e96 --- /dev/null +++ b/tests/qemu-iotests/tests/parallels-read-bitmap.out @@ -0,0 +1,6 @@ +Start NBD server +dirty clusters (cluster size is 64K): +5-6 +10-12 +30 +Kill NBD server --=20 2.29.2