From nobody Wed Nov 19 13:40:20 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=1616001514; cv=none; d=zohomail.com; s=zohoarc; b=OvEDSefFm7+5dgVy03BU2Y2So8Q781OeX2A0EFl4ZiLR0etGyIx+zbhDlP6QkTiRxG8kx2NWPKxAW0TUPjmMupZuhKgQoaTFYj/sR8rCh04+IkCUMB0Jb52hhZO+GLn/MTyS08F2e8JhQ9EIjfXgB9WTDy3kT/TDIHo3ifTyP4s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616001514; 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=kPgM8tDgBE3TVEP0nZY1Ty8qk1hsfxzQKFlH8ABvL5g=; b=YxTwNJ9w5pgMejcu5btGPIPXJ3yiHYcAe7PZoLyvNU8cLiHnhjyHHPauqjGKcLvgVVFvLPfPWwQIQQ8lJ0lSHwBtehUyMHygaQObdoN63EomGRMpbCJHNYQrJbzLxNfyN5GoqHkJv2hysZBTzUUc2JbvVS6vtrGImYm+ejoZ5Tk= 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 1616001514384629.7773448014683; Wed, 17 Mar 2021 10:18:34 -0700 (PDT) Received: from localhost ([::1]:60334 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMZoX-00054v-Aa for importer@patchew.org; Wed, 17 Mar 2021 13:18:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46674) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMZmi-0003b4-Kv; Wed, 17 Mar 2021 13:16:40 -0400 Received: from fanzine.igalia.com ([178.60.130.6]:38051) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lMZmg-0006rT-MR; Wed, 17 Mar 2021 13:16:40 -0400 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 1lMZmd-0003uy-Pm; Wed, 17 Mar 2021 18:16:35 +0100 Received: from berto by perseus.local with local (Exim 4.92) (envelope-from ) id 1lMZmQ-0007Rg-FW; Wed, 17 Mar 2021 18:16:22 +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=kPgM8tDgBE3TVEP0nZY1Ty8qk1hsfxzQKFlH8ABvL5g=; b=GUcKp/0BoowkKOxCVjubSDJ8ErYrSfGZNiajKtGJUPh8DkGFjxrtOoHhWtQ9S/97Ty3F80hX0eWtUr7KjATeEld5Vl8TYzpErB1h9NH4PEhbCUwrImfyRuUkvoYHqDMGMw8rlaTOnHo5Qg2GYmn2e4ES3797NRHc2GXuieWlxg0sqMrNunuftR9A+HydrHirnmpjwIh56xuNS5KVPvwIjVX+KFuvMwvnAuX7CM2j0nT5I5ShwuBfMqoHmq0O7mb406IkchhAKxtNjiyqX3y7ScgktfRwu1YJB3aP7NjZto8ZFzv0KCYPoWAwcfy94imzhe3Fs7xQKYLnrA5gVOMNnA==; From: Alberto Garcia To: qemu-devel@nongnu.org Subject: [PATCH v4 5/6] iotests: Test reopening multiple devices at the same time Date: Wed, 17 Mar 2021 18:15:56 +0100 Message-Id: <8c6598327d954239476e7528d0f0ec90c449efb4.1616000692.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 c27557fa6b..1a4413e6ab 100755 --- a/tests/qemu-iotests/245 +++ b/tests/qemu-iotests/245 @@ -649,6 +649,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