From nobody Thu Dec 18 13:29:47 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=1566232185; cv=none; d=zoho.com; s=zohoarc; b=d64a0BbhO1jMOWeAhvH/3EVABbQfZ++SMQK8dpxvZAt0bsiJCxjkBenkZCb6QJZ1KSGMJMPSg8RZNQ4xlVuwa82bnakcpw7OUOy7LizC1Kd+HlQDEPzTdbhC9sOTWdbvkIn6lI5+h8vF9eWff1pxOj6Ww/2I3jnf8PkpPVu0MTQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566232185; 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=lfm+27RI38QWBZpBiv9TFCoA7ZlSZiAkboMA6s59eXE=; b=I8wvV3+UWmDm78u2lLFYsi3J+9T9CvQQ3wVLBbrd4a92lRuBNI11mzyf3u3I7ki22ijOE8qq8buryq0MSga5ZKEwDcaLPgns45KxP8dAADodRmxyO3aWJVLkQJCjdIL3yUt+iwMMYMcaox4i+yrdIu8o+6tCShzYkmVkyS+biSc= 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 1566232185593312.53667161458236; Mon, 19 Aug 2019 09:29:45 -0700 (PDT) Received: from localhost ([::1]:55332 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzkXQ-0000vu-0Y for importer@patchew.org; Mon, 19 Aug 2019 12:29:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35658) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzkMF-0003MZ-03 for qemu-devel@nongnu.org; Mon, 19 Aug 2019 12:18:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hzkMD-0006Y0-AB for qemu-devel@nongnu.org; Mon, 19 Aug 2019 12:18:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54706) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hzkM6-0006SS-NQ; Mon, 19 Aug 2019 12:18:06 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D39A93001834; Mon, 19 Aug 2019 16:17:58 +0000 (UTC) Received: from localhost (ovpn-204-64.brq.redhat.com [10.40.204.64]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6B7A79A060; Mon, 19 Aug 2019 16:17:58 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 19 Aug 2019 18:17:18 +0200 Message-Id: <20190819161723.7746-13-mreitz@redhat.com> In-Reply-To: <20190819161723.7746-1-mreitz@redhat.com> References: <20190819161723.7746-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Mon, 19 Aug 2019 16:17:58 +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] [PULL 12/17] iotests: Full mirror to existing non-zero image 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 , Peter Maydell , 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" The result of a sync=3Dfull mirror should always be the equal to the input. Therefore, existing images should be treated as potentially non-zero and thus should be explicitly initialized to be zero beforehand. Signed-off-by: Max Reitz Message-id: 20190724171239.8764-12-mreitz@redhat.com Signed-off-by: Max Reitz --- tests/qemu-iotests/041 | 62 +++++++++++++++++++++++++++++++++++--- tests/qemu-iotests/041.out | 4 +-- 2 files changed, 60 insertions(+), 6 deletions(-) diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041 index 26bf1701eb..8bc8f81db7 100755 --- a/tests/qemu-iotests/041 +++ b/tests/qemu-iotests/041 @@ -741,8 +741,15 @@ class TestUnbackedSource(iotests.QMPTestCase): def setUp(self): qemu_img('create', '-f', iotests.imgfmt, test_img, str(TestUnbackedSource.image_len)) - self.vm =3D iotests.VM().add_drive(test_img) + self.vm =3D iotests.VM() self.vm.launch() + result =3D self.vm.qmp('blockdev-add', node_name=3D'drive0', + driver=3Diotests.imgfmt, + file=3D{ + 'driver': 'file', + 'filename': test_img, + }) + self.assert_qmp(result, 'return', {}) =20 def tearDown(self): self.vm.shutdown() @@ -751,7 +758,7 @@ class TestUnbackedSource(iotests.QMPTestCase): =20 def test_absolute_paths_full(self): self.assert_no_active_block_jobs() - result =3D self.vm.qmp('drive-mirror', device=3D'drive0', + result =3D self.vm.qmp('drive-mirror', job_id=3D'drive0', device= =3D'drive0', sync=3D'full', target=3Dtarget_img, mode=3D'absolute-paths') self.assert_qmp(result, 'return', {}) @@ -760,7 +767,7 @@ class TestUnbackedSource(iotests.QMPTestCase): =20 def test_absolute_paths_top(self): self.assert_no_active_block_jobs() - result =3D self.vm.qmp('drive-mirror', device=3D'drive0', + result =3D self.vm.qmp('drive-mirror', job_id=3D'drive0', device= =3D'drive0', sync=3D'top', target=3Dtarget_img, mode=3D'absolute-paths') self.assert_qmp(result, 'return', {}) @@ -769,13 +776,60 @@ class TestUnbackedSource(iotests.QMPTestCase): =20 def test_absolute_paths_none(self): self.assert_no_active_block_jobs() - result =3D self.vm.qmp('drive-mirror', device=3D'drive0', + result =3D self.vm.qmp('drive-mirror', job_id=3D'drive0', device= =3D'drive0', sync=3D'none', target=3Dtarget_img, mode=3D'absolute-paths') self.assert_qmp(result, 'return', {}) self.complete_and_wait() self.assert_no_active_block_jobs() =20 + def test_existing_full(self): + qemu_img('create', '-f', iotests.imgfmt, target_img, + str(self.image_len)) + qemu_io('-c', 'write -P 42 0 64k', target_img) + + self.assert_no_active_block_jobs() + result =3D self.vm.qmp('drive-mirror', job_id=3D'drive0', device= =3D'drive0', + sync=3D'full', target=3Dtarget_img, mode=3D'e= xisting') + self.assert_qmp(result, 'return', {}) + self.complete_and_wait() + self.assert_no_active_block_jobs() + + result =3D self.vm.qmp('blockdev-del', node_name=3D'drive0') + self.assert_qmp(result, 'return', {}) + + self.assertTrue(iotests.compare_images(test_img, target_img), + 'target image does not match source after mirrorin= g') + + def test_blockdev_full(self): + qemu_img('create', '-f', iotests.imgfmt, target_img, + str(self.image_len)) + qemu_io('-c', 'write -P 42 0 64k', target_img) + + result =3D self.vm.qmp('blockdev-add', node_name=3D'target', + driver=3Diotests.imgfmt, + file=3D{ + 'driver': 'file', + 'filename': target_img, + }) + self.assert_qmp(result, 'return', {}) + + self.assert_no_active_block_jobs() + result =3D self.vm.qmp('blockdev-mirror', job_id=3D'drive0', devic= e=3D'drive0', + sync=3D'full', target=3D'target') + self.assert_qmp(result, 'return', {}) + self.complete_and_wait() + self.assert_no_active_block_jobs() + + result =3D self.vm.qmp('blockdev-del', node_name=3D'drive0') + self.assert_qmp(result, 'return', {}) + + result =3D self.vm.qmp('blockdev-del', node_name=3D'target') + self.assert_qmp(result, 'return', {}) + + self.assertTrue(iotests.compare_images(test_img, target_img), + 'target image does not match source after mirrorin= g') + class TestGranularity(iotests.QMPTestCase): image_len =3D 10 * 1024 * 1024 # MB =20 diff --git a/tests/qemu-iotests/041.out b/tests/qemu-iotests/041.out index e071d0b261..2c448b4239 100644 --- a/tests/qemu-iotests/041.out +++ b/tests/qemu-iotests/041.out @@ -1,5 +1,5 @@ -..........................................................................= .............. +..........................................................................= ................ ---------------------------------------------------------------------- -Ran 88 tests +Ran 90 tests =20 OK --=20 2.21.0