From nobody Mon Oct 6 15:01:32 2025 Delivered-To: importer@patchew.org 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; 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; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583412836; cv=none; d=zohomail.com; s=zohoarc; b=Fp4xLDRbzelVHecY6CkTKqgAhbVx0v4j2kX6Py8zhsTl3xgAmuiEf/6t8xVldjpoLZcelMqTz4/DZPipLN6oqJ6Egg3rDw0iS1ffYF3epK7Pg9umDIDa4WshuIiR84XKDLqrA//dB0K2Rj7DWLf21aTPNzcwVacRj0iLBhVUNgw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583412836; h=Content-Type: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=/zPTFjuyuzO+Rviy/Mw1VA7INx1FF4XiP46tn/EKlf0=; b=OAEvTPu9HZDAt3aiSjwSqKbL9pKFAISAs9KvLZLoLkKr/5KbkMZq+Yv6oWR0FRZWoCktFvt+qI9E6wNJn3OotF2eg/Uimq979EmDgaawcBgh84kGJOgTmgz4ZvC46v8+fVBErhU1S0YA8moGcSck/AF0flaVkeJ5WCFjGeuiORE= 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; 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 1583412836127260.85679295122804; Thu, 5 Mar 2020 04:53:56 -0800 (PST) Received: from localhost ([::1]:48514 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9q0h-0003gY-4j for importer@patchew.org; Thu, 05 Mar 2020 07:53:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43183) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9py3-0008Le-Sq for qemu-devel@nongnu.org; Thu, 05 Mar 2020 07:51:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j9py2-0006Hf-TD for qemu-devel@nongnu.org; Thu, 05 Mar 2020 07:51:11 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:40500 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j9py2-0006HH-Pq for qemu-devel@nongnu.org; Thu, 05 Mar 2020 07:51:10 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-91-v8Q3ZUQ1PpmUJlHENeWCZA-1; Thu, 05 Mar 2020 07:51:08 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AF13E100550E; Thu, 5 Mar 2020 12:51:07 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-117-210.ams2.redhat.com [10.36.117.210]) by smtp.corp.redhat.com (Postfix) with ESMTP id 89590272A9; Thu, 5 Mar 2020 12:51:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583412670; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/zPTFjuyuzO+Rviy/Mw1VA7INx1FF4XiP46tn/EKlf0=; b=euiHq5QvnfpGJKYvbBcxhCJEdBKKfU0bb/L5JEj9TWp9rQB4Tes79LYB5BXya4MITg1BIc 7r/5QKA1Eto0rWaPImGHmlZd+oKtFkLd26qDnhtL2iubS3PAXFEKPHsy1bFAXMfQYYTglG QpM3iwcGjDF0GgRydODrhUzSbv020HA= X-MC-Unique: v8Q3ZUQ1PpmUJlHENeWCZA-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PATCH 1/4] block: Make bdrv_get_cumulative_perm() public Date: Thu, 5 Mar 2020 13:50:57 +0100 Message-Id: <20200305125100.386-2-kwolf@redhat.com> In-Reply-To: <20200305125100.386-1-kwolf@redhat.com> References: <20200305125100.386-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 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: kwolf@redhat.com, pkrempa@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com 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" Signed-off-by: Kevin Wolf --- include/block/block_int.h | 3 +++ block.c | 6 ++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index f422c0bff0..71164c4ee1 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -1226,6 +1226,9 @@ BdrvChild *bdrv_root_attach_child(BlockDriverState *c= hild_bs, void *opaque, Error **errp); void bdrv_root_unref_child(BdrvChild *child); =20 +void bdrv_get_cumulative_perm(BlockDriverState *bs, uint64_t *perm, + uint64_t *shared_perm); + /** * Sets a BdrvChild's permissions. Avoid if the parent is a BDS; use * bdrv_child_refresh_perms() instead and make the parent's diff --git a/block.c b/block.c index 60e4e273af..5428d121b1 100644 --- a/block.c +++ b/block.c @@ -1872,8 +1872,6 @@ static int bdrv_child_check_perm(BdrvChild *c, BlockR= eopenQueue *q, bool *tighten_restrictions, Error **errp); static void bdrv_child_abort_perm_update(BdrvChild *c); static void bdrv_child_set_perm(BdrvChild *c, uint64_t perm, uint64_t shar= ed); -static void bdrv_get_cumulative_perm(BlockDriverState *bs, uint64_t *perm, - uint64_t *shared_perm); =20 typedef struct BlockReopenQueueEntry { bool prepared; @@ -2097,8 +2095,8 @@ static void bdrv_set_perm(BlockDriverState *bs, uint6= 4_t cumulative_perms, } } =20 -static void bdrv_get_cumulative_perm(BlockDriverState *bs, uint64_t *perm, - uint64_t *shared_perm) +void bdrv_get_cumulative_perm(BlockDriverState *bs, uint64_t *perm, + uint64_t *shared_perm) { BdrvChild *c; uint64_t cumulative_perms =3D 0; --=20 2.20.1 From nobody Mon Oct 6 15:01:32 2025 Delivered-To: importer@patchew.org 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; 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; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583412906; cv=none; d=zohomail.com; s=zohoarc; b=D7sfpiBcuzPPQvDidXDgr05ETeqlQMibOkfnOA+xGV3R0ao25UWifJWbyld/1F4nsjbCm+6vhPA1Ux03JKGUyj41iE5NTcvkTceix2myx1ClJFN0xe7p0GthsZf5Og/PR60vqoUVVdVTiFofYqst8r+WRXqmJPTyl4KCt5KqOvY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583412906; h=Content-Type: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=tmfXvHKaAYfmdyuEH+HGHNe3Vb7rTFVd+tbKs+hk7xA=; b=RazuSlw/s2zRJ52QgaU9JPvDsSV0lKg4Nq8AFcfAsz0R2jgGhoBO6qEwaI+Y6muJCNKhV97W8xAIyqs5257j2NLVODrjHfkQwaglF7vjL6T3omswhxUiFpznrpk6CakdzY4CRipLjOo0PkVJkKZqPbC/TX2P0KKeS/u4CwXXcg8= 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; 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 1583412906145990.6901053469944; Thu, 5 Mar 2020 04:55:06 -0800 (PST) Received: from localhost ([::1]:48530 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9q1p-0005kW-3H for importer@patchew.org; Thu, 05 Mar 2020 07:55:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43212) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9py5-0008Or-9J for qemu-devel@nongnu.org; Thu, 05 Mar 2020 07:51:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j9py4-0006JL-1c for qemu-devel@nongnu.org; Thu, 05 Mar 2020 07:51:13 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:30464 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j9py3-0006Ik-Uu for qemu-devel@nongnu.org; Thu, 05 Mar 2020 07:51:12 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-212-PiE5bvpuNYCf75frQKaviw-1; Thu, 05 Mar 2020 07:51:10 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 222C01005510; Thu, 5 Mar 2020 12:51:09 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-117-210.ams2.redhat.com [10.36.117.210]) by smtp.corp.redhat.com (Postfix) with ESMTP id 00760272A3; Thu, 5 Mar 2020 12:51:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583412671; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tmfXvHKaAYfmdyuEH+HGHNe3Vb7rTFVd+tbKs+hk7xA=; b=H7IZGvWvgsJiYZh+BMGcn2hEHMmDOTzkruafSDMqTQtwU8msA/qXr65IqQ+K/Fx+IeKfXV eHoT+adDq+LJh0abivxQ3+GG5KZfopn/n29tUDx/GpkpZMNM5kQSETFsvFi/ByEnmwPat3 3B8mdMKFf1ZfS3A2fPnYejdYWwRZQ+Q= X-MC-Unique: PiE5bvpuNYCf75frQKaviw-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PATCH 2/4] block: Relax restrictions for blockdev-snapshot Date: Thu, 5 Mar 2020 13:50:58 +0100 Message-Id: <20200305125100.386-3-kwolf@redhat.com> In-Reply-To: <20200305125100.386-1-kwolf@redhat.com> References: <20200305125100.386-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 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: kwolf@redhat.com, pkrempa@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com 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" blockdev-snapshot returned an error if the overlay was already in use, which it defined as having any BlockBackend parent. This is in fact both too strict (some parents can tolerate the change of visible data caused by attaching a backing file) and too loose (some non-BlockBackend parents may not be happy with it). One important use case that is prevented by the too strict check is live storage migration with blockdev-mirror. Here, the target node is usually opened without a backing file so that the active layer is mirrored while its backing chain can be copied in the background. The backing chain should be attached to the mirror target node when finalising the job, just before switching the users of the source node to the new copy (at which point the mirror job still has a reference to the node). drive-mirror did this automatically, but with blockdev-mirror this is the job of the QMP client, so it needs a way to do this. blockdev-snapshot is the obvious way, so this patch makes it work in this scenario. The new condition is that no parent uses CONSISTENT_READ permissions. This will ensure that the operation will still be blocked when the node is attached to the guest device, so blockdev-snapshot remains safe. (For the sake of completeness, x-blockdev-reopen can be used to achieve the same, however it is a big hammer, performs the graph change completely unchecked and is still experimental. So even with the option of using x-blockdev-reopen, there are reasons why blockdev-snapshot should be able to perform this operation.) Signed-off-by: Kevin Wolf --- blockdev.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/blockdev.c b/blockdev.c index 3e44fa766b..bba0e9775b 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1501,6 +1501,7 @@ static void external_snapshot_prepare(BlkActionState = *common, TransactionAction *action =3D common->action; AioContext *aio_context; AioContext *old_context; + uint64_t perm, shared; int ret; =20 /* 'blockdev-snapshot' and 'blockdev-snapshot-sync' have similar @@ -1616,16 +1617,17 @@ static void external_snapshot_prepare(BlkActionStat= e *common, goto out; } =20 - if (bdrv_has_blk(state->new_bs)) { + /* + * Allow attaching a backing file to an overlay that's already in use = only + * if the parents don't assume that they are already seeing a valid im= age. + * (Specifically, allow it as a mirror target, which is write-only acc= ess.) + */ + bdrv_get_cumulative_perm(state->new_bs, &perm, &shared); + if (perm & BLK_PERM_CONSISTENT_READ) { error_setg(errp, "The overlay is already in use"); goto out; } =20 - if (bdrv_op_is_blocked(state->new_bs, BLOCK_OP_TYPE_EXTERNAL_SNAPSHOT, - errp)) { - goto out; - } - if (state->new_bs->backing !=3D NULL) { error_setg(errp, "The overlay already has a backing image"); goto out; --=20 2.20.1 From nobody Mon Oct 6 15:01:32 2025 Delivered-To: importer@patchew.org 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; 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; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583413009; cv=none; d=zohomail.com; s=zohoarc; b=KJcvor4xcium9ILd61qb0yzueYVUjP+5Mb/E4HIf5CuJGK4NaNL4CQUlYXRM5J/CxGgTKyDMwAN1WCS1FGkkZtJbpcP8+dY5SGp0B9ILzmYMNfKtqSRUb7p+p5W+f9iu68nyX8u/UpFR2NcIfJ9t2nyUB7Hxl9crBNJqG3LWHnc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583413009; h=Content-Type: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=GWmFsTqSPEH50eOtsc4mu7xbbfJh9pJRysylAo4hCak=; b=nOtKPdupf9prf5Y5KMVYqbFyrRHm1vc9Y1EI5208I7eFfsPMQaWAx3brwBi2nKjxDGgdIrEZiFM6znSgARjZ++Br+ab9a6GvoqietohhTO1Nefb7aGmLOx4WRKgPL2WvLu9+7ZXxoo2S6k6GsFElGMkCYgeagZv1mpk4487XIQk= 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; 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 1583413009402699.6366161223239; Thu, 5 Mar 2020 04:56:49 -0800 (PST) Received: from localhost ([::1]:48556 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9q3U-0007kV-9M for importer@patchew.org; Thu, 05 Mar 2020 07:56:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43249) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9py6-0008Rq-No for qemu-devel@nongnu.org; Thu, 05 Mar 2020 07:51:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j9py5-0006Lu-JM for qemu-devel@nongnu.org; Thu, 05 Mar 2020 07:51:14 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:35539 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j9py5-0006Km-FU for qemu-devel@nongnu.org; Thu, 05 Mar 2020 07:51:13 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-424-JtaASwOjNiCgZIYnOROrSg-1; Thu, 05 Mar 2020 07:51:11 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8B5CA19067E1; Thu, 5 Mar 2020 12:51:10 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-117-210.ams2.redhat.com [10.36.117.210]) by smtp.corp.redhat.com (Postfix) with ESMTP id 67CC5272A9; Thu, 5 Mar 2020 12:51:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583412673; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GWmFsTqSPEH50eOtsc4mu7xbbfJh9pJRysylAo4hCak=; b=UACtu4tl3YSmcW1cn/Vllbn81bzMkOWUuGmDHsjUUiA8krZV3qgoSS4Fx6DS+Vf1NgtIYG chX5QT6Dtl6yEPcHbxUnyx0WVFAx1dZ4BEFEbVCKNivWTm+UShBz3wlfphbCbhK1sLewsw Yu7+rDIzcffeiKVUwRn8oS2AgHgbhzQ= X-MC-Unique: JtaASwOjNiCgZIYnOROrSg-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PATCH 3/4] iotests: Fix run_job() with use_log=False Date: Thu, 5 Mar 2020 13:50:59 +0100 Message-Id: <20200305125100.386-4-kwolf@redhat.com> In-Reply-To: <20200305125100.386-1-kwolf@redhat.com> References: <20200305125100.386-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 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: kwolf@redhat.com, pkrempa@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com 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" The 'job-complete' QMP command should be run with qmp() rather than qmp_log() if use_log=3DFalse is passed. Signed-off-by: Kevin Wolf --- tests/qemu-iotests/iotests.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 8815052eb5..23043baa26 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -624,7 +624,10 @@ class VM(qtest.QEMUQtestMachine): if use_log: log('Job failed: %s' % (j['error'])) elif status =3D=3D 'ready': - self.qmp_log('job-complete', id=3Djob) + if use_log: + self.qmp_log('job-complete', id=3Djob) + else: + self.qmp('job-complete', id=3Djob) elif status =3D=3D 'pending' and not auto_finalize: if pre_finalize: pre_finalize() --=20 2.20.1 From nobody Mon Oct 6 15:01:32 2025 Delivered-To: importer@patchew.org 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; 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; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583413067; cv=none; d=zohomail.com; s=zohoarc; b=J/XLOXPqL4kjnX+r0UrjRcu3bgByAeyeZCaTMOraS2EU4SDeVTFFwUVRnCoNNc5IwQtZvsurfPCUqtmkA+SAoIMCDOGWV7TnSHjFvR9em51QnXz3/TQzy39dASSJkRzSwvYvNM4Gy92U3Q9SpdlsgFDLyGcp4z0DQJhyDjczu5o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583413067; h=Content-Type: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=5ymmIvFo9y8it5tHvs5HJdQpTHTZ9Djw2gEhP2j+GG8=; b=LTcEFlLw59uQM80N/5wkcs8zxR8toa+RqZs5bF5tpEeQKXQzrSyyF41VEwJYuvocFub4rpSozdZ98H7GTYE9Cid998czOW8FUa4gUbzwZUwLWKlbPKGBsKL0X9gi4MDa3KpEUP+m8hxlu5L4j5nU/VKhvffaC9QT6gyBeODh4Q8= 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; 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 1583413067430805.8048753073302; Thu, 5 Mar 2020 04:57:47 -0800 (PST) Received: from localhost ([::1]:48562 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9q4P-0000CZ-F4 for importer@patchew.org; Thu, 05 Mar 2020 07:57:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43275) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9py8-0008WA-Mf for qemu-devel@nongnu.org; Thu, 05 Mar 2020 07:51:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j9py7-0006Ow-An for qemu-devel@nongnu.org; Thu, 05 Mar 2020 07:51:16 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:54492 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j9py7-0006OC-62 for qemu-devel@nongnu.org; Thu, 05 Mar 2020 07:51:15 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-12-53eQi5msMailP53Gw0M6QQ-1; Thu, 05 Mar 2020 07:51:13 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id ED0A41005510; Thu, 5 Mar 2020 12:51:11 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-117-210.ams2.redhat.com [10.36.117.210]) by smtp.corp.redhat.com (Postfix) with ESMTP id CE010272A3; Thu, 5 Mar 2020 12:51:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583412674; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5ymmIvFo9y8it5tHvs5HJdQpTHTZ9Djw2gEhP2j+GG8=; b=LBwFAJGbCOK3h1sAfc/G36tYO+h5bvFtf9GkSSyjcb7WHZNQfkpe8nGHrE+nFABjtc2Lga RIDfXIED77XEgISGALVu5ZjcZdFKfpEIx4tVqowrkOuS4ti3eeaNHLBmzofsNI1NLqFH6Q 5lVZaDRPk8cbykUXfP0YrPjq8VO3hH0= X-MC-Unique: 53eQi5msMailP53Gw0M6QQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PATCH 4/4] iotests: Test mirror with temporarily disabled target backing file Date: Thu, 5 Mar 2020 13:51:00 +0100 Message-Id: <20200305125100.386-5-kwolf@redhat.com> In-Reply-To: <20200305125100.386-1-kwolf@redhat.com> References: <20200305125100.386-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 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: kwolf@redhat.com, pkrempa@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com 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" The newly tested scenario is a common live storage migration scenario: The target node is opened without a backing file so that the active layer is mirrored while its backing chain can be copied in the background. The backing chain should be attached to the mirror target node when finalising the job, just before switching the users of the source node to the new copy (at which point the mirror job still has a reference to the node). drive-mirror did this automatically, but with blockdev-mirror this is the job of the QMP client. This patch adds test cases for two ways to achieve the desired result, using either x-blockdev-reopen or blockdev-snapshot. Signed-off-by: Kevin Wolf --- tests/qemu-iotests/155 | 54 ++++++++++++++++++++++++++++++++++---- tests/qemu-iotests/155.out | 4 +-- 2 files changed, 51 insertions(+), 7 deletions(-) diff --git a/tests/qemu-iotests/155 b/tests/qemu-iotests/155 index f237868710..8f293a9885 100755 --- a/tests/qemu-iotests/155 +++ b/tests/qemu-iotests/155 @@ -45,10 +45,15 @@ target_img =3D os.path.join(iotests.test_dir, 'target.'= + iotests.imgfmt) # image during runtime, only makes sense if # target_blockdev_backing is not None # (None: same as target_backing) +# target_open_with_backing: If True, the target image is added with its ba= cking +# chain opened right away. If False, blockdev-add +# opens it without a backing file and job comple= tion +# is supposed to open the backing chain. =20 class BaseClass(iotests.QMPTestCase): target_blockdev_backing =3D None target_real_backing =3D None + target_open_with_backing =3D True =20 def setUp(self): qemu_img('create', '-f', iotests.imgfmt, back0_img, '1440K') @@ -80,9 +85,13 @@ class BaseClass(iotests.QMPTestCase): options =3D { 'node-name': 'target', 'driver': iotests.imgfmt, 'file': { 'driver': 'file', + 'node-name': 'target-file', 'filename': target_img } } - if self.target_blockdev_backing: - options['backing'] =3D self.target_blockdev_backing + + if not self.target_open_with_backing: + options['backing'] =3D None + elif self.target_blockdev_backing: + options['backing'] =3D self.target_blockdev_backing =20 result =3D self.vm.qmp('blockdev-add', **options) self.assert_qmp(result, 'return', {}) @@ -147,10 +156,14 @@ class BaseClass(iotests.QMPTestCase): # cmd: Mirroring command to execute, either drive-mirror or blockdev-mirror =20 class MirrorBaseClass(BaseClass): + def openBacking(self): + pass + def runMirror(self, sync): if self.cmd =3D=3D 'blockdev-mirror': result =3D self.vm.qmp(self.cmd, job_id=3D'mirror-job', device= =3D'source', - sync=3Dsync, target=3D'target') + sync=3Dsync, target=3D'target', + auto_finalize=3DFalse) else: if self.existing: mode =3D 'existing' @@ -159,11 +172,12 @@ class MirrorBaseClass(BaseClass): result =3D self.vm.qmp(self.cmd, job_id=3D'mirror-job', device= =3D'source', sync=3Dsync, target=3Dtarget_img, format=3Diotests.imgfmt, mode=3Dmode, - node_name=3D'target') + node_name=3D'target', auto_finalize=3DFal= se) =20 self.assert_qmp(result, 'return', {}) =20 - self.complete_and_wait('mirror-job') + self.vm.run_job('mirror-job', use_log=3DFalse, auto_finalize=3DFal= se, + pre_finalize=3Dself.openBacking, auto_dismiss=3DTr= ue) =20 def testFull(self): self.runMirror('full') @@ -221,6 +235,36 @@ class TestBlockdevMirrorForcedBacking(MirrorBaseClass): target_blockdev_backing =3D { 'driver': 'null-co' } target_real_backing =3D 'null-co://' =20 +class TestBlockdevMirrorBlockdevReopenBacking(MirrorBaseClass): + cmd =3D 'blockdev-mirror' + existing =3D True + target_backing =3D 'null-co://' + target_open_with_backing =3D False + + def openBacking(self): + if not self.target_open_with_backing: + result =3D self.vm.qmp('blockdev-add', node_name=3D"backing", + driver=3D"null-co") + self.assert_qmp(result, 'return', {}) + result =3D self.vm.qmp('x-blockdev-reopen', node_name=3D"targe= t", + driver=3Diotests.imgfmt, file=3D"target-f= ile", + backing=3D"backing") + self.assert_qmp(result, 'return', {}) + +class TestBlockdevMirrorBlockdevSnapshotBacking(MirrorBaseClass): + cmd =3D 'blockdev-mirror' + existing =3D True + target_backing =3D 'null-co://' + target_open_with_backing =3D False + + def openBacking(self): + if not self.target_open_with_backing: + result =3D self.vm.qmp('blockdev-add', node_name=3D"backing", + driver=3D"null-co") + self.assert_qmp(result, 'return', {}) + result =3D self.vm.qmp('blockdev-snapshot', node=3D"backing", + overlay=3D"target") + self.assert_qmp(result, 'return', {}) =20 class TestCommit(BaseClass): existing =3D False diff --git a/tests/qemu-iotests/155.out b/tests/qemu-iotests/155.out index 4176bb9402..4fd1c2dcd2 100644 --- a/tests/qemu-iotests/155.out +++ b/tests/qemu-iotests/155.out @@ -1,5 +1,5 @@ -................... +......................... ---------------------------------------------------------------------- -Ran 19 tests +Ran 25 tests =20 OK --=20 2.20.1