From patchwork Tue Feb 18 10:34:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 1239921 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=eKvmoYjR; 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 48MHLy2rgDz9sRh for ; Tue, 18 Feb 2020 21:35:54 +1100 (AEDT) Received: from localhost ([::1]:60450 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j40EK-00010i-72 for incoming@patchwork.ozlabs.org; Tue, 18 Feb 2020 05:35:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51968) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j40Dc-0000wy-1R for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j40Da-0007JH-Sp for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:07 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:34065 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 1j40Da-0007Ix-OA for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582022106; 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=TYrnGQvnIp4hR7+02aVeNf2B9V4JyaHfAzZh/E13Tzk=; b=eKvmoYjRSnvEuKlvZ+GXsDGDMN84zutNkpZ+lHYsdKP5a0gNq47EW6qxPbtuQehYIt1V47 sM9PSHPJvzticlkCPRJlE0GGSvsTPr6z1ztoRgGqxMuTulyzSDceR+0P90WUNedYx442pd uDlNV57M4ps+fpuUIFLrW3A8C+wEv5Y= 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-35-EGNAsc17NEa69aQSzw8GXA-1; Tue, 18 Feb 2020 05:35:01 -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 6797E18A6EDE; Tue, 18 Feb 2020 10:35:00 +0000 (UTC) Received: from localhost (unknown [10.36.118.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D70B790F6E; Tue, 18 Feb 2020 10:34:59 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v4 01/19] blockdev: Allow external snapshots everywhere Date: Tue, 18 Feb 2020 11:34:36 +0100 Message-Id: <20200218103454.296704-2-mreitz@redhat.com> In-Reply-To: <20200218103454.296704-1-mreitz@redhat.com> References: <20200218103454.296704-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: EGNAsc17NEa69aQSzw8GXA-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 43d931fd79..1745d740ec 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1592,11 +1592,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 Tue Feb 18 10:34:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 1239924 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=dKmIDU9w; 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 48MHNr4l56z9sRh for ; Tue, 18 Feb 2020 21:37:32 +1100 (AEDT) Received: from localhost ([::1]:60572 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j40Fs-0004xJ-SL for incoming@patchwork.ozlabs.org; Tue, 18 Feb 2020 05:37:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51993) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j40De-00010I-G9 for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j40Dd-0007KA-B5 for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:10 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:43528 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 1j40Dd-0007K1-7m for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582022108; 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=RAzEvMdOaOBLUZB8+8SgwVF8nHkQ8p1euy5J91x21UA=; b=dKmIDU9wZTCtnrdnMw2kheoLY3tUsQB0dIBgc1ajJVq2VtS9THh4/1wE8D+l5lERuwVHtz ELdNBpP52j02cygqQBS+YjbeizUoTHnGK6rLYx4psOldqw1vIrrW6y1CeO+zJOxqGdfXUi YVUn7ZxNXxDneaA5FXHxa1NmzwNRNzk= 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-375-IUb4n4BpPUaxkZ8fDhXflQ-1; Tue, 18 Feb 2020 05:35:05 -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 2B7E613F8; Tue, 18 Feb 2020 10:35:04 +0000 (UTC) Received: from localhost (unknown [10.36.118.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E9EC790F6E; Tue, 18 Feb 2020 10:35:02 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v4 02/19] blockdev: Allow resizing everywhere Date: Tue, 18 Feb 2020 11:34:37 +0100 Message-Id: <20200218103454.296704-3-mreitz@redhat.com> In-Reply-To: <20200218103454.296704-1-mreitz@redhat.com> References: <20200218103454.296704-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: IUb4n4BpPUaxkZ8fDhXflQ-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" 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 1745d740ec..011dcfec27 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3331,11 +3331,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 Tue Feb 18 10:34:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 1239932 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=c3vIEEPF; 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 48MHTh4JBGz9sRf for ; Tue, 18 Feb 2020 21:41:44 +1100 (AEDT) Received: from localhost ([::1]:60676 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j40Jy-0005dB-87 for incoming@patchwork.ozlabs.org; Tue, 18 Feb 2020 05:41:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51997) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j40De-00010V-Rn for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j40Dd-0007KI-NA for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:10 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:46746 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 1j40Dd-0007K4-Il for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582022109; 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=7YTYv8AieZotQAw9UExylWnb2sFwtVYrQjgy0Kvcwkk=; b=c3vIEEPFFiuqJR7JqCESrNopcQhnD/ZphHK8R8K5IejjwLGZHzQS3W9ho9AZdkPzDxcN50 ZPeJr0DoRonyvLrMYuHpDAl+pdcSVW76s1wfwXksNuOORhmRRbGpyaUvVnwQPuX7Z4Yu5S yOoOVRR+CGWgOCPHYb4J8DXmK4/XFCQ= 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-166-Dasi2l6kOVqs5jJYA2RjGg-1; Tue, 18 Feb 2020 05:35:07 -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 849038010F8; Tue, 18 Feb 2020 10:35:06 +0000 (UTC) Received: from localhost (unknown [10.36.118.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1CBE01BC6D; Tue, 18 Feb 2020 10:35:05 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v4 03/19] block: Drop bdrv_is_first_non_filter() Date: Tue, 18 Feb 2020 11:34:38 +0100 Message-Id: <20200218103454.296704-4-mreitz@redhat.com> In-Reply-To: <20200218103454.296704-1-mreitz@redhat.com> References: <20200218103454.296704-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: Dasi2l6kOVqs5jJYA2RjGg-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 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 998bb41a5b..f6731fa9be 100644 --- a/block.c +++ b/block.c @@ -6235,32 +6235,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 78026679ab..a6c0f6668e 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -394,7 +394,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 Tue Feb 18 10:34:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 1239922 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=X3Tq+UJd; 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 48MHM93Fjwz9sRh for ; Tue, 18 Feb 2020 21:36:05 +1100 (AEDT) Received: from localhost ([::1]:60502 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j40EV-0001lM-9B for incoming@patchwork.ozlabs.org; Tue, 18 Feb 2020 05:36:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52047) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j40Dk-00019z-3R for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j40Di-0007M6-OH for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:15 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:21980 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 1j40Di-0007Lr-KM for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582022114; 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=yvBWi2s6/tJLBi+ftR5NPxjefGGwG5hSWq/ZKgtM+YU=; b=X3Tq+UJdZkk9h6C3KM2fV3aDM5H+gqVSZPzQK4MIwU/YffmlsQWkYaW2dOI6V8fLnWuEpS nNfyWvZLknYzIErbVLe7ngXW1ThM1mSQphCU52fkTXQLfqrVeypiD5IsdhF185buCsQrrn qmtlnFNCe0IWwYKq1ebjpYLRIoCloZI= 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-44-qbxdX0FsOdCmAzmznA_8ug-1; Tue, 18 Feb 2020 05:35:10 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6AF8D18A6EC3; Tue, 18 Feb 2020 10:35:09 +0000 (UTC) Received: from localhost (unknown [10.36.118.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D2CBE5D9E2; Tue, 18 Feb 2020 10:35:08 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v4 04/19] iotests: Let 041 use -blockdev for quorum children Date: Tue, 18 Feb 2020 11:34:39 +0100 Message-Id: <20200218103454.296704-5-mreitz@redhat.com> In-Reply-To: <20200218103454.296704-1-mreitz@redhat.com> References: <20200218103454.296704-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: qbxdX0FsOdCmAzmznA_8ug-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" 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 43556b9727..aa7d54d968 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 Tue Feb 18 10:34:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 1239934 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=AJG2OSHE; 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 48MHWg4Sg8z9sRf for ; Tue, 18 Feb 2020 21:43:27 +1100 (AEDT) Received: from localhost ([::1]:60708 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j40Ld-0000Oq-H6 for incoming@patchwork.ozlabs.org; Tue, 18 Feb 2020 05:43:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52091) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j40Dm-0001FH-GK for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j40Dl-0007NN-9y for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:18 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:53002 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 1j40Dl-0007NA-5v for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582022116; 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=AJG2OSHEwiSG4otYOP+pxrjsktbY+DEPsUmuGAHfo8O7Ne6qSMFOtc00Sw+zuWonGXOMem 8GO/JwGpEu5MZYTX4rIh1DuoOvprYrynoQiCE33hM9hd484t6tsPamObr8X7mvh5Pt1p2W 33RGZCLkdj7DbDEH8KlROD3jP8WeLOs= 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-358-M_u9Cak6PNmGTPls4H-zuw-1; Tue, 18 Feb 2020 05:35:13 -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 02056800D55; Tue, 18 Feb 2020 10:35:12 +0000 (UTC) Received: from localhost (unknown [10.36.118.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6F2C81001925; Tue, 18 Feb 2020 10:35:11 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v4 05/19] quorum: Fix child permissions Date: Tue, 18 Feb 2020 11:34:40 +0100 Message-Id: <20200218103454.296704-6-mreitz@redhat.com> In-Reply-To: <20200218103454.296704-1-mreitz@redhat.com> References: <20200218103454.296704-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: M_u9Cak6PNmGTPls4H-zuw-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" 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 Tue Feb 18 10:34:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 1239925 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=U3rVkjco; 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 48MHPT1Cjpz9sRk for ; Tue, 18 Feb 2020 21:38:05 +1100 (AEDT) Received: from localhost ([::1]:60586 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j40GQ-0006Ec-UP for incoming@patchwork.ozlabs.org; Tue, 18 Feb 2020 05:38:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52107) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j40Dn-0001Hm-RJ for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j40Dm-0007Ny-CF for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:19 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:41527 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 1j40Dm-0007Nf-72 for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582022117; 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=RDmr9dxLhKqzcnPEfIoo4QRCiihKM20kv8WdUr/XucY=; b=U3rVkjcozYRDwPMrc0vEnLeUR/GyWYhtkNWyVECBU/KiqQX4wvwffEMEgV1xuNxHRs0ppX dKLKyKWAJFL0zdTaBwGbi/KgivuWdypoYIGTz0v5OhezvgPbpETZem5nkbbSzPd4gFHaVJ T700YH5dscPgVwRAeQIpvX0gddf4Xns= 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-338--STIPRxVONGfUREyvsYY_Q-1; Tue, 18 Feb 2020 05:35:16 -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 0E8E0800D48; Tue, 18 Feb 2020 10:35:15 +0000 (UTC) Received: from localhost (unknown [10.36.118.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 814428CCC5; Tue, 18 Feb 2020 10:35:14 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v4 06/19] block: Add bdrv_recurse_can_replace() Date: Tue, 18 Feb 2020 11:34:41 +0100 Message-Id: <20200218103454.296704-7-mreitz@redhat.com> In-Reply-To: <20200218103454.296704-1-mreitz@redhat.com> References: <20200218103454.296704-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: -STIPRxVONGfUREyvsYY_Q-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" 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 f6731fa9be..553ccff216 100644 --- a/block.c +++ b/block.c @@ -6235,6 +6235,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 640fb82c78..eaefac210e 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); @@ -1263,6 +1270,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 Tue Feb 18 10:34:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 1239926 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=Nh1xrKlj; 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 48MHQq0czJz9sRf for ; Tue, 18 Feb 2020 21:39:14 +1100 (AEDT) Received: from localhost ([::1]:60606 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j40HY-0000Wg-Jy for incoming@patchwork.ozlabs.org; Tue, 18 Feb 2020 05:39:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52147) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j40Ds-0001WU-Fu for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j40Dr-0007Pk-D4 for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:24 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:43403 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 1j40Dr-0007PM-85 for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582022122; 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=Nh1xrKljuRz6KXOY5NcxkprUCHxxox2jzs++JLakz9FqnkBf+1d4JNGzpInQvEExnUZVS9 L/VElxOssoR9Odt3ezlJ6Xn6BaNvFKsqv88VFF6PPkwZi/rw+mFFxUvFz2ecf3GkQsj5lI nRsTJ2/tvu8LJx+3s5t1Q666rxfj+Co= 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-169-sNFd9L_xMNO1bsHI031s7A-1; Tue, 18 Feb 2020 05:35:19 -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 22AD31005514; Tue, 18 Feb 2020 10:35:18 +0000 (UTC) Received: from localhost (unknown [10.36.118.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 93AF019481; Tue, 18 Feb 2020 10:35:17 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v4 07/19] blkverify: Implement .bdrv_recurse_can_replace() Date: Tue, 18 Feb 2020 11:34:42 +0100 Message-Id: <20200218103454.296704-8-mreitz@redhat.com> In-Reply-To: <20200218103454.296704-1-mreitz@redhat.com> References: <20200218103454.296704-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: sNFd9L_xMNO1bsHI031s7A-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" 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 Tue Feb 18 10:34:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 1239927 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=VgXQg1/B; 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 48MHQw6Qv8z9sRf for ; Tue, 18 Feb 2020 21:39:20 +1100 (AEDT) Received: from localhost ([::1]:60608 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j40He-0000l7-9f for incoming@patchwork.ozlabs.org; Tue, 18 Feb 2020 05:39:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52187) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j40Dv-0001hP-KD for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j40Du-0007R8-BL for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:27 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:40393 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 1j40Du-0007Qk-6c for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582022125; 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=9aPVtQzc7vjGemDWS1kpzm+7k6kudt5hwR47rSwH8tM=; b=VgXQg1/Bt2oVYfgkHjnypFThHJfUwc3Cg/DZdlxZbNLN+RfBdd6LIsiicgQ0V/fHoBP9Tf EG6kOUYia4pBg8Y4K6CXTBmv0+TPFOiZkPY/qZr7UPkRR5iV2KKjGKT3Eaq3e1VJv7+8ao u+O9OssdLs5IbwR8iA10PeA/K8RitvQ= 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-104-dJ2bKjQKMgyGbJbaCEmcVQ-1; Tue, 18 Feb 2020 05:35:22 -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 01F9413FB; Tue, 18 Feb 2020 10:35:21 +0000 (UTC) Received: from localhost (unknown [10.36.118.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6877D384; Tue, 18 Feb 2020 10:35:20 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v4 08/19] quorum: Implement .bdrv_recurse_can_replace() Date: Tue, 18 Feb 2020 11:34:43 +0100 Message-Id: <20200218103454.296704-9-mreitz@redhat.com> In-Reply-To: <20200218103454.296704-1-mreitz@redhat.com> References: <20200218103454.296704-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: dJ2bKjQKMgyGbJbaCEmcVQ-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 --- block/quorum.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/block/quorum.c b/block/quorum.c index 17b439056f..3ece6e4382 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -813,6 +813,59 @@ 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]->bs == to_replace) { + /* + * We now have to ensure that there is no other parent + * that cares about replacing this child by a node with + * potentially different data. + * We do so by checking whether there are any other parents + * at all, which is stricter than necessary, but also very + * simple. (We may decide to implement something more + * complex and permissive when there is an actual need for + * it.) + */ + return QLIST_FIRST(&to_replace->parents) == s->children[i] && + QLIST_NEXT(s->children[i], next_parent) == NULL; + } + } + + return false; +} + static int quorum_valid_threshold(int threshold, int num_children, Error **errp) { @@ -1164,6 +1217,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 Tue Feb 18 10:34:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 1239930 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=JscX5uoJ; 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 48MHSm4dtWz9sRf for ; Tue, 18 Feb 2020 21:40:56 +1100 (AEDT) Received: from localhost ([::1]:60648 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j40JC-0004Br-Gu for incoming@patchwork.ozlabs.org; Tue, 18 Feb 2020 05:40:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52219) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j40Dy-0001o3-Bf for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j40Dx-0007TS-5m for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:30 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:44325 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 1j40Dx-0007TK-1e for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582022128; 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=wrJiiw5y0UxtoIosHElrm5q85GG0zS+pG2zOdvNiYJM=; b=JscX5uoJuAKfkGq3K2842QWoSZu+SLlQINememDVEZY4J7cDFlQtejgBfnWB3P2ZAXIFtl QRKp6MDk5KyXTgtS1ecmuwxui+jQ60/rJmDirvblguhQzV5bymjGa0Kskuo1PuwhN//y6I SzpHseXgsZ0pOAq/tBmDIP6E2vTi67o= 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-375-McHMmTziN6yKRI3RhE8RHw-1; Tue, 18 Feb 2020 05:35:25 -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 EF966477; Tue, 18 Feb 2020 10:35:23 +0000 (UTC) Received: from localhost (unknown [10.36.118.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6AC2860BE1; Tue, 18 Feb 2020 10:35:23 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v4 09/19] block: Use bdrv_recurse_can_replace() Date: Tue, 18 Feb 2020 11:34:44 +0100 Message-Id: <20200218103454.296704-10-mreitz@redhat.com> In-Reply-To: <20200218103454.296704-1-mreitz@redhat.com> References: <20200218103454.296704-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: McHMmTziN6yKRI3RhE8RHw-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" 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 553ccff216..7efe8f3b03 100644 --- a/block.c +++ b/block.c @@ -6273,6 +6273,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) { @@ -6297,8 +6308,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 Tue Feb 18 10:34:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 1239931 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=MkItaxz5; 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 48MHT04T2fz9sRf for ; Tue, 18 Feb 2020 21:41:08 +1100 (AEDT) Received: from localhost ([::1]:60654 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j40JO-0004hL-E2 for incoming@patchwork.ozlabs.org; Tue, 18 Feb 2020 05:41:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52236) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j40E0-0001pX-25 for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j40Dy-0007Tw-AM for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:31 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:42106 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 1j40Dy-0007Th-5x for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582022129; 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=+tBUdMXFjuNS9B5/OxkBBXbM0EpKz4wBlh7jc2FjNIk=; b=MkItaxz5Idf9G0ClXof9AhjbkIEKlULbT0ca88JZFyMvdrTZ/eNd2mUVLOeB2LRt/jhQiu zVGsLW+Zsf164XWryN9hJeOV2YLm5AOG9477pptAFla3olIYsc2Mz1s/lptqi11/dAGbVB g1eGQ1sSZybrilVi5TqSoviyuOI6eQo= 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-309-4GJE_XP0MDa9fBhNgtygAQ-1; Tue, 18 Feb 2020 05:35:28 -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 12E0D18A6EC2; Tue, 18 Feb 2020 10:35:27 +0000 (UTC) Received: from localhost (unknown [10.36.118.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2C33290772; Tue, 18 Feb 2020 10:35:26 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v4 10/19] block: Remove bdrv_recurse_is_first_non_filter() Date: Tue, 18 Feb 2020 11:34:45 +0100 Message-Id: <20200218103454.296704-11-mreitz@redhat.com> In-Reply-To: <20200218103454.296704-1-mreitz@redhat.com> References: <20200218103454.296704-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: 4GJE_XP0MDa9fBhNgtygAQ-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" 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 7efe8f3b03..ca2cfbcb62 100644 --- a/block.c +++ b/block.c @@ -6202,39 +6202,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 3ece6e4382..f57b0402d9 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -796,23 +796,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]->bs, - candidate); - if (perm) { - return true; - } - } - - return false; -} - static bool quorum_recurse_can_replace(BlockDriverState *bs, BlockDriverState *to_replace) { @@ -1216,7 +1199,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 a6c0f6668e..cd6b5b95aa 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -391,10 +391,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 eaefac210e..6f9fd5e20e 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 Tue Feb 18 10:34:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 1239937 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=DyB6BovZ; 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 48MHYC3g68z9sRf for ; Tue, 18 Feb 2020 21:44:47 +1100 (AEDT) Received: from localhost ([::1]:60732 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j40Mv-00034A-8V for incoming@patchwork.ozlabs.org; Tue, 18 Feb 2020 05:44:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52252) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j40E3-0001qn-1J for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j40E1-0007Ui-Ey for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:34 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:60088 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 1j40E0-0007UV-UI for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582022132; 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=DyB6BovZ7Zn3dfeO8Kv6XtQqu8cYsm8l7mSVBQ/IEDVuPXFbBGniptfvHNQ1xpYG6XJc9K 0l0USVPjDHcA2iUfWS2WqPK0uU4JraanCeOfDfbproRoTWS4+GGaCagYddJToSGG8oWEzR Jqsj9BiDlI7j82LGAx1J0Fc9UQlAwmk= 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-284-s6GvOgoVNs63w4D90gI1jg-1; Tue, 18 Feb 2020 05:35:30 -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 E3005107ACC4; Tue, 18 Feb 2020 10:35:29 +0000 (UTC) Received: from localhost (unknown [10.36.118.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5BDC719756; Tue, 18 Feb 2020 10:35:29 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v4 11/19] mirror: Double-check immediately before replacing Date: Tue, 18 Feb 2020 11:34:46 +0100 Message-Id: <20200218103454.296704-12-mreitz@redhat.com> In-Reply-To: <20200218103454.296704-1-mreitz@redhat.com> References: <20200218103454.296704-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: s6GvOgoVNs63w4D90gI1jg-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" 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 Tue Feb 18 10:34:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 1239933 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=fuB2Z2Ox; 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 48MHW16q4Fz9sRf for ; Tue, 18 Feb 2020 21:42:53 +1100 (AEDT) Received: from localhost ([::1]:60700 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j40L4-0007nL-7a for incoming@patchwork.ozlabs.org; Tue, 18 Feb 2020 05:42:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52286) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j40E9-0001w2-0E for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j40E6-0007WM-Kq for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:40 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:32093 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 1j40E6-0007W2-Hc for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582022137; 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=qa1ssF0uaXNQpOeysKdHqIyaUPNzIgzDTTYOvuRRX4w=; b=fuB2Z2OxTUwSFF9yN5fD/E+t4L43ECjVN44mhe9VbdhhVJAqi9jboUwv8rqiVf8SXK4Z5z oPGmqIb4/4T5O97E8o/tW8OAPKKfCOHLOyrQ3DNzcMDl7geY9iWLAUpCjaCuYFGCCgo9XF GFXViXcDgzB+Ks08Wv7YAlLGprQqzdc= 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-26-FGtNsV5sOnqg4Rwz25zFKQ-1; Tue, 18 Feb 2020 05:35:33 -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 D7762107ACC7; Tue, 18 Feb 2020 10:35:32 +0000 (UTC) Received: from localhost (unknown [10.36.118.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5CC6D87058; Tue, 18 Feb 2020 10:35:32 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v4 12/19] quorum: Stop marking it as a filter Date: Tue, 18 Feb 2020 11:34:47 +0100 Message-Id: <20200218103454.296704-13-mreitz@redhat.com> In-Reply-To: <20200218103454.296704-1-mreitz@redhat.com> References: <20200218103454.296704-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: FGtNsV5sOnqg4Rwz25zFKQ-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 f57b0402d9..6d7a56bd93 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -1198,7 +1198,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 Tue Feb 18 10:34:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 1239936 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=MCdfbBX+; 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 48MHXr1qWFz9sRf for ; Tue, 18 Feb 2020 21:44:27 +1100 (AEDT) Received: from localhost ([::1]:60726 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j40Mb-0002LT-NN for incoming@patchwork.ozlabs.org; Tue, 18 Feb 2020 05:44:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52320) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j40EC-000218-Kw for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j40EA-0007az-35 for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:44 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:40298 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 1j40E9-0007aB-GP for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582022141; 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=nQNFJ14X/ikrDk925Im8rM8pR51+9I3aAdwR0MHpuCs=; b=MCdfbBX+9jjHp6udLjAFIn87//MiIH5sjXVGvtSGKkSCfO1UIRMmy7pINKD+qg+Iu0FUkk bDxxmW38oo2Aropx0v+ukrKf5af/Cvf9Hb7KUlK+HduZOFkPuG8G39nnHzYkhsn5pQ89iL jP+x6DYRmV0ePmBBb3M5ZjSOEkc0Rrs= 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-369-8G6DrBeBM6y7y6FN3oQU0w-1; Tue, 18 Feb 2020 05:35:37 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D09CC802566; Tue, 18 Feb 2020 10:35:35 +0000 (UTC) Received: from localhost (unknown [10.36.118.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4CA825D9E2; Tue, 18 Feb 2020 10:35:34 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v4 13/19] iotests: Use complete_and_wait() in 155 Date: Tue, 18 Feb 2020 11:34:48 +0100 Message-Id: <20200218103454.296704-14-mreitz@redhat.com> In-Reply-To: <20200218103454.296704-1-mreitz@redhat.com> References: <20200218103454.296704-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: 8G6DrBeBM6y7y6FN3oQU0w-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" 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 e35b1d534b..f237868710 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 Tue Feb 18 10:34:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 1239939 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=PyOu8qKH; 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 48MHZk5HsXz9sRf for ; Tue, 18 Feb 2020 21:46:06 +1100 (AEDT) Received: from localhost ([::1]:60768 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j40OC-0005TH-Ln for incoming@patchwork.ozlabs.org; Tue, 18 Feb 2020 05:46:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52342) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j40ED-000254-Px for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j40EC-0007cE-J7 for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:45 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:24412 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 1j40EB-0007aM-98 for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582022141; 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=JJiSY8aLeMkLp7k5JdMdK9u1USDPPnfK/5mrL6tNNLU=; b=PyOu8qKHuFpK4JTC4hcywgsknnpDmkJnf9+xz4UHq+QFFkF0lf72whAfOkVwYGCudiBISO 5xujF/KE7ovumJuBGHdsiTLFKNwvx2XhSXAw4QIM05LWO+FCKUB5XujZbahsv6z9l8c+6/ eC2mRQFTxkd8m/pQcjauz30DtmbXn/U= 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-166-xEu3n3P-MYiWjaTVj7XXaw-1; Tue, 18 Feb 2020 05:35:39 -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 C9016100550E; Tue, 18 Feb 2020 10:35:38 +0000 (UTC) Received: from localhost (unknown [10.36.118.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 45D961001920; Tue, 18 Feb 2020 10:35:37 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v4 14/19] iotests: Add VM.assert_block_path() Date: Tue, 18 Feb 2020 11:34:49 +0100 Message-Id: <20200218103454.296704-15-mreitz@redhat.com> In-Reply-To: <20200218103454.296704-1-mreitz@redhat.com> References: <20200218103454.296704-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: xEu3n3P-MYiWjaTVj7XXaw-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 --- tests/qemu-iotests/iotests.py | 59 +++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 0473e824ed..8815052eb5 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -714,6 +714,65 @@ 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) + + # An empty @path is not allowed, so the root node must be present + assert node is not None, 'Root node %s not found' % root + + for child_name in iter_path: + assert node is not None, 'Cannot follow path %s%s' % (root, 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 Tue Feb 18 10:34:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 1239928 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=HQ7Jlo0z; 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 48MHRn5mJsz9sRf for ; Tue, 18 Feb 2020 21:40:05 +1100 (AEDT) Received: from localhost ([::1]:60633 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j40IN-0002ZC-OH for incoming@patchwork.ozlabs.org; Tue, 18 Feb 2020 05:40:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52358) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j40EF-0002Aw-Ji for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j40EE-0007db-Ba for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:47 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:58427 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 1j40EE-0007dQ-7D for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582022145; 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=fVQnZPVSOrLUX76idZL/c1TGsWgDLcKuCrSjTmmLAuA=; b=HQ7Jlo0zdX7N+M3mgfYcpC4Sa31AEotshLAlzxuqRrnAZLUW5tU+aY7bvAt+Cii0vaO+Zl cB2TFDqWxkirMyOw3tHbFYfvBwsn1QLrb1G7gP+XlQo659zcD1Ny9zDVPJeKIuIRbaFizX xHniU0MfHshQPPV0urDldEYDhAvA++E= 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-165-dHm_5IAnPYSx-tytbnriDw-1; Tue, 18 Feb 2020 05:35:42 -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 C7545477; Tue, 18 Feb 2020 10:35:41 +0000 (UTC) Received: from localhost (unknown [10.36.118.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3D54B19E9C; Tue, 18 Feb 2020 10:35:40 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v4 15/19] iotests/041: Drop superfluous shutdowns Date: Tue, 18 Feb 2020 11:34:50 +0100 Message-Id: <20200218103454.296704-16-mreitz@redhat.com> In-Reply-To: <20200218103454.296704-1-mreitz@redhat.com> References: <20200218103454.296704-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: dHm_5IAnPYSx-tytbnriDw-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" 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 aa7d54d968..7b2cf5c2f8 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 Tue Feb 18 10:34:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 1239935 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=GCRZ6skw; 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 48MHX34yFFz9sRf for ; Tue, 18 Feb 2020 21:43:47 +1100 (AEDT) Received: from localhost ([::1]:60714 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j40Lx-0000zw-Jh for incoming@patchwork.ozlabs.org; Tue, 18 Feb 2020 05:43:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52399) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j40EJ-0002Kv-6L for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j40EI-0007fS-1u for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:51 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:54853 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 1j40EH-0007fH-Um for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582022149; 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=tVmhVcx1utaWa+od2sk93VEg73HvGcMJgHxX4QbcIqk=; b=GCRZ6skweXRATqruydg+KLZq2wiBC13bApE9sO2pqEK2m/OpQNw6B7F4iDR3DhzKncVv0D EF/EcpkqMABOiZOFOmELdjGvwHgatJDiO/P1qKfQbZYz7UH0eT9nCLxqc5U6IaXJ/sAWGZ vkEd3hJnX47KOdcRqlGkRDLl+o6EpV8= 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-113-gwrvP7x5OuKJfCpFnLcPdw-1; Tue, 18 Feb 2020 05:35:46 -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 D3918107ACC7; Tue, 18 Feb 2020 10:35:44 +0000 (UTC) Received: from localhost (unknown [10.36.118.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4DA9119E9C; Tue, 18 Feb 2020 10:35:43 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v4 16/19] iotests: Resolve TODOs in 041 Date: Tue, 18 Feb 2020 11:34:51 +0100 Message-Id: <20200218103454.296704-17-mreitz@redhat.com> In-Reply-To: <20200218103454.296704-1-mreitz@redhat.com> References: <20200218103454.296704-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: gwrvP7x5OuKJfCpFnLcPdw-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" 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 7b2cf5c2f8..084da6baf3 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 Tue Feb 18 10:34:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 1239938 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=XeXNgRQv; 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 48MHYp4nTRz9sRf for ; Tue, 18 Feb 2020 21:45:18 +1100 (AEDT) Received: from localhost ([::1]:60740 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j40NQ-0003k1-HE for incoming@patchwork.ozlabs.org; Tue, 18 Feb 2020 05:45:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52416) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j40EO-0002YQ-3p for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j40EN-0007go-5d for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:56 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:60852 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 1j40EN-0007gc-1K for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582022154; 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=6Ng67lvkKpwyx6+Ab/FS8/+s7Ayy26WAiL5em8dKNTc=; b=XeXNgRQv6/QbszFZX94p2mOBHBfk10S3ggOtjgQ0zykOU3MtzBG1UgPfLwcSdM56HUaAh5 p6XkmVNAtwGj54RPKQjbBQM4h8AVWZ6ncx6+H2z5NC+ztZ6dWfj1NiIr1oWIc76nBLGYfu bek8LIsorQg01PtuTAMw8bebIn3sRp4= 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-228-vkRicEyVP5SOoA-T0Y90bA-1; Tue, 18 Feb 2020 05:35:48 -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 C4A07800D48; Tue, 18 Feb 2020 10:35:47 +0000 (UTC) Received: from localhost (unknown [10.36.118.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3DDC719E9C; Tue, 18 Feb 2020 10:35:47 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v4 17/19] iotests: Use self.image_len in TestRepairQuorum Date: Tue, 18 Feb 2020 11:34:52 +0100 Message-Id: <20200218103454.296704-18-mreitz@redhat.com> In-Reply-To: <20200218103454.296704-1-mreitz@redhat.com> References: <20200218103454.296704-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: vkRicEyVP5SOoA-T0Y90bA-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" 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 084da6baf3..1d9e64ff6d 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 Tue Feb 18 10:34:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 1239941 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=Cnj1+tb7; 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 48MHcj1hqqz9sRf for ; Tue, 18 Feb 2020 21:47:49 +1100 (AEDT) Received: from localhost ([::1]:60802 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j40Pq-0008FV-5T for incoming@patchwork.ozlabs.org; Tue, 18 Feb 2020 05:47:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52437) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j40EQ-0002eD-6H for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j40EO-0007hZ-TE for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:58 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:49427 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 1j40EO-0007hL-Ol for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582022156; 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=ks70kKUuxDnFJRe7lsAwIiHxB7dO030+sVv/2ybyOec=; b=Cnj1+tb7GmkGyjgNIYXVqoSSeqwMXlPq+XNfbJRHhcKTbKy72Ac129/rQwPsX7f0WNOQbh E1mctByWMJwcTTbTz6bcMj+cG59vtqv9yekbqsWb/SECSYSXzmkXb4E2gNzLdmDvYQDLiq DoEUxIg8BWuXcbpSwkon5iW7HETzk5Q= 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-25--gb2IRw5MbSe1y0Jjp9GoQ-1; Tue, 18 Feb 2020 05:35:51 -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 D488C107ACC7; Tue, 18 Feb 2020 10:35:50 +0000 (UTC) Received: from localhost (unknown [10.36.118.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5333260BE1; Tue, 18 Feb 2020 10:35:50 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v4 18/19] iotests: Add tests for invalid Quorum @replaces Date: Tue, 18 Feb 2020 11:34:53 +0100 Message-Id: <20200218103454.296704-19-mreitz@redhat.com> In-Reply-To: <20200218103454.296704-1-mreitz@redhat.com> References: <20200218103454.296704-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: -gb2IRw5MbSe1y0Jjp9GoQ-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" 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 1d9e64ff6d..53c8671969 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 Tue Feb 18 10:34:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 1239940 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=PZRP2V4y; 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 48MHc615lvz9sRf for ; Tue, 18 Feb 2020 21:47:18 +1100 (AEDT) Received: from localhost ([::1]:60794 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j40PM-0007Dh-14 for incoming@patchwork.ozlabs.org; Tue, 18 Feb 2020 05:47:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52439) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j40EQ-0002ex-DN for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j40EP-0007hf-AX for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:58 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:50326 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 1j40EP-0007hW-6n for qemu-devel@nongnu.org; Tue, 18 Feb 2020 05:35:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582022156; 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=NOwyEZkXMhtI9AeACtC6cAXN0eIjbatiCTsVadLLWwE=; b=PZRP2V4y5DNjdLT4KPVLqebLBpX02YtPyIp3gLicVUYEyobfmkAGNk7uYuNmNapmqW21wn VMpYHwmTyc+p0UlzhHQoCyGAD33SXQYvI60Cf9LDO7LPK5Hn2QXylQpho3xT1y+/gIVCkf LaU+XPPhorSwmdjTj00xTBMZyK7m7QE= 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-128-g5nOf7IUNcWMmg6FSsPhrw-1; Tue, 18 Feb 2020 05:35:54 -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 E9E59801E70; Tue, 18 Feb 2020 10:35:53 +0000 (UTC) Received: from localhost (unknown [10.36.118.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 630ED19481; Tue, 18 Feb 2020 10:35:53 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v4 19/19] iotests: Check that @replaces can replace filters Date: Tue, 18 Feb 2020 11:34:54 +0100 Message-Id: <20200218103454.296704-20-mreitz@redhat.com> In-Reply-To: <20200218103454.296704-1-mreitz@redhat.com> References: <20200218103454.296704-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: g5nOf7IUNcWMmg6FSsPhrw-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 53c8671969..532a3827e7 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