From patchwork Thu Jan 30 21:44:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 1231653 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=LzDN0i8d; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 487vDB4MRXz9sPK for ; Fri, 31 Jan 2020 08:50:34 +1100 (AEDT) Received: from localhost ([::1]:39760 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHhn-0004Ey-DK for incoming@patchwork.ozlabs.org; Thu, 30 Jan 2020 16:50:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33019) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHcB-0004JM-V0 for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:44:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ixHcA-00033i-Qp for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:44:43 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:52591 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 1ixHcA-00031a-Lk for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:44:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580420682; 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=TM4jM9Mqmd/WmtrFPjy3wXLYjWdFXzeHdwDDTFWk8Uk=; b=LzDN0i8d9PZ+F5JgBy3lqWi+ylAHGPAZ58pD2qA+hi1DBcEt392t7j0tyG+kek8G58cCA2 UGFslc+rqvTCKiinb36DKlYijYosm6/y7y0QGFUqtkVu+F8IobN8OLE/U++l+9umdbWcEN 7fVtFH+Lg9DxzLRdKr2JYpbVNUhONjA= 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-249-0HVGktWTNBGa229sX_CK6g-1; Thu, 30 Jan 2020 16:44:37 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 39E348C3D06; Thu, 30 Jan 2020 21:44:36 +0000 (UTC) Received: from localhost (ovpn-204-145.brq.redhat.com [10.40.204.145]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9D2AE77939; Thu, 30 Jan 2020 21:44:35 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v3 01/21] blockdev: Allow external snapshots everywhere Date: Thu, 30 Jan 2020 22:44:11 +0100 Message-Id: <20200130214431.333510-2-mreitz@redhat.com> In-Reply-To: <20200130214431.333510-1-mreitz@redhat.com> References: <20200130214431.333510-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: 0HVGktWTNBGa229sX_CK6g-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" There is no good reason why we would allow external snapshots only on the first non-filter node in a chain. Parent BDSs should not care whether their child is replaced by a snapshot. (If they do care, they should announce that via freezing the chain, which is checked in bdrv_append() through bdrv_set_backing_hd().) Before we had bdrv_is_first_non_filter() here (since 212a5a8f095), there was a special function bdrv_check_ext_snapshot() that allowed snapshots by default, but block drivers could override this. Only blkverify did so, however. It is not clear to me why blkverify would do so; maybe just so that the testee block driver would not be replaced. The introducing commit f6186f49e2c does not explain why. Maybe because 08b24cfe376 would have been the correct solution? (Which adds a .supports_backing check.) Signed-off-by: Max Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy --- blockdev.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/blockdev.c b/blockdev.c index 4cd9a58d36..d47ed8e569 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1596,11 +1596,6 @@ static void external_snapshot_prepare(BlkActionState *common, } } - if (!bdrv_is_first_non_filter(state->old_bs)) { - error_setg(errp, QERR_FEATURE_DISABLED, "snapshot"); - goto out; - } - if (action->type == TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC) { BlockdevSnapshotSync *s = action->u.blockdev_snapshot_sync.data; const char *format = s->has_format ? s->format : "qcow2"; From patchwork Thu Jan 30 21:44:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 1231651 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=KEORGVD+; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 487vBq2zQVz9sNx for ; Fri, 31 Jan 2020 08:49:23 +1100 (AEDT) Received: from localhost ([::1]:39742 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHgf-0002ZO-8o for incoming@patchwork.ozlabs.org; Thu, 30 Jan 2020 16:49:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33022) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHcC-0004JT-1E for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:44:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ixHcA-00034M-Ty for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:44:43 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:44110 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 1ixHcA-00031B-Ok for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:44:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580420682; 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=kNANRqxDaNAbjw3RnwVG76NgDmT98rBThz+qB88J5uY=; b=KEORGVD+fyBBD8fEbBHmUwFld6q7alroLwA9VxXfwUmsitaKi+np4iY9Yn2TcG/lfPkek4 MZ8pnRIwwkxLVge4AeyIxOSK8w3ibmfrFET4mkvPTw0kCEsVLjjZZkwjWepe8kUfrrLfPv BPHageZdn29alug0wDBzov/I5Fmj/AI= 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-252-blDjVaPEPtmcFeOqCsl9_A-1; Thu, 30 Jan 2020 16:44:39 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 835039A879; Thu, 30 Jan 2020 21:44:38 +0000 (UTC) Received: from localhost (ovpn-204-145.brq.redhat.com [10.40.204.145]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1C6E777939; Thu, 30 Jan 2020 21:44:37 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v3 02/21] blockdev: Allow resizing everywhere Date: Thu, 30 Jan 2020 22:44:12 +0100 Message-Id: <20200130214431.333510-3-mreitz@redhat.com> In-Reply-To: <20200130214431.333510-1-mreitz@redhat.com> References: <20200130214431.333510-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: blDjVaPEPtmcFeOqCsl9_A-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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: Kevin Wolf , Vladimir Sementsov-Ogievskiy , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Block nodes that do not allow resizing should not share BLK_PERM_RESIZE. It does not matter whether they are the first non-filter in their chain or not. Signed-off-by: Max Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy --- blockdev.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/blockdev.c b/blockdev.c index d47ed8e569..bdd66d6c48 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3335,11 +3335,6 @@ void qmp_block_resize(bool has_device, const char *device, aio_context = bdrv_get_aio_context(bs); aio_context_acquire(aio_context); - if (!bdrv_is_first_non_filter(bs)) { - error_setg(errp, QERR_FEATURE_DISABLED, "resize"); - goto out; - } - if (size < 0) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "size", "a >0 size"); goto out; From patchwork Thu Jan 30 21:44:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 1231647 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=bmhMj6Kv; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 487v8n6Xthz9sNx for ; Fri, 31 Jan 2020 08:47:36 +1100 (AEDT) Received: from localhost ([::1]:39718 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHet-00086H-M6 for incoming@patchwork.ozlabs.org; Thu, 30 Jan 2020 16:47:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33101) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHcG-0004S9-4F for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:44:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ixHcF-0003OJ-0L for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:44:48 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:33558 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 1ixHcE-0003M5-RT for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:44:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580420686; 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=YkqxlVGYqeQ2kN5TdDYnJb9onnZj65OuIAqL7EzEkck=; b=bmhMj6KvLbCjV3B6JhlnJaTk1t6tzCjpRXPEjOqMyUPXOg+ZdXjaOo0Aomucg+iBJXZt0x +Iuk+mX1eIA/ImMcTr3r+rV8PKjrcVaPO8fPQTEQ1V6aWewWDb88nxlYz0c7lV9gL8nhW9 4LUT9trzLCF/rKWczJUcHcoTyVSPCsA= 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-344-JBtIOu1cNbmREPExzFMkkg-1; Thu, 30 Jan 2020 16:44:41 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D5EE81005F76; Thu, 30 Jan 2020 21:44:40 +0000 (UTC) Received: from localhost (ovpn-204-145.brq.redhat.com [10.40.204.145]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6CDE360BE1; Thu, 30 Jan 2020 21:44:40 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v3 03/21] block: Drop bdrv_is_first_non_filter() Date: Thu, 30 Jan 2020 22:44:13 +0100 Message-Id: <20200130214431.333510-4-mreitz@redhat.com> In-Reply-To: <20200130214431.333510-1-mreitz@redhat.com> References: <20200130214431.333510-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: JBtIOu1cNbmREPExzFMkkg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.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: Kevin Wolf , Vladimir Sementsov-Ogievskiy , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" It is unused now. (And it was ugly because it needed to explore all BDS chains from the top.) Signed-off-by: Max Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy --- block.c | 26 -------------------------- include/block/block.h | 1 - 2 files changed, 27 deletions(-) diff --git a/block.c b/block.c index 99ce26d64d..6f58a4900f 100644 --- a/block.c +++ b/block.c @@ -6212,32 +6212,6 @@ bool bdrv_recurse_is_first_non_filter(BlockDriverState *bs, return false; } -/* This function checks if the candidate is the first non filter bs down it's - * bs chain. Since we don't have pointers to parents it explore all bs chains - * from the top. Some filters can choose not to pass down the recursion. - */ -bool bdrv_is_first_non_filter(BlockDriverState *candidate) -{ - BlockDriverState *bs; - BdrvNextIterator it; - - /* walk down the bs forest recursively */ - for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) { - bool perm; - - /* try to recurse in this top level bs */ - perm = bdrv_recurse_is_first_non_filter(bs, candidate); - - /* candidate is the first non filter */ - if (perm) { - bdrv_next_cleanup(&it); - return true; - } - } - - return false; -} - BlockDriverState *check_to_replace_node(BlockDriverState *parent_bs, const char *node_name, Error **errp) { diff --git a/include/block/block.h b/include/block/block.h index e9dcfef7fa..8f6a0cad9c 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -404,7 +404,6 @@ int bdrv_amend_options(BlockDriverState *bs_new, QemuOpts *opts, /* external snapshots */ bool bdrv_recurse_is_first_non_filter(BlockDriverState *bs, BlockDriverState *candidate); -bool bdrv_is_first_non_filter(BlockDriverState *candidate); /* check if a named node can be replaced when doing drive-mirror */ BlockDriverState *check_to_replace_node(BlockDriverState *parent_bs, From patchwork Thu Jan 30 21:44:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 1231657 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=IVUpkG2Z; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 487vHf3n6qz9sNx for ; Fri, 31 Jan 2020 08:53:34 +1100 (AEDT) Received: from localhost ([::1]:39820 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHkh-0000IS-Ue for incoming@patchwork.ozlabs.org; Thu, 30 Jan 2020 16:53:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33093) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHcF-0004RL-P4 for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:44:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ixHcE-0003LY-Cu for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:44:47 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:56007 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 1ixHcE-0003KG-8r for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:44:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580420685; 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=G4n4HUCaIGhP4zdLYqxLtNxQJ7B2nvsVvLmrQc2ewyA=; b=IVUpkG2Z8IGGKyHrFSeJw6baYgN7pN8MFJCANh4v6KoR1H4WfMhfNMEvte0BtNCUzN2YNI SWFfjYhBePRPoJMhva9ceiTYXqWVCBSKLMh/Qev59zSG7GgDVYEyg7OJOQSTSH35LsqXMA 1s95IBapZPTkXlb1HbxAygMtA62cUBM= 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-226-O6VO5X2wPvyzpVbyjArw7Q-1; Thu, 30 Jan 2020 16:44:44 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 29E3D8C4171; Thu, 30 Jan 2020 21:44:43 +0000 (UTC) Received: from localhost (ovpn-204-145.brq.redhat.com [10.40.204.145]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B773087B00; Thu, 30 Jan 2020 21:44:42 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v3 04/21] iotests: Let 041 use -blockdev for quorum children Date: Thu, 30 Jan 2020 22:44:14 +0100 Message-Id: <20200130214431.333510-5-mreitz@redhat.com> In-Reply-To: <20200130214431.333510-1-mreitz@redhat.com> References: <20200130214431.333510-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: O6VO5X2wPvyzpVbyjArw7Q-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.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: Kevin Wolf , Vladimir Sementsov-Ogievskiy , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Using -drive with default options means that a virtio-blk drive will be created that has write access to the to-be quorum children. Quorum should have exclusive write access to them, so we should use -blockdev instead. Signed-off-by: Max Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/041 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041 index 0181f7a9b6..a429281f61 100755 --- a/tests/qemu-iotests/041 +++ b/tests/qemu-iotests/041 @@ -885,7 +885,10 @@ class TestRepairQuorum(iotests.QMPTestCase): # Assign a node name to each quorum image in order to manipulate # them opts = "node-name=img%i" % self.IMAGES.index(i) - self.vm = self.vm.add_drive(i, opts) + opts += ',driver=%s' % iotests.imgfmt + opts += ',file.driver=file' + opts += ',file.filename=%s' % i + self.vm = self.vm.add_blockdev(opts) self.vm.launch() From patchwork Thu Jan 30 21:44:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 1231655 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=IJ087V6C; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 487vG04kj2z9sNx for ; Fri, 31 Jan 2020 08:52:08 +1100 (AEDT) Received: from localhost ([::1]:39786 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHjK-0006I9-Hy for incoming@patchwork.ozlabs.org; Thu, 30 Jan 2020 16:52:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33178) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHcL-0004aH-D1 for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:44:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ixHcK-0003dy-9w for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:44:53 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:49271 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 1ixHcK-0003ai-5c for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:44:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580420690; 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=JqWjZxjtWIp3MWC4LNtMxsi6Ek69Xqn/5MO9nTKp1ok=; b=IJ087V6C2WUZ9cs2pfzIVhmTrBcUVHnChxdRgVD1LYv6eL97L1qmMFwaDer1Xo+lM7NOZ/ thQItu3gXeXdFifZceTWx2/tck6/c6IjFwp+aMsGL2iLnpmlU13smLyWfCm20EOtIMwy+O OeFuR8Jqmh7s4avGrZ7k6kzboXPPwro= 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-412-LwZgIHFjP1CVBW3rN12WWg-1; Thu, 30 Jan 2020 16:44:46 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 760DF73404; Thu, 30 Jan 2020 21:44:45 +0000 (UTC) Received: from localhost (ovpn-204-145.brq.redhat.com [10.40.204.145]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0F3DF1001B23; Thu, 30 Jan 2020 21:44:44 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v3 05/21] quorum: Fix child permissions Date: Thu, 30 Jan 2020 22:44:15 +0100 Message-Id: <20200130214431.333510-6-mreitz@redhat.com> In-Reply-To: <20200130214431.333510-1-mreitz@redhat.com> References: <20200130214431.333510-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: LwZgIHFjP1CVBW3rN12WWg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.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: Kevin Wolf , Vladimir Sementsov-Ogievskiy , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Quorum cannot share WRITE or RESIZE on its children. Presumably, it only does so because as a filter, it seemed intuitively correct to point its .bdrv_child_perm to bdrv_filter_default_perm(). However, it is not really a filter, and bdrv_filter_default_perm() does not work for it, so we have to provide a custom .bdrv_child_perm implementation. Signed-off-by: Max Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/quorum.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/block/quorum.c b/block/quorum.c index df68adcfaa..17b439056f 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -1114,6 +1114,23 @@ static char *quorum_dirname(BlockDriverState *bs, Error **errp) return NULL; } +static void quorum_child_perm(BlockDriverState *bs, BdrvChild *c, + const BdrvChildRole *role, + BlockReopenQueue *reopen_queue, + uint64_t perm, uint64_t shared, + uint64_t *nperm, uint64_t *nshared) +{ + *nperm = perm & DEFAULT_PERM_PASSTHROUGH; + + /* + * We cannot share RESIZE or WRITE, as this would make the + * children differ from each other. + */ + *nshared = (shared & (BLK_PERM_CONSISTENT_READ | + BLK_PERM_WRITE_UNCHANGED)) + | DEFAULT_PERM_UNCHANGED; +} + static const char *const quorum_strong_runtime_opts[] = { QUORUM_OPT_VOTE_THRESHOLD, QUORUM_OPT_BLKVERIFY, @@ -1143,7 +1160,7 @@ static BlockDriver bdrv_quorum = { .bdrv_add_child = quorum_add_child, .bdrv_del_child = quorum_del_child, - .bdrv_child_perm = bdrv_filter_default_perms, + .bdrv_child_perm = quorum_child_perm, .is_filter = true, .bdrv_recurse_is_first_non_filter = quorum_recurse_is_first_non_filter, From patchwork Thu Jan 30 21:44:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 1231656 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=MTarBBpW; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 487vG94YChz9sNx for ; Fri, 31 Jan 2020 08:52:17 +1100 (AEDT) Received: from localhost ([::1]:39792 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHjT-0006at-Ht for incoming@patchwork.ozlabs.org; Thu, 30 Jan 2020 16:52:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33283) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHcP-0004ke-Na for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:44:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ixHcO-0003uQ-Bw for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:44:57 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:27870 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 1ixHcO-0003tN-7l for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:44:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580420695; 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=iCAmo/jwaRQqIDZ5IhRZyCsBgUlZuKmTMDrYNtPvXbM=; b=MTarBBpWuKgX0m1LilcDfB97mhYuJEsNnd0t0b8JiQBlQRQzRd1h49mLgmfNSZPj81z4Aq OKpxVN/VamK/A7M9+Dwe6rSuRvdG+UOWbjqZr9sGRymKtzHEIMOAeVzDf0sBovckad/KST EH2JolHvSZBN6UgX3YKnXuGqCo6bt/k= 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-155-hBNhTg2APdCRHWtIvgbDtQ-1; Thu, 30 Jan 2020 16:44:48 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id C2F9E801A08; Thu, 30 Jan 2020 21:44:47 +0000 (UTC) Received: from localhost (ovpn-204-145.brq.redhat.com [10.40.204.145]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5B92577949; Thu, 30 Jan 2020 21:44:47 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v3 06/21] block: Add bdrv_recurse_can_replace() Date: Thu, 30 Jan 2020 22:44:16 +0100 Message-Id: <20200130214431.333510-7-mreitz@redhat.com> In-Reply-To: <20200130214431.333510-1-mreitz@redhat.com> References: <20200130214431.333510-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: hBNhTg2APdCRHWtIvgbDtQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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: Kevin Wolf , Vladimir Sementsov-Ogievskiy , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" After a couple of follow-up patches, this function will replace bdrv_recurse_is_first_non_filter() in check_to_replace_node(). bdrv_recurse_is_first_non_filter() is both not sufficiently specific for check_to_replace_node() (it allows cases that should not be allowed, like replacing child nodes of quorum with dissenting data that have more parents than just quorum), and it is too restrictive (it is perfectly fine to replace filters). Signed-off-by: Max Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy --- block.c | 38 ++++++++++++++++++++++++++++++++++++++ include/block/block_int.h | 10 ++++++++++ 2 files changed, 48 insertions(+) diff --git a/block.c b/block.c index 6f58a4900f..6623248443 100644 --- a/block.c +++ b/block.c @@ -6212,6 +6212,44 @@ bool bdrv_recurse_is_first_non_filter(BlockDriverState *bs, return false; } +/* + * This function checks whether the given @to_replace is allowed to be + * replaced by a node that always shows the same data as @bs. This is + * used for example to verify whether the mirror job can replace + * @to_replace by the target mirrored from @bs. + * To be replaceable, @bs and @to_replace may either be guaranteed to + * always show the same data (because they are only connected through + * filters), or some driver may allow replacing one of its children + * because it can guarantee that this child's data is not visible at + * all (for example, for dissenting quorum children that have no other + * parents). + */ +bool bdrv_recurse_can_replace(BlockDriverState *bs, + BlockDriverState *to_replace) +{ + if (!bs || !bs->drv) { + return false; + } + + if (bs == to_replace) { + return true; + } + + /* See what the driver can do */ + if (bs->drv->bdrv_recurse_can_replace) { + return bs->drv->bdrv_recurse_can_replace(bs, to_replace); + } + + /* For filters without an own implementation, we can recurse on our own */ + if (bs->drv->is_filter) { + BdrvChild *child = bs->file ?: bs->backing; + return bdrv_recurse_can_replace(child->bs, to_replace); + } + + /* Safe default */ + return false; +} + BlockDriverState *check_to_replace_node(BlockDriverState *parent_bs, const char *node_name, Error **errp) { diff --git a/include/block/block_int.h b/include/block/block_int.h index dd033d0b37..75f03dcc38 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -102,6 +102,13 @@ struct BlockDriver { */ bool (*bdrv_recurse_is_first_non_filter)(BlockDriverState *bs, BlockDriverState *candidate); + /* + * Return true if @to_replace can be replaced by a BDS with the + * same data as @bs without it affecting @bs's behavior (that is, + * without it being visible to @bs's parents). + */ + bool (*bdrv_recurse_can_replace)(BlockDriverState *bs, + BlockDriverState *to_replace); int (*bdrv_probe)(const uint8_t *buf, int buf_size, const char *filename); int (*bdrv_probe_device)(const char *filename); @@ -1264,6 +1271,9 @@ void bdrv_format_default_perms(BlockDriverState *bs, BdrvChild *c, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared); +bool bdrv_recurse_can_replace(BlockDriverState *bs, + BlockDriverState *to_replace); + /* * Default implementation for drivers to pass bdrv_co_block_status() to * their file. From patchwork Thu Jan 30 21:44:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 1231652 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=c1PML+xU; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 487vC40w5Kz9sNx for ; Fri, 31 Jan 2020 08:49:36 +1100 (AEDT) Received: from localhost ([::1]:39748 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHgr-0002uC-UG for incoming@patchwork.ozlabs.org; Thu, 30 Jan 2020 16:49:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33207) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHcM-0004cZ-Cc for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:44:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ixHcL-0003jK-8J for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:44:54 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:28057 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 1ixHcL-0003hQ-3u for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:44:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580420692; 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=lyBO0LHcnSgut5s8ijX92IhUO31aC59wxCEUTOSlOFo=; b=c1PML+xUcLJRn6lieD/iP8OlbEV3WYTPtbpXr9R7iYaFVXFwRLwH7bzBsBikrPdmWdzJP0 XhwP9TzSPD5FamcTnkvQQrqzhKcv0ldIKOWXKfTAj0uRoLSAx1yAzMNMfWr1NO4zexcNTe M9gJQf3rMf47FDlUpemgf/8M6mDwXzo= 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-30-Q5sZa6z6PLiJ-7bKOj1P9g-1; Thu, 30 Jan 2020 16:44:51 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1CE8773418; Thu, 30 Jan 2020 21:44:50 +0000 (UTC) Received: from localhost (ovpn-204-145.brq.redhat.com [10.40.204.145]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A7BBD84BCE; Thu, 30 Jan 2020 21:44:49 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v3 07/21] blkverify: Implement .bdrv_recurse_can_replace() Date: Thu, 30 Jan 2020 22:44:17 +0100 Message-Id: <20200130214431.333510-8-mreitz@redhat.com> In-Reply-To: <20200130214431.333510-1-mreitz@redhat.com> References: <20200130214431.333510-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: Q5sZa6z6PLiJ-7bKOj1P9g-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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: Kevin Wolf , Vladimir Sementsov-Ogievskiy , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Max Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/blkverify.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/block/blkverify.c b/block/blkverify.c index 304b0a1368..0add3ab483 100644 --- a/block/blkverify.c +++ b/block/blkverify.c @@ -282,6 +282,20 @@ static bool blkverify_recurse_is_first_non_filter(BlockDriverState *bs, return bdrv_recurse_is_first_non_filter(s->test_file->bs, candidate); } +static bool blkverify_recurse_can_replace(BlockDriverState *bs, + BlockDriverState *to_replace) +{ + BDRVBlkverifyState *s = bs->opaque; + + /* + * blkverify quits the whole qemu process if there is a mismatch + * between bs->file->bs and s->test_file->bs. Therefore, we know + * know that both must match bs and we can recurse down to either. + */ + return bdrv_recurse_can_replace(bs->file->bs, to_replace) || + bdrv_recurse_can_replace(s->test_file->bs, to_replace); +} + static void blkverify_refresh_filename(BlockDriverState *bs) { BDRVBlkverifyState *s = bs->opaque; @@ -328,6 +342,7 @@ static BlockDriver bdrv_blkverify = { .is_filter = true, .bdrv_recurse_is_first_non_filter = blkverify_recurse_is_first_non_filter, + .bdrv_recurse_can_replace = blkverify_recurse_can_replace, }; static void bdrv_blkverify_init(void) From patchwork Thu Jan 30 21:44:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 1231666 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=PgtH3nBV; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 487vNj2z6Vz9sNx for ; Fri, 31 Jan 2020 08:57:57 +1100 (AEDT) Received: from localhost ([::1]:39904 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHox-0000bx-A0 for incoming@patchwork.ozlabs.org; Thu, 30 Jan 2020 16:57:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33325) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHcR-0004oO-Ki for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:45:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ixHcP-0003yG-Tv for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:44:59 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:34630 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 1ixHcP-0003xy-Q6 for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:44:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580420697; 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=gDdCF/ChIzOZEc+2w4m/T5Xyag1Kq9vTzGsn7kFoMuI=; b=PgtH3nBVfB0S/nbbq74wmN9VOkQrX90g6Nh2YHL40oNF1D5dSpH9zMwWas86AoaTZMkecf EPchB1F09h0QCB0/YA559OMGsy9/MC/b7O9uPa2HBh1uGxh5CvdPAqlYpuk5IlGsB1+83f 2KQStz4YkiG3tmDJAI2SoUwF3wOdKxE= 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-407-zr6e0kvOML68aIDgZntdNA-1; Thu, 30 Jan 2020 16:44:53 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 951E1108C254; Thu, 30 Jan 2020 21:44:52 +0000 (UTC) Received: from localhost (ovpn-204-145.brq.redhat.com [10.40.204.145]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0310B88840; Thu, 30 Jan 2020 21:44:51 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v3 08/21] quorum: Store children in own structure Date: Thu, 30 Jan 2020 22:44:18 +0100 Message-Id: <20200130214431.333510-9-mreitz@redhat.com> In-Reply-To: <20200130214431.333510-1-mreitz@redhat.com> References: <20200130214431.333510-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: zr6e0kvOML68aIDgZntdNA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This will be useful when we want to store additional attributes for each child. Signed-off-by: Max Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/quorum.c | 64 ++++++++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 28 deletions(-) diff --git a/block/quorum.c b/block/quorum.c index 17b439056f..59cd524502 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -65,9 +65,13 @@ typedef struct QuorumVotes { bool (*compare)(QuorumVoteValue *a, QuorumVoteValue *b); } QuorumVotes; +typedef struct QuorumChild { + BdrvChild *child; +} QuorumChild; + /* the following structure holds the state of one quorum instance */ typedef struct BDRVQuorumState { - BdrvChild **children; /* children BlockDriverStates */ + QuorumChild *children; int num_children; /* children count */ unsigned next_child_index; /* the index of the next child that should * be added @@ -264,7 +268,7 @@ static void quorum_report_bad_versions(BDRVQuorumState *s, } QLIST_FOREACH(item, &version->items, next) { quorum_report_bad(QUORUM_OP_TYPE_READ, acb->offset, acb->bytes, - s->children[item->index]->bs->node_name, 0); + s->children[item->index].child->bs->node_name, 0); } } } @@ -279,7 +283,7 @@ static void quorum_rewrite_entry(void *opaque) * corrupted data. * Mask out BDRV_REQ_WRITE_UNCHANGED because this overwrites the * area with different data from the other children. */ - bdrv_co_pwritev(s->children[co->idx], acb->offset, acb->bytes, + bdrv_co_pwritev(s->children[co->idx].child, acb->offset, acb->bytes, acb->qiov, acb->flags & ~BDRV_REQ_WRITE_UNCHANGED); /* Wake up the caller after the last rewrite */ @@ -578,8 +582,8 @@ static void read_quorum_children_entry(void *opaque) int i = co->idx; QuorumChildRequest *sacb = &acb->qcrs[i]; - sacb->bs = s->children[i]->bs; - sacb->ret = bdrv_co_preadv(s->children[i], acb->offset, acb->bytes, + sacb->bs = s->children[i].child->bs; + sacb->ret = bdrv_co_preadv(s->children[i].child, acb->offset, acb->bytes, &acb->qcrs[i].qiov, 0); if (sacb->ret == 0) { @@ -605,7 +609,8 @@ static int read_quorum_children(QuorumAIOCB *acb) acb->children_read = s->num_children; for (i = 0; i < s->num_children; i++) { - acb->qcrs[i].buf = qemu_blockalign(s->children[i]->bs, acb->qiov->size); + acb->qcrs[i].buf = qemu_blockalign(s->children[i].child->bs, + acb->qiov->size); qemu_iovec_init(&acb->qcrs[i].qiov, acb->qiov->niov); qemu_iovec_clone(&acb->qcrs[i].qiov, acb->qiov, acb->qcrs[i].buf); } @@ -647,8 +652,8 @@ static int read_fifo_child(QuorumAIOCB *acb) /* We try to read the next child in FIFO order if we failed to read */ do { n = acb->children_read++; - acb->qcrs[n].bs = s->children[n]->bs; - ret = bdrv_co_preadv(s->children[n], acb->offset, acb->bytes, + acb->qcrs[n].bs = s->children[n].child->bs; + ret = bdrv_co_preadv(s->children[n].child, acb->offset, acb->bytes, acb->qiov, 0); if (ret < 0) { quorum_report_bad_acb(&acb->qcrs[n], ret); @@ -688,8 +693,8 @@ static void write_quorum_entry(void *opaque) int i = co->idx; QuorumChildRequest *sacb = &acb->qcrs[i]; - sacb->bs = s->children[i]->bs; - sacb->ret = bdrv_co_pwritev(s->children[i], acb->offset, acb->bytes, + sacb->bs = s->children[i].child->bs; + sacb->ret = bdrv_co_pwritev(s->children[i].child, acb->offset, acb->bytes, acb->qiov, acb->flags); if (sacb->ret == 0) { acb->success_count++; @@ -743,12 +748,12 @@ static int64_t quorum_getlength(BlockDriverState *bs) int i; /* check that all file have the same length */ - result = bdrv_getlength(s->children[0]->bs); + result = bdrv_getlength(s->children[0].child->bs); if (result < 0) { return result; } for (i = 1; i < s->num_children; i++) { - int64_t value = bdrv_getlength(s->children[i]->bs); + int64_t value = bdrv_getlength(s->children[i].child->bs); if (value < 0) { return value; } @@ -774,10 +779,10 @@ static coroutine_fn int quorum_co_flush(BlockDriverState *bs) error_votes.compare = quorum_64bits_compare; for (i = 0; i < s->num_children; i++) { - result = bdrv_co_flush(s->children[i]->bs); + result = bdrv_co_flush(s->children[i].child->bs); if (result) { quorum_report_bad(QUORUM_OP_TYPE_FLUSH, 0, 0, - s->children[i]->bs->node_name, result); + s->children[i].child->bs->node_name, result); result_value.l = result; quorum_count_vote(&error_votes, &result_value, i); } else { @@ -803,7 +808,7 @@ static bool quorum_recurse_is_first_non_filter(BlockDriverState *bs, int i; for (i = 0; i < s->num_children; i++) { - bool perm = bdrv_recurse_is_first_non_filter(s->children[i]->bs, + bool perm = bdrv_recurse_is_first_non_filter(s->children[i].child->bs, candidate); if (perm) { return true; @@ -932,7 +937,7 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags, } /* allocate the children array */ - s->children = g_new0(BdrvChild *, s->num_children); + s->children = g_new0(QuorumChild, s->num_children); opened = g_new0(bool, s->num_children); for (i = 0; i < s->num_children; i++) { @@ -940,8 +945,9 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags, ret = snprintf(indexstr, 32, "children.%d", i); assert(ret < 32); - s->children[i] = bdrv_open_child(NULL, options, indexstr, bs, - &child_format, false, &local_err); + s->children[i].child = bdrv_open_child(NULL, options, indexstr, bs, + &child_format, false, + &local_err); if (local_err) { ret = -EINVAL; goto close_exit; @@ -962,7 +968,7 @@ close_exit: if (!opened[i]) { continue; } - bdrv_unref_child(bs, s->children[i]); + bdrv_unref_child(bs, s->children[i].child); } g_free(s->children); g_free(opened); @@ -979,7 +985,7 @@ static void quorum_close(BlockDriverState *bs) int i; for (i = 0; i < s->num_children; i++) { - bdrv_unref_child(bs, s->children[i]); + bdrv_unref_child(bs, s->children[i].child); } g_free(s->children); @@ -998,8 +1004,8 @@ static void quorum_add_child(BlockDriverState *bs, BlockDriverState *child_bs, return; } - assert(s->num_children <= INT_MAX / sizeof(BdrvChild *)); - if (s->num_children == INT_MAX / sizeof(BdrvChild *) || + assert(s->num_children <= INT_MAX / sizeof(QuorumChild)); + if (s->num_children == INT_MAX / sizeof(QuorumChild) || s->next_child_index == UINT_MAX) { error_setg(errp, "Too many children"); return; @@ -1022,8 +1028,10 @@ static void quorum_add_child(BlockDriverState *bs, BlockDriverState *child_bs, s->next_child_index--; goto out; } - s->children = g_renew(BdrvChild *, s->children, s->num_children + 1); - s->children[s->num_children++] = child; + s->children = g_renew(QuorumChild, s->children, s->num_children + 1); + s->children[s->num_children++] = (QuorumChild){ + .child = child, + }; out: bdrv_drained_end(bs); @@ -1036,7 +1044,7 @@ static void quorum_del_child(BlockDriverState *bs, BdrvChild *child, int i; for (i = 0; i < s->num_children; i++) { - if (s->children[i] == child) { + if (s->children[i].child == child) { break; } } @@ -1058,8 +1066,8 @@ static void quorum_del_child(BlockDriverState *bs, BdrvChild *child, /* We can safely remove this child now */ memmove(&s->children[i], &s->children[i + 1], - (s->num_children - i - 1) * sizeof(BdrvChild *)); - s->children = g_renew(BdrvChild *, s->children, --s->num_children); + (s->num_children - i - 1) * sizeof(QuorumChild)); + s->children = g_renew(QuorumChild, s->children, --s->num_children); bdrv_unref_child(bs, child); bdrv_drained_end(bs); @@ -1100,7 +1108,7 @@ static void quorum_gather_child_options(BlockDriverState *bs, QDict *target, for (i = 0; i < s->num_children; i++) { qlist_append(children_list, - qobject_ref(s->children[i]->bs->full_open_options)); + qobject_ref(s->children[i].child->bs->full_open_options)); } } From patchwork Thu Jan 30 21:44:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 1231658 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=TLFbjOyD; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 487vHj36Mbz9sNx for ; Fri, 31 Jan 2020 08:53:37 +1100 (AEDT) Received: from localhost ([::1]:39822 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHkl-0000TU-AX for incoming@patchwork.ozlabs.org; Thu, 30 Jan 2020 16:53:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33363) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHcT-0004sY-CS for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:45:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ixHcS-00044o-BI for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:45:01 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:54458 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 1ixHcS-00044C-82 for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:45:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580420699; 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=/oPtPL8zf9tJoCJa4teoozK5YutntkpEjfe0LxqwwmU=; b=TLFbjOyDbxh3aZ8swKrdBGjno2rRmH+lAsL6kyaXMvOx3sIY9R+pFwtqnaDIKAlJqnLLKS dYIp2kDS6VddWLnXK7UiwdRI33jCEt+Emdx15WjEPXSi+6MBUoH4cuMsOrG0aSEadBCy5M Dd8RGs4KMGcsQSVzqBjsw9hUIWJFO3o= 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-13-Rz-x4JnINymMcem07Z0-2A-1; Thu, 30 Jan 2020 16:44:56 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E10F27341D; Thu, 30 Jan 2020 21:44:54 +0000 (UTC) Received: from localhost (ovpn-204-145.brq.redhat.com [10.40.204.145]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7B1B060BE1; Thu, 30 Jan 2020 21:44:54 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v3 09/21] quorum: Add QuorumChild.to_be_replaced Date: Thu, 30 Jan 2020 22:44:19 +0100 Message-Id: <20200130214431.333510-10-mreitz@redhat.com> In-Reply-To: <20200130214431.333510-1-mreitz@redhat.com> References: <20200130214431.333510-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: Rz-x4JnINymMcem07Z0-2A-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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: Kevin Wolf , Vladimir Sementsov-Ogievskiy , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" We will need this to verify that Quorum can let one of its children be replaced without breaking anything else. Signed-off-by: Max Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/quorum.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/block/quorum.c b/block/quorum.c index 59cd524502..6a7224c9e4 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -67,6 +67,13 @@ typedef struct QuorumVotes { typedef struct QuorumChild { BdrvChild *child; + + /* + * If set, check whether this node can be replaced without any + * other parent noticing: Unshare CONSISTENT_READ, and take the + * WRITE permission. + */ + bool to_be_replaced; } QuorumChild; /* the following structure holds the state of one quorum instance */ @@ -1128,6 +1135,18 @@ static void quorum_child_perm(BlockDriverState *bs, BdrvChild *c, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared) { + BDRVQuorumState *s = bs->opaque; + int child_i = -1; + + if (c) { + for (child_i = 0; child_i < s->num_children; child_i++) { + if (s->children[child_i].child == c) { + break; + } + } + assert(child_i < s->num_children); + } + *nperm = perm & DEFAULT_PERM_PASSTHROUGH; /* @@ -1137,6 +1156,12 @@ static void quorum_child_perm(BlockDriverState *bs, BdrvChild *c, *nshared = (shared & (BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE_UNCHANGED)) | DEFAULT_PERM_UNCHANGED; + + if (child_i >= 0 && s->children[child_i].to_be_replaced) { + /* Prepare for sudden data changes */ + *nperm |= BLK_PERM_WRITE; + *nshared &= ~BLK_PERM_CONSISTENT_READ; + } } static const char *const quorum_strong_runtime_opts[] = { From patchwork Thu Jan 30 21:44:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 1231661 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=LtoxdsnW; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 487vKx4tRTz9sNx for ; Fri, 31 Jan 2020 08:55:33 +1100 (AEDT) Received: from localhost ([::1]:39850 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHmd-00045D-J6 for incoming@patchwork.ozlabs.org; Thu, 30 Jan 2020 16:55:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33405) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHcW-0004xd-PU for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:45:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ixHcU-0004BZ-FQ for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:45:03 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:42073 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 1ixHcU-0004A4-AJ for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:45:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580420701; 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=x/ebeROUpozO9G18Nn37Qclo1gAsS3p1IXwOd05lc8I=; b=LtoxdsnWH63ctD4RZwlbv4lExr6sjxIOBB7LIPI1M+1XgF5ySpd92R3uXl2R6zRlts7SX6 zJS5eoeIDxU7ZO7KQycLTomnpCZJKxhHs3yOE8J+ZzzQLkOqm6LwE4sKJXaNS5a+W38M/w WR7D0x88rhddcZk06gdP821PBkhl4Ls= 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-256-eHk9S9_ONHazVFui3XAe4g-1; Thu, 30 Jan 2020 16:44:58 -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 3B98B800E21; Thu, 30 Jan 2020 21:44:57 +0000 (UTC) Received: from localhost (ovpn-204-145.brq.redhat.com [10.40.204.145]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C6BEB19756; Thu, 30 Jan 2020 21:44:56 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v3 10/21] quorum: Implement .bdrv_recurse_can_replace() Date: Thu, 30 Jan 2020 22:44:20 +0100 Message-Id: <20200130214431.333510-11-mreitz@redhat.com> In-Reply-To: <20200130214431.333510-1-mreitz@redhat.com> References: <20200130214431.333510-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: eHk9S9_ONHazVFui3XAe4g-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.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: Kevin Wolf , Vladimir Sementsov-Ogievskiy , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Max Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/quorum.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/block/quorum.c b/block/quorum.c index 6a7224c9e4..22c1060b42 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -825,6 +825,62 @@ static bool quorum_recurse_is_first_non_filter(BlockDriverState *bs, return false; } +static bool quorum_recurse_can_replace(BlockDriverState *bs, + BlockDriverState *to_replace) +{ + BDRVQuorumState *s = bs->opaque; + int i; + + for (i = 0; i < s->num_children; i++) { + /* + * We have no idea whether our children show the same data as + * this node (@bs). It is actually highly likely that + * @to_replace does not, because replacing a broken child is + * one of the main use cases here. + * + * We do know that the new BDS will match @bs, so replacing + * any of our children by it will be safe. It cannot change + * the data this quorum node presents to its parents. + * + * However, replacing @to_replace by @bs in any of our + * children's chains may change visible data somewhere in + * there. We therefore cannot recurse down those chains with + * bdrv_recurse_can_replace(). + * (More formally, bdrv_recurse_can_replace() requires that + * @to_replace will be replaced by something matching the @bs + * passed to it. We cannot guarantee that.) + * + * Thus, we can only check whether any of our immediate + * children matches @to_replace. + * + * (In the future, we might add a function to recurse down a + * chain that checks that nothing there cares about a change + * in data from the respective child in question. For + * example, most filters do not care when their child's data + * suddenly changes, as long as their parents do not care.) + */ + if (s->children[i].child->bs == to_replace) { + int ret; + + /* + * We now have to ensure that there is no other parent + * that cares about replacing this child by a node with + * potentially different data. + */ + s->children[i].to_be_replaced = true; + ret = bdrv_child_refresh_perms(bs, s->children[i].child, NULL); + + /* Revert permissions */ + s->children[i].to_be_replaced = false; + bdrv_child_refresh_perms(bs, s->children[i].child, &error_abort); + + return ret == 0; + } + } + + return false; +} + static int quorum_valid_threshold(int threshold, int num_children, Error **errp) { @@ -1197,6 +1253,7 @@ static BlockDriver bdrv_quorum = { .is_filter = true, .bdrv_recurse_is_first_non_filter = quorum_recurse_is_first_non_filter, + .bdrv_recurse_can_replace = quorum_recurse_can_replace, .strong_runtime_opts = quorum_strong_runtime_opts, }; From patchwork Thu Jan 30 21:44:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 1231660 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Hnp5ymFv; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 487vJc2DjWz9sNx for ; Fri, 31 Jan 2020 08:54:24 +1100 (AEDT) Received: from localhost ([::1]:39834 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHlW-0002Br-2y for incoming@patchwork.ozlabs.org; Thu, 30 Jan 2020 16:54:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33445) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHcY-00050a-NA for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:45:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ixHcW-0004M9-RV for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:45:06 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:27590 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 1ixHcW-0004Kv-NY for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:45:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580420704; 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=yobEeL2sj2S6wzNbHotodRKWB0mxzy2pX9PMQ2Zv6Eg=; b=Hnp5ymFvCHWchAvmByJXst2r2RRj52Rv6jdGIo/F1yPeLF9K9Lcl1W2jYA0XhOw09PcgJJ WjCs8g2vBBL0wqEcGAv2ajf+Lfp5PtsTzDaabbyS+KZ75uZGrc24bjLO1oPra9d1hLWM0y SrdaSrnqyRahdDckPZuTtplBHVP25co= 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-218-QrscCLsxMH-2hOBwcPLXLg-1; Thu, 30 Jan 2020 16:45:00 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 90AFB800D55; Thu, 30 Jan 2020 21:44:59 +0000 (UTC) Received: from localhost (ovpn-204-145.brq.redhat.com [10.40.204.145]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2A17677939; Thu, 30 Jan 2020 21:44:58 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v3 11/21] block: Use bdrv_recurse_can_replace() Date: Thu, 30 Jan 2020 22:44:21 +0100 Message-Id: <20200130214431.333510-12-mreitz@redhat.com> In-Reply-To: <20200130214431.333510-1-mreitz@redhat.com> References: <20200130214431.333510-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: QrscCLsxMH-2hOBwcPLXLg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.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: Kevin Wolf , Vladimir Sementsov-Ogievskiy , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Let check_to_replace_node() use the more specialized bdrv_recurse_can_replace() instead of bdrv_recurse_is_first_non_filter(), which is too restrictive (or, in the case of quorum, sometimes not restrictive enough). Signed-off-by: Max Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy --- block.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/block.c b/block.c index 6623248443..67844ad5ac 100644 --- a/block.c +++ b/block.c @@ -6250,6 +6250,17 @@ bool bdrv_recurse_can_replace(BlockDriverState *bs, return false; } +/* + * Check whether the given @node_name can be replaced by a node that + * has the same data as @parent_bs. If so, return @node_name's BDS; + * NULL otherwise. + * + * @node_name must be a (recursive) *child of @parent_bs (or this + * function will return NULL). + * + * The result (whether the node can be replaced or not) is only valid + * for as long as no graph or permission changes occur. + */ BlockDriverState *check_to_replace_node(BlockDriverState *parent_bs, const char *node_name, Error **errp) { @@ -6274,8 +6285,11 @@ BlockDriverState *check_to_replace_node(BlockDriverState *parent_bs, * Another benefit is that this tests exclude backing files which are * blocked by the backing blockers. */ - if (!bdrv_recurse_is_first_non_filter(parent_bs, to_replace_bs)) { - error_setg(errp, "Only top most non filter can be replaced"); + if (!bdrv_recurse_can_replace(parent_bs, to_replace_bs)) { + error_setg(errp, "Cannot replace '%s' by a node mirrored from '%s', " + "because it cannot be guaranteed that doing so would not " + "lead to an abrupt change of visible data", + node_name, parent_bs->node_name); to_replace_bs = NULL; goto out; } From patchwork Thu Jan 30 21:44:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 1231663 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=eFLPXpvc; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 487vLs2CZKz9sPK for ; Fri, 31 Jan 2020 08:56:21 +1100 (AEDT) Received: from localhost ([::1]:39874 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHnP-0005bw-81 for incoming@patchwork.ozlabs.org; Thu, 30 Jan 2020 16:56:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33492) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHcb-00054g-5v for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:45:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ixHcZ-0004Py-FS for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:45:09 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:48659 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 1ixHcY-0004Ml-Ld for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:45:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580420705; 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=3xIY5wm9tf0E9ejiJ8LukaVPky+sBx1Jh0x2HSwDI9w=; b=eFLPXpvciJ2P+qHoDpvtdnXYWX9bnKy6EBm0iJTRUInQVccQ9ONd43adWwqxkWWBWG05hq 0FkchcVbKSunZ7WMb9PJ+7N3mZSlxBlejGOC+oCZrPxLjKIStbtFnYMP5sid0xjmLeTb88 a5m+hgg+AQWf7Fi+3Tm6Q9EKMBj0ShU= 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-224-FHx28rhYNKaUcGV8pJktIA-1; Thu, 30 Jan 2020 16:45:03 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1B773107ACCD; Thu, 30 Jan 2020 21:45:02 +0000 (UTC) Received: from localhost (ovpn-204-145.brq.redhat.com [10.40.204.145]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 753DB10018FF; Thu, 30 Jan 2020 21:45:01 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v3 12/21] block: Remove bdrv_recurse_is_first_non_filter() Date: Thu, 30 Jan 2020 22:44:22 +0100 Message-Id: <20200130214431.333510-13-mreitz@redhat.com> In-Reply-To: <20200130214431.333510-1-mreitz@redhat.com> References: <20200130214431.333510-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: FHx28rhYNKaUcGV8pJktIA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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: Kevin Wolf , Vladimir Sementsov-Ogievskiy , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" It no longer has any users. Signed-off-by: Max Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy --- block.c | 33 --------------------------------- block/blkverify.c | 15 --------------- block/copy-on-read.c | 9 --------- block/filter-compress.c | 9 --------- block/quorum.c | 18 ------------------ block/replication.c | 7 ------- block/throttle.c | 8 -------- include/block/block.h | 4 ---- include/block/block_int.h | 8 -------- 9 files changed, 111 deletions(-) diff --git a/block.c b/block.c index 67844ad5ac..1a27205252 100644 --- a/block.c +++ b/block.c @@ -6179,39 +6179,6 @@ int bdrv_amend_options(BlockDriverState *bs, QemuOpts *opts, return bs->drv->bdrv_amend_options(bs, opts, status_cb, cb_opaque, errp); } -/* This function will be called by the bdrv_recurse_is_first_non_filter method - * of block filter and by bdrv_is_first_non_filter. - * It is used to test if the given bs is the candidate or recurse more in the - * node graph. - */ -bool bdrv_recurse_is_first_non_filter(BlockDriverState *bs, - BlockDriverState *candidate) -{ - /* return false if basic checks fails */ - if (!bs || !bs->drv) { - return false; - } - - /* the code reached a non block filter driver -> check if the bs is - * the same as the candidate. It's the recursion termination condition. - */ - if (!bs->drv->is_filter) { - return bs == candidate; - } - /* Down this path the driver is a block filter driver */ - - /* If the block filter recursion method is defined use it to recurse down - * the node graph. - */ - if (bs->drv->bdrv_recurse_is_first_non_filter) { - return bs->drv->bdrv_recurse_is_first_non_filter(bs, candidate); - } - - /* the driver is a block filter but don't allow to recurse -> return false - */ - return false; -} - /* * This function checks whether the given @to_replace is allowed to be * replaced by a node that always shows the same data as @bs. This is diff --git a/block/blkverify.c b/block/blkverify.c index 0add3ab483..ba6b1853ae 100644 --- a/block/blkverify.c +++ b/block/blkverify.c @@ -268,20 +268,6 @@ static int blkverify_co_flush(BlockDriverState *bs) return bdrv_co_flush(s->test_file->bs); } -static bool blkverify_recurse_is_first_non_filter(BlockDriverState *bs, - BlockDriverState *candidate) -{ - BDRVBlkverifyState *s = bs->opaque; - - bool perm = bdrv_recurse_is_first_non_filter(bs->file->bs, candidate); - - if (perm) { - return true; - } - - return bdrv_recurse_is_first_non_filter(s->test_file->bs, candidate); -} - static bool blkverify_recurse_can_replace(BlockDriverState *bs, BlockDriverState *to_replace) { @@ -341,7 +327,6 @@ static BlockDriver bdrv_blkverify = { .bdrv_co_flush = blkverify_co_flush, .is_filter = true, - .bdrv_recurse_is_first_non_filter = blkverify_recurse_is_first_non_filter, .bdrv_recurse_can_replace = blkverify_recurse_can_replace, }; diff --git a/block/copy-on-read.c b/block/copy-on-read.c index e95223d3cb..242d3ff055 100644 --- a/block/copy-on-read.c +++ b/block/copy-on-read.c @@ -118,13 +118,6 @@ static void cor_lock_medium(BlockDriverState *bs, bool locked) } -static bool cor_recurse_is_first_non_filter(BlockDriverState *bs, - BlockDriverState *candidate) -{ - return bdrv_recurse_is_first_non_filter(bs->file->bs, candidate); -} - - static BlockDriver bdrv_copy_on_read = { .format_name = "copy-on-read", @@ -143,8 +136,6 @@ static BlockDriver bdrv_copy_on_read = { .bdrv_co_block_status = bdrv_co_block_status_from_file, - .bdrv_recurse_is_first_non_filter = cor_recurse_is_first_non_filter, - .has_variable_length = true, .is_filter = true, }; diff --git a/block/filter-compress.c b/block/filter-compress.c index 60137fb680..82c315b298 100644 --- a/block/filter-compress.c +++ b/block/filter-compress.c @@ -128,13 +128,6 @@ static void compress_lock_medium(BlockDriverState *bs, bool locked) } -static bool compress_recurse_is_first_non_filter(BlockDriverState *bs, - BlockDriverState *candidate) -{ - return bdrv_recurse_is_first_non_filter(bs->file->bs, candidate); -} - - static BlockDriver bdrv_compress = { .format_name = "compress", @@ -154,8 +147,6 @@ static BlockDriver bdrv_compress = { .bdrv_co_block_status = bdrv_co_block_status_from_file, - .bdrv_recurse_is_first_non_filter = compress_recurse_is_first_non_filter, - .has_variable_length = true, .is_filter = true, }; diff --git a/block/quorum.c b/block/quorum.c index 22c1060b42..476def878d 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -808,23 +808,6 @@ static coroutine_fn int quorum_co_flush(BlockDriverState *bs) return result; } -static bool quorum_recurse_is_first_non_filter(BlockDriverState *bs, - BlockDriverState *candidate) -{ - BDRVQuorumState *s = bs->opaque; - int i; - - for (i = 0; i < s->num_children; i++) { - bool perm = bdrv_recurse_is_first_non_filter(s->children[i].child->bs, - candidate); - if (perm) { - return true; - } - } - - return false; -} - static bool quorum_recurse_can_replace(BlockDriverState *bs, BlockDriverState *to_replace) { @@ -1252,7 +1235,6 @@ static BlockDriver bdrv_quorum = { .bdrv_child_perm = quorum_child_perm, .is_filter = true, - .bdrv_recurse_is_first_non_filter = quorum_recurse_is_first_non_filter, .bdrv_recurse_can_replace = quorum_recurse_can_replace, .strong_runtime_opts = quorum_strong_runtime_opts, diff --git a/block/replication.c b/block/replication.c index 99532ce521..d6681b6c84 100644 --- a/block/replication.c +++ b/block/replication.c @@ -306,12 +306,6 @@ out: return ret; } -static bool replication_recurse_is_first_non_filter(BlockDriverState *bs, - BlockDriverState *candidate) -{ - return bdrv_recurse_is_first_non_filter(bs->file->bs, candidate); -} - static void secondary_do_checkpoint(BDRVReplicationState *s, Error **errp) { Error *local_err = NULL; @@ -699,7 +693,6 @@ static BlockDriver bdrv_replication = { .bdrv_co_writev = replication_co_writev, .is_filter = true, - .bdrv_recurse_is_first_non_filter = replication_recurse_is_first_non_filter, .has_variable_length = true, .strong_runtime_opts = replication_strong_runtime_opts, diff --git a/block/throttle.c b/block/throttle.c index 0349f42257..71f4bb0ad1 100644 --- a/block/throttle.c +++ b/block/throttle.c @@ -207,12 +207,6 @@ static void throttle_reopen_abort(BDRVReopenState *reopen_state) reopen_state->opaque = NULL; } -static bool throttle_recurse_is_first_non_filter(BlockDriverState *bs, - BlockDriverState *candidate) -{ - return bdrv_recurse_is_first_non_filter(bs->file->bs, candidate); -} - static void coroutine_fn throttle_co_drain_begin(BlockDriverState *bs) { ThrottleGroupMember *tgm = bs->opaque; @@ -252,8 +246,6 @@ static BlockDriver bdrv_throttle = { .bdrv_co_pwrite_zeroes = throttle_co_pwrite_zeroes, .bdrv_co_pdiscard = throttle_co_pdiscard, - .bdrv_recurse_is_first_non_filter = throttle_recurse_is_first_non_filter, - .bdrv_attach_aio_context = throttle_attach_aio_context, .bdrv_detach_aio_context = throttle_detach_aio_context, diff --git a/include/block/block.h b/include/block/block.h index 8f6a0cad9c..764a217de6 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -401,10 +401,6 @@ int bdrv_amend_options(BlockDriverState *bs_new, QemuOpts *opts, BlockDriverAmendStatusCB *status_cb, void *cb_opaque, Error **errp); -/* external snapshots */ -bool bdrv_recurse_is_first_non_filter(BlockDriverState *bs, - BlockDriverState *candidate); - /* check if a named node can be replaced when doing drive-mirror */ BlockDriverState *check_to_replace_node(BlockDriverState *parent_bs, const char *node_name, Error **errp); diff --git a/include/block/block_int.h b/include/block/block_int.h index 75f03dcc38..589a797fab 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -94,14 +94,6 @@ struct BlockDriver { * must implement them and return -ENOTSUP. */ bool is_filter; - /* for snapshots block filter like Quorum can implement the - * following recursive callback. - * It's purpose is to recurse on the filter children while calling - * bdrv_recurse_is_first_non_filter on them. - * For a sample implementation look in the future Quorum block filter. - */ - bool (*bdrv_recurse_is_first_non_filter)(BlockDriverState *bs, - BlockDriverState *candidate); /* * Return true if @to_replace can be replaced by a BDS with the * same data as @bs without it affecting @bs's behavior (that is, From patchwork Thu Jan 30 21:44:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 1231659 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=O7a+u0wS; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 487vJR6z9gz9sNx for ; Fri, 31 Jan 2020 08:54:15 +1100 (AEDT) Received: from localhost ([::1]:39832 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHlN-0001wX-S8 for incoming@patchwork.ozlabs.org; Thu, 30 Jan 2020 16:54:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33532) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHce-00057T-44 for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:45:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ixHcc-0004ai-LC for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:45:11 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:39013 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 1ixHcc-0004XT-Fp for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:45:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580420709; 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=zAXK4A1gwm6JGoSTkcy70CJDNhiVlAh1hgkdPBAzHyg=; b=O7a+u0wSJNsYF2fTe03UZTvSmRnVsYmSf7HmdPADShCa+lQ7qghLb1o4ci11m2Cm0NPHED VOEluVzKQ39YnTXT42PiCioNXMmt56iwhRsYGn5hWujNQs51u1iORpZY5oW7FRv+pYZ26a Ov33IunOGXH9D6pYiQscmUejpWXTBFs= 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-177-8LkCqwhtMwO0pXSfMtgB_w-1; Thu, 30 Jan 2020 16:45:07 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4B14573426; Thu, 30 Jan 2020 21:45:06 +0000 (UTC) Received: from localhost (ovpn-204-145.brq.redhat.com [10.40.204.145]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 04F5810018FF; Thu, 30 Jan 2020 21:45:03 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v3 13/21] mirror: Double-check immediately before replacing Date: Thu, 30 Jan 2020 22:44:23 +0100 Message-Id: <20200130214431.333510-14-mreitz@redhat.com> In-Reply-To: <20200130214431.333510-1-mreitz@redhat.com> References: <20200130214431.333510-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: 8LkCqwhtMwO0pXSfMtgB_w-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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: Kevin Wolf , Vladimir Sementsov-Ogievskiy , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" There is no guarantee that we can still replace the node we want to replace at the end of the mirror job. Double-check by calling bdrv_recurse_can_replace(). Signed-off-by: Max Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/mirror.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/block/mirror.c b/block/mirror.c index cacbc70014..447051dbc6 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -700,7 +700,19 @@ static int mirror_exit_common(Job *job) * drain potential other users of the BDS before changing the graph. */ assert(s->in_drain); bdrv_drained_begin(target_bs); - bdrv_replace_node(to_replace, target_bs, &local_err); + /* + * Cannot use check_to_replace_node() here, because that would + * check for an op blocker on @to_replace, and we have our own + * there. + */ + if (bdrv_recurse_can_replace(src, to_replace)) { + bdrv_replace_node(to_replace, target_bs, &local_err); + } else { + error_setg(&local_err, "Can no longer replace '%s' by '%s', " + "because it can no longer be guaranteed that doing so " + "would not lead to an abrupt change of visible data", + to_replace->node_name, target_bs->node_name); + } bdrv_drained_end(target_bs); if (local_err) { error_report_err(local_err); From patchwork Thu Jan 30 21:44:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 1231665 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Xs9hKt9R; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 487vNX3gz5z9sNx for ; Fri, 31 Jan 2020 08:57:46 +1100 (AEDT) Received: from localhost ([::1]:39900 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHol-00005q-QQ for incoming@patchwork.ozlabs.org; Thu, 30 Jan 2020 16:57:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33608) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHcj-0005CX-IO for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:45:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ixHci-0004q7-Ad for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:45:17 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:36115 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 1ixHci-0004lW-4E for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:45:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580420714; 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=f8yL8mul3nLGCwjVN50zJzmxvwvWKZK3WhaZ6AhhD88=; b=Xs9hKt9RYuI8HLWMBvxM6NjqaS5p2+8CYUK3TAJlBiXdIgHuDgaw7p5WOGRuSL85sMMUzq KApaggxfXrHvwHt6BVmaZMaTEr8o6U5BoRMsTQftkdu1BWNzVSSNITa690Ag71G9ko68JP HMHEltQX3AOGpjamLvBrOrug0TcmVs0= 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-326-A1dKH2CYNDyYTe-Hdt8tYQ-1; Thu, 30 Jan 2020 16:45:09 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A2C4A801E78; Thu, 30 Jan 2020 21:45:08 +0000 (UTC) Received: from localhost (ovpn-204-145.brq.redhat.com [10.40.204.145]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 391C587B2C; Thu, 30 Jan 2020 21:45:08 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v3 14/21] quorum: Stop marking it as a filter Date: Thu, 30 Jan 2020 22:44:24 +0100 Message-Id: <20200130214431.333510-15-mreitz@redhat.com> In-Reply-To: <20200130214431.333510-1-mreitz@redhat.com> References: <20200130214431.333510-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: A1dKH2CYNDyYTe-Hdt8tYQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.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: Kevin Wolf , Vladimir Sementsov-Ogievskiy , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Quorum is not a filter, for example because it cannot guarantee which of its children will serve the next request. Thus, any of its children may differ from the data visible to quorum's parents. We have other filters with multiple children, but they differ in this aspect: - blkverify quits the whole qemu process if its children differ. As such, we can always skip it when we want to skip it (as a filter node) by going to any of its children. Both have the same data. - replication generally serves requests from bs->file, so this is its only actually filtered child. - Block job filters currently only have one child, but they will probably get more children in the future. Still, they will always have only one actually filtered child. Having "filters" as a dedicated node category only makes sense if you can skip them by going to a one fixed child that always shows the same data as the filter node. Quorum cannot fulfill this, so it is not a filter. Signed-off-by: Max Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/quorum.c | 1 - 1 file changed, 1 deletion(-) diff --git a/block/quorum.c b/block/quorum.c index 476def878d..d85db88dbb 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -1234,7 +1234,6 @@ static BlockDriver bdrv_quorum = { .bdrv_child_perm = quorum_child_perm, - .is_filter = true, .bdrv_recurse_can_replace = quorum_recurse_can_replace, .strong_runtime_opts = quorum_strong_runtime_opts, From patchwork Thu Jan 30 21:44:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 1231668 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=HdcJa29r; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 487vPc3lB2z9sNx for ; Fri, 31 Jan 2020 08:58:44 +1100 (AEDT) Received: from localhost ([::1]:39920 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHpi-0002Ji-Dj for incoming@patchwork.ozlabs.org; Thu, 30 Jan 2020 16:58:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33722) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHcq-0005Rg-Nx for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:45:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ixHcp-0005N5-KK for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:45:24 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:29746 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 1ixHcp-0005KQ-EX for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:45:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580420723; 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=MS+ma7oGKfRFgU/rdO9Fq+4N8jcqlGHdtX6uKa9wUJw=; b=HdcJa29rTytyLJ2oNQewTsI6GyC2M7jmscoerjcA+jVN+MuY6G+KdiXksNBlns5TMZWC3J 5F96/6va54JqSXBaDUFMuo7U0VmHZ4yZampBt+cFFUMamCCSuwx9ysm4dziXr0XZeppKga HYTlY5eXTBuY1xcXSmQowWM8uzqJUYQ= 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-84-VktqMydWNi2Ncw2-UiSMMQ-1; Thu, 30 Jan 2020 16:45:12 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 127721010913; Thu, 30 Jan 2020 21:45:11 +0000 (UTC) Received: from localhost (ovpn-204-145.brq.redhat.com [10.40.204.145]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9024C1001B23; Thu, 30 Jan 2020 21:45:10 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v3 15/21] iotests: Use complete_and_wait() in 155 Date: Thu, 30 Jan 2020 22:44:25 +0100 Message-Id: <20200130214431.333510-16-mreitz@redhat.com> In-Reply-To: <20200130214431.333510-1-mreitz@redhat.com> References: <20200130214431.333510-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: VktqMydWNi2Ncw2-UiSMMQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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: Kevin Wolf , Vladimir Sementsov-Ogievskiy , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This way, we get to see errors during the completion phase. Signed-off-by: Max Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/155 | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/tests/qemu-iotests/155 b/tests/qemu-iotests/155 index e19485911c..d7ef2579d3 100755 --- a/tests/qemu-iotests/155 +++ b/tests/qemu-iotests/155 @@ -163,12 +163,7 @@ class MirrorBaseClass(BaseClass): self.assert_qmp(result, 'return', {}) - self.vm.event_wait('BLOCK_JOB_READY') - - result = self.vm.qmp('block-job-complete', device='mirror-job') - self.assert_qmp(result, 'return', {}) - - self.vm.event_wait('BLOCK_JOB_COMPLETED') + self.complete_and_wait('mirror-job') def testFull(self): self.runMirror('full') From patchwork Thu Jan 30 21:44:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 1231664 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=DSU/KA39; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 487vM23bKFz9sPK for ; Fri, 31 Jan 2020 08:56:30 +1100 (AEDT) Received: from localhost ([::1]:39876 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHnY-0005ee-DF for incoming@patchwork.ozlabs.org; Thu, 30 Jan 2020 16:56:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33651) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHcm-0005I9-SB for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:45:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ixHcl-00053Z-KW for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:45:20 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:35580 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 1ixHcl-000503-ET for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:45:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580420719; 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=shrWSK6Ov06puri1nWGHpSuDgV37Ra1SkZO+4VRJSB0=; b=DSU/KA39tzTDok6LngRtcp7/qz4Rs7VGTb2wST1LMNibrDjXQPTorej5YmiH1LNV0jvwmf Uf7ZJxCIEljdb477Z3u3cn/hpPMaXqBmcxAq83FZk6jMgJXtenN6796QMa87x+ADnH5sDN aiTSHEeDNd7TcjP+EkTV122SS4ahbn0= 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-176-ZLcmCmV1PJmilVGt3romtg-1; Thu, 30 Jan 2020 16:45:15 -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 67E44108C316; Thu, 30 Jan 2020 21:45:13 +0000 (UTC) Received: from localhost (ovpn-204-145.brq.redhat.com [10.40.204.145]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F110E19488; Thu, 30 Jan 2020 21:45:12 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v3 16/21] iotests: Add VM.assert_block_path() Date: Thu, 30 Jan 2020 22:44:26 +0100 Message-Id: <20200130214431.333510-17-mreitz@redhat.com> In-Reply-To: <20200130214431.333510-1-mreitz@redhat.com> References: <20200130214431.333510-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: ZLcmCmV1PJmilVGt3romtg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.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: Kevin Wolf , Vladimir Sementsov-Ogievskiy , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Max Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/iotests.py | 56 +++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 01b58dcb50..69861cf05e 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -713,6 +713,62 @@ class VM(qtest.QEMUQtestMachine): return fields.items() <= ret.items() + def assert_block_path(self, root, path, expected_node, graph=None): + """ + Check whether the node under the given path in the block graph + is @expected_node. + + @root is the node name of the node where the @path is rooted. + + @path is a string that consists of child names separated by + slashes. It must begin with a slash. + + Examples for @root + @path: + - root="qcow2-node", path="/backing/file" + - root="quorum-node", path="/children.2/file" + + Hypothetically, @path could be empty, in which case it would + point to @root. However, in practice this case is not useful + and hence not allowed. + + @expected_node may be None. (All elements of the path but the + leaf must still exist.) + + @graph may be None or the result of an x-debug-query-block-graph + call that has already been performed. + """ + if graph is None: + graph = self.qmp('x-debug-query-block-graph')['return'] + + iter_path = iter(path.split('/')) + + # Must start with a / + assert next(iter_path) == '' + + node = next((node for node in graph['nodes'] if node['name'] == root), + None) + + for child_name in iter_path: + assert node is not None, 'Cannot follow path %s' % path + + try: + node_id = next(edge['child'] for edge in graph['edges'] \ + if edge['parent'] == node['id'] and + edge['name'] == child_name) + + node = next(node for node in graph['nodes'] \ + if node['id'] == node_id) + except StopIteration: + node = None + + if node is None: + assert expected_node is None, \ + 'No node found under %s (but expected %s)' % \ + (path, expected_node) + else: + assert node['name'] == expected_node, \ + 'Found node %s under %s (but expected %s)' % \ + (node['name'], path, expected_node) index_re = re.compile(r'([^\[]+)\[([^\]]+)\]') From patchwork Thu Jan 30 21:44:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 1231669 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=N/y7BHQa; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 487vQV6DJ3z9sNx for ; Fri, 31 Jan 2020 08:59:30 +1100 (AEDT) Received: from localhost ([::1]:39932 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHqS-00041r-Pg for incoming@patchwork.ozlabs.org; Thu, 30 Jan 2020 16:59:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33702) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHcq-0005QS-SA for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:45:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ixHco-0005I9-Jf for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:45:23 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:21065 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 1ixHco-0005AY-F4 for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:45:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580420721; 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=hfEAeEeoLYiuKThlyZdwC0vvP+j3sfH5+r9f+P/RhZI=; b=N/y7BHQalheFq/oPGw8IB+qnlM1ri4BiAzZ7w1elQo2sVM7drku0F4QTrUdwfLeCH7XjJU T5JWAaboEufChZuw7aY9hNbl+IoX7WNPV4jRd2yzm6Fz57IRwyZrS5ozgpnkHx3+8VlrWz uWZlOmkvy2K49IBY1kDEZs5edIf+WVA= 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-251-TDRAxoGxPUW84OoBbdFwZg-1; Thu, 30 Jan 2020 16:45:17 -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 C51FF108C31D; Thu, 30 Jan 2020 21:45:15 +0000 (UTC) Received: from localhost (ovpn-204-145.brq.redhat.com [10.40.204.145]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5376119488; Thu, 30 Jan 2020 21:45:15 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v3 17/21] iotests/041: Drop superfluous shutdowns Date: Thu, 30 Jan 2020 22:44:27 +0100 Message-Id: <20200130214431.333510-18-mreitz@redhat.com> In-Reply-To: <20200130214431.333510-1-mreitz@redhat.com> References: <20200130214431.333510-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: TDRAxoGxPUW84OoBbdFwZg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" All tearDowns in 041 shutdown the VM. Thus, test cases do not need to do it themselves (unless they need the VM to be down for some post-operation check). Signed-off-by: Max Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/041 | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041 index a429281f61..20cfad1d2c 100755 --- a/tests/qemu-iotests/041 +++ b/tests/qemu-iotests/041 @@ -80,7 +80,6 @@ class TestSingleDrive(iotests.QMPTestCase): self.cancel_and_wait(force=True) result = self.vm.qmp('query-block') self.assert_qmp(result, 'return[0]/inserted/file', test_img) - self.vm.shutdown() def test_cancel_after_ready(self): self.assert_no_active_block_jobs() @@ -201,8 +200,6 @@ class TestSingleDrive(iotests.QMPTestCase): self.assert_qmp(result, 'return[0]/node-name', 'top') self.assert_qmp(result, 'return[0]/backing/node-name', 'base') - self.vm.shutdown() - def test_medium_not_found(self): if iotests.qemu_default_machine != 'pc': return @@ -455,7 +452,6 @@ new_state = "1" self.assert_qmp(event, 'data/id', 'drive0') self.assert_no_active_block_jobs() - self.vm.shutdown() def test_ignore_read(self): self.assert_no_active_block_jobs() @@ -475,7 +471,6 @@ new_state = "1" result = self.vm.qmp('query-block-jobs') self.assert_qmp(result, 'return[0]/paused', False) self.complete_and_wait() - self.vm.shutdown() def test_large_cluster(self): self.assert_no_active_block_jobs() @@ -540,7 +535,6 @@ new_state = "1" self.complete_and_wait(wait_ready=False) self.assert_no_active_block_jobs() - self.vm.shutdown() class TestWriteErrors(iotests.QMPTestCase): image_len = 2 * 1024 * 1024 # MB @@ -614,7 +608,6 @@ new_state = "1" completed = True self.assert_no_active_block_jobs() - self.vm.shutdown() def test_ignore_write(self): self.assert_no_active_block_jobs() @@ -631,7 +624,6 @@ new_state = "1" result = self.vm.qmp('query-block-jobs') self.assert_qmp(result, 'return[0]/paused', False) self.complete_and_wait() - self.vm.shutdown() def test_stop_write(self): self.assert_no_active_block_jobs() @@ -667,7 +659,6 @@ new_state = "1" self.complete_and_wait(wait_ready=False) self.assert_no_active_block_jobs() - self.vm.shutdown() class TestSetSpeed(iotests.QMPTestCase): image_len = 80 * 1024 * 1024 # MB @@ -936,7 +927,6 @@ class TestRepairQuorum(iotests.QMPTestCase): # here we check that the last registered quorum file has not been # swapped out and unref self.assert_has_block_node(None, quorum_img3) - self.vm.shutdown() def test_cancel_after_ready(self): self.assert_no_active_block_jobs() @@ -1043,7 +1033,6 @@ class TestRepairQuorum(iotests.QMPTestCase): self.assert_has_block_node("repair0", quorum_repair_img) # TODO: a better test requiring some QEMU infrastructure will be added # to check that this file is really driven by quorum - self.vm.shutdown() # Test mirroring with a source that does not have any parents (not even a # BlockBackend) From patchwork Thu Jan 30 21:44:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 1231670 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=BfEOQI9k; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 487vQk0TRfz9sPK for ; Fri, 31 Jan 2020 08:59:42 +1100 (AEDT) Received: from localhost ([::1]:39950 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHqd-0004Tv-Vq for incoming@patchwork.ozlabs.org; Thu, 30 Jan 2020 16:59:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33736) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHcr-0005SL-AA for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:45:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ixHcq-0005PY-5b for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:45:25 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:47638 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 1ixHcq-0005NE-0C for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:45:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580420723; 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=c8wxhgncUAiINMH8Y8QNRrciJqGSz80fNdmk186zzKA=; b=BfEOQI9kdCH2jlA5dewiKwMEDGprSIEj6Es5WY2upFoRaP8n+7DjE8Oeew48hZsqvKHtds /VD1PQnRuqmeRBdDTsPVp/eO510NW3MBBOpJdXrJvm/wf7mNRaLZ5MUWoWwDbnjj4Fgzjq rP/us9n0K/5mbcXqUXyd0Z18Y0k4Kts= 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-14-BAM3yxtHPeyKvU4-mO3_KQ-1; Thu, 30 Jan 2020 16:45:19 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 181B118C35CC; Thu, 30 Jan 2020 21:45:18 +0000 (UTC) Received: from localhost (ovpn-204-145.brq.redhat.com [10.40.204.145]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A67315C1B2; Thu, 30 Jan 2020 21:45:17 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v3 18/21] iotests: Resolve TODOs in 041 Date: Thu, 30 Jan 2020 22:44:28 +0100 Message-Id: <20200130214431.333510-19-mreitz@redhat.com> In-Reply-To: <20200130214431.333510-1-mreitz@redhat.com> References: <20200130214431.333510-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: BAM3yxtHPeyKvU4-mO3_KQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.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: Kevin Wolf , Vladimir Sementsov-Ogievskiy , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Max Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/041 | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041 index 20cfad1d2c..41db2c222a 100755 --- a/tests/qemu-iotests/041 +++ b/tests/qemu-iotests/041 @@ -909,8 +909,7 @@ class TestRepairQuorum(iotests.QMPTestCase): self.complete_and_wait(drive="job0") self.assert_has_block_node("repair0", quorum_repair_img) - # TODO: a better test requiring some QEMU infrastructure will be added - # to check that this file is really driven by quorum + self.vm.assert_block_path('quorum0', '/children.1', 'repair0') self.vm.shutdown() self.assertTrue(iotests.compare_images(quorum_img2, quorum_repair_img), 'target image does not match source after mirroring') @@ -1031,8 +1030,7 @@ class TestRepairQuorum(iotests.QMPTestCase): self.complete_and_wait('job0') self.assert_has_block_node("repair0", quorum_repair_img) - # TODO: a better test requiring some QEMU infrastructure will be added - # to check that this file is really driven by quorum + self.vm.assert_block_path('quorum0', '/children.1', 'repair0') # Test mirroring with a source that does not have any parents (not even a # BlockBackend) From patchwork Thu Jan 30 21:44:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 1231672 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Q5cmJO4i; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 487vTH1NDRz9sRK for ; Fri, 31 Jan 2020 09:01:55 +1100 (AEDT) Received: from localhost ([::1]:40000 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHsn-0006yk-36 for incoming@patchwork.ozlabs.org; Thu, 30 Jan 2020 17:01:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33758) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHct-0005Tg-4B for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:45:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ixHcp-0005Nt-S7 for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:45:25 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:59342 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 1ixHcp-0005Li-M3 for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:45:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580420723; 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=KKEgQJJAD+cD01BP6Kg+6JM2yzv9ZXtLc2lrG+rh4sE=; b=Q5cmJO4in5uODLwgOnZJkxkXvGgqR6Ic5PsrAUL+YSUFehw0+USeIigQyG0SRZjm2YjJ/I yyd+yJTOV2lETnrTbEkLBNhUbT7cVigvS4OkmwztL3aXG/n0qoIhKsL6fI5WJ2AW89ZM1m kjhemarPhjudcfxM8C8OiQXDUFEcL6M= 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-354-bAWalxJKOt2TxSRRU_cSZg-1; Thu, 30 Jan 2020 16:45:21 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6E09C108C317; Thu, 30 Jan 2020 21:45:20 +0000 (UTC) Received: from localhost (ovpn-204-145.brq.redhat.com [10.40.204.145]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0619B60BE1; Thu, 30 Jan 2020 21:45:19 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v3 19/21] iotests: Use self.image_len in TestRepairQuorum Date: Thu, 30 Jan 2020 22:44:29 +0100 Message-Id: <20200130214431.333510-20-mreitz@redhat.com> In-Reply-To: <20200130214431.333510-1-mreitz@redhat.com> References: <20200130214431.333510-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: bAWalxJKOt2TxSRRU_cSZg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.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: Kevin Wolf , Vladimir Sementsov-Ogievskiy , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 041's TestRepairQuorum has its own image_len, no need to refer to TestSingleDrive. (This patch allows commenting out TestSingleDrive to speed up 041 during test testing.) Signed-off-by: Max Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/041 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041 index 41db2c222a..1295a92021 100755 --- a/tests/qemu-iotests/041 +++ b/tests/qemu-iotests/041 @@ -872,7 +872,7 @@ class TestRepairQuorum(iotests.QMPTestCase): # Add each individual quorum images for i in self.IMAGES: qemu_img('create', '-f', iotests.imgfmt, i, - str(TestSingleDrive.image_len)) + str(self.image_len)) # Assign a node name to each quorum image in order to manipulate # them opts = "node-name=img%i" % self.IMAGES.index(i) From patchwork Thu Jan 30 21:44:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 1231667 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=d/U24q7P; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 487vNk05g2z9sPK for ; Fri, 31 Jan 2020 08:57:58 +1100 (AEDT) Received: from localhost ([::1]:39912 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHox-000132-TI for incoming@patchwork.ozlabs.org; Thu, 30 Jan 2020 16:57:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33822) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHcw-0005dC-I3 for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:45:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ixHcv-0005i3-5z for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:45:30 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:54502 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 1ixHcv-0005gW-1T for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:45:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580420728; 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=ZKjPEmfBVqCSgizzCCTUQblhEIiPDt8kq7y1TFHiGR4=; b=d/U24q7Po+dMx9o+71OcBvv3w7eRnDd0n2xlS+NZkFQQbeWRE0ZPIgoS1ouxf2Mr9VnqpK DwWH1ULkRQ4oXLrzpBFqq+chd5vvEFxkq/4pxVszcpMqS575RmWIj0AWArCUuouuHdVU/K k5IY468ZAMMudZNLx6KotAhP7USy+Gk= 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-156-Wk_DWFIfP9SQAh34Y4J22w-1; Thu, 30 Jan 2020 16:45:23 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BA8AF8024D9; Thu, 30 Jan 2020 21:45:22 +0000 (UTC) Received: from localhost (ovpn-204-145.brq.redhat.com [10.40.204.145]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 530825C1B2; Thu, 30 Jan 2020 21:45:22 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v3 20/21] iotests: Add tests for invalid Quorum @replaces Date: Thu, 30 Jan 2020 22:44:30 +0100 Message-Id: <20200130214431.333510-21-mreitz@redhat.com> In-Reply-To: <20200130214431.333510-1-mreitz@redhat.com> References: <20200130214431.333510-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: Wk_DWFIfP9SQAh34Y4J22w-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.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: Kevin Wolf , Vladimir Sementsov-Ogievskiy , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Add two tests to see that you cannot replace a Quorum child with the mirror job while the child is in use by a different parent. Signed-off-by: Max Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/041 | 70 +++++++++++++++++++++++++++++++++++++- tests/qemu-iotests/041.out | 4 +-- 2 files changed, 71 insertions(+), 3 deletions(-) diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041 index 1295a92021..12149c7786 100755 --- a/tests/qemu-iotests/041 +++ b/tests/qemu-iotests/041 @@ -20,6 +20,7 @@ import time import os +import re import iotests from iotests import qemu_img, qemu_io @@ -34,6 +35,8 @@ quorum_img3 = os.path.join(iotests.test_dir, 'quorum3.img') quorum_repair_img = os.path.join(iotests.test_dir, 'quorum_repair.img') quorum_snapshot_file = os.path.join(iotests.test_dir, 'quorum_snapshot.img') +nbd_sock_path = os.path.join(iotests.test_dir, 'nbd.sock') + class TestSingleDrive(iotests.QMPTestCase): image_len = 1 * 1024 * 1024 # MB qmp_cmd = 'drive-mirror' @@ -892,7 +895,8 @@ class TestRepairQuorum(iotests.QMPTestCase): def tearDown(self): self.vm.shutdown() - for i in self.IMAGES + [ quorum_repair_img, quorum_snapshot_file ]: + for i in self.IMAGES + [ quorum_repair_img, quorum_snapshot_file, + nbd_sock_path ]: # Do a try/except because the test may have deleted some images try: os.remove(i) @@ -1032,6 +1036,70 @@ class TestRepairQuorum(iotests.QMPTestCase): self.assert_has_block_node("repair0", quorum_repair_img) self.vm.assert_block_path('quorum0', '/children.1', 'repair0') + def test_with_other_parent(self): + """ + Check that we cannot replace a Quorum child when it has other + parents. + """ + result = self.vm.qmp('nbd-server-start', + addr={ + 'type': 'unix', + 'data': {'path': nbd_sock_path} + }) + self.assert_qmp(result, 'return', {}) + + result = self.vm.qmp('nbd-server-add', device='img1') + self.assert_qmp(result, 'return', {}) + + result = self.vm.qmp('drive-mirror', job_id='mirror', device='quorum0', + sync='full', node_name='repair0', replaces='img1', + target=quorum_repair_img, format=iotests.imgfmt) + self.assert_qmp(result, 'error/desc', + "Cannot replace 'img1' by a node mirrored from " + "'quorum0', because it cannot be guaranteed that doing " + "so would not lead to an abrupt change of visible data") + + def test_with_other_parents_after_mirror_start(self): + """ + The same as test_with_other_parent(), but add the NBD server + only when the mirror job is already running. + """ + result = self.vm.qmp('nbd-server-start', + addr={ + 'type': 'unix', + 'data': {'path': nbd_sock_path} + }) + self.assert_qmp(result, 'return', {}) + + result = self.vm.qmp('drive-mirror', job_id='mirror', device='quorum0', + sync='full', node_name='repair0', replaces='img1', + target=quorum_repair_img, format=iotests.imgfmt) + self.assert_qmp(result, 'return', {}) + + result = self.vm.qmp('nbd-server-add', device='img1') + self.assert_qmp(result, 'return', {}) + + # The full error message goes to stderr, we will check it later + self.complete_and_wait('mirror', + completion_error='Operation not permitted') + + # Should not have been replaced + self.vm.assert_block_path('quorum0', '/children.1', 'img1') + + # Check the full error message now + self.vm.shutdown() + log = self.vm.get_log() + log = re.sub(r'^\[I \d+\.\d+\] OPENED\n', '', log) + log = re.sub(r'^Formatting.*\n', '', log) + log = re.sub(r'\n\[I \+\d+\.\d+\] CLOSED\n?$', '', log) + log = re.sub(r'^qemu-system-[^:]*: ', '', log) + + self.assertEqual(log, + "Can no longer replace 'img1' by 'repair0', because " + + "it can no longer be guaranteed that doing so would " + + "not lead to an abrupt change of visible data") + + # Test mirroring with a source that does not have any parents (not even a # BlockBackend) class TestOrphanedSource(iotests.QMPTestCase): diff --git a/tests/qemu-iotests/041.out b/tests/qemu-iotests/041.out index f496be9197..ffc779b4d1 100644 --- a/tests/qemu-iotests/041.out +++ b/tests/qemu-iotests/041.out @@ -1,5 +1,5 @@ -........................................................................................... +............................................................................................. ---------------------------------------------------------------------- -Ran 91 tests +Ran 93 tests OK From patchwork Thu Jan 30 21:44:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 1231671 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Lq7D7Grn; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 487vSm5l4dz9sNx for ; Fri, 31 Jan 2020 09:01:28 +1100 (AEDT) Received: from localhost ([::1]:39988 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHsM-0006XF-An for incoming@patchwork.ozlabs.org; Thu, 30 Jan 2020 17:01:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33834) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHcx-0005eK-7H for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:45:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ixHcw-0005ly-1E for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:45:31 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:47830 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 1ixHcv-0005jg-SP for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:45:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580420729; 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=eDgpmAX3G5Roq6SzTXWkDXVbFx48rOF92VefYHm5Keo=; b=Lq7D7GrnfuYXzbS9ce+hvHYrsO/2hX/EBkF6LZ5AOc8PurU2eI1ArQ2MAeUl/RcCAIzgen SDsZC07xTw0jUr6fZQnr07yEl7/nzUYEbs1tBf2nAtgxsKg4RNcL1/dCS62ke5RZ9GXYlB yAOiZPV2oHA9daeqcq2CpOicMxryb2M= 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-334-BgTVY3x5MAyg3k587E27zw-1; Thu, 30 Jan 2020 16:45:27 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 121B910CE780; Thu, 30 Jan 2020 21:45:25 +0000 (UTC) Received: from localhost (ovpn-204-145.brq.redhat.com [10.40.204.145]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9D1CB1001B23; Thu, 30 Jan 2020 21:45:24 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v3 21/21] iotests: Check that @replaces can replace filters Date: Thu, 30 Jan 2020 22:44:31 +0100 Message-Id: <20200130214431.333510-22-mreitz@redhat.com> In-Reply-To: <20200130214431.333510-1-mreitz@redhat.com> References: <20200130214431.333510-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: BgTVY3x5MAyg3k587E27zw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.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: Kevin Wolf , Vladimir Sementsov-Ogievskiy , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Max Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/041 | 46 ++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/041.out | 4 ++-- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041 index 12149c7786..5ff995dbe2 100755 --- a/tests/qemu-iotests/041 +++ b/tests/qemu-iotests/041 @@ -1190,6 +1190,52 @@ class TestOrphanedSource(iotests.QMPTestCase): self.assertFalse('mirror-filter' in nodes, 'Mirror filter node did not disappear') +# Test cases for @replaces that do not necessarily involve Quorum +class TestReplaces(iotests.QMPTestCase): + # Each of these test cases needs their own block graph, so do not + # create any nodes here + def setUp(self): + self.vm = iotests.VM() + self.vm.launch() + + def tearDown(self): + self.vm.shutdown() + for img in (test_img, target_img): + try: + os.remove(img) + except OSError: + pass + + @iotests.skip_if_unsupported(['copy-on-read']) + def test_replace_filter(self): + """ + Check that we can replace filter nodes. + """ + result = self.vm.qmp('blockdev-add', **{ + 'driver': 'copy-on-read', + 'node-name': 'filter0', + 'file': { + 'driver': 'copy-on-read', + 'node-name': 'filter1', + 'file': { + 'driver': 'null-co' + } + } + }) + self.assert_qmp(result, 'return', {}) + + result = self.vm.qmp('blockdev-add', + node_name='target', driver='null-co') + self.assert_qmp(result, 'return', {}) + + result = self.vm.qmp('blockdev-mirror', job_id='mirror', device='filter0', + target='target', sync='full', replaces='filter1') + self.assert_qmp(result, 'return', {}) + + self.complete_and_wait('mirror') + + self.vm.assert_block_path('filter0', '/file', 'target') + if __name__ == '__main__': iotests.main(supported_fmts=['qcow2', 'qed'], supported_protocols=['file'], diff --git a/tests/qemu-iotests/041.out b/tests/qemu-iotests/041.out index ffc779b4d1..877b76fd31 100644 --- a/tests/qemu-iotests/041.out +++ b/tests/qemu-iotests/041.out @@ -1,5 +1,5 @@ -............................................................................................. +.............................................................................................. ---------------------------------------------------------------------- -Ran 93 tests +Ran 94 tests OK