From nobody Sun Feb 8 14:21: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.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; dmarc=fail(p=none dis=none) header.from=virtuozzo.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1538390374635576.4145689624431; Mon, 1 Oct 2018 03:39:34 -0700 (PDT) Received: from localhost ([::1]:37205 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6vbx-0003CX-Dp for importer@patchew.org; Mon, 01 Oct 2018 06:39:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40631) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6vSi-0005BU-7S for qemu-devel@nongnu.org; Mon, 01 Oct 2018 06:30:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g6vSe-0002wJ-1C for qemu-devel@nongnu.org; Mon, 01 Oct 2018 06:30:00 -0400 Received: from relay.sw.ru ([185.231.240.75]:39698) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g6vSd-0002Jz-Oy; Mon, 01 Oct 2018 06:29:55 -0400 Received: from [10.28.8.145] (helo=kvm.sw.ru) by relay.sw.ru with esmtp (Exim 4.90_1) (envelope-from ) id 1g6vSI-0005Yj-2v; Mon, 01 Oct 2018 13:29:34 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Mon, 1 Oct 2018 13:29:26 +0300 Message-Id: <20181001102928.20533-17-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20181001102928.20533-1-vsementsov@virtuozzo.com> References: <20181001102928.20533-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 v3 16/18] iotests: test new fleecing-hook driver in context of 222 iotest 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, vsementsov@virtuozzo.com, famz@redhat.com, wencongyang2@huawei.com, xiechanglong.d@gmail.com, armbru@redhat.com, mreitz@redhat.com, stefanha@redhat.com, den@openvz.org, jsnow@redhat.com, jcody@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 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/222 | 59 +++++++++++++++++++++++++++------- tests/qemu-iotests/222.out | 66 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 114 insertions(+), 11 deletions(-) diff --git a/tests/qemu-iotests/222 b/tests/qemu-iotests/222 index 0ead56d574..3063dd0705 100644 --- a/tests/qemu-iotests/222 +++ b/tests/qemu-iotests/222 @@ -4,7 +4,9 @@ # point-in-time snapshot of a node that can be queried over NBD. # # Copyright (C) 2018 Red Hat, Inc. +# Copyright (c) 2018 Virtuozzo International GmbH. All rights reserved. # John helped, too. +# And Vladimir, a bit. # # 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 @@ -46,11 +48,40 @@ remainder =3D [("0xd5", "0x108000", "32k"), # Right-en= d of partial-left [1] ("0xdc", "32M", "32k"), # Left-end of partial-right [2] ("0xcd", "0x3ff0000", "64k")] # patterns[3] =20 -with iotests.FilePath('base.img') as base_img_path, \ - iotests.FilePath('fleece.img') as fleece_img_path, \ - iotests.FilePath('nbd.sock') as nbd_sock_path, \ - iotests.VM() as vm: +class Fleecing(): + def __init__(self, vm, src_node, tgt_node): + self.vm =3D vm + self.src_node =3D src_node + self.tgt_node =3D tgt_node =20 +class OldBackupFleecing(Fleecing): + def start(self): + log(self.vm.qmp("blockdev-backup", + device=3Dself.src_node, + target=3Dself.tgt_node, + sync=3D"none")) + + def stop(self): + log(self.vm.qmp('block-job-cancel', device=3Dself.src_node)) + log(self.vm.event_wait('BLOCK_JOB_CANCELLED'), + filters=3D[iotests.filter_qmp_event]) + + +class FleecingHookFleecing(Fleecing): + def start(self): + log(self.vm.qmp("blockdev-add", **{ + "driver": "fleecing-hook", + "node-name": "hook", + "append-to": self.src_node, + "target": self.tgt_node, + })) + + def stop(self): + log(self.vm.qmp('x-drop-fleecing', node_name=3D"hook")) + + +def do_test(base_img_path, fleece_img_path, nbd_sock_path, fleecing): + vm =3D iotests.VM() log('--- Setting up images ---') log('') =20 @@ -77,6 +108,7 @@ with iotests.FilePath('base.img') as base_img_path, \ =20 src_node =3D "drive0" tgt_node =3D "fleeceNode" + fl =3D fleecing(vm, src_node, tgt_node) =20 # create tgt_node backed by src_node log(vm.qmp("blockdev-add", **{ @@ -90,10 +122,7 @@ with iotests.FilePath('base.img') as base_img_path, \ })) =20 # Establish COW from source to fleecing node - log(vm.qmp("blockdev-backup", - device=3Dsrc_node, - target=3Dtgt_node, - sync=3D"none")) + fl.start() =20 log('') log('--- Setting up NBD Export ---') @@ -137,10 +166,8 @@ with iotests.FilePath('base.img') as base_img_path, \ log('--- Cleanup ---') log('') =20 - log(vm.qmp('block-job-cancel', device=3Dsrc_node)) - log(vm.event_wait('BLOCK_JOB_CANCELLED'), - filters=3D[iotests.filter_qmp_event]) log(vm.qmp('nbd-server-stop')) + fl.stop() log(vm.qmp('blockdev-del', node_name=3Dtgt_node)) vm.shutdown() =20 @@ -155,3 +182,13 @@ with iotests.FilePath('base.img') as base_img_path, \ =20 log('') log('Done') + +def test(fleecing): + with iotests.FilePath('base.img') as base_img_path, \ + iotests.FilePath('fleece.img') as fleece_img_path, \ + iotests.FilePath('nbd.sock') as nbd_sock_path: + + do_test(base_img_path, fleece_img_path, nbd_sock_path, fleecing) + +test(OldBackupFleecing) +test(FleecingHookFleecing) diff --git a/tests/qemu-iotests/222.out b/tests/qemu-iotests/222.out index 48f336a02b..28c3623ee8 100644 --- a/tests/qemu-iotests/222.out +++ b/tests/qemu-iotests/222.out @@ -49,9 +49,75 @@ read -P0 0x3fe0000 64k =20 --- Cleanup --- =20 +{u'return': {}} {u'return': {}} {u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u= 'device': u'drive0', u'type': u'backup', u'speed': 0, u'len': 67108864, u'o= ffset': 393216}, u'event': u'BLOCK_JOB_CANCELLED'} {u'return': {}} + +--- Confirming writes --- + +read -P0xab 0 64k +read -P0xad 0x00f8000 64k +read -P0x1d 0x2008000 64k +read -P0xea 0x3fe0000 64k +read -P0xd5 0x108000 32k +read -P0xdc 32M 32k +read -P0xcd 0x3ff0000 64k + +Done +--- Setting up images --- + +Done + +--- Launching VM --- + +Done + +--- Setting up Fleecing Graph --- + +{u'return': {}} +{u'return': {}} + +--- Setting up NBD Export --- + +{u'return': {}} +{u'return': {}} + +--- Sanity Check --- + +read -P0x5d 0 64k +read -P0xd5 1M 64k +read -P0xdc 32M 64k +read -P0xcd 0x3ff0000 64k +read -P0 0x00f8000 32k +read -P0 0x2010000 32k +read -P0 0x3fe0000 64k + +--- Testing COW --- + +write -P0xab 0 64k +{u'return': u''} +write -P0xad 0x00f8000 64k +{u'return': u''} +write -P0x1d 0x2008000 64k +{u'return': u''} +write -P0xea 0x3fe0000 64k +{u'return': u''} + +--- Verifying Data --- + +read -P0x5d 0 64k +read -P0xd5 1M 64k +read -P0xdc 32M 64k +read -P0xcd 0x3ff0000 64k +read -P0 0x00f8000 32k +read -P0 0x2010000 32k +read -P0 0x3fe0000 64k + +--- Cleanup --- + +{u'return': {}} +{u'return': {}} {u'return': {}} =20 --- Confirming writes --- --=20 2.18.0