From nobody Wed Nov 19 08:44:58 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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 ARC-Seal: i=1; a=rsa-sha256; t=1615317587; cv=none; d=zohomail.com; s=zohoarc; b=ErgTYwm8ZXZb7FbK05ARwS7T49qnk9+sC+qOR2LtO/LyIILiGJSujsW426o6jV0vukoJDsLxwXq/KZsOdgD4zql6kXJ7iun5bjRQ4JgQklDPX6wiAc0AqJ6ZTJY2Bq3L4BTLLndzMZxwQgPY5YWeeYCGvdybVG7yb/8OyZgT3pY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615317587; 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; bh=sLcazRBYDZOTf/U/pqyZY5+acPdr0M5SVvjch2P+1lw=; b=Ux+24GWENszXipHSEO9dcerVJcal+FNRhu5oUg1ld91iRy/ZRb4uAWfxHQo3gnD3QTg46u/e2hQcB0Etuy8OEikPBcXqXH7FwUT+9hjix4Q7Dqn/bIR5SKACsGP9vCgOEJeukMOx5NCW8zMzqcSg1QpuzRUcwgBgvNQaz5dsyDE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1615317587753642.9772665515292; Tue, 9 Mar 2021 11:19:47 -0800 (PST) Received: from localhost ([::1]:53060 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lJhtS-0004gk-Gg for importer@patchew.org; Tue, 09 Mar 2021 14:19:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59720) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJfrK-0001Gb-Nt; Tue, 09 Mar 2021 12:09:27 -0500 Received: from fanzine.igalia.com ([178.60.130.6]:40108) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lJfrC-0001DP-8y; Tue, 09 Mar 2021 12:09:26 -0500 Received: from [213.94.25.37] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1lJfqn-0003Lt-P1; Tue, 09 Mar 2021 18:08:53 +0100 Received: from berto by perseus.local with local (Exim 4.92) (envelope-from ) id 1lJfqa-0005Ib-OO; Tue, 09 Mar 2021 18:08:40 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=sLcazRBYDZOTf/U/pqyZY5+acPdr0M5SVvjch2P+1lw=; b=R+K7NMw7TYdGg1TdozkGzeuQYnizJpGmcGqyFSA3bORXo3QZj2IrRtx3ljuLQktwYTbCp+5Hwv/U/I3767KxdFBtzC7fKBpZAItlMCq7Vt2+j7ynOdHK1uCQPlgVCY5iwfn/0CvujsniuFQw8/GJlxsvIMy1nv1BRj1urymSFKg0PVqCmzPdCfG4czP8vBVj/Co5Cn01V+FywASuzqCPkmTWofHSjqYujNuI9EtRwNbumysLCLq9G1CeZHx36f490yu2Y6G2CZyRqSTFZarY0AVZyXVvysF/TTcerJCDX4JGPRJ5mTLC6NjYlKAc+CVpA6lq5zBCo+ClyMMb3ubjZQ==; From: Alberto Garcia To: qemu-devel@nongnu.org Subject: [PATCH v3 5/6] iotests: Test reopening multiple devices at the same time Date: Tue, 9 Mar 2021 18:08:31 +0100 Message-Id: <23d5f5437212a7d9640c663e6c32daf8f31ae8cb.1615309297.git.berto@igalia.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 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=178.60.130.6; envelope-from=berto@igalia.com; helo=fanzine.igalia.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Alberto Garcia , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This test swaps the images used by two active block devices. This is now possible thanks to the new ability to run x-blockdev-reopen on multiple devices at the same time. Signed-off-by: Alberto Garcia --- tests/qemu-iotests/245 | 41 ++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/245.out | 4 ++-- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/tests/qemu-iotests/245 b/tests/qemu-iotests/245 index 53281228bc..fb11eb146d 100755 --- a/tests/qemu-iotests/245 +++ b/tests/qemu-iotests/245 @@ -648,6 +648,47 @@ class TestBlockdevReopen(iotests.QMPTestCase): '-c', 'read -P 0x40 0x40008 1', '-c', 'read -P 0x80 0x40010 1', h= d_path[0]) =20 + # Swap the disk images of two active block devices + def test_swap_files(self): + # Add hd0 and hd2 (none of them with backing files) + opts0 =3D hd_opts(0) + result =3D self.vm.qmp('blockdev-add', conv_keys =3D False, **opts= 0) + self.assert_qmp(result, 'return', {}) + + opts2 =3D hd_opts(2) + result =3D self.vm.qmp('blockdev-add', conv_keys =3D False, **opts= 2) + self.assert_qmp(result, 'return', {}) + + # Write different data to both block devices + self.run_qemu_io("hd0", "write -P 0xa0 0 1k") + self.run_qemu_io("hd2", "write -P 0xa2 0 1k") + + # Check that the data reads correctly + self.run_qemu_io("hd0", "read -P 0xa0 0 1k") + self.run_qemu_io("hd2", "read -P 0xa2 0 1k") + + # It's not possible to make a block device use an image that + # is already being used by the other device. + self.reopen(opts0, {'file': 'hd2-file'}, + "Conflicts with use by hd0 as 'file', which does not a= llow 'write, resize' on hd2-file") + self.reopen(opts2, {'file': 'hd0-file'}, + "Conflicts with use by hd2 as 'file', which does not a= llow 'write, resize' on hd0-file") + + # But we can swap the images if we reopen both devices at the + # same time + opts0['file'] =3D 'hd2-file' + opts2['file'] =3D 'hd0-file' + self.reopenMultiple([opts0, opts2]) + self.run_qemu_io("hd0", "read -P 0xa2 0 1k") + self.run_qemu_io("hd2", "read -P 0xa0 0 1k") + + # And we can of course come back to the original state + opts0['file'] =3D 'hd0-file' + opts2['file'] =3D 'hd2-file' + self.reopenMultiple([opts0, opts2]) + self.run_qemu_io("hd0", "read -P 0xa0 0 1k") + self.run_qemu_io("hd2", "read -P 0xa2 0 1k") + # Misc reopen tests with different block drivers @iotests.skip_if_unsupported(['quorum', 'throttle']) def test_misc_drivers(self): diff --git a/tests/qemu-iotests/245.out b/tests/qemu-iotests/245.out index 6ea1b2798f..c4230b51d1 100644 --- a/tests/qemu-iotests/245.out +++ b/tests/qemu-iotests/245.out @@ -17,8 +17,8 @@ read 1/1 bytes at offset 262152 read 1/1 bytes at offset 262160 1 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 -........................ +......................... ---------------------------------------------------------------------- -Ran 24 tests +Ran 25 tests =20 OK --=20 2.20.1