From nobody Wed Nov 12 04:58:17 2025 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565368102; cv=none; d=zoho.com; s=zohoarc; b=iePO4RmKjaZEPB6JOsVap7Z0JysuXWmBNfNKNE3arSjCpK/Ar/apXIx1ioruxzIHfI/gG1dys2nd9YtrGkzboEz9GdSsY3/0Ebv7Us8LzPC9DgktLVi186T/sOwF2jtawWHz/i7JHQrV4lwrNaf7X+57vC5v7PSZuIGXCme5y0M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565368102; h=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:ARC-Authentication-Results; bh=Tr8uNnIhNoU50Ol9HGpH7oHKRr7nER/MP4OajAjTqhE=; b=A3vEqekOwfcAE1Gi6tFwBlnO6n7oi5gU4wWN0HQh7o0+eLoitr41U5jZzfHwHvtZz7GQ5RlPYaBWy/5seTD/xZMIWdVmUbWyEJDqJoWvm8DfhWFRGV5QkmuRruyJUXcIhIpaPoYOlzd2adlJq570DDQgltNj9igi8vRI0kQVNJE= 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1565368102712370.013528850781; Fri, 9 Aug 2019 09:28:22 -0700 (PDT) Received: from localhost ([::1]:32828 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hw7kb-000821-PQ for importer@patchew.org; Fri, 09 Aug 2019 12:28:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57887) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hw7Yc-0004gN-Ce for qemu-devel@nongnu.org; Fri, 09 Aug 2019 12:15:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hw7Yb-0004pp-C0 for qemu-devel@nongnu.org; Fri, 09 Aug 2019 12:15:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48470) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hw7YZ-0004oa-1G; Fri, 09 Aug 2019 12:15:55 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5E3EE3058359; Fri, 9 Aug 2019 16:15:54 +0000 (UTC) Received: from localhost (unknown [10.40.205.179]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 94F245D772; Fri, 9 Aug 2019 16:15:52 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 9 Aug 2019 18:14:07 +0200 Message-Id: <20190809161407.11920-43-mreitz@redhat.com> In-Reply-To: <20190809161407.11920-1-mreitz@redhat.com> References: <20190809161407.11920-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Fri, 09 Aug 2019 16:15:54 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v6 42/42] iotests: Test committing to overridden backing 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: Kevin Wolf , Vladimir Sementsov-Ogievskiy , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Signed-off-by: Max Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/040 | 61 ++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/040.out | 4 +-- 2 files changed, 63 insertions(+), 2 deletions(-) diff --git a/tests/qemu-iotests/040 b/tests/qemu-iotests/040 index a0a0db8889..558fdb9a09 100755 --- a/tests/qemu-iotests/040 +++ b/tests/qemu-iotests/040 @@ -605,5 +605,66 @@ class TestCommitWithFilters(iotests.QMPTestCase): # 3 has been comitted into 2 self.pattern_files[3] =3D self.img2 =20 +class TestCommitWithOverriddenBacking(iotests.QMPTestCase): + img_base_a =3D os.path.join(iotests.test_dir, 'base_a.img') + img_base_b =3D os.path.join(iotests.test_dir, 'base_b.img') + img_top =3D os.path.join(iotests.test_dir, 'top.img') + + def setUp(self): + qemu_img('create', '-f', iotests.imgfmt, self.img_base_a, '1M') + qemu_img('create', '-f', iotests.imgfmt, self.img_base_b, '1M') + qemu_img('create', '-f', iotests.imgfmt, '-b', self.img_base_a, \ + self.img_top) + + self.vm =3D iotests.VM() + self.vm.launch() + + # Use base_b instead of base_a as the backing of top + result =3D self.vm.qmp('blockdev-add', **{ + 'node-name': 'top', + 'driver': iotests.imgfmt, + 'file': { + 'driver': 'file', + 'filename': self.img_top + }, + 'backing': { + 'node-name': 'base', + 'driver': iotests.imgfmt, + 'file': { + 'driver': 'file', + 'filename': self.img_base_b + } + } + }) + self.assert_qmp(result, 'return', {}) + + def tearDown(self): + self.vm.shutdown() + os.remove(self.img_top) + os.remove(self.img_base_a) + os.remove(self.img_base_b) + + def test_commit_to_a(self): + # Try committing to base_a (which should fail, as top's + # backing image is base_b instead) + result =3D self.vm.qmp('block-commit', + job_id=3D'commit', + device=3D'top', + base=3Dself.img_base_a) + self.assert_qmp(result, 'error/class', 'GenericError') + + def test_commit_to_b(self): + # Try committing to base_b (which should work, since that is + # actually top's backing image) + result =3D self.vm.qmp('block-commit', + job_id=3D'commit', + device=3D'top', + base=3Dself.img_base_b) + self.assert_qmp(result, 'return', {}) + + self.vm.event_wait('BLOCK_JOB_READY') + self.vm.qmp('block-job-complete', device=3D'commit') + self.vm.event_wait('BLOCK_JOB_COMPLETED') + if __name__ =3D=3D '__main__': iotests.main(supported_fmts=3D['qcow2', 'qed']) diff --git a/tests/qemu-iotests/040.out b/tests/qemu-iotests/040.out index fe58934d7a..499af0e2ff 100644 --- a/tests/qemu-iotests/040.out +++ b/tests/qemu-iotests/040.out @@ -1,5 +1,5 @@ -................................................... +..................................................... ---------------------------------------------------------------------- -Ran 51 tests +Ran 53 tests =20 OK --=20 2.21.0