From patchwork Fri Dec 18 15:12:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 11982425 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B638C4361B for ; Fri, 18 Dec 2020 15:14:55 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id BC27A23AFD for ; Fri, 18 Dec 2020 15:14:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BC27A23AFD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:41824 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqHT1-0003Yx-22 for qemu-devel@archiver.kernel.org; Fri, 18 Dec 2020 10:14:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53566) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqHRH-0001Lv-4b for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:03 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:49987) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kqHRC-0005Db-3e for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304376; 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=igkvQViNUbm07x9rI3jrUrfsKmNw2U3xx27aMs6S8Xo=; b=aQZoB6ozK+TUA9yRIg4x7clsD/cJ2Uc4uNdxHuo94aXt0iN9kEqBLlHAmkt81Y5gqTNM5t Q+QVWqzo5z25Q+wzqu6ZdVQWvwogegrRmsXaX6KQmSdwOqYt1xbj2pQioj7orHktacTiLV SFVfrUfWvu2MYCUVQxrHaL8Wc+qrSsA= 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-498-ZgmCsDH9Muy1Q6nhaSmVQw-1; Fri, 18 Dec 2020 10:12:54 -0500 X-MC-Unique: ZgmCsDH9Muy1Q6nhaSmVQw-1 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 6992E801817; Fri, 18 Dec 2020 15:12:53 +0000 (UTC) Received: from localhost (ovpn-114-84.ams2.redhat.com [10.36.114.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 079AB2C161; Fri, 18 Dec 2020 15:12:52 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 01/30] block: add bdrv_refresh_perms() helper Date: Fri, 18 Dec 2020 16:12:20 +0100 Message-Id: <20201218151249.715731-2-mreitz@redhat.com> In-Reply-To: <20201218151249.715731-1-mreitz@redhat.com> References: <20201218151249.715731-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Vladimir Sementsov-Ogievskiy Make separate function for common pattern. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20201106124241.16950-5-vsementsov@virtuozzo.com> [mreitz: Squashed in https://lists.nongnu.org/archive/html/qemu-block/2020-11/msg00299.html] Signed-off-by: Max Reitz --- block.c | 61 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/block.c b/block.c index 8f177504d4..3a07693608 100644 --- a/block.c +++ b/block.c @@ -2327,6 +2327,24 @@ static void bdrv_child_abort_perm_update(BdrvChild *c) bdrv_abort_perm_update(c->bs); } +static int bdrv_refresh_perms(BlockDriverState *bs, bool *tighten_restrictions, + Error **errp) +{ + int ret; + uint64_t perm, shared_perm; + + bdrv_get_cumulative_perm(bs, &perm, &shared_perm); + ret = bdrv_check_perm(bs, NULL, perm, shared_perm, NULL, + tighten_restrictions, errp); + if (ret < 0) { + bdrv_abort_perm_update(bs); + return ret; + } + bdrv_set_perm(bs, perm, shared_perm); + + return 0; +} + int bdrv_child_try_set_perm(BdrvChild *c, uint64_t perm, uint64_t shared, Error **errp) { @@ -2642,22 +2660,15 @@ static void bdrv_replace_child(BdrvChild *child, BlockDriverState *new_bs) } if (old_bs) { - /* Update permissions for old node. This is guaranteed to succeed - * because we're just taking a parent away, so we're loosening - * restrictions. */ bool tighten_restrictions; - int ret; - bdrv_get_cumulative_perm(old_bs, &perm, &shared_perm); - ret = bdrv_check_perm(old_bs, NULL, perm, shared_perm, NULL, - &tighten_restrictions, NULL); + /* + * Update permissions for old node. We're just taking a parent away, so + * we're loosening restrictions. Errors of permission update are not + * fatal in this case, ignore them. + */ + bdrv_refresh_perms(old_bs, &tighten_restrictions, NULL); assert(tighten_restrictions == false); - if (ret < 0) { - /* We only tried to loosen restrictions, so errors are not fatal */ - bdrv_abort_perm_update(old_bs); - } else { - bdrv_set_perm(old_bs, perm, shared_perm); - } /* When the parent requiring a non-default AioContext is removed, the * node moves back to the main AioContext */ @@ -5781,7 +5792,6 @@ void bdrv_init_with_whitelist(void) int coroutine_fn bdrv_co_invalidate_cache(BlockDriverState *bs, Error **errp) { BdrvChild *child, *parent; - uint64_t perm, shared_perm; Error *local_err = NULL; int ret; BdrvDirtyBitmap *bm; @@ -5813,14 +5823,11 @@ int coroutine_fn bdrv_co_invalidate_cache(BlockDriverState *bs, Error **errp) */ if (bs->open_flags & BDRV_O_INACTIVE) { bs->open_flags &= ~BDRV_O_INACTIVE; - bdrv_get_cumulative_perm(bs, &perm, &shared_perm); - ret = bdrv_check_perm(bs, NULL, perm, shared_perm, NULL, NULL, errp); + ret = bdrv_refresh_perms(bs, NULL, errp); if (ret < 0) { - bdrv_abort_perm_update(bs); bs->open_flags |= BDRV_O_INACTIVE; return ret; } - bdrv_set_perm(bs, perm, shared_perm); if (bs->drv->bdrv_co_invalidate_cache) { bs->drv->bdrv_co_invalidate_cache(bs, &local_err); @@ -5896,7 +5903,6 @@ static int bdrv_inactivate_recurse(BlockDriverState *bs) { BdrvChild *child, *parent; bool tighten_restrictions; - uint64_t perm, shared_perm; int ret; if (!bs->drv) { @@ -5930,18 +5936,13 @@ static int bdrv_inactivate_recurse(BlockDriverState *bs) bs->open_flags |= BDRV_O_INACTIVE; - /* Update permissions, they may differ for inactive nodes */ - bdrv_get_cumulative_perm(bs, &perm, &shared_perm); - ret = bdrv_check_perm(bs, NULL, perm, shared_perm, NULL, - &tighten_restrictions, NULL); + /* + * Update permissions, they may differ for inactive nodes. + * We only tried to loosen restrictions, so errors are not fatal, ignore + * them. + */ + bdrv_refresh_perms(bs, &tighten_restrictions, NULL); assert(tighten_restrictions == false); - if (ret < 0) { - /* We only tried to loosen restrictions, so errors are not fatal */ - bdrv_abort_perm_update(bs); - } else { - bdrv_set_perm(bs, perm, shared_perm); - } - /* Recursively inactivate children */ QLIST_FOREACH(child, &bs->children, next) { From patchwork Fri Dec 18 15:12:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 11982427 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E7ACC2BBCF for ; Fri, 18 Dec 2020 15:14:56 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 2C8B223AFD for ; Fri, 18 Dec 2020 15:14:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2C8B223AFD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:41774 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqHT5-0003Xl-7m for qemu-devel@archiver.kernel.org; Fri, 18 Dec 2020 10:14:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53572) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqHRH-0001My-SU for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:03 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:55537) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kqHRG-0005Ez-0S for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304381; 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=Ls2wWdlZPujsIJlCnhMtMhIKyomgLyG4yXk9iQumZlA=; b=hqqLMpqwKjqsSh5AxGpD64DbnUNHYdUQlDT4qGoYBw+hRA21DiiKjqtAxrs8CGQMROKJzw o/U4U9wM54sW8hZaxtq2D54qc+72j/XYQ+LvlhfemRxhe+xn23SiWAnUZ48U6FXIfAxnQ9 1tuLclGr3ECItx9wLX5Ek33FLxei/Gc= 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-107-V4_NUJhkNQWze4S-ZViTXQ-1; Fri, 18 Dec 2020 10:12:56 -0500 X-MC-Unique: V4_NUJhkNQWze4S-ZViTXQ-1 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 8EEC0190B2B3; Fri, 18 Dec 2020 15:12:55 +0000 (UTC) Received: from localhost (ovpn-114-84.ams2.redhat.com [10.36.114.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 310605D769; Fri, 18 Dec 2020 15:12:55 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 02/30] block: bdrv_set_perm() drop redundant parameters. Date: Fri, 18 Dec 2020 16:12:21 +0100 Message-Id: <20201218151249.715731-3-mreitz@redhat.com> In-Reply-To: <20201218151249.715731-1-mreitz@redhat.com> References: <20201218151249.715731-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Vladimir Sementsov-Ogievskiy We should never set permissions other than cumulative permissions of parents. During bdrv_reopen_multiple() we _check_ for synthetic permissions but when we do _set_ the graph is already updated. Add an assertion to bdrv_reopen_multiple(), other cases are more obvious. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20201106124241.16950-6-vsementsov@virtuozzo.com> Reviewed-by: Max Reitz Signed-off-by: Max Reitz --- block.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/block.c b/block.c index 3a07693608..66ab6caa7d 100644 --- a/block.c +++ b/block.c @@ -2112,9 +2112,9 @@ static void bdrv_abort_perm_update(BlockDriverState *bs) } } -static void bdrv_set_perm(BlockDriverState *bs, uint64_t cumulative_perms, - uint64_t cumulative_shared_perms) +static void bdrv_set_perm(BlockDriverState *bs) { + uint64_t cumulative_perms, cumulative_shared_perms; BlockDriver *drv = bs->drv; BdrvChild *c; @@ -2122,6 +2122,8 @@ static void bdrv_set_perm(BlockDriverState *bs, uint64_t cumulative_perms, return; } + bdrv_get_cumulative_perm(bs, &cumulative_perms, &cumulative_shared_perms); + /* Update this node */ if (drv->bdrv_set_perm) { drv->bdrv_set_perm(bs, cumulative_perms, cumulative_shared_perms); @@ -2304,16 +2306,12 @@ static int bdrv_child_check_perm(BdrvChild *c, BlockReopenQueue *q, static void bdrv_child_set_perm(BdrvChild *c, uint64_t perm, uint64_t shared) { - uint64_t cumulative_perms, cumulative_shared_perms; - c->has_backup_perm = false; c->perm = perm; c->shared_perm = shared; - bdrv_get_cumulative_perm(c->bs, &cumulative_perms, - &cumulative_shared_perms); - bdrv_set_perm(c->bs, cumulative_perms, cumulative_shared_perms); + bdrv_set_perm(c->bs); } static void bdrv_child_abort_perm_update(BdrvChild *c) @@ -2340,7 +2338,7 @@ static int bdrv_refresh_perms(BlockDriverState *bs, bool *tighten_restrictions, bdrv_abort_perm_update(bs); return ret; } - bdrv_set_perm(bs, perm, shared_perm); + bdrv_set_perm(bs); return 0; } @@ -2641,7 +2639,6 @@ static void bdrv_replace_child_noperm(BdrvChild *child, static void bdrv_replace_child(BdrvChild *child, BlockDriverState *new_bs) { BlockDriverState *old_bs = child->bs; - uint64_t perm, shared_perm; /* Asserts that child->frozen == false */ bdrv_replace_child_noperm(child, new_bs); @@ -2655,8 +2652,7 @@ static void bdrv_replace_child(BdrvChild *child, BlockDriverState *new_bs) * restrictions. */ if (new_bs) { - bdrv_get_cumulative_perm(new_bs, &perm, &shared_perm); - bdrv_set_perm(new_bs, perm, shared_perm); + bdrv_set_perm(new_bs); } if (old_bs) { @@ -3874,7 +3870,13 @@ cleanup_perm: } if (ret == 0) { - bdrv_set_perm(state->bs, state->perm, state->shared_perm); + uint64_t perm, shared; + + bdrv_get_cumulative_perm(state->bs, &perm, &shared); + assert(perm == state->perm); + assert(shared == state->shared_perm); + + bdrv_set_perm(state->bs); } else { bdrv_abort_perm_update(state->bs); if (state->replace_backing_bs && state->new_backing_bs) { @@ -4644,8 +4646,7 @@ static void bdrv_replace_node_common(BlockDriverState *from, bdrv_unref(from); } - bdrv_get_cumulative_perm(to, &perm, &shared); - bdrv_set_perm(to, perm, shared); + bdrv_set_perm(to); out: g_slist_free(list); From patchwork Fri Dec 18 15:12:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 11982433 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 53095C4361B for ; Fri, 18 Dec 2020 15:18:15 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id E83CE23AFD for ; Fri, 18 Dec 2020 15:18:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E83CE23AFD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:50246 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqHWH-000785-Qq for qemu-devel@archiver.kernel.org; Fri, 18 Dec 2020 10:18:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53576) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqHRJ-0001Q4-0m for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:05 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:20031) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kqHRG-0005F3-2n for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304381; 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=FBKK5/o64NiNGzP+zRBp/vpj/NUN1zZjDdXc3aUXuU8=; b=X6M4/ZponxH4iDv5hsYjzKYFG4Pz9eQb6lirwU8rMKAWLafvAu89fsMjmeWBgxlz9wgnS1 OybFfZ8Wr27SVd+mhLNQP9x24Vvvos7OKOjpeJBs5PvWWNUEGUBALW1Fi9BANcZ5/nqgaT n7Qgpufm4tvY+4/VJxX5D/K+RqqLmP4= 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-279-AKhHFtOVMxW2KhKquq8ouA-1; Fri, 18 Dec 2020 10:12:59 -0500 X-MC-Unique: AKhHFtOVMxW2KhKquq8ouA-1 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 D81AB8030A2; Fri, 18 Dec 2020 15:12:57 +0000 (UTC) Received: from localhost (ovpn-114-84.ams2.redhat.com [10.36.114.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7A63A60C5F; Fri, 18 Dec 2020 15:12:57 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 03/30] block: bdrv_child_set_perm() drop redundant parameters. Date: Fri, 18 Dec 2020 16:12:22 +0100 Message-Id: <20201218151249.715731-4-mreitz@redhat.com> In-Reply-To: <20201218151249.715731-1-mreitz@redhat.com> References: <20201218151249.715731-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Vladimir Sementsov-Ogievskiy We must set the permission used for _check_. Assert that we have backup and drop extra arguments. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20201106124241.16950-7-vsementsov@virtuozzo.com> Reviewed-by: Max Reitz Signed-off-by: Max Reitz --- block.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/block.c b/block.c index 66ab6caa7d..f66388b9ea 100644 --- a/block.c +++ b/block.c @@ -1903,7 +1903,7 @@ static int bdrv_child_check_perm(BdrvChild *c, BlockReopenQueue *q, GSList *ignore_children, bool *tighten_restrictions, Error **errp); static void bdrv_child_abort_perm_update(BdrvChild *c); -static void bdrv_child_set_perm(BdrvChild *c, uint64_t perm, uint64_t shared); +static void bdrv_child_set_perm(BdrvChild *c); typedef struct BlockReopenQueueEntry { bool prepared; @@ -2137,11 +2137,7 @@ static void bdrv_set_perm(BlockDriverState *bs) /* Update all children */ QLIST_FOREACH(c, &bs->children, next) { - uint64_t cur_perm, cur_shared; - bdrv_child_perm(bs, c->bs, c, c->role, NULL, - cumulative_perms, cumulative_shared_perms, - &cur_perm, &cur_shared); - bdrv_child_set_perm(c, cur_perm, cur_shared); + bdrv_child_set_perm(c); } } @@ -2304,13 +2300,10 @@ static int bdrv_child_check_perm(BdrvChild *c, BlockReopenQueue *q, return 0; } -static void bdrv_child_set_perm(BdrvChild *c, uint64_t perm, uint64_t shared) +static void bdrv_child_set_perm(BdrvChild *c) { c->has_backup_perm = false; - c->perm = perm; - c->shared_perm = shared; - bdrv_set_perm(c->bs); } @@ -2369,7 +2362,7 @@ int bdrv_child_try_set_perm(BdrvChild *c, uint64_t perm, uint64_t shared, return ret; } - bdrv_child_set_perm(c, perm, shared); + bdrv_child_set_perm(c); return 0; } From patchwork Fri Dec 18 15:12:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 11982435 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4A5FC4361B for ; Fri, 18 Dec 2020 15:18:17 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 29B0B23AFD for ; Fri, 18 Dec 2020 15:18:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 29B0B23AFD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:50528 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqHWK-0007G4-6Z for qemu-devel@archiver.kernel.org; Fri, 18 Dec 2020 10:18:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53614) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqHRO-0001dD-Bh for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:10 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:34432) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kqHRL-0005Hk-OX for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304387; 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=4Zt+p4pJebC79I3akP94SypsVPg1h4mDGUxrQPDOUrE=; b=im/JfSaR3JcLeLTXKBTx/ddFcuaSfFbmN9ixlP0NY11q9g2UQtPekn539DxztkyHSe0nEg 3jW1pdlJykftCvSGHUN14lRu2zZsSjEe8lb0rsCA6NhLPrGfXOBHDNrLe0uKKyeV1hlB/p aQH+zO8dm97UBt7wZ6XzKkUZMmTGn4k= 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-525-KzKBU7fLN-GyK80P-Wp_Jw-1; Fri, 18 Dec 2020 10:13:01 -0500 X-MC-Unique: KzKBU7fLN-GyK80P-Wp_Jw-1 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 2B0648030AD; Fri, 18 Dec 2020 15:13:00 +0000 (UTC) Received: from localhost (ovpn-114-84.ams2.redhat.com [10.36.114.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 92EB72DACE; Fri, 18 Dec 2020 15:12:59 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 04/30] block: drop tighten_restrictions Date: Fri, 18 Dec 2020 16:12:23 +0100 Message-Id: <20201218151249.715731-5-mreitz@redhat.com> In-Reply-To: <20201218151249.715731-1-mreitz@redhat.com> References: <20201218151249.715731-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Vladimir Sementsov-Ogievskiy The only users of this thing are: 1. bdrv_child_try_set_perm, to ignore failures on loosen restrictions 2. assertion in bdrv_replace_child 3. assertion in bdrv_inactivate_recurse Assertions are not enough reason for overcomplication the permission update system. So, look at bdrv_child_try_set_perm. We are interested in tighten_restrictions only on failure. But on failure this field is not reliable: we may fail in the middle of permission update, some nodes are not touched and we don't know should their permissions be tighten or not. So, we rely on the fact that if we loose restrictions on some node (or BdrvChild), we'll not tighten restriction in the whole subtree as part of this update (assertions 2 and 3 rely on this fact as well). And, if we rely on this fact anyway, we can just check it on top, and don't pass additional pointer through the whole recursive infrastructure. Note also, that further patches will fix real bugs in permission update system, so now is good time to simplify it, as a help for further refactorings. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20201106124241.16950-8-vsementsov@virtuozzo.com> [mreitz: Fixed rebase conflict] Signed-off-by: Max Reitz --- block.c | 89 +++++++++++---------------------------------------------- 1 file changed, 17 insertions(+), 72 deletions(-) diff --git a/block.c b/block.c index f66388b9ea..b57421a969 100644 --- a/block.c +++ b/block.c @@ -1900,8 +1900,7 @@ static int bdrv_fill_options(QDict **options, const char *filename, static int bdrv_child_check_perm(BdrvChild *c, BlockReopenQueue *q, uint64_t perm, uint64_t shared, - GSList *ignore_children, - bool *tighten_restrictions, Error **errp); + GSList *ignore_children, Error **errp); static void bdrv_child_abort_perm_update(BdrvChild *c); static void bdrv_child_set_perm(BdrvChild *c); @@ -1974,43 +1973,18 @@ static void bdrv_child_perm(BlockDriverState *bs, BlockDriverState *child_bs, * permissions of all its parents. This involves checking whether all necessary * permission changes to child nodes can be performed. * - * Will set *tighten_restrictions to true if and only if new permissions have to - * be taken or currently shared permissions are to be unshared. Otherwise, - * errors are not fatal as long as the caller accepts that the restrictions - * remain tighter than they need to be. The caller still has to abort the - * transaction. - * @tighten_restrictions cannot be used together with @q: When reopening, we may - * encounter fatal errors even though no restrictions are to be tightened. For - * example, changing a node from RW to RO will fail if the WRITE permission is - * to be kept. - * * A call to this function must always be followed by a call to bdrv_set_perm() * or bdrv_abort_perm_update(). */ static int bdrv_check_perm(BlockDriverState *bs, BlockReopenQueue *q, uint64_t cumulative_perms, uint64_t cumulative_shared_perms, - GSList *ignore_children, - bool *tighten_restrictions, Error **errp) + GSList *ignore_children, Error **errp) { BlockDriver *drv = bs->drv; BdrvChild *c; int ret; - assert(!q || !tighten_restrictions); - - if (tighten_restrictions) { - uint64_t current_perms, current_shared; - uint64_t added_perms, removed_shared_perms; - - bdrv_get_cumulative_perm(bs, ¤t_perms, ¤t_shared); - - added_perms = cumulative_perms & ~current_perms; - removed_shared_perms = current_shared & ~cumulative_shared_perms; - - *tighten_restrictions = added_perms || removed_shared_perms; - } - /* Write permissions never work with read-only images */ if ((cumulative_perms & (BLK_PERM_WRITE | BLK_PERM_WRITE_UNCHANGED)) && !bdrv_is_writable_after_reopen(bs, q)) @@ -2067,18 +2041,12 @@ static int bdrv_check_perm(BlockDriverState *bs, BlockReopenQueue *q, /* Check all children */ QLIST_FOREACH(c, &bs->children, next) { uint64_t cur_perm, cur_shared; - bool child_tighten_restr; bdrv_child_perm(bs, c->bs, c, c->role, q, cumulative_perms, cumulative_shared_perms, &cur_perm, &cur_shared); ret = bdrv_child_check_perm(c, q, cur_perm, cur_shared, ignore_children, - tighten_restrictions ? &child_tighten_restr - : NULL, errp); - if (tighten_restrictions) { - *tighten_restrictions |= child_tighten_restr; - } if (ret < 0) { return ret; } @@ -2201,22 +2169,18 @@ char *bdrv_perm_names(uint64_t perm) * set, the BdrvChild objects in this list are ignored in the calculations; * this allows checking permission updates for an existing reference. * - * See bdrv_check_perm() for the semantics of @tighten_restrictions. - * * Needs to be followed by a call to either bdrv_set_perm() or * bdrv_abort_perm_update(). */ static int bdrv_check_update_perm(BlockDriverState *bs, BlockReopenQueue *q, uint64_t new_used_perm, uint64_t new_shared_perm, GSList *ignore_children, - bool *tighten_restrictions, Error **errp) { BdrvChild *c; uint64_t cumulative_perms = new_used_perm; uint64_t cumulative_shared_perms = new_shared_perm; - assert(!q || !tighten_restrictions); /* There is no reason why anyone couldn't tolerate write_unchanged */ assert(new_shared_perm & BLK_PERM_WRITE_UNCHANGED); @@ -2230,10 +2194,6 @@ static int bdrv_check_update_perm(BlockDriverState *bs, BlockReopenQueue *q, char *user = bdrv_child_user_desc(c); char *perm_names = bdrv_perm_names(new_used_perm & ~c->shared_perm); - if (tighten_restrictions) { - *tighten_restrictions = true; - } - error_setg(errp, "Conflicts with use by %s as '%s', which does not " "allow '%s' on %s", user, c->name, perm_names, bdrv_get_node_name(c->bs)); @@ -2246,10 +2206,6 @@ static int bdrv_check_update_perm(BlockDriverState *bs, BlockReopenQueue *q, char *user = bdrv_child_user_desc(c); char *perm_names = bdrv_perm_names(c->perm & ~new_shared_perm); - if (tighten_restrictions) { - *tighten_restrictions = true; - } - error_setg(errp, "Conflicts with use by %s as '%s', which uses " "'%s' on %s", user, c->name, perm_names, bdrv_get_node_name(c->bs)); @@ -2263,21 +2219,19 @@ static int bdrv_check_update_perm(BlockDriverState *bs, BlockReopenQueue *q, } return bdrv_check_perm(bs, q, cumulative_perms, cumulative_shared_perms, - ignore_children, tighten_restrictions, errp); + ignore_children, errp); } /* Needs to be followed by a call to either bdrv_child_set_perm() or * bdrv_child_abort_perm_update(). */ static int bdrv_child_check_perm(BdrvChild *c, BlockReopenQueue *q, uint64_t perm, uint64_t shared, - GSList *ignore_children, - bool *tighten_restrictions, Error **errp) + GSList *ignore_children, Error **errp) { int ret; ignore_children = g_slist_prepend(g_slist_copy(ignore_children), c); - ret = bdrv_check_update_perm(c->bs, q, perm, shared, ignore_children, - tighten_restrictions, errp); + ret = bdrv_check_update_perm(c->bs, q, perm, shared, ignore_children, errp); g_slist_free(ignore_children); if (ret < 0) { @@ -2318,15 +2272,13 @@ static void bdrv_child_abort_perm_update(BdrvChild *c) bdrv_abort_perm_update(c->bs); } -static int bdrv_refresh_perms(BlockDriverState *bs, bool *tighten_restrictions, - Error **errp) +static int bdrv_refresh_perms(BlockDriverState *bs, Error **errp) { int ret; uint64_t perm, shared_perm; bdrv_get_cumulative_perm(bs, &perm, &shared_perm); - ret = bdrv_check_perm(bs, NULL, perm, shared_perm, NULL, - tighten_restrictions, errp); + ret = bdrv_check_perm(bs, NULL, perm, shared_perm, NULL, errp); if (ret < 0) { bdrv_abort_perm_update(bs); return ret; @@ -2341,13 +2293,12 @@ int bdrv_child_try_set_perm(BdrvChild *c, uint64_t perm, uint64_t shared, { Error *local_err = NULL; int ret; - bool tighten_restrictions; - ret = bdrv_child_check_perm(c, NULL, perm, shared, NULL, - &tighten_restrictions, &local_err); + ret = bdrv_child_check_perm(c, NULL, perm, shared, NULL, &local_err); if (ret < 0) { bdrv_child_abort_perm_update(c); - if (tighten_restrictions) { + if ((perm & ~c->perm) || (c->shared_perm & ~shared)) { + /* tighten permissions */ error_propagate(errp, local_err); } else { /* @@ -2649,15 +2600,12 @@ static void bdrv_replace_child(BdrvChild *child, BlockDriverState *new_bs) } if (old_bs) { - bool tighten_restrictions; - /* * Update permissions for old node. We're just taking a parent away, so * we're loosening restrictions. Errors of permission update are not * fatal in this case, ignore them. */ - bdrv_refresh_perms(old_bs, &tighten_restrictions, NULL); - assert(tighten_restrictions == false); + bdrv_refresh_perms(old_bs, NULL); /* When the parent requiring a non-default AioContext is removed, the * node moves back to the main AioContext */ @@ -2687,8 +2635,7 @@ BdrvChild *bdrv_root_attach_child(BlockDriverState *child_bs, Error *local_err = NULL; int ret; - ret = bdrv_check_update_perm(child_bs, NULL, perm, shared_perm, NULL, NULL, - errp); + ret = bdrv_check_update_perm(child_bs, NULL, perm, shared_perm, NULL, errp); if (ret < 0) { bdrv_abort_perm_update(child_bs); bdrv_unref(child_bs); @@ -3820,7 +3767,7 @@ int bdrv_reopen_multiple(BlockReopenQueue *bs_queue, Error **errp) QTAILQ_FOREACH(bs_entry, bs_queue, entry) { BDRVReopenState *state = &bs_entry->state; ret = bdrv_check_perm(state->bs, bs_queue, state->perm, - state->shared_perm, NULL, NULL, errp); + state->shared_perm, NULL, errp); if (ret < 0) { goto cleanup_perm; } @@ -3832,7 +3779,7 @@ int bdrv_reopen_multiple(BlockReopenQueue *bs_queue, Error **errp) bs_queue, state->perm, state->shared_perm, &nperm, &nshared); ret = bdrv_check_update_perm(state->new_backing_bs, NULL, - nperm, nshared, NULL, NULL, errp); + nperm, nshared, NULL, errp); if (ret < 0) { goto cleanup_perm; } @@ -4622,7 +4569,7 @@ static void bdrv_replace_node_common(BlockDriverState *from, /* Check whether the required permissions can be granted on @to, ignoring * all BdrvChild in @list so that they can't block themselves. */ - ret = bdrv_check_update_perm(to, NULL, perm, shared, list, NULL, errp); + ret = bdrv_check_update_perm(to, NULL, perm, shared, list, errp); if (ret < 0) { bdrv_abort_perm_update(to); goto out; @@ -5817,7 +5764,7 @@ int coroutine_fn bdrv_co_invalidate_cache(BlockDriverState *bs, Error **errp) */ if (bs->open_flags & BDRV_O_INACTIVE) { bs->open_flags &= ~BDRV_O_INACTIVE; - ret = bdrv_refresh_perms(bs, NULL, errp); + ret = bdrv_refresh_perms(bs, errp); if (ret < 0) { bs->open_flags |= BDRV_O_INACTIVE; return ret; @@ -5896,7 +5843,6 @@ static bool bdrv_has_bds_parent(BlockDriverState *bs, bool only_active) static int bdrv_inactivate_recurse(BlockDriverState *bs) { BdrvChild *child, *parent; - bool tighten_restrictions; int ret; if (!bs->drv) { @@ -5935,8 +5881,7 @@ static int bdrv_inactivate_recurse(BlockDriverState *bs) * We only tried to loosen restrictions, so errors are not fatal, ignore * them. */ - bdrv_refresh_perms(bs, &tighten_restrictions, NULL); - assert(tighten_restrictions == false); + bdrv_refresh_perms(bs, NULL); /* Recursively inactivate children */ QLIST_FOREACH(child, &bs->children, next) { From patchwork Fri Dec 18 15:12:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 11982449 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 53282C2BBCF for ; Fri, 18 Dec 2020 15:23:26 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 06BA723B2A for ; Fri, 18 Dec 2020 15:23:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 06BA723B2A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:39188 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqHbJ-0005o5-4R for qemu-devel@archiver.kernel.org; Fri, 18 Dec 2020 10:23:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53828) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqHRl-0002O7-2x for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:33 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:29709) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kqHRY-0005Lg-Hy for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304398; 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=Vxhts5e2n+UdsdcV0xw0bup7B4SRoxXIwLetgSH5hgM=; b=gCOYjpez9breIBsZN0PwtS+vTeDof/Xd0L7n36xZsTb/5DEYG8h44C3qKinrUZzi/uLNgy yrN1XOSyRPizQOOp/MSUP0oP2z3EMN1f2W5WUNs4LO/192t2/EeiC+9G0xc3+HaUUkl73W 1MLQnlGKrcJUcr3ALdDtAJ9rqJZ4tZQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-407-xP7HUCl7PCa3DsU-WbWrxQ-1; Fri, 18 Dec 2020 10:13:05 -0500 X-MC-Unique: xP7HUCl7PCa3DsU-WbWrxQ-1 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 0E7351005D44; Fri, 18 Dec 2020 15:13:04 +0000 (UTC) Received: from localhost (ovpn-114-84.ams2.redhat.com [10.36.114.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2F60F10016FF; Fri, 18 Dec 2020 15:13:02 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 05/30] block: simplify comment to BDRV_REQ_SERIALISING Date: Fri, 18 Dec 2020 16:12:24 +0100 Message-Id: <20201218151249.715731-6-mreitz@redhat.com> In-Reply-To: <20201218151249.715731-1-mreitz@redhat.com> References: <20201218151249.715731-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Vladimir Sementsov-Ogievskiy 1. BDRV_REQ_NO_SERIALISING doesn't exist already, don't mention it. 2. We are going to add one more user of BDRV_REQ_SERIALISING, so comment about backup becomes a bit confusing here. The use case in backup is documented in block/backup.c, so let's just drop duplication here. 3. The fact that BDRV_REQ_SERIALISING is only for write requests is omitted. Add a note. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Stefan Hajnoczi Reviewed-by: Alberto Garcia Message-Id: <20201021145859.11201-2-vsementsov@virtuozzo.com> Signed-off-by: Max Reitz --- include/block/block.h | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/include/block/block.h b/include/block/block.h index 5b81e33e94..a3f3dcc88f 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -63,16 +63,7 @@ typedef enum { * content. */ BDRV_REQ_WRITE_UNCHANGED = 0x40, - /* - * BDRV_REQ_SERIALISING forces request serialisation for writes. - * It is used to ensure that writes to the backing file of a backup process - * target cannot race with a read of the backup target that defers to the - * backing file. - * - * Note, that BDRV_REQ_SERIALISING is _not_ opposite in meaning to - * BDRV_REQ_NO_SERIALISING. A more descriptive name for the latter might be - * _DO_NOT_WAIT_FOR_SERIALISING, except that is too long. - */ + /* Forces request serialisation. Use only with write requests. */ BDRV_REQ_SERIALISING = 0x80, /* Execute the request only if the operation can be offloaded or otherwise From patchwork Fri Dec 18 15:12:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 11982431 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0B87C4361B for ; Fri, 18 Dec 2020 15:17:58 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 83BED23AFD for ; Fri, 18 Dec 2020 15:17:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 83BED23AFD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:49666 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqHW1-0006tc-E3 for qemu-devel@archiver.kernel.org; Fri, 18 Dec 2020 10:17:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53694) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqHRT-0001pL-3M for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:15 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:43827) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kqHRR-0005JF-Ed for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304392; 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=xJiEf52kBwjzkSm42TkiheUWTQr6Ww5uUJ9fkpn4mek=; b=dILsjvNYEHi2s5j7pAmrYlAZB56F35dIK6iYOYg64YoxVfHgYSjKnO4i+uNsYW9sBhVtpz PocbFj0QCxrNQX8jiZsRFv7vG5yYZzriskrAHmhdtLoioFNUOpULyPdE1wOyF3Lh939RcX 1SigPErTz6Eu2MItMKemVegE1JZhsKQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-30-oj5G4S-FObaZt_GVGcXawQ-1; Fri, 18 Dec 2020 10:13:08 -0500 X-MC-Unique: oj5G4S-FObaZt_GVGcXawQ-1 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 41A1180362E; Fri, 18 Dec 2020 15:13:06 +0000 (UTC) Received: from localhost (ovpn-114-84.ams2.redhat.com [10.36.114.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C14C710013C0; Fri, 18 Dec 2020 15:13:05 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 06/30] block/io.c: drop assertion on double waiting for request serialisation Date: Fri, 18 Dec 2020 16:12:25 +0100 Message-Id: <20201218151249.715731-7-mreitz@redhat.com> In-Reply-To: <20201218151249.715731-1-mreitz@redhat.com> References: <20201218151249.715731-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Vladimir Sementsov-Ogievskiy The comments states, that on misaligned request we should have already been waiting. But for bdrv_padding_rmw_read, we called bdrv_mark_request_serialising with align = request_alignment, and now we serialise with align = cluster_size. So we may have to wait again with larger alignment. Note, that the only user of BDRV_REQ_SERIALISING is backup which issues cluster-aligned requests, so seems the assertion should not fire for now. But it's wrong anyway. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Paolo Bonzini Message-Id: <20201021145859.11201-3-vsementsov@virtuozzo.com> Signed-off-by: Max Reitz --- block/io.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/block/io.c b/block/io.c index 24205f5168..27370107b2 100644 --- a/block/io.c +++ b/block/io.c @@ -1827,7 +1827,6 @@ bdrv_co_write_req_prepare(BdrvChild *child, int64_t offset, uint64_t bytes, BdrvTrackedRequest *req, int flags) { BlockDriverState *bs = child->bs; - bool waited; int64_t end_sector = DIV_ROUND_UP(offset + bytes, BDRV_SECTOR_SIZE); if (bs->read_only) { @@ -1839,15 +1838,7 @@ bdrv_co_write_req_prepare(BdrvChild *child, int64_t offset, uint64_t bytes, assert(!(flags & ~BDRV_REQ_MASK)); if (flags & BDRV_REQ_SERIALISING) { - waited = bdrv_mark_request_serialising(req, bdrv_get_cluster_size(bs)); - /* - * For a misaligned request we should have already waited earlier, - * because we come after bdrv_padding_rmw_read which must be called - * with the request already marked as serialising. - */ - assert(!waited || - (req->offset == req->overlap_offset && - req->bytes == req->overlap_bytes)); + bdrv_mark_request_serialising(req, bdrv_get_cluster_size(bs)); } else { bdrv_wait_serialising_requests(req); } From patchwork Fri Dec 18 15:12:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 11982429 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74B60C4361B for ; Fri, 18 Dec 2020 15:15:34 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 0C77B23AFD for ; Fri, 18 Dec 2020 15:15:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0C77B23AFD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:42500 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqHTg-0003p4-VO for qemu-devel@archiver.kernel.org; Fri, 18 Dec 2020 10:15:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53678) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqHRS-0001nb-Ev for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:14 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:26567) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kqHRQ-0005J7-Gq for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304391; 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=VjNjrx90XKG//IjNFwwul7DqKmA9bmAOojMsq5hElc8=; b=Uu4wlKgAbyLpuJiP6dMP+NXdumTp6I96inCFxxRKP6Ky6UTO8D/oxOByF2crgc1dIiex6R PwE/bbn+/58qdpFcdriKSq3H0/rqWxC87BGf0DK+2sB3Wqoc763Jyr7SvnNeMvzpeODWXk 1CaiwYZYLIdBmzpgOBeyb39OOaXoaEc= 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-172-swVfubwrPXm_Ek86nJHTnw-1; Fri, 18 Dec 2020 10:13:09 -0500 X-MC-Unique: swVfubwrPXm_Ek86nJHTnw-1 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 82663B8101; Fri, 18 Dec 2020 15:13:08 +0000 (UTC) Received: from localhost (ovpn-114-84.ams2.redhat.com [10.36.114.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 25F632C154; Fri, 18 Dec 2020 15:13:07 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 07/30] block/io: split out bdrv_find_conflicting_request Date: Fri, 18 Dec 2020 16:12:26 +0100 Message-Id: <20201218151249.715731-8-mreitz@redhat.com> In-Reply-To: <20201218151249.715731-1-mreitz@redhat.com> References: <20201218151249.715731-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Vladimir Sementsov-Ogievskiy To be reused in separate. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Stefan Hajnoczi Message-Id: <20201021145859.11201-4-vsementsov@virtuozzo.com> Signed-off-by: Max Reitz --- block/io.c | 71 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 30 deletions(-) diff --git a/block/io.c b/block/io.c index 27370107b2..640136b8bc 100644 --- a/block/io.c +++ b/block/io.c @@ -754,43 +754,54 @@ static bool tracked_request_overlaps(BdrvTrackedRequest *req, return true; } +/* Called with self->bs->reqs_lock held */ +static BdrvTrackedRequest * +bdrv_find_conflicting_request(BdrvTrackedRequest *self) +{ + BdrvTrackedRequest *req; + + QLIST_FOREACH(req, &self->bs->tracked_requests, list) { + if (req == self || (!req->serialising && !self->serialising)) { + continue; + } + if (tracked_request_overlaps(req, self->overlap_offset, + self->overlap_bytes)) + { + /* + * Hitting this means there was a reentrant request, for + * example, a block driver issuing nested requests. This must + * never happen since it means deadlock. + */ + assert(qemu_coroutine_self() != req->co); + + /* + * If the request is already (indirectly) waiting for us, or + * will wait for us as soon as it wakes up, then just go on + * (instead of producing a deadlock in the former case). + */ + if (!req->waiting_for) { + return req; + } + } + } + + return NULL; +} + static bool coroutine_fn bdrv_wait_serialising_requests_locked(BlockDriverState *bs, BdrvTrackedRequest *self) { BdrvTrackedRequest *req; - bool retry; bool waited = false; - do { - retry = false; - QLIST_FOREACH(req, &bs->tracked_requests, list) { - if (req == self || (!req->serialising && !self->serialising)) { - continue; - } - if (tracked_request_overlaps(req, self->overlap_offset, - self->overlap_bytes)) - { - /* Hitting this means there was a reentrant request, for - * example, a block driver issuing nested requests. This must - * never happen since it means deadlock. - */ - assert(qemu_coroutine_self() != req->co); - - /* If the request is already (indirectly) waiting for us, or - * will wait for us as soon as it wakes up, then just go on - * (instead of producing a deadlock in the former case). */ - if (!req->waiting_for) { - self->waiting_for = req; - qemu_co_queue_wait(&req->wait_queue, &bs->reqs_lock); - self->waiting_for = NULL; - retry = true; - waited = true; - break; - } - } - } - } while (retry); + while ((req = bdrv_find_conflicting_request(self))) { + self->waiting_for = req; + qemu_co_queue_wait(&req->wait_queue, &bs->reqs_lock); + self->waiting_for = NULL; + waited = true; + } + return waited; } From patchwork Fri Dec 18 15:12:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 11982439 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8BE6DC4361B for ; Fri, 18 Dec 2020 15:21:16 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 21D8023B09 for ; Fri, 18 Dec 2020 15:21:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 21D8023B09 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:59002 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqHZD-0002PG-4Y for qemu-devel@archiver.kernel.org; Fri, 18 Dec 2020 10:21:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53784) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqHRj-0002KI-T6 for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:31 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:58216) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kqHRT-0005KO-DQ for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304394; 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=9JlaYswQA0vvc45miU+Q8W6Iwdxog2uKkMMyy708v14=; b=GMkMdstkeF4unJGGn9hHryBJXbEWrSTMKEm/lLFCqa2mfh+nr41nulMNychtrsG+TTqsgI QLSUWoG74Ndwjn4iMwbgDI8EsoNyE8unogdPhLBVhEfdXuUJAqIDl/vSv7bFXB0Ut5E6ZM BPx8BZCLzUuLDbGNDfscfdO3TClZ8Cs= 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-239-helDwy9vO_KdZ8-qemTYvw-1; Fri, 18 Dec 2020 10:13:11 -0500 X-MC-Unique: helDwy9vO_KdZ8-qemTYvw-1 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 9F367B8102; Fri, 18 Dec 2020 15:13:10 +0000 (UTC) Received: from localhost (ovpn-114-84.ams2.redhat.com [10.36.114.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 43C3237A0; Fri, 18 Dec 2020 15:13:10 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 08/30] block/io: bdrv_wait_serialising_requests_locked: drop extra bs arg Date: Fri, 18 Dec 2020 16:12:27 +0100 Message-Id: <20201218151249.715731-9-mreitz@redhat.com> In-Reply-To: <20201218151249.715731-1-mreitz@redhat.com> References: <20201218151249.715731-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Vladimir Sementsov-Ogievskiy bs is linked in req, so no needs to pass it separately. Most of tracked-requests API doesn't have bs argument. Actually, after this patch only tracked_request_begin has it, but it's for purpose. While being here, also add a comment about what "_locked" is. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Stefan Hajnoczi Message-Id: <20201021145859.11201-5-vsementsov@virtuozzo.com> Signed-off-by: Max Reitz --- block/io.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/block/io.c b/block/io.c index 640136b8bc..d7015378a3 100644 --- a/block/io.c +++ b/block/io.c @@ -788,16 +788,16 @@ bdrv_find_conflicting_request(BdrvTrackedRequest *self) return NULL; } +/* Called with self->bs->reqs_lock held */ static bool coroutine_fn -bdrv_wait_serialising_requests_locked(BlockDriverState *bs, - BdrvTrackedRequest *self) +bdrv_wait_serialising_requests_locked(BdrvTrackedRequest *self) { BdrvTrackedRequest *req; bool waited = false; while ((req = bdrv_find_conflicting_request(self))) { self->waiting_for = req; - qemu_co_queue_wait(&req->wait_queue, &bs->reqs_lock); + qemu_co_queue_wait(&req->wait_queue, &self->bs->reqs_lock); self->waiting_for = NULL; waited = true; } @@ -821,7 +821,7 @@ bool bdrv_mark_request_serialising(BdrvTrackedRequest *req, uint64_t align) req->overlap_offset = MIN(req->overlap_offset, overlap_offset); req->overlap_bytes = MAX(req->overlap_bytes, overlap_bytes); - waited = bdrv_wait_serialising_requests_locked(bs, req); + waited = bdrv_wait_serialising_requests_locked(req); qemu_co_mutex_unlock(&bs->reqs_lock); return waited; } @@ -903,7 +903,7 @@ static bool coroutine_fn bdrv_wait_serialising_requests(BdrvTrackedRequest *self } qemu_co_mutex_lock(&bs->reqs_lock); - waited = bdrv_wait_serialising_requests_locked(bs, self); + waited = bdrv_wait_serialising_requests_locked(self); qemu_co_mutex_unlock(&bs->reqs_lock); return waited; From patchwork Fri Dec 18 15:12:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 11982443 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12DCAC4361B for ; Fri, 18 Dec 2020 15:21:39 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id AAD8A2395C for ; Fri, 18 Dec 2020 15:21:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AAD8A2395C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:60284 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqHZZ-0002v2-JG for qemu-devel@archiver.kernel.org; Fri, 18 Dec 2020 10:21:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53794) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqHRj-0002LK-LA for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:31 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:29708) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kqHRU-0005Kr-Op for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304396; 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=UIRyURj/PxrjA5uLEl5KoZWL4j+HjoCqB151bcjtbWE=; b=MR5XdjWc8FazzJJKO//wif4fK92Goo9izmkjGyRgOxI0kqR0hH5by+rxrU2XAVKjOViPSz ZQ9d4rAd+DUOYRLPYvjoPJ3M2jeQfc0AZ/3SxwCT6r9xurScHiEZ8BxHA9/xP8nKXfNmv7 /+yO7/97J0+nhWXDBO5Tt0KZRjt1kIY= 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-386-QgsQfkVGMjeCoaa2i44S1w-1; Fri, 18 Dec 2020 10:13:13 -0500 X-MC-Unique: QgsQfkVGMjeCoaa2i44S1w-1 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 B7AD8107ACE3; Fri, 18 Dec 2020 15:13:12 +0000 (UTC) Received: from localhost (ovpn-114-84.ams2.redhat.com [10.36.114.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5A87B5D9E4; Fri, 18 Dec 2020 15:13:12 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 09/30] block: bdrv_mark_request_serialising: split non-waiting function Date: Fri, 18 Dec 2020 16:12:28 +0100 Message-Id: <20201218151249.715731-10-mreitz@redhat.com> In-Reply-To: <20201218151249.715731-1-mreitz@redhat.com> References: <20201218151249.715731-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Vladimir Sementsov-Ogievskiy We'll need a separate function, which will only "mark" request serialising with specified align but not wait for conflicting requests. So, it will be like old bdrv_mark_request_serialising(), before merging bdrv_wait_serialising_requests_locked() into it. To reduce the possible mess, let's do the following: Public function that does both marking and waiting will be called bdrv_make_request_serialising, and private function which will only "mark" will be called tracked_request_set_serialising(). Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz Message-Id: <20201021145859.11201-6-vsementsov@virtuozzo.com> Signed-off-by: Max Reitz --- include/block/block_int.h | 3 ++- block/file-posix.c | 2 +- block/io.c | 35 +++++++++++++++++++++++------------ 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index 1eeafc118c..b9ef61fe4d 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -1060,7 +1060,8 @@ extern unsigned int bdrv_drain_all_count; void bdrv_apply_subtree_drain(BdrvChild *child, BlockDriverState *new_parent); void bdrv_unapply_subtree_drain(BdrvChild *child, BlockDriverState *old_parent); -bool coroutine_fn bdrv_mark_request_serialising(BdrvTrackedRequest *req, uint64_t align); +bool coroutine_fn bdrv_make_request_serialising(BdrvTrackedRequest *req, + uint64_t align); BdrvTrackedRequest *coroutine_fn bdrv_co_get_self_request(BlockDriverState *bs); int get_tmp_filename(char *filename, int size); diff --git a/block/file-posix.c b/block/file-posix.c index 9804681d5c..00cdaaa2d4 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2953,7 +2953,7 @@ raw_do_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int bytes, assert(bdrv_check_request(req->offset, req->bytes) == 0); - bdrv_mark_request_serialising(req, bs->bl.request_alignment); + bdrv_make_request_serialising(req, bs->bl.request_alignment); } #endif diff --git a/block/io.c b/block/io.c index d7015378a3..fadfed3ab8 100644 --- a/block/io.c +++ b/block/io.c @@ -805,15 +805,14 @@ bdrv_wait_serialising_requests_locked(BdrvTrackedRequest *self) return waited; } -bool bdrv_mark_request_serialising(BdrvTrackedRequest *req, uint64_t align) +/* Called with req->bs->reqs_lock held */ +static void tracked_request_set_serialising(BdrvTrackedRequest *req, + uint64_t align) { - BlockDriverState *bs = req->bs; int64_t overlap_offset = req->offset & ~(align - 1); uint64_t overlap_bytes = ROUND_UP(req->offset + req->bytes, align) - overlap_offset; - bool waited; - qemu_co_mutex_lock(&bs->reqs_lock); if (!req->serialising) { qatomic_inc(&req->bs->serialising_in_flight); req->serialising = true; @@ -821,9 +820,6 @@ bool bdrv_mark_request_serialising(BdrvTrackedRequest *req, uint64_t align) req->overlap_offset = MIN(req->overlap_offset, overlap_offset); req->overlap_bytes = MAX(req->overlap_bytes, overlap_bytes); - waited = bdrv_wait_serialising_requests_locked(req); - qemu_co_mutex_unlock(&bs->reqs_lock); - return waited; } /** @@ -909,6 +905,21 @@ static bool coroutine_fn bdrv_wait_serialising_requests(BdrvTrackedRequest *self return waited; } +bool coroutine_fn bdrv_make_request_serialising(BdrvTrackedRequest *req, + uint64_t align) +{ + bool waited; + + qemu_co_mutex_lock(&req->bs->reqs_lock); + + tracked_request_set_serialising(req, align); + waited = bdrv_wait_serialising_requests_locked(req); + + qemu_co_mutex_unlock(&req->bs->reqs_lock); + + return waited; +} + int bdrv_check_request(int64_t offset, int64_t bytes) { if (offset < 0 || bytes < 0) { @@ -1434,7 +1445,7 @@ static int coroutine_fn bdrv_aligned_preadv(BdrvChild *child, * with each other for the same cluster. For example, in copy-on-read * it ensures that the CoR read and write operations are atomic and * guest writes cannot interleave between them. */ - bdrv_mark_request_serialising(req, bdrv_get_cluster_size(bs)); + bdrv_make_request_serialising(req, bdrv_get_cluster_size(bs)); } else { bdrv_wait_serialising_requests(req); } @@ -1849,7 +1860,7 @@ bdrv_co_write_req_prepare(BdrvChild *child, int64_t offset, uint64_t bytes, assert(!(flags & ~BDRV_REQ_MASK)); if (flags & BDRV_REQ_SERIALISING) { - bdrv_mark_request_serialising(req, bdrv_get_cluster_size(bs)); + bdrv_make_request_serialising(req, bdrv_get_cluster_size(bs)); } else { bdrv_wait_serialising_requests(req); } @@ -2015,7 +2026,7 @@ static int coroutine_fn bdrv_co_do_zero_pwritev(BdrvChild *child, padding = bdrv_init_padding(bs, offset, bytes, &pad); if (padding) { - bdrv_mark_request_serialising(req, align); + bdrv_make_request_serialising(req, align); bdrv_padding_rmw_read(child, req, &pad, true); @@ -2129,7 +2140,7 @@ int coroutine_fn bdrv_co_pwritev_part(BdrvChild *child, } if (bdrv_pad_request(bs, &qiov, &qiov_offset, &offset, &bytes, &pad)) { - bdrv_mark_request_serialising(&req, align); + bdrv_make_request_serialising(&req, align); bdrv_padding_rmw_read(child, &req, &pad, false); } @@ -3250,7 +3261,7 @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child, int64_t offset, bool exact, * new area, we need to make sure that no write requests are made to it * concurrently or they might be overwritten by preallocation. */ if (new_bytes) { - bdrv_mark_request_serialising(&req, 1); + bdrv_make_request_serialising(&req, 1); } if (bs->read_only) { error_setg(errp, "Image is read-only"); From patchwork Fri Dec 18 15:12:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 11982441 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD869C2BBCF for ; Fri, 18 Dec 2020 15:21:16 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 1F6A42395C for ; Fri, 18 Dec 2020 15:21:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1F6A42395C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:59004 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqHZD-0002PL-30 for qemu-devel@archiver.kernel.org; Fri, 18 Dec 2020 10:21:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53816) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqHRk-0002Mv-Ln for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:32 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:38629) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kqHRX-0005M9-Ty for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304399; 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=ssTocPi+hsLdcjxpQrjq4t7dzRnf2X0D8JBuOL+aHWw=; b=YzMPY52oGtraOLHVa0bymJYWBvZM9ymLRwDOm+IYKtMO/MMMwjlMoFHUIyZWnwEqIJUYaX QI1Bmb8BABG09Chb0eqZ4heyh2FUZb26GiJ0Os01H9cj+NohTxSNTYB2g8olXCIKukMYTU 7EchXNgW4Ljz3fe4JWNgAyU6qQ7fP5Y= 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-501-fqlYeJ5NN5G3mS_V64BdYg-1; Fri, 18 Dec 2020 10:13:16 -0500 X-MC-Unique: fqlYeJ5NN5G3mS_V64BdYg-1 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 0498A803621; Fri, 18 Dec 2020 15:13:15 +0000 (UTC) Received: from localhost (ovpn-114-84.ams2.redhat.com [10.36.114.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 95CB510013C0; Fri, 18 Dec 2020 15:13:14 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 10/30] block: introduce BDRV_REQ_NO_WAIT flag Date: Fri, 18 Dec 2020 16:12:29 +0100 Message-Id: <20201218151249.715731-11-mreitz@redhat.com> In-Reply-To: <20201218151249.715731-1-mreitz@redhat.com> References: <20201218151249.715731-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Vladimir Sementsov-Ogievskiy Add flag to make serialising request no wait: if there are conflicting requests, just return error immediately. It's will be used in upcoming preallocate filter. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz Message-Id: <20201021145859.11201-7-vsementsov@virtuozzo.com> Signed-off-by: Max Reitz --- include/block/block.h | 9 ++++++++- block/io.c | 11 ++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/include/block/block.h b/include/block/block.h index a3f3dcc88f..a193545b6a 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -77,8 +77,15 @@ typedef enum { * written to qiov parameter which may be NULL. */ BDRV_REQ_PREFETCH = 0x200, + + /* + * If we need to wait for other requests, just fail immediately. Used + * only together with BDRV_REQ_SERIALISING. + */ + BDRV_REQ_NO_WAIT = 0x400, + /* Mask of valid flags */ - BDRV_REQ_MASK = 0x3ff, + BDRV_REQ_MASK = 0x7ff, } BdrvRequestFlags; typedef struct BlockSizes { diff --git a/block/io.c b/block/io.c index fadfed3ab8..95b1c56c06 100644 --- a/block/io.c +++ b/block/io.c @@ -1858,9 +1858,18 @@ bdrv_co_write_req_prepare(BdrvChild *child, int64_t offset, uint64_t bytes, assert(!(bs->open_flags & BDRV_O_INACTIVE)); assert((bs->open_flags & BDRV_O_NO_IO) == 0); assert(!(flags & ~BDRV_REQ_MASK)); + assert(!((flags & BDRV_REQ_NO_WAIT) && !(flags & BDRV_REQ_SERIALISING))); if (flags & BDRV_REQ_SERIALISING) { - bdrv_make_request_serialising(req, bdrv_get_cluster_size(bs)); + QEMU_LOCK_GUARD(&bs->reqs_lock); + + tracked_request_set_serialising(req, bdrv_get_cluster_size(bs)); + + if ((flags & BDRV_REQ_NO_WAIT) && bdrv_find_conflicting_request(req)) { + return -EBUSY; + } + + bdrv_wait_serialising_requests_locked(req); } else { bdrv_wait_serialising_requests(req); } From patchwork Fri Dec 18 15:12:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 11982447 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86145C4361B for ; Fri, 18 Dec 2020 15:23:25 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 1C41C23B2A for ; Fri, 18 Dec 2020 15:23:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1C41C23B2A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:39120 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqHbI-0005mR-5B for qemu-devel@archiver.kernel.org; Fri, 18 Dec 2020 10:23:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53842) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqHRl-0002P9-L9 for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:33 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:51245) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kqHRY-0005Mb-Ne for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304400; 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=SMA9/l+fvoL9xbJXJhENML8DdN9ZjKIsDJEXEF7PAFI=; b=NHHc5cJvvqW4FhfOiR6crZQ+/uSEzROzn9pSXv9hmdwVYkZ5CrIrPhwXlCJWEwEsfBwxtV AKgksGhTNwCbWa4FJVuQHD2LgNDZQ9OZQgM4IJSSozcrTvIPeD/WhNQPysuZSzLADbCNVW WGhGv05wzB5Ha7bjnZVqCpywzJSN/aw= 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-1-YcEcPmpvMgKTa4HPZuOReA-1; Fri, 18 Dec 2020 10:13:18 -0500 X-MC-Unique: YcEcPmpvMgKTa4HPZuOReA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1A52D803626; Fri, 18 Dec 2020 15:13:17 +0000 (UTC) Received: from localhost (ovpn-114-84.ams2.redhat.com [10.36.114.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B3D2C17577; Fri, 18 Dec 2020 15:13:16 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 11/30] block: bdrv_check_perm(): process children anyway Date: Fri, 18 Dec 2020 16:12:30 +0100 Message-Id: <20201218151249.715731-12-mreitz@redhat.com> In-Reply-To: <20201218151249.715731-1-mreitz@redhat.com> References: <20201218151249.715731-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Vladimir Sementsov-Ogievskiy Do generic processing even for drivers which define .bdrv_check_perm handler. It's needed for further preallocate filter: it will need to do additional action on bdrv_check_perm, but don't want to reimplement generic logic. The patch doesn't change existing behaviour: the only driver that implements bdrv_check_perm is file-posix, but it never has any children. Also, bdrv_set_perm() don't stop processing if driver has .bdrv_set_perm handler as well. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20201021145859.11201-8-vsementsov@virtuozzo.com> Reviewed-by: Max Reitz Signed-off-by: Max Reitz --- block.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/block.c b/block.c index b57421a969..64412ee7de 100644 --- a/block.c +++ b/block.c @@ -2028,8 +2028,11 @@ static int bdrv_check_perm(BlockDriverState *bs, BlockReopenQueue *q, } if (drv->bdrv_check_perm) { - return drv->bdrv_check_perm(bs, cumulative_perms, - cumulative_shared_perms, errp); + ret = drv->bdrv_check_perm(bs, cumulative_perms, + cumulative_shared_perms, errp); + if (ret < 0) { + return ret; + } } /* Drivers that never have children can omit .bdrv_child_perm() */ From patchwork Fri Dec 18 15:12:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 11982465 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5742C4361B for ; Fri, 18 Dec 2020 15:27:02 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 0E92423B54 for ; Fri, 18 Dec 2020 15:27:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0E92423B54 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:51294 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqHem-0002Mr-Sl for qemu-devel@archiver.kernel.org; Fri, 18 Dec 2020 10:27:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54008) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqHRr-0002e5-P5 for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:40 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:32921) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kqHRf-0005Oi-5L for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304406; 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=5pMrRLW1pNIL8Mvj5t1VwJcCti4VoRFw2mGD2tv12t4=; b=Ph73k/SXA2VB876v4sJQWLoWNEVbPfcjClL5n2TZZf34jgj3ZiIzumVgu0UNqQKShkDYGi WKB/SMf9o0Tjbj8uRRTVIcdjEvMrN2RVo0yTkLOCRPKCcmtioxm9davXPZeV973mF9BOYc OZLU4JUEZoCNedHkNL5TuhM0j810Ypg= 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-567-E3j_ji-0OyCH_KXAtyaf0Q-1; Fri, 18 Dec 2020 10:13:20 -0500 X-MC-Unique: E3j_ji-0OyCH_KXAtyaf0Q-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 831578030A1; Fri, 18 Dec 2020 15:13:19 +0000 (UTC) Received: from localhost (ovpn-114-84.ams2.redhat.com [10.36.114.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C20D85C1C5; Fri, 18 Dec 2020 15:13:18 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 12/30] block: introduce preallocate filter Date: Fri, 18 Dec 2020 16:12:31 +0100 Message-Id: <20201218151249.715731-13-mreitz@redhat.com> In-Reply-To: <20201218151249.715731-1-mreitz@redhat.com> References: <20201218151249.715731-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Vladimir Sementsov-Ogievskiy It's intended to be inserted between format and protocol nodes to preallocate additional space (expanding protocol file) on writes crossing EOF. It improves performance for file-systems with slow allocation. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20201021145859.11201-9-vsementsov@virtuozzo.com> Reviewed-by: Max Reitz [mreitz: Two comment fixes, and bumped the version from 5.2 to 6.0] Signed-off-by: Max Reitz --- docs/system/qemu-block-drivers.rst.inc | 26 ++ qapi/block-core.json | 20 +- block/preallocate.c | 559 +++++++++++++++++++++++++ block/meson.build | 1 + 4 files changed, 605 insertions(+), 1 deletion(-) create mode 100644 block/preallocate.c diff --git a/docs/system/qemu-block-drivers.rst.inc b/docs/system/qemu-block-drivers.rst.inc index b052a6d14e..60a064b232 100644 --- a/docs/system/qemu-block-drivers.rst.inc +++ b/docs/system/qemu-block-drivers.rst.inc @@ -952,3 +952,29 @@ on host and see if there are locks held by the QEMU process on the image file. More than one byte could be locked by the QEMU instance, each byte of which reflects a particular permission that is acquired or protected by the running block driver. + +Filter drivers +~~~~~~~~~~~~~~ + +QEMU supports several filter drivers, which don't store any data, but perform +some additional tasks, hooking io requests. + +.. program:: filter-drivers +.. option:: preallocate + + The preallocate filter driver is intended to be inserted between format + and protocol nodes and preallocates some additional space + (expanding the protocol file) when writing past the file’s end. This can be + useful for file-systems with slow allocation. + + Supported options: + + .. program:: preallocate + .. option:: prealloc-align + + On preallocation, align the file length to this value (in bytes), default 1M. + + .. program:: preallocate + .. option:: prealloc-size + + How much to preallocate (in bytes), default 128M. diff --git a/qapi/block-core.json b/qapi/block-core.json index 04c5196e59..3484986d1c 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2829,7 +2829,7 @@ 'cloop', 'compress', 'copy-on-read', 'dmg', 'file', 'ftp', 'ftps', 'gluster', 'host_cdrom', 'host_device', 'http', 'https', 'iscsi', 'luks', 'nbd', 'nfs', 'null-aio', 'null-co', 'nvme', 'parallels', - 'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'rbd', + 'preallocate', 'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'rbd', { 'name': 'replication', 'if': 'defined(CONFIG_REPLICATION)' }, 'sheepdog', 'ssh', 'throttle', 'vdi', 'vhdx', 'vmdk', 'vpc', 'vvfat' ] } @@ -3098,6 +3098,23 @@ 'data': { 'aes': 'QCryptoBlockOptionsQCow', 'luks': 'QCryptoBlockOptionsLUKS'} } +## +# @BlockdevOptionsPreallocate: +# +# Filter driver intended to be inserted between format and protocol node +# and do preallocation in protocol node on write. +# +# @prealloc-align: on preallocation, align file length to this number, +# default 1048576 (1M) +# +# @prealloc-size: how much to preallocate, default 134217728 (128M) +# +# Since: 6.0 +## +{ 'struct': 'BlockdevOptionsPreallocate', + 'base': 'BlockdevOptionsGenericFormat', + 'data': { '*prealloc-align': 'int', '*prealloc-size': 'int' } } + ## # @BlockdevOptionsQcow2: # @@ -4006,6 +4023,7 @@ 'null-co': 'BlockdevOptionsNull', 'nvme': 'BlockdevOptionsNVMe', 'parallels': 'BlockdevOptionsGenericFormat', + 'preallocate':'BlockdevOptionsPreallocate', 'qcow2': 'BlockdevOptionsQcow2', 'qcow': 'BlockdevOptionsQcow', 'qed': 'BlockdevOptionsGenericCOWFormat', diff --git a/block/preallocate.c b/block/preallocate.c new file mode 100644 index 0000000000..b619206304 --- /dev/null +++ b/block/preallocate.c @@ -0,0 +1,559 @@ +/* + * preallocate filter driver + * + * The driver performs preallocate operation: it is injected above + * some node, and before each write over EOF it does additional preallocating + * write-zeroes request. + * + * Copyright (c) 2020 Virtuozzo International GmbH. + * + * Author: + * Sementsov-Ogievskiy Vladimir + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "qemu/osdep.h" + +#include "qapi/error.h" +#include "qemu/module.h" +#include "qemu/option.h" +#include "qemu/units.h" +#include "block/block_int.h" + + +typedef struct PreallocateOpts { + int64_t prealloc_size; + int64_t prealloc_align; +} PreallocateOpts; + +typedef struct BDRVPreallocateState { + PreallocateOpts opts; + + /* + * Track real data end, to crop preallocation on close. If < 0 the status is + * unknown. + * + * @data_end is a maximum of file size on open (or when we get write/resize + * permissions) and all write request ends after it. So it's safe to + * truncate to data_end if it is valid. + */ + int64_t data_end; + + /* + * Start of trailing preallocated area which reads as zero. May be smaller + * than data_end, if user does over-EOF write zero operation. If < 0 the + * status is unknown. + * + * If both @zero_start and @file_end are valid, the region + * [@zero_start, @file_end) is known to be preallocated zeroes. If @file_end + * is not valid, @zero_start doesn't make much sense. + */ + int64_t zero_start; + + /* + * Real end of file. Actually the cache for bdrv_getlength(bs->file->bs), + * to avoid extra lseek() calls on each write operation. If < 0 the status + * is unknown. + */ + int64_t file_end; + + /* + * All three states @data_end, @zero_start and @file_end are guaranteed to + * be invalid (< 0) when we don't have both exclusive BLK_PERM_RESIZE and + * BLK_PERM_WRITE permissions on file child. + */ +} BDRVPreallocateState; + +#define PREALLOCATE_OPT_PREALLOC_ALIGN "prealloc-align" +#define PREALLOCATE_OPT_PREALLOC_SIZE "prealloc-size" +static QemuOptsList runtime_opts = { + .name = "preallocate", + .head = QTAILQ_HEAD_INITIALIZER(runtime_opts.head), + .desc = { + { + .name = PREALLOCATE_OPT_PREALLOC_ALIGN, + .type = QEMU_OPT_SIZE, + .help = "on preallocation, align file length to this number, " + "default 1M", + }, + { + .name = PREALLOCATE_OPT_PREALLOC_SIZE, + .type = QEMU_OPT_SIZE, + .help = "how much to preallocate, default 128M", + }, + { /* end of list */ } + }, +}; + +static bool preallocate_absorb_opts(PreallocateOpts *dest, QDict *options, + BlockDriverState *child_bs, Error **errp) +{ + QemuOpts *opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); + + if (!qemu_opts_absorb_qdict(opts, options, errp)) { + return false; + } + + dest->prealloc_align = + qemu_opt_get_size(opts, PREALLOCATE_OPT_PREALLOC_ALIGN, 1 * MiB); + dest->prealloc_size = + qemu_opt_get_size(opts, PREALLOCATE_OPT_PREALLOC_SIZE, 128 * MiB); + + qemu_opts_del(opts); + + if (!QEMU_IS_ALIGNED(dest->prealloc_align, BDRV_SECTOR_SIZE)) { + error_setg(errp, "prealloc-align parameter of preallocate filter " + "is not aligned to %llu", BDRV_SECTOR_SIZE); + return false; + } + + if (!QEMU_IS_ALIGNED(dest->prealloc_align, + child_bs->bl.request_alignment)) { + error_setg(errp, "prealloc-align parameter of preallocate filter " + "is not aligned to underlying node request alignment " + "(%" PRIi32 ")", child_bs->bl.request_alignment); + return false; + } + + return true; +} + +static int preallocate_open(BlockDriverState *bs, QDict *options, int flags, + Error **errp) +{ + BDRVPreallocateState *s = bs->opaque; + + /* + * s->data_end and friends should be initialized on permission update. + * For this to work, mark them invalid. + */ + s->file_end = s->zero_start = s->data_end = -EINVAL; + + bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds, + BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, + false, errp); + if (!bs->file) { + return -EINVAL; + } + + if (!preallocate_absorb_opts(&s->opts, options, bs->file->bs, errp)) { + return -EINVAL; + } + + bs->supported_write_flags = BDRV_REQ_WRITE_UNCHANGED | + (BDRV_REQ_FUA & bs->file->bs->supported_write_flags); + + bs->supported_zero_flags = BDRV_REQ_WRITE_UNCHANGED | + ((BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK) & + bs->file->bs->supported_zero_flags); + + return 0; +} + +static void preallocate_close(BlockDriverState *bs) +{ + int ret; + BDRVPreallocateState *s = bs->opaque; + + if (s->data_end < 0) { + return; + } + + if (s->file_end < 0) { + s->file_end = bdrv_getlength(bs->file->bs); + if (s->file_end < 0) { + return; + } + } + + if (s->data_end < s->file_end) { + ret = bdrv_truncate(bs->file, s->data_end, true, PREALLOC_MODE_OFF, 0, + NULL); + s->file_end = ret < 0 ? ret : s->data_end; + } +} + + +/* + * Handle reopen. + * + * We must implement reopen handlers, otherwise reopen just don't work. Handle + * new options and don't care about preallocation state, as it is handled in + * set/check permission handlers. + */ + +static int preallocate_reopen_prepare(BDRVReopenState *reopen_state, + BlockReopenQueue *queue, Error **errp) +{ + PreallocateOpts *opts = g_new0(PreallocateOpts, 1); + + if (!preallocate_absorb_opts(opts, reopen_state->options, + reopen_state->bs->file->bs, errp)) { + g_free(opts); + return -EINVAL; + } + + reopen_state->opaque = opts; + + return 0; +} + +static void preallocate_reopen_commit(BDRVReopenState *state) +{ + BDRVPreallocateState *s = state->bs->opaque; + + s->opts = *(PreallocateOpts *)state->opaque; + + g_free(state->opaque); + state->opaque = NULL; +} + +static void preallocate_reopen_abort(BDRVReopenState *state) +{ + g_free(state->opaque); + state->opaque = NULL; +} + +static coroutine_fn int preallocate_co_preadv_part( + BlockDriverState *bs, uint64_t offset, uint64_t bytes, + QEMUIOVector *qiov, size_t qiov_offset, int flags) +{ + return bdrv_co_preadv_part(bs->file, offset, bytes, qiov, qiov_offset, + flags); +} + +static int coroutine_fn preallocate_co_pdiscard(BlockDriverState *bs, + int64_t offset, int bytes) +{ + return bdrv_co_pdiscard(bs->file, offset, bytes); +} + +static bool can_write_resize(uint64_t perm) +{ + return (perm & BLK_PERM_WRITE) && (perm & BLK_PERM_RESIZE); +} + +static bool has_prealloc_perms(BlockDriverState *bs) +{ + BDRVPreallocateState *s = bs->opaque; + + if (can_write_resize(bs->file->perm)) { + assert(!(bs->file->shared_perm & BLK_PERM_WRITE)); + assert(!(bs->file->shared_perm & BLK_PERM_RESIZE)); + return true; + } + + assert(s->data_end < 0); + assert(s->zero_start < 0); + assert(s->file_end < 0); + return false; +} + +/* + * Call on each write. Returns true if @want_merge_zero is true and the region + * [offset, offset + bytes) is zeroed (as a result of this call or earlier + * preallocation). + * + * want_merge_zero is used to merge write-zero request with preallocation in + * one bdrv_co_pwrite_zeroes() call. + */ +static bool coroutine_fn handle_write(BlockDriverState *bs, int64_t offset, + int64_t bytes, bool want_merge_zero) +{ + BDRVPreallocateState *s = bs->opaque; + int64_t end = offset + bytes; + int64_t prealloc_start, prealloc_end; + int ret; + + if (!has_prealloc_perms(bs)) { + /* We don't have state neither should try to recover it */ + return false; + } + + if (s->data_end < 0) { + s->data_end = bdrv_getlength(bs->file->bs); + if (s->data_end < 0) { + return false; + } + + if (s->file_end < 0) { + s->file_end = s->data_end; + } + } + + if (end <= s->data_end) { + return false; + } + + /* We have valid s->data_end, and request writes beyond it. */ + + s->data_end = end; + if (s->zero_start < 0 || !want_merge_zero) { + s->zero_start = end; + } + + if (s->file_end < 0) { + s->file_end = bdrv_getlength(bs->file->bs); + if (s->file_end < 0) { + return false; + } + } + + /* Now s->data_end, s->zero_start and s->file_end are valid. */ + + if (end <= s->file_end) { + /* No preallocation needed. */ + return want_merge_zero && offset >= s->zero_start; + } + + /* Now we want new preallocation, as request writes beyond s->file_end. */ + + prealloc_start = want_merge_zero ? MIN(offset, s->file_end) : s->file_end; + prealloc_end = QEMU_ALIGN_UP(end + s->opts.prealloc_size, + s->opts.prealloc_align); + + ret = bdrv_co_pwrite_zeroes( + bs->file, prealloc_start, prealloc_end - prealloc_start, + BDRV_REQ_NO_FALLBACK | BDRV_REQ_SERIALISING | BDRV_REQ_NO_WAIT); + if (ret < 0) { + s->file_end = ret; + return false; + } + + s->file_end = prealloc_end; + return want_merge_zero; +} + +static int coroutine_fn preallocate_co_pwrite_zeroes(BlockDriverState *bs, + int64_t offset, int bytes, BdrvRequestFlags flags) +{ + bool want_merge_zero = + !(flags & ~(BDRV_REQ_ZERO_WRITE | BDRV_REQ_NO_FALLBACK)); + if (handle_write(bs, offset, bytes, want_merge_zero)) { + return 0; + } + + return bdrv_co_pwrite_zeroes(bs->file, offset, bytes, flags); +} + +static coroutine_fn int preallocate_co_pwritev_part(BlockDriverState *bs, + uint64_t offset, + uint64_t bytes, + QEMUIOVector *qiov, + size_t qiov_offset, + int flags) +{ + handle_write(bs, offset, bytes, false); + + return bdrv_co_pwritev_part(bs->file, offset, bytes, qiov, qiov_offset, + flags); +} + +static int coroutine_fn +preallocate_co_truncate(BlockDriverState *bs, int64_t offset, + bool exact, PreallocMode prealloc, + BdrvRequestFlags flags, Error **errp) +{ + ERRP_GUARD(); + BDRVPreallocateState *s = bs->opaque; + int ret; + + if (s->data_end >= 0 && offset > s->data_end) { + if (s->file_end < 0) { + s->file_end = bdrv_getlength(bs->file->bs); + if (s->file_end < 0) { + error_setg(errp, "failed to get file length"); + return s->file_end; + } + } + + if (prealloc == PREALLOC_MODE_FALLOC) { + /* + * If offset <= s->file_end, the task is already done, just + * update s->data_end, to move part of "filter preallocation" + * to "preallocation requested by user". + * Otherwise just proceed to preallocate missing part. + */ + if (offset <= s->file_end) { + s->data_end = offset; + return 0; + } + } else { + /* + * We have to drop our preallocation, to + * - avoid "Cannot use preallocation for shrinking files" in + * case of offset < file_end + * - give PREALLOC_MODE_OFF a chance to keep small disk + * usage + * - give PREALLOC_MODE_FULL a chance to actually write the + * whole region as user expects + */ + if (s->file_end > s->data_end) { + ret = bdrv_co_truncate(bs->file, s->data_end, true, + PREALLOC_MODE_OFF, 0, errp); + if (ret < 0) { + s->file_end = ret; + error_prepend(errp, "preallocate-filter: failed to drop " + "write-zero preallocation: "); + return ret; + } + s->file_end = s->data_end; + } + } + + s->data_end = offset; + } + + ret = bdrv_co_truncate(bs->file, offset, exact, prealloc, flags, errp); + if (ret < 0) { + s->file_end = s->zero_start = s->data_end = ret; + return ret; + } + + if (has_prealloc_perms(bs)) { + s->file_end = s->zero_start = s->data_end = offset; + } + return 0; +} + +static int coroutine_fn preallocate_co_flush(BlockDriverState *bs) +{ + return bdrv_co_flush(bs->file->bs); +} + +static int64_t preallocate_getlength(BlockDriverState *bs) +{ + int64_t ret; + BDRVPreallocateState *s = bs->opaque; + + if (s->data_end >= 0) { + return s->data_end; + } + + ret = bdrv_getlength(bs->file->bs); + + if (has_prealloc_perms(bs)) { + s->file_end = s->zero_start = s->data_end = ret; + } + + return ret; +} + +static int preallocate_check_perm(BlockDriverState *bs, + uint64_t perm, uint64_t shared, Error **errp) +{ + BDRVPreallocateState *s = bs->opaque; + + if (s->data_end >= 0 && !can_write_resize(perm)) { + /* + * Lose permissions. + * We should truncate in check_perm, as in set_perm bs->file->perm will + * be already changed, and we should not violate it. + */ + if (s->file_end < 0) { + s->file_end = bdrv_getlength(bs->file->bs); + if (s->file_end < 0) { + error_setg(errp, "Failed to get file length"); + return s->file_end; + } + } + + if (s->data_end < s->file_end) { + int ret = bdrv_truncate(bs->file, s->data_end, true, + PREALLOC_MODE_OFF, 0, NULL); + if (ret < 0) { + error_setg(errp, "Failed to drop preallocation"); + s->file_end = ret; + return ret; + } + s->file_end = s->data_end; + } + } + + return 0; +} + +static void preallocate_set_perm(BlockDriverState *bs, + uint64_t perm, uint64_t shared) +{ + BDRVPreallocateState *s = bs->opaque; + + if (can_write_resize(perm)) { + if (s->data_end < 0) { + s->data_end = s->file_end = s->zero_start = + bdrv_getlength(bs->file->bs); + } + } else { + /* + * We drop our permissions, as well as allow shared + * permissions (see preallocate_child_perm), anyone will be able to + * change the child, so mark all states invalid. We'll regain control if + * get good permissions back. + */ + s->data_end = s->file_end = s->zero_start = -EINVAL; + } +} + +static void preallocate_child_perm(BlockDriverState *bs, BdrvChild *c, + BdrvChildRole role, BlockReopenQueue *reopen_queue, + uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared) +{ + bdrv_default_perms(bs, c, role, reopen_queue, perm, shared, nperm, nshared); + + if (can_write_resize(perm)) { + /* This should come by default, but let's enforce: */ + *nperm |= BLK_PERM_WRITE | BLK_PERM_RESIZE; + + /* + * Don't share, to keep our states s->file_end, s->data_end and + * s->zero_start valid. + */ + *nshared &= ~(BLK_PERM_WRITE | BLK_PERM_RESIZE); + } +} + +BlockDriver bdrv_preallocate_filter = { + .format_name = "preallocate", + .instance_size = sizeof(BDRVPreallocateState), + + .bdrv_getlength = preallocate_getlength, + .bdrv_open = preallocate_open, + .bdrv_close = preallocate_close, + + .bdrv_reopen_prepare = preallocate_reopen_prepare, + .bdrv_reopen_commit = preallocate_reopen_commit, + .bdrv_reopen_abort = preallocate_reopen_abort, + + .bdrv_co_preadv_part = preallocate_co_preadv_part, + .bdrv_co_pwritev_part = preallocate_co_pwritev_part, + .bdrv_co_pwrite_zeroes = preallocate_co_pwrite_zeroes, + .bdrv_co_pdiscard = preallocate_co_pdiscard, + .bdrv_co_flush = preallocate_co_flush, + .bdrv_co_truncate = preallocate_co_truncate, + + .bdrv_check_perm = preallocate_check_perm, + .bdrv_set_perm = preallocate_set_perm, + .bdrv_child_perm = preallocate_child_perm, + + .has_variable_length = true, + .is_filter = true, +}; + +static void bdrv_preallocate_init(void) +{ + bdrv_register(&bdrv_preallocate_filter); +} + +block_init(bdrv_preallocate_init); diff --git a/block/meson.build b/block/meson.build index 5dcc1e5cce..7595d86c41 100644 --- a/block/meson.build +++ b/block/meson.build @@ -12,6 +12,7 @@ block_ss.add(files( 'block-copy.c', 'commit.c', 'copy-on-read.c', + 'preallocate.c', 'create.c', 'crypto.c', 'dirty-bitmap.c', From patchwork Fri Dec 18 15:12:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 11982437 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26A9BC4361B for ; Fri, 18 Dec 2020 15:18:49 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id B7BED23AFD for ; Fri, 18 Dec 2020 15:18:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B7BED23AFD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:52280 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqHWp-0007xq-Ca for qemu-devel@archiver.kernel.org; Fri, 18 Dec 2020 10:18:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53900) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqHRo-0002Up-1T for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:36 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:59494) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kqHRd-0005Nl-PK for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304405; 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=BuUBGlzQeQc562DDY6TzCsCi51Tehdy4f8SYetPcnqw=; b=FwAv3IYenCQy4XryZ73OpZDtddvURYh8nS1vwR+sjKZ0MohYr306wPPLFCh7qPESU5kW4P knBmYILnCdLYRTr73l6s0bcin4v8XdyOgBExCfseTpujf50V5SxhvVFfCIUzD/TpXHDzdV D6PTWu6k9js+eiTzt+qSx0vIlKv0HXo= 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-134-sGP-4R8KN2uPwdMAkSlqSw-1; Fri, 18 Dec 2020 10:13:22 -0500 X-MC-Unique: sGP-4R8KN2uPwdMAkSlqSw-1 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 D94FD107ACE6; Fri, 18 Dec 2020 15:13:21 +0000 (UTC) Received: from localhost (ovpn-114-84.ams2.redhat.com [10.36.114.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7B82F60CED; Fri, 18 Dec 2020 15:13:21 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 13/30] qemu-io: add preallocate mode parameter for truncate command Date: Fri, 18 Dec 2020 16:12:32 +0100 Message-Id: <20201218151249.715731-14-mreitz@redhat.com> In-Reply-To: <20201218151249.715731-1-mreitz@redhat.com> References: <20201218151249.715731-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Vladimir Sementsov-Ogievskiy This will be used in further test. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz Message-Id: <20201021145859.11201-10-vsementsov@virtuozzo.com> Signed-off-by: Max Reitz --- qemu-io-cmds.c | 46 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index 4153f1c0b0..97611969cb 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -1698,13 +1698,42 @@ static const cmdinfo_t flush_cmd = { .oneline = "flush all in-core file state to disk", }; +static int truncate_f(BlockBackend *blk, int argc, char **argv); +static const cmdinfo_t truncate_cmd = { + .name = "truncate", + .altname = "t", + .cfunc = truncate_f, + .perm = BLK_PERM_WRITE | BLK_PERM_RESIZE, + .argmin = 1, + .argmax = 3, + .args = "[-m prealloc_mode] off", + .oneline = "truncates the current file at the given offset", +}; + static int truncate_f(BlockBackend *blk, int argc, char **argv) { Error *local_err = NULL; int64_t offset; - int ret; + int c, ret; + PreallocMode prealloc = PREALLOC_MODE_OFF; - offset = cvtnum(argv[1]); + while ((c = getopt(argc, argv, "m:")) != -1) { + switch (c) { + case 'm': + prealloc = qapi_enum_parse(&PreallocMode_lookup, optarg, + PREALLOC_MODE__MAX, NULL); + if (prealloc == PREALLOC_MODE__MAX) { + error_report("Invalid preallocation mode '%s'", optarg); + return -EINVAL; + } + break; + default: + qemuio_command_usage(&truncate_cmd); + return -EINVAL; + } + } + + offset = cvtnum(argv[optind]); if (offset < 0) { print_cvtnum_err(offset, argv[1]); return offset; @@ -1715,7 +1744,7 @@ static int truncate_f(BlockBackend *blk, int argc, char **argv) * exact=true. It is better to err on the "emit more errors" side * than to be overly permissive. */ - ret = blk_truncate(blk, offset, false, PREALLOC_MODE_OFF, 0, &local_err); + ret = blk_truncate(blk, offset, false, prealloc, 0, &local_err); if (ret < 0) { error_report_err(local_err); return ret; @@ -1724,17 +1753,6 @@ static int truncate_f(BlockBackend *blk, int argc, char **argv) return 0; } -static const cmdinfo_t truncate_cmd = { - .name = "truncate", - .altname = "t", - .cfunc = truncate_f, - .perm = BLK_PERM_WRITE | BLK_PERM_RESIZE, - .argmin = 1, - .argmax = 1, - .args = "off", - .oneline = "truncates the current file at the given offset", -}; - static int length_f(BlockBackend *blk, int argc, char **argv) { int64_t size; From patchwork Fri Dec 18 15:12:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 11982451 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62B6FC4361B for ; Fri, 18 Dec 2020 15:24:14 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 079F723B51 for ; Fri, 18 Dec 2020 15:24:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 079F723B51 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:41786 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqHc3-0006pq-Rh for qemu-devel@archiver.kernel.org; Fri, 18 Dec 2020 10:24:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53942) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqHRp-0002Yc-Ho for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:37 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:54276) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kqHRh-0005Ov-4z for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304408; 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=nePBOte7Ef+Q0kbPVIXSFIsfmlBHc73YjzfApsE4dMg=; b=K/hCiypTJ5BpbXnKikUlUUhtEes0czR1AS5r8mtXc5aWTdI8L0x6pn0N+dmh8xm95J4/Iv okU187EQGSYNK1VAhIfO6L9PrtTUECIlmKUI2TvGclj1vror1SBacqPlKxeoQnbsl8ivpU Jn2Lwue74V7W4o6aG2z/cFX/I3SQB48= 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-263-j73iKH7bNM2YXS5UFte4xA-1; Fri, 18 Dec 2020 10:13:25 -0500 X-MC-Unique: j73iKH7bNM2YXS5UFte4xA-1 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 EFF1B190B2A0; Fri, 18 Dec 2020 15:13:23 +0000 (UTC) Received: from localhost (ovpn-114-84.ams2.redhat.com [10.36.114.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 963042BFF1; Fri, 18 Dec 2020 15:13:23 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 14/30] iotests: qemu_io_silent: support --image-opts Date: Fri, 18 Dec 2020 16:12:33 +0100 Message-Id: <20201218151249.715731-15-mreitz@redhat.com> In-Reply-To: <20201218151249.715731-1-mreitz@redhat.com> References: <20201218151249.715731-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Vladimir Sementsov-Ogievskiy Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz Message-Id: <20201021145859.11201-11-vsementsov@virtuozzo.com> Signed-off-by: Max Reitz --- tests/qemu-iotests/iotests.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index bcd4fe5b6f..1b7f376348 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -205,7 +205,12 @@ def qemu_io_log(*args): def qemu_io_silent(*args): '''Run qemu-io and return the exit code, suppressing stdout''' - args = qemu_io_args + list(args) + if '-f' in args or '--image-opts' in args: + default_args = qemu_io_args_no_fmt + else: + default_args = qemu_io_args + + args = default_args + list(args) exitcode = subprocess.call(args, stdout=open('/dev/null', 'w')) if exitcode < 0: sys.stderr.write('qemu-io received signal %i: %s\n' % From patchwork Fri Dec 18 15:12:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 11982469 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DCD2FC2BBD4 for ; Fri, 18 Dec 2020 15:28:49 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 73C9523B55 for ; Fri, 18 Dec 2020 15:28:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 73C9523B55 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:56660 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqHgW-0004cI-Cu for qemu-devel@archiver.kernel.org; Fri, 18 Dec 2020 10:28:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54060) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqHRt-0002eu-HT for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:41 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:47883) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kqHRk-0005Q7-9h for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304411; 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=KpELzEE13FisWZ41bYaFFcgjVL07EkAwsJtKzu5Tl3Y=; b=O6n9T0aIfJnQmXP7ZM0euipJvlKAkxOuQ+tVzheJxeM1HkLKpOFta+d5tsgi2FndJXtxKk Fa+iUDQR1PUrTNhqBSXveuKbZloj2ydmm8OSQRYry4zLewgn6v+OtY8uYhmIp1Nupz/zU+ dkLAaoc9myOBi+dwu6urLJCNmNFaxMk= 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-202-Xro0oQZ_MiG7b4opMTCsLQ-1; Fri, 18 Dec 2020 10:13:27 -0500 X-MC-Unique: Xro0oQZ_MiG7b4opMTCsLQ-1 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 47E691005D44; Fri, 18 Dec 2020 15:13:26 +0000 (UTC) Received: from localhost (ovpn-114-84.ams2.redhat.com [10.36.114.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B993D1002382; Fri, 18 Dec 2020 15:13:25 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 15/30] iotests.py: execute_setup_common(): add required_fmts argument Date: Fri, 18 Dec 2020 16:12:34 +0100 Message-Id: <20201218151249.715731-16-mreitz@redhat.com> In-Reply-To: <20201218151249.715731-1-mreitz@redhat.com> References: <20201218151249.715731-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Vladimir Sementsov-Ogievskiy Add a parameter to skip test if some needed additional formats are not supported (for example filter drivers). Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20201021145859.11201-12-vsementsov@virtuozzo.com> Reviewed-by: Max Reitz Signed-off-by: Max Reitz --- tests/qemu-iotests/iotests.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 1b7f376348..dcdcd0387f 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -1123,6 +1123,11 @@ def _verify_aio_mode(supported_aio_modes: Sequence[str] = ()) -> None: if supported_aio_modes and (aiomode not in supported_aio_modes): notrun('not suitable for this aio mode: %s' % aiomode) +def _verify_formats(required_formats: Sequence[str] = ()) -> None: + usf_list = list(set(required_formats) - set(supported_formats())) + if usf_list: + notrun(f'formats {usf_list} are not whitelisted') + def supports_quorum(): return 'quorum' in qemu_img_pipe('--help') @@ -1280,7 +1285,8 @@ def execute_setup_common(supported_fmts: Sequence[str] = (), supported_aio_modes: Sequence[str] = (), unsupported_fmts: Sequence[str] = (), supported_protocols: Sequence[str] = (), - unsupported_protocols: Sequence[str] = ()) -> bool: + unsupported_protocols: Sequence[str] = (), + required_fmts: Sequence[str] = ()) -> bool: """ Perform necessary setup for either script-style or unittest-style tests. @@ -1306,6 +1312,7 @@ def execute_setup_common(supported_fmts: Sequence[str] = (), _verify_platform(supported=supported_platforms) _verify_cache_mode(supported_cache_modes) _verify_aio_mode(supported_aio_modes) + _verify_formats(required_fmts) return debug From patchwork Fri Dec 18 15:12:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 11982445 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DDEEDC4361B for ; Fri, 18 Dec 2020 15:21:42 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 738572395C for ; Fri, 18 Dec 2020 15:21:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 738572395C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:60702 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqHZd-00035B-E3 for qemu-devel@archiver.kernel.org; Fri, 18 Dec 2020 10:21:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54034) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqHRs-0002eC-Um for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:41 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:48055) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kqHRm-0005RN-Hb for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304413; 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=6ErUEnaNKG6/qSd1Y8m/jb6ba8DX2JHoW//aeqtNNhg=; b=CYvsghTa9JO7k80Y8wNLiSob5sBsArkFBOwrUm6NR9IODGwHedOIHiZn0Dulr0d8nPwCmi Fob7DrTyHqUdzfxTdpjy2oewrohQeR9ds4JSIo2d0NmAOINfqGmluAGwKHtaErjH5iDqON XvJFQ+CEvxbf/PDU/9ePKf/fUsGkvrQ= 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-182-IOmWYGXmO8OeNuXdUo5yAw-1; Fri, 18 Dec 2020 10:13:29 -0500 X-MC-Unique: IOmWYGXmO8OeNuXdUo5yAw-1 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 918CA1005D4E; Fri, 18 Dec 2020 15:13:28 +0000 (UTC) Received: from localhost (ovpn-114-84.ams2.redhat.com [10.36.114.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0666C2998C; Fri, 18 Dec 2020 15:13:27 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 16/30] iotests: add 298 to test new preallocate filter driver Date: Fri, 18 Dec 2020 16:12:35 +0100 Message-Id: <20201218151249.715731-17-mreitz@redhat.com> In-Reply-To: <20201218151249.715731-1-mreitz@redhat.com> References: <20201218151249.715731-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Vladimir Sementsov-Ogievskiy Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20201021145859.11201-13-vsementsov@virtuozzo.com> Reviewed-by: Max Reitz Signed-off-by: Max Reitz --- tests/qemu-iotests/298 | 186 +++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/298.out | 5 + tests/qemu-iotests/group | 1 + 3 files changed, 192 insertions(+) create mode 100644 tests/qemu-iotests/298 create mode 100644 tests/qemu-iotests/298.out diff --git a/tests/qemu-iotests/298 b/tests/qemu-iotests/298 new file mode 100644 index 0000000000..d535946b5f --- /dev/null +++ b/tests/qemu-iotests/298 @@ -0,0 +1,186 @@ +#!/usr/bin/env python3 +# +# Test for preallocate filter +# +# Copyright (c) 2020 Virtuozzo International GmbH. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +import os +import iotests + +MiB = 1024 * 1024 +disk = os.path.join(iotests.test_dir, 'disk') +overlay = os.path.join(iotests.test_dir, 'overlay') +refdisk = os.path.join(iotests.test_dir, 'refdisk') +drive_opts = f'node-name=disk,driver={iotests.imgfmt},' \ + f'file.node-name=filter,file.driver=preallocate,' \ + f'file.file.node-name=file,file.file.filename={disk}' + + +class TestPreallocateBase(iotests.QMPTestCase): + def setUp(self): + iotests.qemu_img_create('-f', iotests.imgfmt, disk, str(10 * MiB)) + + def tearDown(self): + try: + self.check_small() + check = iotests.qemu_img_check(disk) + self.assertFalse('leaks' in check) + self.assertFalse('corruptions' in check) + self.assertEqual(check['check-errors'], 0) + finally: + os.remove(disk) + + def check_big(self): + self.assertTrue(os.path.getsize(disk) > 100 * MiB) + + def check_small(self): + self.assertTrue(os.path.getsize(disk) < 10 * MiB) + + +class TestQemuImg(TestPreallocateBase): + def test_qemu_img(self): + p = iotests.QemuIoInteractive('--image-opts', drive_opts) + + p.cmd('write 0 1M') + p.cmd('flush') + + self.check_big() + + p.close() + + +class TestPreallocateFilter(TestPreallocateBase): + def setUp(self): + super().setUp() + self.vm = iotests.VM().add_drive(path=None, opts=drive_opts) + self.vm.launch() + + def tearDown(self): + self.vm.shutdown() + super().tearDown() + + def test_prealloc(self): + self.vm.hmp_qemu_io('drive0', 'write 0 1M') + self.check_big() + + def test_external_snapshot(self): + self.test_prealloc() + + result = self.vm.qmp('blockdev-snapshot-sync', node_name='disk', + snapshot_file=overlay, + snapshot_node_name='overlay') + self.assert_qmp(result, 'return', {}) + + # on reopen to r-o base preallocation should be dropped + self.check_small() + + self.vm.hmp_qemu_io('drive0', 'write 1M 1M') + + result = self.vm.qmp('block-commit', device='overlay') + self.assert_qmp(result, 'return', {}) + self.complete_and_wait() + + # commit of new megabyte should trigger preallocation + self.check_big() + + def test_reopen_opts(self): + result = self.vm.qmp('x-blockdev-reopen', **{ + 'node-name': 'disk', + 'driver': iotests.imgfmt, + 'file': { + 'node-name': 'filter', + 'driver': 'preallocate', + 'prealloc-size': 20 * MiB, + 'prealloc-align': 5 * MiB, + 'file': { + 'node-name': 'file', + 'driver': 'file', + 'filename': disk + } + } + }) + self.assert_qmp(result, 'return', {}) + + self.vm.hmp_qemu_io('drive0', 'write 0 1M') + self.assertTrue(os.path.getsize(disk) == 25 * MiB) + + +class TestTruncate(iotests.QMPTestCase): + def setUp(self): + iotests.qemu_img_create('-f', iotests.imgfmt, disk, str(10 * MiB)) + iotests.qemu_img_create('-f', iotests.imgfmt, refdisk, str(10 * MiB)) + + def tearDown(self): + os.remove(disk) + os.remove(refdisk) + + def do_test(self, prealloc_mode, new_size): + ret = iotests.qemu_io_silent('--image-opts', '-c', 'write 0 10M', '-c', + f'truncate -m {prealloc_mode} {new_size}', + drive_opts) + self.assertEqual(ret, 0) + + ret = iotests.qemu_io_silent('-f', iotests.imgfmt, '-c', 'write 0 10M', + '-c', + f'truncate -m {prealloc_mode} {new_size}', + refdisk) + self.assertEqual(ret, 0) + + stat = os.stat(disk) + refstat = os.stat(refdisk) + + # Probably we'll want preallocate filter to keep align to cluster when + # shrink preallocation, so, ignore small differece + self.assertLess(abs(stat.st_size - refstat.st_size), 64 * 1024) + + # Preallocate filter may leak some internal clusters (for example, if + # guest write far over EOF, skipping some clusters - they will remain + # fallocated, preallocate filter don't care about such leaks, it drops + # only trailing preallocation. + self.assertLess(abs(stat.st_blocks - refstat.st_blocks) * 512, + 1024 * 1024) + + def test_real_shrink(self): + self.do_test('off', '5M') + + def test_truncate_inside_preallocated_area__falloc(self): + self.do_test('falloc', '50M') + + def test_truncate_inside_preallocated_area__metadata(self): + self.do_test('metadata', '50M') + + def test_truncate_inside_preallocated_area__full(self): + self.do_test('full', '50M') + + def test_truncate_inside_preallocated_area__off(self): + self.do_test('off', '50M') + + def test_truncate_over_preallocated_area__falloc(self): + self.do_test('falloc', '150M') + + def test_truncate_over_preallocated_area__metadata(self): + self.do_test('metadata', '150M') + + def test_truncate_over_preallocated_area__full(self): + self.do_test('full', '150M') + + def test_truncate_over_preallocated_area__off(self): + self.do_test('off', '150M') + + +if __name__ == '__main__': + iotests.main(supported_fmts=['qcow2'], required_fmts=['preallocate']) diff --git a/tests/qemu-iotests/298.out b/tests/qemu-iotests/298.out new file mode 100644 index 0000000000..fa16b5ccef --- /dev/null +++ b/tests/qemu-iotests/298.out @@ -0,0 +1,5 @@ +............. +---------------------------------------------------------------------- +Ran 13 tests + +OK diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 9a8394b4cd..614d58369e 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -307,6 +307,7 @@ 295 rw 296 rw 297 meta +298 299 auto quick 300 migration 301 backing quick From patchwork Fri Dec 18 15:12: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: 11982455 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 951C8C4361B for ; Fri, 18 Dec 2020 15:26:01 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 3332C23B53 for ; Fri, 18 Dec 2020 15:26:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3332C23B53 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:47608 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqHdo-0000mI-7X for qemu-devel@archiver.kernel.org; Fri, 18 Dec 2020 10:26:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54020) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqHRs-0002e9-I1 for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:40 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:49070) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kqHRm-0005RQ-P9 for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304414; 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=Yvl573oFX9RGR5mQkaX0BDpoc+eMQS8HwIvBQAZxvB0=; b=L4JN2HUGCogiIWMAZ3Xu8pll/XYR9lm23/HcQ9WybPOKOFh+vvYGyCmXsZgd3/fWHrIoXR TmNBYBg0PpRFzsZsyCYEwl2q2FwyHXEazGdcm7dqDv0sr9PI2U+ClO/WbDjxJO+YN2bmBx CxaLxTWUFDA0ZM3Ssq2m7iMuvxRsrmk= 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-361-SMpIhd8YPvKRvkqb442IYQ-1; Fri, 18 Dec 2020 10:13:31 -0500 X-MC-Unique: SMpIhd8YPvKRvkqb442IYQ-1 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 B175D190B2A5; Fri, 18 Dec 2020 15:13:30 +0000 (UTC) Received: from localhost (ovpn-114-84.ams2.redhat.com [10.36.114.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 50C2260CED; Fri, 18 Dec 2020 15:13:30 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 17/30] scripts/simplebench: fix grammar: s/successed/succeeded/ Date: Fri, 18 Dec 2020 16:12:36 +0100 Message-Id: <20201218151249.715731-18-mreitz@redhat.com> In-Reply-To: <20201218151249.715731-1-mreitz@redhat.com> References: <20201218151249.715731-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Vladimir Sementsov-Ogievskiy Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20201021145859.11201-14-vsementsov@virtuozzo.com> Reviewed-by: Max Reitz Signed-off-by: Max Reitz --- scripts/simplebench/simplebench.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/simplebench/simplebench.py b/scripts/simplebench/simplebench.py index 59e7314ff6..2445932fc2 100644 --- a/scripts/simplebench/simplebench.py +++ b/scripts/simplebench/simplebench.py @@ -54,14 +54,14 @@ def bench_one(test_func, test_env, test_case, count=5, initial_run=True): result = {'runs': runs} - successed = [r for r in runs if ('seconds' in r)] - if successed: - avg = sum(r['seconds'] for r in successed) / len(successed) + succeeded = [r for r in runs if ('seconds' in r)] + if succeeded: + avg = sum(r['seconds'] for r in succeeded) / len(succeeded) result['average'] = avg - result['delta'] = max(abs(r['seconds'] - avg) for r in successed) + result['delta'] = max(abs(r['seconds'] - avg) for r in succeeded) - if len(successed) < count: - result['n-failed'] = count - len(successed) + if len(succeeded) < count: + result['n-failed'] = count - len(succeeded) return result From patchwork Fri Dec 18 15:12: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: 11982453 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BC9CEC4361B for ; Fri, 18 Dec 2020 15:24:51 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 4D76323B53 for ; Fri, 18 Dec 2020 15:24:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4D76323B53 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:44032 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqHcg-0007k5-Bm for qemu-devel@archiver.kernel.org; Fri, 18 Dec 2020 10:24:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54076) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqHRt-0002fa-UP for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:41 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:45076) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kqHRp-0005Tf-6H for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304416; 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=4NCDuLaz3zRp/UWCIa6k+LnZQ5acpxDGb42gPb+819w=; b=YDygDm/zKggC7WXJ4hHvU+GTYhNRDc+mkzGnPzzi2H57uWkAZDlVn5WYP5QomJUzJ8yRwl Y5adKdba3qnNLH6z4pzJd2eBHAUCQFinPLQbU/COy8MC/PrJicmh+KwEGnSP9nCQsgfFpK m6M9JVVRzdXIepTWbF0s2DE6qaxjtHw= 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-541-Hiyy6TZgPH2xAqjxql1XvA-1; Fri, 18 Dec 2020 10:13:34 -0500 X-MC-Unique: Hiyy6TZgPH2xAqjxql1XvA-1 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 D13EE107ACF5; Fri, 18 Dec 2020 15:13:32 +0000 (UTC) Received: from localhost (ovpn-114-84.ams2.redhat.com [10.36.114.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 702606A251; Fri, 18 Dec 2020 15:13:32 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 18/30] scripts/simplebench: support iops Date: Fri, 18 Dec 2020 16:12:37 +0100 Message-Id: <20201218151249.715731-19-mreitz@redhat.com> In-Reply-To: <20201218151249.715731-1-mreitz@redhat.com> References: <20201218151249.715731-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Vladimir Sementsov-Ogievskiy Support benchmarks returning not seconds but iops. We'll use it for further new test. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20201021145859.11201-15-vsementsov@virtuozzo.com> Reviewed-by: Max Reitz Signed-off-by: Max Reitz --- scripts/simplebench/simplebench.py | 38 ++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/scripts/simplebench/simplebench.py b/scripts/simplebench/simplebench.py index 2445932fc2..2251cd34ea 100644 --- a/scripts/simplebench/simplebench.py +++ b/scripts/simplebench/simplebench.py @@ -24,9 +24,12 @@ def bench_one(test_func, test_env, test_case, count=5, initial_run=True): test_func -- benchmarking function with prototype test_func(env, case), which takes test_env and test_case - arguments and returns {'seconds': int} (which is benchmark - result) on success and {'error': str} on error. Returned - dict may contain any other additional fields. + arguments and on success returns dict with 'seconds' or + 'iops' (or both) fields, specifying the benchmark result. + If both 'iops' and 'seconds' provided, the 'iops' is + considered the main, and 'seconds' is just an additional + info. On failure test_func should return {'error': str}. + Returned dict may contain any other additional fields. test_env -- test environment - opaque first argument for test_func test_case -- test case - opaque second argument for test_func count -- how many times to call test_func, to calculate average @@ -34,8 +37,9 @@ def bench_one(test_func, test_env, test_case, count=5, initial_run=True): Returns dict with the following fields: 'runs': list of test_func results - 'average': average seconds per run (exists only if at least one run - succeeded) + 'dimension': dimension of results, may be 'seconds' or 'iops' + 'average': average value (iops or seconds) per run (exists only if at + least one run succeeded) 'delta': maximum delta between test_func result and the average (exists only if at least one run succeeded) 'n-failed': number of failed runs (exists only if at least one run @@ -54,11 +58,19 @@ def bench_one(test_func, test_env, test_case, count=5, initial_run=True): result = {'runs': runs} - succeeded = [r for r in runs if ('seconds' in r)] + succeeded = [r for r in runs if ('seconds' in r or 'iops' in r)] if succeeded: - avg = sum(r['seconds'] for r in succeeded) / len(succeeded) + if 'iops' in succeeded[0]: + assert all('iops' in r for r in succeeded) + dim = 'iops' + else: + assert all('seconds' in r for r in succeeded) + assert all('iops' not in r for r in succeeded) + dim = 'seconds' + avg = sum(r[dim] for r in succeeded) / len(succeeded) + result['dimension'] = dim result['average'] = avg - result['delta'] = max(abs(r['seconds'] - avg) for r in succeeded) + result['delta'] = max(abs(r[dim] - avg) for r in succeeded) if len(succeeded) < count: result['n-failed'] = count - len(succeeded) @@ -118,11 +130,17 @@ def ascii(results): """Return ASCII representation of bench() returned dict.""" from tabulate import tabulate + dim = None tab = [[""] + [c['id'] for c in results['envs']]] for case in results['cases']: row = [case['id']] for env in results['envs']: - row.append(ascii_one(results['tab'][case['id']][env['id']])) + res = results['tab'][case['id']][env['id']] + if dim is None: + dim = res['dimension'] + else: + assert dim == res['dimension'] + row.append(ascii_one(res)) tab.append(row) - return tabulate(tab) + return f'All results are in {dim}\n\n' + tabulate(tab) From patchwork Fri Dec 18 15:12: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: 11982463 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7336EC4361B for ; Fri, 18 Dec 2020 15:26:43 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id D535223B53 for ; Fri, 18 Dec 2020 15:26:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D535223B53 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:50270 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqHeT-0001x7-RP for qemu-devel@archiver.kernel.org; Fri, 18 Dec 2020 10:26:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54090) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqHRu-0002fz-P5 for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:42 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:38234) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kqHRq-0005UL-VA for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304418; 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=+5cZhGfdH0mWZaKM1/ZnrXjXQouCmHUFDVzSpDSzyic=; b=LaT2xg3+8L8qLjrHFPHy3dM5TXnABiYoS/KGvY0QhudJmkH6jaV30DJJZ6F7mAXDyyhrUy L3krnRwNGBGDcJC+5eFG8rY8Ph+4FM2YB2pzmi2gAS3lXqARSfJ4m/MZONZy7xLtqpLl0z Z5joObJ1MihTYHS5SMeVcVyq80/mOtM= 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-208-o8NidpluNGi9SDoon_WxDQ-1; Fri, 18 Dec 2020 10:13:36 -0500 X-MC-Unique: o8NidpluNGi9SDoon_WxDQ-1 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 1B34E190B2A0; Fri, 18 Dec 2020 15:13:35 +0000 (UTC) Received: from localhost (ovpn-114-84.ams2.redhat.com [10.36.114.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B6B9360C43; Fri, 18 Dec 2020 15:13:34 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 19/30] scripts/simplebench: use standard deviation for +- error Date: Fri, 18 Dec 2020 16:12:38 +0100 Message-Id: <20201218151249.715731-20-mreitz@redhat.com> In-Reply-To: <20201218151249.715731-1-mreitz@redhat.com> References: <20201218151249.715731-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Vladimir Sementsov-Ogievskiy Standard deviation is more usual to see after +- than current maximum of deviations. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20201021145859.11201-16-vsementsov@virtuozzo.com> Reviewed-by: Max Reitz Signed-off-by: Max Reitz --- scripts/simplebench/simplebench.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/simplebench/simplebench.py b/scripts/simplebench/simplebench.py index 2251cd34ea..55ec1ad5db 100644 --- a/scripts/simplebench/simplebench.py +++ b/scripts/simplebench/simplebench.py @@ -18,6 +18,8 @@ # along with this program. If not, see . # +import statistics + def bench_one(test_func, test_env, test_case, count=5, initial_run=True): """Benchmark one test-case @@ -40,7 +42,7 @@ def bench_one(test_func, test_env, test_case, count=5, initial_run=True): 'dimension': dimension of results, may be 'seconds' or 'iops' 'average': average value (iops or seconds) per run (exists only if at least one run succeeded) - 'delta': maximum delta between test_func result and the average + 'stdev': standard deviation of results (exists only if at least one run succeeded) 'n-failed': number of failed runs (exists only if at least one run failed) @@ -67,10 +69,9 @@ def bench_one(test_func, test_env, test_case, count=5, initial_run=True): assert all('seconds' in r for r in succeeded) assert all('iops' not in r for r in succeeded) dim = 'seconds' - avg = sum(r[dim] for r in succeeded) / len(succeeded) result['dimension'] = dim - result['average'] = avg - result['delta'] = max(abs(r[dim] - avg) for r in succeeded) + result['average'] = statistics.mean(r[dim] for r in succeeded) + result['stdev'] = statistics.stdev(r[dim] for r in succeeded) if len(succeeded) < count: result['n-failed'] = count - len(succeeded) @@ -81,7 +82,7 @@ def bench_one(test_func, test_env, test_case, count=5, initial_run=True): def ascii_one(result): """Return ASCII representation of bench_one() returned dict.""" if 'average' in result: - s = '{:.2f} +- {:.2f}'.format(result['average'], result['delta']) + s = '{:.2f} +- {:.2f}'.format(result['average'], result['stdev']) if 'n-failed' in result: s += '\n({} failed)'.format(result['n-failed']) return s From patchwork Fri Dec 18 15:12: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: 11982471 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 857BBC2BBCF for ; Fri, 18 Dec 2020 15:29:49 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 0CB6023B5D for ; Fri, 18 Dec 2020 15:29:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0CB6023B5D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:59560 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqHhT-0005pq-UI for qemu-devel@archiver.kernel.org; Fri, 18 Dec 2020 10:29:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54138) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqHRy-0002jr-6d for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:46 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:34955) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kqHRt-0005Vf-9F for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304420; 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=aOZFKCukIL4SqnJNkKVGb1/6oBSKYt+4AbvJ2tcp+tk=; b=GHEHyX8RVQY1i7FWqHqV3/8nWbivkgXdU57xrebIZc0WIeEQ8Af8rbotv0OoTZo3Uy58iW R5zXvcCzlSVfb4C5Us9otNjLC5CAs66b6zjPNDR+c1TvOOkloXi489C4VSE8zLj6+LiFUZ qc2fa0rlR7tE12IMn+MEXILn9ZhUKhk= 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-459-7QOVA4ysOnu4_OPEZiCfSA-1; Fri, 18 Dec 2020 10:13:38 -0500 X-MC-Unique: 7QOVA4ysOnu4_OPEZiCfSA-1 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 35CDEB8100; Fri, 18 Dec 2020 15:13:37 +0000 (UTC) Received: from localhost (ovpn-114-84.ams2.redhat.com [10.36.114.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CC59D60CED; Fri, 18 Dec 2020 15:13:36 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 20/30] simplebench: rename ascii() to results_to_text() Date: Fri, 18 Dec 2020 16:12:39 +0100 Message-Id: <20201218151249.715731-21-mreitz@redhat.com> In-Reply-To: <20201218151249.715731-1-mreitz@redhat.com> References: <20201218151249.715731-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Vladimir Sementsov-Ogievskiy Next patch will use utf8 plus-minus symbol, let's use more generic (and more readable) name. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20201021145859.11201-17-vsementsov@virtuozzo.com> Reviewed-by: Max Reitz Signed-off-by: Max Reitz --- scripts/simplebench/bench-example.py | 2 +- scripts/simplebench/bench_write_req.py | 2 +- scripts/simplebench/simplebench.py | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/simplebench/bench-example.py b/scripts/simplebench/bench-example.py index c642a5b891..f24cf22fe9 100644 --- a/scripts/simplebench/bench-example.py +++ b/scripts/simplebench/bench-example.py @@ -77,4 +77,4 @@ test_envs = [ ] result = simplebench.bench(bench_func, test_envs, test_cases, count=3) -print(simplebench.ascii(result)) +print(simplebench.results_to_text(result)) diff --git a/scripts/simplebench/bench_write_req.py b/scripts/simplebench/bench_write_req.py index ca1178fd68..e175bcd7a4 100755 --- a/scripts/simplebench/bench_write_req.py +++ b/scripts/simplebench/bench_write_req.py @@ -167,4 +167,4 @@ if __name__ == '__main__': result = simplebench.bench(bench_func, test_envs, test_cases, count=3, initial_run=False) - print(simplebench.ascii(result)) + print(simplebench.results_to_text(result)) diff --git a/scripts/simplebench/simplebench.py b/scripts/simplebench/simplebench.py index 55ec1ad5db..aa74b78a04 100644 --- a/scripts/simplebench/simplebench.py +++ b/scripts/simplebench/simplebench.py @@ -79,8 +79,8 @@ def bench_one(test_func, test_env, test_case, count=5, initial_run=True): return result -def ascii_one(result): - """Return ASCII representation of bench_one() returned dict.""" +def result_to_text(result): + """Return text representation of bench_one() returned dict.""" if 'average' in result: s = '{:.2f} +- {:.2f}'.format(result['average'], result['stdev']) if 'n-failed' in result: @@ -127,8 +127,8 @@ def bench(test_func, test_envs, test_cases, *args, **vargs): return results -def ascii(results): - """Return ASCII representation of bench() returned dict.""" +def results_to_text(results): + """Return text representation of bench() returned dict.""" from tabulate import tabulate dim = None @@ -141,7 +141,7 @@ def ascii(results): dim = res['dimension'] else: assert dim == res['dimension'] - row.append(ascii_one(res)) + row.append(result_to_text(res)) tab.append(row) return f'All results are in {dim}\n\n' + tabulate(tab) From patchwork Fri Dec 18 15:12: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: 11982481 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7A7AC2BBCF for ; Fri, 18 Dec 2020 15:33:20 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 2F3B823B6B for ; Fri, 18 Dec 2020 15:33:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2F3B823B6B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:39266 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqHks-0000wT-LR for qemu-devel@archiver.kernel.org; Fri, 18 Dec 2020 10:33:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54204) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqHS1-0002ky-WF for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:50 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:56943) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kqHRx-0005Wa-Q9 for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304425; 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=z3lKdk1VphxgXZtQrQQx5saPGM0quIsvXrGGU8V7EYc=; b=dgE0TaSFUdvjJ8JpaWjzX4rrXkAsuJiLMvwseSFjxvzN4X0Xhax+xeGyoVJwctB8jI15aF cYQGCYDkPkt3oc/8z6A6UawXkGVTG4wwLeRmqxbNdIj07FyFCIxgipQHMbBih4PUw5eqKM n1WEfscK50ZtE9ZpdjwNjkKKB17acs4= 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-109-kn1f6d4mORuRwu7-dVPFgA-1; Fri, 18 Dec 2020 10:13:41 -0500 X-MC-Unique: kn1f6d4mORuRwu7-dVPFgA-1 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 73B81801817; Fri, 18 Dec 2020 15:13:39 +0000 (UTC) Received: from localhost (ovpn-114-84.ams2.redhat.com [10.36.114.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F1DAF5D769; Fri, 18 Dec 2020 15:13:38 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 21/30] simplebench: move results_to_text() into separate file Date: Fri, 18 Dec 2020 16:12:40 +0100 Message-Id: <20201218151249.715731-22-mreitz@redhat.com> In-Reply-To: <20201218151249.715731-1-mreitz@redhat.com> References: <20201218151249.715731-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Vladimir Sementsov-Ogievskiy Let's keep view part in separate: this way it's better to improve it in the following commits. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20201021145859.11201-18-vsementsov@virtuozzo.com> Reviewed-by: Max Reitz Signed-off-by: Max Reitz --- scripts/simplebench/bench-example.py | 3 +- scripts/simplebench/bench_write_req.py | 3 +- scripts/simplebench/results_to_text.py | 48 ++++++++++++++++++++++++++ scripts/simplebench/simplebench.py | 31 ----------------- 4 files changed, 52 insertions(+), 33 deletions(-) create mode 100644 scripts/simplebench/results_to_text.py diff --git a/scripts/simplebench/bench-example.py b/scripts/simplebench/bench-example.py index f24cf22fe9..d9c7f7bc17 100644 --- a/scripts/simplebench/bench-example.py +++ b/scripts/simplebench/bench-example.py @@ -19,6 +19,7 @@ # import simplebench +from results_to_text import results_to_text from bench_block_job import bench_block_copy, drv_file, drv_nbd @@ -77,4 +78,4 @@ test_envs = [ ] result = simplebench.bench(bench_func, test_envs, test_cases, count=3) -print(simplebench.results_to_text(result)) +print(results_to_text(result)) diff --git a/scripts/simplebench/bench_write_req.py b/scripts/simplebench/bench_write_req.py index e175bcd7a4..da601ea2fe 100755 --- a/scripts/simplebench/bench_write_req.py +++ b/scripts/simplebench/bench_write_req.py @@ -26,6 +26,7 @@ import sys import os import subprocess import simplebench +from results_to_text import results_to_text def bench_func(env, case): @@ -167,4 +168,4 @@ if __name__ == '__main__': result = simplebench.bench(bench_func, test_envs, test_cases, count=3, initial_run=False) - print(simplebench.results_to_text(result)) + print(results_to_text(result)) diff --git a/scripts/simplebench/results_to_text.py b/scripts/simplebench/results_to_text.py new file mode 100644 index 0000000000..58d909ffd9 --- /dev/null +++ b/scripts/simplebench/results_to_text.py @@ -0,0 +1,48 @@ +# Simple benchmarking framework +# +# Copyright (c) 2019 Virtuozzo International GmbH. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + + +def result_to_text(result): + """Return text representation of bench_one() returned dict.""" + if 'average' in result: + s = '{:.2f} +- {:.2f}'.format(result['average'], result['stdev']) + if 'n-failed' in result: + s += '\n({} failed)'.format(result['n-failed']) + return s + else: + return 'FAILED' + + +def results_to_text(results): + """Return text representation of bench() returned dict.""" + from tabulate import tabulate + + dim = None + tab = [[""] + [c['id'] for c in results['envs']]] + for case in results['cases']: + row = [case['id']] + for env in results['envs']: + res = results['tab'][case['id']][env['id']] + if dim is None: + dim = res['dimension'] + else: + assert dim == res['dimension'] + row.append(result_to_text(res)) + tab.append(row) + + return f'All results are in {dim}\n\n' + tabulate(tab) diff --git a/scripts/simplebench/simplebench.py b/scripts/simplebench/simplebench.py index aa74b78a04..f61513af90 100644 --- a/scripts/simplebench/simplebench.py +++ b/scripts/simplebench/simplebench.py @@ -79,17 +79,6 @@ def bench_one(test_func, test_env, test_case, count=5, initial_run=True): return result -def result_to_text(result): - """Return text representation of bench_one() returned dict.""" - if 'average' in result: - s = '{:.2f} +- {:.2f}'.format(result['average'], result['stdev']) - if 'n-failed' in result: - s += '\n({} failed)'.format(result['n-failed']) - return s - else: - return 'FAILED' - - def bench(test_func, test_envs, test_cases, *args, **vargs): """Fill benchmark table @@ -125,23 +114,3 @@ def bench(test_func, test_envs, test_cases, *args, **vargs): print('Done') return results - - -def results_to_text(results): - """Return text representation of bench() returned dict.""" - from tabulate import tabulate - - dim = None - tab = [[""] + [c['id'] for c in results['envs']]] - for case in results['cases']: - row = [case['id']] - for env in results['envs']: - res = results['tab'][case['id']][env['id']] - if dim is None: - dim = res['dimension'] - else: - assert dim == res['dimension'] - row.append(result_to_text(res)) - tab.append(row) - - return f'All results are in {dim}\n\n' + tabulate(tab) From patchwork Fri Dec 18 15:12:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 11982473 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7758DC4361B for ; Fri, 18 Dec 2020 15:29:49 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 0A5F223B55 for ; Fri, 18 Dec 2020 15:29:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0A5F223B55 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:59630 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqHhT-0005rM-WA for qemu-devel@archiver.kernel.org; Fri, 18 Dec 2020 10:29:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54248) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqHS4-0002m7-Jt for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:53 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:22052) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kqHRx-0005Wh-Va for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304425; 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=lBFUGvyc6BYZ1fwbm+lORX0XcvfRUUPOwZ+l+og7TMY=; b=h/lACNPyrhG2IAbgi5ZCJ14rM7m9y3KWl6Eaz7TZW/kD9MpgDYuSCTFu+6Z8WvmFCtiU8o 7WzG6hcQZhbNvtOAShYkW4p4PIzGso6AIuYS4V9RSxifqVK55zOMrmCg5c1IRI1KHcJfMf J6mqOyiTBnPSD1aHM+wxtPsNLTHgGMM= 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-451-VSHJpNZcNjy3quX-tw34sw-1; Fri, 18 Dec 2020 10:13:42 -0500 X-MC-Unique: VSHJpNZcNjy3quX-tw34sw-1 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 B4382107ACF5; Fri, 18 Dec 2020 15:13:41 +0000 (UTC) Received: from localhost (ovpn-114-84.ams2.redhat.com [10.36.114.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4734910013C0; Fri, 18 Dec 2020 15:13:41 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 22/30] simplebench/results_to_text: improve view of the table Date: Fri, 18 Dec 2020 16:12:41 +0100 Message-Id: <20201218151249.715731-23-mreitz@redhat.com> In-Reply-To: <20201218151249.715731-1-mreitz@redhat.com> References: <20201218151249.715731-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Vladimir Sementsov-Ogievskiy Move to generic format for floats and percentage for error. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20201021145859.11201-19-vsementsov@virtuozzo.com> Acked-by: Max Reitz Signed-off-by: Max Reitz --- scripts/simplebench/results_to_text.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/simplebench/results_to_text.py b/scripts/simplebench/results_to_text.py index 58d909ffd9..479f7ac1d4 100644 --- a/scripts/simplebench/results_to_text.py +++ b/scripts/simplebench/results_to_text.py @@ -16,11 +16,22 @@ # along with this program. If not, see . # +import math + + +def format_value(x, stdev): + stdev_pr = stdev / x * 100 + if stdev_pr < 1.5: + # don't care too much + return f'{x:.2g}' + else: + return f'{x:.2g} ± {math.ceil(stdev_pr)}%' + def result_to_text(result): """Return text representation of bench_one() returned dict.""" if 'average' in result: - s = '{:.2f} +- {:.2f}'.format(result['average'], result['stdev']) + s = format_value(result['average'], result['stdev']) if 'n-failed' in result: s += '\n({} failed)'.format(result['n-failed']) return s From patchwork Fri Dec 18 15:12: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: 11982489 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 332E5C2BBCF for ; Fri, 18 Dec 2020 15:36:53 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id A076C23B5F for ; Fri, 18 Dec 2020 15:36:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A076C23B5F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:48206 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqHoJ-0004nD-L9 for qemu-devel@archiver.kernel.org; Fri, 18 Dec 2020 10:36:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54224) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqHS3-0002l7-J6 for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:51 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:60867) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kqHS0-0005XG-7f for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304427; 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=pZjO/hv+Ki5k2sjhSd9oXkWuNGDLay6RmZOiKskYRz0=; b=ETllhh8UYTm3rFMyYKT/3ZNs/pi71KqH/ONgFKhAm898Lo75JkvtraRsfHu0Fab625o2iZ hvASxV3y5DqVLSxj16SCujlzKwrFQnRFaOsLy5kAO4hfI013KpoLo/ilLwpgLuKmqDknba 2E5fRj9ZTI1PBoc5KcUdbNoCshTUyJw= 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-419-jDLiRTh3MeS0dZGdNjZNPQ-1; Fri, 18 Dec 2020 10:13:44 -0500 X-MC-Unique: jDLiRTh3MeS0dZGdNjZNPQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DA444190B2A2; Fri, 18 Dec 2020 15:13:43 +0000 (UTC) Received: from localhost (ovpn-114-84.ams2.redhat.com [10.36.114.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7D3355C1C5; Fri, 18 Dec 2020 15:13:43 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 23/30] simplebench/results_to_text: add difference line to the table Date: Fri, 18 Dec 2020 16:12:42 +0100 Message-Id: <20201218151249.715731-24-mreitz@redhat.com> In-Reply-To: <20201218151249.715731-1-mreitz@redhat.com> References: <20201218151249.715731-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Vladimir Sementsov-Ogievskiy Performance improvements / degradations are usually discussed in percentage. Let's make the script calculate it for us. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20201021145859.11201-20-vsementsov@virtuozzo.com> Reviewed-by: Max Reitz [mreitz: 'seconds' instead of 'secs'] Signed-off-by: Max Reitz --- scripts/simplebench/results_to_text.py | 67 +++++++++++++++++++++++--- 1 file changed, 60 insertions(+), 7 deletions(-) diff --git a/scripts/simplebench/results_to_text.py b/scripts/simplebench/results_to_text.py index 479f7ac1d4..e46940fdf2 100644 --- a/scripts/simplebench/results_to_text.py +++ b/scripts/simplebench/results_to_text.py @@ -17,6 +17,10 @@ # import math +import tabulate + +# We want leading whitespace for difference row cells (see below) +tabulate.PRESERVE_WHITESPACE = True def format_value(x, stdev): @@ -39,21 +43,70 @@ def result_to_text(result): return 'FAILED' -def results_to_text(results): - """Return text representation of bench() returned dict.""" - from tabulate import tabulate - +def results_dimension(results): dim = None - tab = [[""] + [c['id'] for c in results['envs']]] for case in results['cases']: - row = [case['id']] for env in results['envs']: res = results['tab'][case['id']][env['id']] if dim is None: dim = res['dimension'] else: assert dim == res['dimension'] + + assert dim in ('iops', 'seconds') + + return dim + + +def results_to_text(results): + """Return text representation of bench() returned dict.""" + n_columns = len(results['envs']) + named_columns = n_columns > 2 + dim = results_dimension(results) + tab = [] + + if named_columns: + # Environment columns are named A, B, ... + tab.append([''] + [chr(ord('A') + i) for i in range(n_columns)]) + + tab.append([''] + [c['id'] for c in results['envs']]) + + for case in results['cases']: + row = [case['id']] + case_results = results['tab'][case['id']] + for env in results['envs']: + res = case_results[env['id']] row.append(result_to_text(res)) tab.append(row) - return f'All results are in {dim}\n\n' + tabulate(tab) + # Add row of difference between columns. For each column starting from + # B we calculate difference with all previous columns. + row = ['', ''] # case name and first column + for i in range(1, n_columns): + cell = '' + env = results['envs'][i] + res = case_results[env['id']] + + if 'average' not in res: + # Failed result + row.append(cell) + continue + + for j in range(0, i): + env_j = results['envs'][j] + res_j = case_results[env_j['id']] + cell += ' ' + + if 'average' not in res_j: + # Failed result + cell += '--' + continue + + col_j = tab[0][j + 1] if named_columns else '' + diff_pr = round((res['average'] - res_j['average']) / + res_j['average'] * 100) + cell += f' {col_j}{diff_pr:+}%' + row.append(cell) + tab.append(row) + + return f'All results are in {dim}\n\n' + tabulate.tabulate(tab) From patchwork Fri Dec 18 15:12: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: 11982491 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22D80C2BBD4 for ; Fri, 18 Dec 2020 15:39:49 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id B0C1223B5D for ; Fri, 18 Dec 2020 15:39:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B0C1223B5D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:56644 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqHr9-0008Ke-Nf for qemu-devel@archiver.kernel.org; Fri, 18 Dec 2020 10:39:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54252) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqHS4-0002m8-QB for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:53 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:47989) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kqHS2-0005YG-1X for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304429; 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=YFaj4vG+3JigRX7CV2Nf7Y5YVospHy1rjKNyw3vchPA=; b=SmgVwqD11TyOhZFAGugXJLdp65kDegno6vNbvO0PTdYFtc/d7pMhjmImg6CJem1OSay1wQ a4OLZxqt6yxLft7Qrrux3gNB9WkwCzfyfCZs57L6Vvoio+OpmKggguf6yyH2ynruz8EL2B xGzQNJk58lUoUQN2USDCImtabWH8AHw= 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-227-aB-8zljbPpia8m1OpyWFCw-1; Fri, 18 Dec 2020 10:13:47 -0500 X-MC-Unique: aB-8zljbPpia8m1OpyWFCw-1 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 44F1A190B2A0; Fri, 18 Dec 2020 15:13:46 +0000 (UTC) Received: from localhost (ovpn-114-84.ams2.redhat.com [10.36.114.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B8AFB614FF; Fri, 18 Dec 2020 15:13:45 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 24/30] simplebench/results_to_text: make executable Date: Fri, 18 Dec 2020 16:12:43 +0100 Message-Id: <20201218151249.715731-25-mreitz@redhat.com> In-Reply-To: <20201218151249.715731-1-mreitz@redhat.com> References: <20201218151249.715731-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Vladimir Sementsov-Ogievskiy Make results_to_text a tool to dump results saved in JSON file. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20201021145859.11201-21-vsementsov@virtuozzo.com> Reviewed-by: Max Reitz Signed-off-by: Max Reitz --- scripts/simplebench/results_to_text.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) mode change 100644 => 100755 scripts/simplebench/results_to_text.py diff --git a/scripts/simplebench/results_to_text.py b/scripts/simplebench/results_to_text.py old mode 100644 new mode 100755 index e46940fdf2..d561e5e2db --- a/scripts/simplebench/results_to_text.py +++ b/scripts/simplebench/results_to_text.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 +# # Simple benchmarking framework # # Copyright (c) 2019 Virtuozzo International GmbH. @@ -110,3 +112,15 @@ def results_to_text(results): tab.append(row) return f'All results are in {dim}\n\n' + tabulate.tabulate(tab) + + +if __name__ == '__main__': + import sys + import json + + if len(sys.argv) < 2: + print(f'USAGE: {sys.argv[0]} results.json') + exit(1) + + with open(sys.argv[1]) as f: + print(results_to_text(json.load(f))) From patchwork Fri Dec 18 15:12: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: 11982479 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1C997C2BBCF for ; Fri, 18 Dec 2020 15:33:09 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 7E3EA23B6C for ; Fri, 18 Dec 2020 15:33:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7E3EA23B6C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:39064 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqHkh-0000rD-Gn for qemu-devel@archiver.kernel.org; Fri, 18 Dec 2020 10:33:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54294) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqHS9-0002rt-0v for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:57 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:35976) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kqHS6-0005a5-Uj for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304434; 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=BZ3AVDP7PsFCYzw2Z6tAtH2iScmw91K0spC2J2QZIqI=; b=VfL6VA6HXbDdT/54q5OegFaBtXgjD0dt8+Zl+ZkNQvPp2gma8o/wqnsMjex5SZ6Ic90pLU rSDS/XaZphuyqLf6bjHQ/Vggii9Gng8u56lSUKaUfQhQV4YB3nITudHiAU1jVRKbMsYl2C CF7DOmo2jpiL2qeoCKge5SQwxURF6x0= 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-537-0vW932ugM2uohay7av6rZQ-1; Fri, 18 Dec 2020 10:13:49 -0500 X-MC-Unique: 0vW932ugM2uohay7av6rZQ-1 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 3B2F71005504; Fri, 18 Dec 2020 15:13:48 +0000 (UTC) Received: from localhost (ovpn-114-84.ams2.redhat.com [10.36.114.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CD6FE47; Fri, 18 Dec 2020 15:13:47 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 25/30] scripts/simplebench: add bench_prealloc.py Date: Fri, 18 Dec 2020 16:12:44 +0100 Message-Id: <20201218151249.715731-26-mreitz@redhat.com> In-Reply-To: <20201218151249.715731-1-mreitz@redhat.com> References: <20201218151249.715731-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Vladimir Sementsov-Ogievskiy Benchmark for new preallocate filter. Example usage: ./bench_prealloc.py ../../build/qemu-img \ ssd-ext4:/path/to/mount/point \ ssd-xfs:/path2 hdd-ext4:/path3 hdd-xfs:/path4 The benchmark shows performance improvement (or degradation) when use new preallocate filter with qcow2 image. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20201021145859.11201-22-vsementsov@virtuozzo.com> Reviewed-by: Max Reitz Signed-off-by: Max Reitz --- scripts/simplebench/bench_prealloc.py | 132 ++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100755 scripts/simplebench/bench_prealloc.py diff --git a/scripts/simplebench/bench_prealloc.py b/scripts/simplebench/bench_prealloc.py new file mode 100755 index 0000000000..85f588c597 --- /dev/null +++ b/scripts/simplebench/bench_prealloc.py @@ -0,0 +1,132 @@ +#!/usr/bin/env python3 +# +# Benchmark preallocate filter +# +# Copyright (c) 2020 Virtuozzo International GmbH. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + + +import sys +import os +import subprocess +import re +import json + +import simplebench +from results_to_text import results_to_text + + +def qemu_img_bench(args): + p = subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, + universal_newlines=True) + + if p.returncode == 0: + try: + m = re.search(r'Run completed in (\d+.\d+) seconds.', p.stdout) + return {'seconds': float(m.group(1))} + except Exception: + return {'error': f'failed to parse qemu-img output: {p.stdout}'} + else: + return {'error': f'qemu-img failed: {p.returncode}: {p.stdout}'} + + +def bench_func(env, case): + fname = f"{case['dir']}/prealloc-test.qcow2" + try: + os.remove(fname) + except OSError: + pass + + subprocess.run([env['qemu-img-binary'], 'create', '-f', 'qcow2', fname, + '16G'], stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, check=True) + + args = [env['qemu-img-binary'], 'bench', '-c', str(case['count']), + '-d', '64', '-s', case['block-size'], '-t', 'none', '-n', '-w'] + if env['prealloc']: + args += ['--image-opts', + 'driver=qcow2,file.driver=preallocate,file.file.driver=file,' + f'file.file.filename={fname}'] + else: + args += ['-f', 'qcow2', fname] + + return qemu_img_bench(args) + + +def auto_count_bench_func(env, case): + case['count'] = 100 + while True: + res = bench_func(env, case) + if 'error' in res: + return res + + if res['seconds'] >= 1: + break + + case['count'] *= 10 + + if res['seconds'] < 5: + case['count'] = round(case['count'] * 5 / res['seconds']) + res = bench_func(env, case) + if 'error' in res: + return res + + res['iops'] = case['count'] / res['seconds'] + return res + + +if __name__ == '__main__': + if len(sys.argv) < 2: + print(f'USAGE: {sys.argv[0]} ' + 'DISK_NAME:DIR_PATH ...') + exit(1) + + qemu_img = sys.argv[1] + + envs = [ + { + 'id': 'no-prealloc', + 'qemu-img-binary': qemu_img, + 'prealloc': False + }, + { + 'id': 'prealloc', + 'qemu-img-binary': qemu_img, + 'prealloc': True + } + ] + + aligned_cases = [] + unaligned_cases = [] + + for disk in sys.argv[2:]: + name, path = disk.split(':') + aligned_cases.append({ + 'id': f'{name}, aligned sequential 16k', + 'block-size': '16k', + 'dir': path + }) + unaligned_cases.append({ + 'id': f'{name}, unaligned sequential 64k', + 'block-size': '16k', + 'dir': path + }) + + result = simplebench.bench(auto_count_bench_func, envs, + aligned_cases + unaligned_cases, count=5) + print(results_to_text(result)) + with open('results.json', 'w') as f: + json.dump(result, f, indent=4) From patchwork Fri Dec 18 15:12: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: 11982467 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 146C3C4361B for ; Fri, 18 Dec 2020 15:27:45 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 8DFB323B53 for ; Fri, 18 Dec 2020 15:27:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8DFB323B53 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:53308 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqHfT-0003DT-IU for qemu-devel@archiver.kernel.org; Fri, 18 Dec 2020 10:27:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54328) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqHSA-0002tr-Br for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:58 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:23488) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kqHS6-0005a8-Um for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304434; 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=fNDKJfS0v1GZqQkI8LDVSyWXYQEb7GcuSlqNCJzmHrs=; b=MTU1EmbkdjLOBbN391/8JI87XN56me+m3YAj7G/Al64Z6M2HBd+vJhDcAgfLXiTTPJFcz8 uYk9SLZgnpGQpUaWyctpEvRQQu6NBY52Z/PQ2jlWXY1+xnTvon+5GqTggQphmmm4NtE6yM pdfUtt2eIGUl+L69StGT5WtdMI+vcFM= 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-411-9JmXfpuePOSwjnIDrao9-Q-1; Fri, 18 Dec 2020 10:13:51 -0500 X-MC-Unique: 9JmXfpuePOSwjnIDrao9-Q-1 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 8CC3259; Fri, 18 Dec 2020 15:13:50 +0000 (UTC) Received: from localhost (ovpn-114-84.ams2.redhat.com [10.36.114.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 027682C161; Fri, 18 Dec 2020 15:13:49 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 26/30] quorum: Implement bdrv_co_block_status() Date: Fri, 18 Dec 2020 16:12:45 +0100 Message-Id: <20201218151249.715731-27-mreitz@redhat.com> In-Reply-To: <20201218151249.715731-1-mreitz@redhat.com> References: <20201218151249.715731-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Alberto Garcia The quorum driver does not implement bdrv_co_block_status() and because of that it always reports to contain data even if all its children are known to be empty. One consequence of this is that if we for example create a quorum with a size of 10GB and we mirror it to a new image the operation will write 10GB of actual zeroes to the destination image wasting a lot of time and disk space. Since a quorum has an arbitrary number of children of potentially different formats there is no way to report all possible allocation status flags in a way that makes sense, so this implementation only reports when a given region is known to contain zeroes (BDRV_BLOCK_ZERO) or not (BDRV_BLOCK_DATA). If all children agree that a region contains zeroes then we can return BDRV_BLOCK_ZERO using the smallest size reported by the children (because all agree that a region of at least that size contains zeroes). If at least one child disagrees we have to return BDRV_BLOCK_DATA. In this case we use the largest of the sizes reported by the children that didn't return BDRV_BLOCK_ZERO (because we know that there won't be an agreement for at least that size). Signed-off-by: Alberto Garcia Tested-by: Tao Xu Reviewed-by: Max Reitz Message-Id: Signed-off-by: Max Reitz --- block/quorum.c | 52 +++++++++++++ tests/qemu-iotests/312 | 148 +++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/312.out | 67 +++++++++++++++++ tests/qemu-iotests/group | 1 + 4 files changed, 268 insertions(+) create mode 100755 tests/qemu-iotests/312 create mode 100644 tests/qemu-iotests/312.out diff --git a/block/quorum.c b/block/quorum.c index 4b08a199b7..ae62b206c9 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -18,6 +18,7 @@ #include "qemu/module.h" #include "qemu/option.h" #include "block/block_int.h" +#include "block/coroutines.h" #include "block/qdict.h" #include "qapi/error.h" #include "qapi/qapi-events-block.h" @@ -1179,6 +1180,56 @@ static void quorum_child_perm(BlockDriverState *bs, BdrvChild *c, | DEFAULT_PERM_UNCHANGED; } +/* + * Each one of the children can report different status flags even + * when they contain the same data, so what this function does is + * return BDRV_BLOCK_ZERO if *all* children agree that a certain + * region contains zeroes, and BDRV_BLOCK_DATA otherwise. + */ +static int coroutine_fn quorum_co_block_status(BlockDriverState *bs, + bool want_zero, + int64_t offset, int64_t count, + int64_t *pnum, int64_t *map, + BlockDriverState **file) +{ + BDRVQuorumState *s = bs->opaque; + int i, ret; + int64_t pnum_zero = count; + int64_t pnum_data = 0; + + for (i = 0; i < s->num_children; i++) { + int64_t bytes; + ret = bdrv_co_common_block_status_above(s->children[i]->bs, NULL, false, + want_zero, offset, count, + &bytes, NULL, NULL, NULL); + if (ret < 0) { + quorum_report_bad(QUORUM_OP_TYPE_READ, offset, count, + s->children[i]->bs->node_name, ret); + pnum_data = count; + break; + } + /* + * Even if all children agree about whether there are zeroes + * or not at @offset they might disagree on the size, so use + * the smallest when reporting BDRV_BLOCK_ZERO and the largest + * when reporting BDRV_BLOCK_DATA. + */ + if (ret & BDRV_BLOCK_ZERO) { + pnum_zero = MIN(pnum_zero, bytes); + } else { + pnum_data = MAX(pnum_data, bytes); + } + } + + if (pnum_data) { + *pnum = pnum_data; + return BDRV_BLOCK_DATA; + } else { + *pnum = pnum_zero; + return BDRV_BLOCK_ZERO; + } +} + static const char *const quorum_strong_runtime_opts[] = { QUORUM_OPT_VOTE_THRESHOLD, QUORUM_OPT_BLKVERIFY, @@ -1197,6 +1248,7 @@ static BlockDriver bdrv_quorum = { .bdrv_close = quorum_close, .bdrv_gather_child_options = quorum_gather_child_options, .bdrv_dirname = quorum_dirname, + .bdrv_co_block_status = quorum_co_block_status, .bdrv_co_flush_to_disk = quorum_co_flush, diff --git a/tests/qemu-iotests/312 b/tests/qemu-iotests/312 new file mode 100755 index 0000000000..1b08f1552f --- /dev/null +++ b/tests/qemu-iotests/312 @@ -0,0 +1,148 @@ +#!/usr/bin/env bash +# +# Test drive-mirror with quorum +# +# The goal of this test is to check how the quorum driver reports +# regions that are known to read as zeroes (BDRV_BLOCK_ZERO). The idea +# is that drive-mirror will try the efficient representation of zeroes +# in the destination image instead of writing actual zeroes. +# +# Copyright (C) 2020 Igalia, S.L. +# Author: Alberto Garcia +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# creator +owner=berto@igalia.com + +seq=`basename $0` +echo "QA output created by $seq" + +status=1 # failure is the default! + +_cleanup() +{ + _rm_test_img "$TEST_IMG.0" + _rm_test_img "$TEST_IMG.1" + _rm_test_img "$TEST_IMG.2" + _rm_test_img "$TEST_IMG.3" + _cleanup_qemu +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter +. ./common.qemu + +_supported_fmt qcow2 +_supported_proto file +_supported_os Linux +_unsupported_imgopts cluster_size data_file + +echo +echo '### Create all images' # three source (quorum), one destination +echo +TEST_IMG="$TEST_IMG.0" _make_test_img -o cluster_size=64k 10M +TEST_IMG="$TEST_IMG.1" _make_test_img -o cluster_size=64k 10M +TEST_IMG="$TEST_IMG.2" _make_test_img -o cluster_size=64k 10M +TEST_IMG="$TEST_IMG.3" _make_test_img -o cluster_size=64k 10M + +quorum="driver=raw,file.driver=quorum,file.vote-threshold=2" +quorum="$quorum,file.children.0.file.filename=$TEST_IMG.0" +quorum="$quorum,file.children.1.file.filename=$TEST_IMG.1" +quorum="$quorum,file.children.2.file.filename=$TEST_IMG.2" +quorum="$quorum,file.children.0.driver=$IMGFMT" +quorum="$quorum,file.children.1.driver=$IMGFMT" +quorum="$quorum,file.children.2.driver=$IMGFMT" + +echo +echo '### Output of qemu-img map (empty quorum)' +echo +$QEMU_IMG map --image-opts $quorum | _filter_qemu_img_map + +# Now we write data to the quorum. All three images will read as +# zeroes in all cases, but with different ways to represent them +# (unallocated clusters, zero clusters, data clusters with zeroes) +# that will have an effect on how the data will be mirrored and the +# output of qemu-img map on the resulting image. +echo +echo '### Write data to the quorum' +echo +# Test 1: data regions surrounded by unallocated clusters. +# Three data regions, the largest one (0x30000) will be picked, end result: +# offset 0x10000, length 0x30000 -> data +$QEMU_IO -c "write -P 0 $((0x10000)) $((0x10000))" "$TEST_IMG.0" | _filter_qemu_io +$QEMU_IO -c "write -P 0 $((0x10000)) $((0x30000))" "$TEST_IMG.1" | _filter_qemu_io +$QEMU_IO -c "write -P 0 $((0x10000)) $((0x20000))" "$TEST_IMG.2" | _filter_qemu_io + +# Test 2: zero regions surrounded by data clusters. +# First we allocate the data clusters. +$QEMU_IO -c "open -o $quorum" -c "write -P 0 $((0x100000)) $((0x40000))" | _filter_qemu_io + +# Three zero regions, the smallest one (0x10000) will be picked, end result: +# offset 0x100000, length 0x10000 -> data +# offset 0x110000, length 0x10000 -> zeroes +# offset 0x120000, length 0x20000 -> data +$QEMU_IO -c "write -z $((0x110000)) $((0x10000))" "$TEST_IMG.0" | _filter_qemu_io +$QEMU_IO -c "write -z $((0x110000)) $((0x30000))" "$TEST_IMG.1" | _filter_qemu_io +$QEMU_IO -c "write -z $((0x110000)) $((0x20000))" "$TEST_IMG.2" | _filter_qemu_io + +# Test 3: zero clusters surrounded by unallocated clusters. +# Everything reads as zeroes, no effect on the end result. +$QEMU_IO -c "write -z $((0x150000)) $((0x10000))" "$TEST_IMG.0" | _filter_qemu_io +$QEMU_IO -c "write -z $((0x150000)) $((0x30000))" "$TEST_IMG.1" | _filter_qemu_io +$QEMU_IO -c "write -z $((0x150000)) $((0x20000))" "$TEST_IMG.2" | _filter_qemu_io + +# Test 4: mix of data and zero clusters. +# The zero region will be ignored in favor of the largest data region +# (0x20000), end result: +# offset 0x200000, length 0x20000 -> data +$QEMU_IO -c "write -P 0 $((0x200000)) $((0x10000))" "$TEST_IMG.0" | _filter_qemu_io +$QEMU_IO -c "write -z $((0x200000)) $((0x30000))" "$TEST_IMG.1" | _filter_qemu_io +$QEMU_IO -c "write -P 0 $((0x200000)) $((0x20000))" "$TEST_IMG.2" | _filter_qemu_io + +echo +echo '### Launch the drive-mirror job' +echo +qemu_comm_method="qmp" _launch_qemu -drive if=virtio,"$quorum" +h=$QEMU_HANDLE +_send_qemu_cmd $h "{ 'execute': 'qmp_capabilities' }" 'return' + +_send_qemu_cmd $h \ + "{'execute': 'drive-mirror', + 'arguments': {'device': 'virtio0', + 'format': '$IMGFMT', + 'target': '$TEST_IMG.3', + 'sync': 'full', + 'mode': 'existing' }}" \ + "BLOCK_JOB_READY.*virtio0" + +_send_qemu_cmd $h \ + "{ 'execute': 'block-job-complete', + 'arguments': { 'device': 'virtio0' } }" \ + 'BLOCK_JOB_COMPLETED' + +_send_qemu_cmd $h "{ 'execute': 'quit' }" '' + +echo +echo '### Output of qemu-img map (destination image)' +echo +$QEMU_IMG map "$TEST_IMG.3" | _filter_qemu_img_map + +# success, all done +echo "*** done" +rm -f $seq.full +status=0 diff --git a/tests/qemu-iotests/312.out b/tests/qemu-iotests/312.out new file mode 100644 index 0000000000..4ae749175b --- /dev/null +++ b/tests/qemu-iotests/312.out @@ -0,0 +1,67 @@ +QA output created by 312 + +### Create all images + +Formatting 'TEST_DIR/t.IMGFMT.0', fmt=IMGFMT size=10485760 +Formatting 'TEST_DIR/t.IMGFMT.1', fmt=IMGFMT size=10485760 +Formatting 'TEST_DIR/t.IMGFMT.2', fmt=IMGFMT size=10485760 +Formatting 'TEST_DIR/t.IMGFMT.3', fmt=IMGFMT size=10485760 + +### Output of qemu-img map (empty quorum) + +Offset Length File + +### Write data to the quorum + +wrote 65536/65536 bytes at offset 65536 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 196608/196608 bytes at offset 65536 +192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 131072/131072 bytes at offset 65536 +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 262144/262144 bytes at offset 1048576 +256 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 65536/65536 bytes at offset 1114112 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 196608/196608 bytes at offset 1114112 +192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 131072/131072 bytes at offset 1114112 +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 65536/65536 bytes at offset 1376256 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 196608/196608 bytes at offset 1376256 +192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 131072/131072 bytes at offset 1376256 +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 65536/65536 bytes at offset 2097152 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 196608/196608 bytes at offset 2097152 +192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 131072/131072 bytes at offset 2097152 +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +### Launch the drive-mirror job + +{ 'execute': 'qmp_capabilities' } +{"return": {}} +{'execute': 'drive-mirror', 'arguments': {'device': 'virtio0', 'format': 'IMGFMT', 'target': 'TEST_DIR/t.IMGFMT.3', 'sync': 'full', 'mode': 'existing' }} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "virtio0"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "virtio0"}} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "virtio0"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "virtio0", "len": 10485760, "offset": 10485760, "speed": 0, "type": "mirror"}} +{ 'execute': 'block-job-complete', 'arguments': { 'device': 'virtio0' } } +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "virtio0"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "virtio0"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "virtio0", "len": 10485760, "offset": 10485760, "speed": 0, "type": "mirror"}} +{ 'execute': 'quit' } + +### Output of qemu-img map (destination image) + +Offset Length File +0x10000 0x30000 TEST_DIR/t.IMGFMT.3 +0x100000 0x10000 TEST_DIR/t.IMGFMT.3 +0x120000 0x20000 TEST_DIR/t.IMGFMT.3 +0x200000 0x20000 TEST_DIR/t.IMGFMT.3 +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 614d58369e..e4fb6327ae 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -318,3 +318,4 @@ 307 rw quick export 308 rw 309 rw auto quick +312 rw auto quick From patchwork Fri Dec 18 15:12: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: 11982487 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A400C4361B for ; Fri, 18 Dec 2020 15:36:45 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id E560523B5F for ; Fri, 18 Dec 2020 15:36:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E560523B5F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:47354 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqHoB-0004QY-ON for qemu-devel@archiver.kernel.org; Fri, 18 Dec 2020 10:36:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54338) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqHSB-0002xI-LA for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:59 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:44331) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kqHS8-0005b7-Ga for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:13:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304435; 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=R/hOmvFwDOtIOQGX7c1jZLrvK6WQnrE3kQaHrbdYWaU=; b=AY1d+yeQrNjCXR9SH1e9SNygsU3INcuzMd5Qm5eYX+1sRBQGRgT3WyRccdoF4Np1WkrMOJ ReIcRs0yKTIoQHj/YgOmFP/EX1XQtEQqan/KmJAJpU/OotlQLFAoo7U8oEyVCCF7Fn/cPA UApH8m/ON/gMvlICD+WI6f320o09uzE= 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-207-ALHM8o1KPuec-4m5DX6waw-1; Fri, 18 Dec 2020 10:13:54 -0500 X-MC-Unique: ALHM8o1KPuec-4m5DX6waw-1 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 D12F6190B2A1; Fri, 18 Dec 2020 15:13:52 +0000 (UTC) Received: from localhost (ovpn-114-84.ams2.redhat.com [10.36.114.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7150210016FF; Fri, 18 Dec 2020 15:13:52 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 27/30] quorum: Implement bdrv_co_pwrite_zeroes() Date: Fri, 18 Dec 2020 16:12:46 +0100 Message-Id: <20201218151249.715731-28-mreitz@redhat.com> In-Reply-To: <20201218151249.715731-1-mreitz@redhat.com> References: <20201218151249.715731-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Alberto Garcia This simply calls bdrv_co_pwrite_zeroes() in all children. bs->supported_zero_flags is also set to the flags that are supported by all children. Signed-off-by: Alberto Garcia Message-Id: <2f09c842781fe336b4c2e40036bba577b7430190.1605286097.git.berto@igalia.com> Reviewed-by: Max Reitz Signed-off-by: Max Reitz --- block/quorum.c | 36 ++++++++++++++++++++++++++++++++++-- tests/qemu-iotests/312 | 11 +++++++++++ tests/qemu-iotests/312.out | 8 ++++++++ 3 files changed, 53 insertions(+), 2 deletions(-) diff --git a/block/quorum.c b/block/quorum.c index ae62b206c9..0bd75450de 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -692,8 +692,13 @@ static void write_quorum_entry(void *opaque) QuorumChildRequest *sacb = &acb->qcrs[i]; sacb->bs = s->children[i]->bs; - sacb->ret = bdrv_co_pwritev(s->children[i], acb->offset, acb->bytes, - acb->qiov, acb->flags); + if (acb->flags & BDRV_REQ_ZERO_WRITE) { + sacb->ret = bdrv_co_pwrite_zeroes(s->children[i], acb->offset, + acb->bytes, acb->flags); + } else { + sacb->ret = bdrv_co_pwritev(s->children[i], acb->offset, acb->bytes, + acb->qiov, acb->flags); + } if (sacb->ret == 0) { acb->success_count++; } else { @@ -739,6 +744,14 @@ static int quorum_co_pwritev(BlockDriverState *bs, uint64_t offset, return ret; } +static int quorum_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, + int bytes, BdrvRequestFlags flags) + +{ + return quorum_co_pwritev(bs, offset, bytes, NULL, + flags | BDRV_REQ_ZERO_WRITE); +} + static int64_t quorum_getlength(BlockDriverState *bs) { BDRVQuorumState *s = bs->opaque; @@ -897,6 +910,21 @@ static QemuOptsList quorum_runtime_opts = { }, }; +static void quorum_refresh_flags(BlockDriverState *bs) +{ + BDRVQuorumState *s = bs->opaque; + int i; + + bs->supported_zero_flags = + BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK; + + for (i = 0; i < s->num_children; i++) { + bs->supported_zero_flags &= s->children[i]->bs->supported_zero_flags; + } + + bs->supported_zero_flags |= BDRV_REQ_WRITE_UNCHANGED; +} + static int quorum_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { @@ -991,6 +1019,7 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags, s->next_child_index = s->num_children; bs->supported_write_flags = BDRV_REQ_WRITE_UNCHANGED; + quorum_refresh_flags(bs); g_free(opened); goto exit; @@ -1062,6 +1091,7 @@ static void quorum_add_child(BlockDriverState *bs, BlockDriverState *child_bs, } s->children = g_renew(BdrvChild *, s->children, s->num_children + 1); s->children[s->num_children++] = child; + quorum_refresh_flags(bs); out: bdrv_drained_end(bs); @@ -1106,6 +1136,7 @@ static void quorum_del_child(BlockDriverState *bs, BdrvChild *child, s->children = g_renew(BdrvChild *, s->children, --s->num_children); bdrv_unref_child(bs, child); + quorum_refresh_flags(bs); bdrv_drained_end(bs); } @@ -1256,6 +1287,7 @@ static BlockDriver bdrv_quorum = { .bdrv_co_preadv = quorum_co_preadv, .bdrv_co_pwritev = quorum_co_pwritev, + .bdrv_co_pwrite_zeroes = quorum_co_pwrite_zeroes, .bdrv_add_child = quorum_add_child, .bdrv_del_child = quorum_del_child, diff --git a/tests/qemu-iotests/312 b/tests/qemu-iotests/312 index 1b08f1552f..41340494b0 100755 --- a/tests/qemu-iotests/312 +++ b/tests/qemu-iotests/312 @@ -114,6 +114,17 @@ $QEMU_IO -c "write -P 0 $((0x200000)) $((0x10000))" "$TEST_IMG.0" | _filter_qemu $QEMU_IO -c "write -z $((0x200000)) $((0x30000))" "$TEST_IMG.1" | _filter_qemu_io $QEMU_IO -c "write -P 0 $((0x200000)) $((0x20000))" "$TEST_IMG.2" | _filter_qemu_io +# Test 5: write data to a region and then zeroize it, doing it +# directly on the quorum device instead of the individual images. +# This has no effect on the end result but proves that the quorum driver +# supports 'write -z'. +$QEMU_IO -c "open -o $quorum" -c "write -P 1 $((0x250000)) $((0x10000))" | _filter_qemu_io +# Verify the data that we just wrote +$QEMU_IO -c "open -o $quorum" -c "read -P 1 $((0x250000)) $((0x10000))" | _filter_qemu_io +$QEMU_IO -c "open -o $quorum" -c "write -z $((0x250000)) $((0x10000))" | _filter_qemu_io +# Now it should read back as zeroes +$QEMU_IO -c "open -o $quorum" -c "read -P 0 $((0x250000)) $((0x10000))" | _filter_qemu_io + echo echo '### Launch the drive-mirror job' echo diff --git a/tests/qemu-iotests/312.out b/tests/qemu-iotests/312.out index 4ae749175b..cdd5c40e08 100644 --- a/tests/qemu-iotests/312.out +++ b/tests/qemu-iotests/312.out @@ -39,6 +39,14 @@ wrote 196608/196608 bytes at offset 2097152 192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) wrote 131072/131072 bytes at offset 2097152 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 65536/65536 bytes at offset 2424832 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 65536/65536 bytes at offset 2424832 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 65536/65536 bytes at offset 2424832 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 65536/65536 bytes at offset 2424832 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) ### Launch the drive-mirror job From patchwork Fri Dec 18 15:12:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 11982493 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41609C4361B for ; Fri, 18 Dec 2020 15:43:33 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id ABD4E23B5D for ; Fri, 18 Dec 2020 15:43:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ABD4E23B5D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:37640 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqHul-0003q8-I8 for qemu-devel@archiver.kernel.org; Fri, 18 Dec 2020 10:43:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54360) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqHSC-00030n-UX for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:14:01 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:45935) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kqHSB-0005bd-3W for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:14:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304438; 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=bbESsW0annaeju1lI3S5fHFEdy1nFIfky+7IOLaBTig=; b=VkrQT6wxWFIg9EwBAErX+kJ2du/zk5LlLOalq/CbgsowxIG9Vx8AlB/gPcOJrlohl/aTcl FlCXCFPR16HktGBHBrgCpHEPfBxf6cXeUmcrf6DJs3LqH8VZGdZACwh6flZ0O176tYh64N myE8/RYVeDtZAHOriG/LH6sdGPlTf8w= 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-398-UmRTWybROTm9EHgLm7eaAg-1; Fri, 18 Dec 2020 10:13:55 -0500 X-MC-Unique: UmRTWybROTm9EHgLm7eaAg-1 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 DF6BF803620; Fri, 18 Dec 2020 15:13:54 +0000 (UTC) Received: from localhost (ovpn-114-84.ams2.redhat.com [10.36.114.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 84CC7648A3; Fri, 18 Dec 2020 15:13:54 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 28/30] block/nvme: Implement fake truncate() coroutine Date: Fri, 18 Dec 2020 16:12:47 +0100 Message-Id: <20201218151249.715731-29-mreitz@redhat.com> In-Reply-To: <20201218151249.715731-1-mreitz@redhat.com> References: <20201218151249.715731-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé NVMe drive cannot be shrunk. Since commit c80d8b06cfa we can use the @exact parameter (set to false) to return success if the block device is larger than the requested offset (even if we can not be shrunk). Use this parameter to implement the NVMe truncate() coroutine, similarly how it is done for the iscsi and file-posix drivers (see commit 82325ae5f2f "Evaluate @exact in protocol drivers"). Reported-by: Xueqiang Wei Suggested-by: Max Reitz Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20201210125202.858656-1-philmd@redhat.com> Signed-off-by: Max Reitz --- block/nvme.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/block/nvme.c b/block/nvme.c index a06a188d53..5a6fbacf4a 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -1389,6 +1389,29 @@ out: } +static int coroutine_fn nvme_co_truncate(BlockDriverState *bs, int64_t offset, + bool exact, PreallocMode prealloc, + BdrvRequestFlags flags, Error **errp) +{ + int64_t cur_length; + + if (prealloc != PREALLOC_MODE_OFF) { + error_setg(errp, "Unsupported preallocation mode '%s'", + PreallocMode_str(prealloc)); + return -ENOTSUP; + } + + cur_length = nvme_getlength(bs); + if (offset != cur_length && exact) { + error_setg(errp, "Cannot resize NVMe devices"); + return -ENOTSUP; + } else if (offset > cur_length) { + error_setg(errp, "Cannot grow NVMe devices"); + return -EINVAL; + } + + return 0; +} static int nvme_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue, Error **errp) @@ -1523,6 +1546,7 @@ static BlockDriver bdrv_nvme = { .bdrv_close = nvme_close, .bdrv_getlength = nvme_getlength, .bdrv_probe_blocksizes = nvme_probe_blocksizes, + .bdrv_co_truncate = nvme_co_truncate, .bdrv_co_preadv = nvme_co_preadv, .bdrv_co_pwritev = nvme_co_pwritev, From patchwork Fri Dec 18 15:12: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: 11982495 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C607C4361B for ; Fri, 18 Dec 2020 15:47:08 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id ADC0623B5D for ; Fri, 18 Dec 2020 15:47:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ADC0623B5D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:44892 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqHyE-0006wI-KK for qemu-devel@archiver.kernel.org; Fri, 18 Dec 2020 10:47:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54390) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqHSG-00039c-OX for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:14:04 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:36934) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kqHSE-0005d1-FV for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:14:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304441; 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=qn7Q59EnGP1ZPTEhjI1jJerEcE7RQ8xV8wemuoF33kQ=; b=hHmxia1Cr0Ei0ItomqNLtiWxBa/+g44ZTukJC5pKm3nL1WcN7z0bYuKK+nSx080uLVuhuV s5oWflx0ReIjKI2BkmHqv9Bp0w6TIuHNxEzlTT2KekbjtSfk9oMlK/JfEs4jyf6O3v13El ExO+kgbs6mUNdOD0iE0qGXuEXf45Xa8= 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-61-v64iocrRMOiMotChjmXD5g-1; Fri, 18 Dec 2020 10:13:58 -0500 X-MC-Unique: v64iocrRMOiMotChjmXD5g-1 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 0C7E5800D62; Fri, 18 Dec 2020 15:13:57 +0000 (UTC) Received: from localhost (ovpn-114-84.ams2.redhat.com [10.36.114.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A76555D769; Fri, 18 Dec 2020 15:13:56 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 29/30] iotests/102: Pass $QEMU_HANDLE to _send_qemu_cmd Date: Fri, 18 Dec 2020 16:12:48 +0100 Message-Id: <20201218151249.715731-30-mreitz@redhat.com> In-Reply-To: <20201218151249.715731-1-mreitz@redhat.com> References: <20201218151249.715731-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The first parameter passed to _send_qemu_cmd is supposed to be the $QEMU_HANDLE. 102 does not do so here, fix it. As a result, the output changes: Now we see the prompt this command is supposedly waiting for before the resize message - as it should be. Signed-off-by: Max Reitz Message-Id: <20201217153803.101231-2-mreitz@redhat.com> Reviewed-by: Kevin Wolf --- tests/qemu-iotests/102 | 2 +- tests/qemu-iotests/102.out | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/qemu-iotests/102 b/tests/qemu-iotests/102 index 2cc3efd1ed..9d747c7bbf 100755 --- a/tests/qemu-iotests/102 +++ b/tests/qemu-iotests/102 @@ -68,7 +68,7 @@ $QEMU_IO -c 'write 0 64k' "$TEST_IMG" | _filter_qemu_io qemu_comm_method=monitor _launch_qemu -drive if=none,file="$TEST_IMG",id=drv0 # Wait for a prompt to appear (so we know qemu has opened the image) -_send_qemu_cmd '' '(qemu)' +_send_qemu_cmd $QEMU_HANDLE '' '(qemu)' $QEMU_IMG resize --shrink --image-opts \ "driver=raw,file.driver=file,file.filename=$TEST_IMG,file.locking=off" \ diff --git a/tests/qemu-iotests/102.out b/tests/qemu-iotests/102.out index cd2fdc7f96..320ed5a52b 100644 --- a/tests/qemu-iotests/102.out +++ b/tests/qemu-iotests/102.out @@ -16,8 +16,8 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=65536 wrote 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) QEMU X.Y.Z monitor - type 'help' for more information -Image resized. (qemu) +Image resized. (qemu) qemu-io drv0 map 64 KiB (0x10000) bytes allocated at offset 0 bytes (0x0) *** done From patchwork Fri Dec 18 15:12: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: 11982477 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2627C4361B for ; Fri, 18 Dec 2020 15:31:29 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 2565923B55 for ; Fri, 18 Dec 2020 15:31:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2565923B55 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:34594 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqHj5-0007Fz-UU for qemu-devel@archiver.kernel.org; Fri, 18 Dec 2020 10:31:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54428) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqHSM-0003Lx-LM for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:14:10 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:22649) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kqHSI-0005fR-A1 for qemu-devel@nongnu.org; Fri, 18 Dec 2020 10:14:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304445; 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=2xPLsnabpMb80NLw/iMCPCLH3FG6MvqTXfLJQWfzdlE=; b=HBMVqt+CfIlCzfr636gawkT2IuMqhQoexB3FIhQFGoB1dA+ZXIPNxjczO8jBtjkCyaeXoM ax6AQ4pCEqBFRiWDTDkUM8niDccp1qGyzHNDndr6lpa5rGHw/18rabVzfhoq7guIJiHNng weRwJD3jLMPWsW2FZYJeipw9Mm05ULg= 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-464-Bj202HOMMoKoBjl2Yj_6Hw-1; Fri, 18 Dec 2020 10:14:01 -0500 X-MC-Unique: Bj202HOMMoKoBjl2Yj_6Hw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1BAFC59; Fri, 18 Dec 2020 15:14:00 +0000 (UTC) Received: from localhost (ovpn-114-84.ams2.redhat.com [10.36.114.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EBC875C1C5; Fri, 18 Dec 2020 15:13:58 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 30/30] iotests: Fix _send_qemu_cmd with bash 5.1 Date: Fri, 18 Dec 2020 16:12:49 +0100 Message-Id: <20201218151249.715731-31-mreitz@redhat.com> In-Reply-To: <20201218151249.715731-1-mreitz@redhat.com> References: <20201218151249.715731-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" With bash 5.1, the output of the following script changes: a=("double space") a=${a[@]:0:1} echo "$a" from "double space" to "double space", i.e. all white space is preserved as-is. This is probably what we actually want here (judging from the "...to accommodate pathnames with spaces" comment), but before 5.1, we would have to quote the ${} slice to get the same behavior. In any case, without quoting, the reference output of many iotests is different between bash 5.1 and pre-5.1, which is not very good. The output of 5.1 is what we want, so whatever we do to get pre-5.1 to the same result, it means we have to fix the reference output of basically all tests that invoke _send_qemu_cmd (except the ones that only use single spaces in the commands they invoke). Instead of quoting the ${} slice (cmd="${$@: 1:...}"), we can also just not use array slicing and replace the whole thing with a simple "cmd=$1; shift", which works because all callers quote the whole $cmd argument anyway. Signed-off-by: Max Reitz Message-Id: <20201217153803.101231-3-mreitz@redhat.com> Reviewed-by: Kevin Wolf --- tests/qemu-iotests/085.out | 167 ++++++++++++++++++++++++++++----- tests/qemu-iotests/094.out | 10 +- tests/qemu-iotests/095.out | 4 +- tests/qemu-iotests/109.out | 88 ++++++++++++----- tests/qemu-iotests/117.out | 13 ++- tests/qemu-iotests/127.out | 12 ++- tests/qemu-iotests/140.out | 10 +- tests/qemu-iotests/141.out | 128 +++++++++++++++++++------ tests/qemu-iotests/143.out | 4 +- tests/qemu-iotests/144.out | 28 +++++- tests/qemu-iotests/153.out | 18 ++-- tests/qemu-iotests/156.out | 39 ++++++-- tests/qemu-iotests/161.out | 18 +++- tests/qemu-iotests/173.out | 25 ++++- tests/qemu-iotests/182.out | 42 +++++++-- tests/qemu-iotests/183.out | 19 +++- tests/qemu-iotests/185.out | 45 +++++++-- tests/qemu-iotests/191.out | 12 ++- tests/qemu-iotests/223.out | 92 ++++++++++++------ tests/qemu-iotests/229.out | 13 ++- tests/qemu-iotests/249.out | 16 +++- tests/qemu-iotests/308.out | 103 +++++++++++++++++--- tests/qemu-iotests/312.out | 10 +- tests/qemu-iotests/common.qemu | 11 +-- 24 files changed, 728 insertions(+), 199 deletions(-) diff --git a/tests/qemu-iotests/085.out b/tests/qemu-iotests/085.out index 7fc44b1c61..32a193f2c2 100644 --- a/tests/qemu-iotests/085.out +++ b/tests/qemu-iotests/085.out @@ -12,56 +12,135 @@ Formatting 'TEST_DIR/t.IMGFMT.2', fmt=IMGFMT size=134217728 === Create a single snapshot on virtio0 === -{ 'execute': 'blockdev-snapshot-sync', 'arguments': { 'device': 'virtio0', 'snapshot-file':'TEST_DIR/1-snapshot-v0.IMGFMT', 'format': 'IMGFMT' } } +{ 'execute': 'blockdev-snapshot-sync', + 'arguments': { 'device': 'virtio0', + 'snapshot-file':'TEST_DIR/1-snapshot-v0.IMGFMT', + 'format': 'IMGFMT' } } Formatting 'TEST_DIR/1-snapshot-v0.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 backing_file=TEST_DIR/t.qcow2.1 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 {"return": {}} === Invalid command - missing device and nodename === -{ 'execute': 'blockdev-snapshot-sync', 'arguments': { 'snapshot-file':'TEST_DIR/1-snapshot-v0.IMGFMT', 'format': 'IMGFMT' } } +{ 'execute': 'blockdev-snapshot-sync', + 'arguments': { 'snapshot-file':'TEST_DIR/1-snapshot-v0.IMGFMT', + 'format': 'IMGFMT' } } {"error": {"class": "GenericError", "desc": "Cannot find device= nor node_name="}} === Invalid command - missing snapshot-file === -{ 'execute': 'blockdev-snapshot-sync', 'arguments': { 'device': 'virtio0', 'format': 'IMGFMT' } } +{ 'execute': 'blockdev-snapshot-sync', + 'arguments': { 'device': 'virtio0', + 'format': 'IMGFMT' } } {"error": {"class": "GenericError", "desc": "Parameter 'snapshot-file' is missing"}} === Create several transactional group snapshots === -{ 'execute': 'transaction', 'arguments': {'actions': [ { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio0', 'snapshot-file': 'TEST_DIR/2-snapshot-v0.IMGFMT' } }, { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio1', 'snapshot-file': 'TEST_DIR/2-snapshot-v1.IMGFMT' } } ] } } +{ 'execute': 'transaction', 'arguments': + {'actions': [ + { 'type': 'blockdev-snapshot-sync', 'data' : + { 'device': 'virtio0', + 'snapshot-file': 'TEST_DIR/2-snapshot-v0.IMGFMT' } }, + { 'type': 'blockdev-snapshot-sync', 'data' : + { 'device': 'virtio1', + 'snapshot-file': 'TEST_DIR/2-snapshot-v1.IMGFMT' } } ] + } } Formatting 'TEST_DIR/2-snapshot-v0.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 backing_file=TEST_DIR/1-snapshot-v0.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 Formatting 'TEST_DIR/2-snapshot-v1.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 backing_file=TEST_DIR/t.qcow2.2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 {"return": {}} -{ 'execute': 'transaction', 'arguments': {'actions': [ { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio0', 'snapshot-file': 'TEST_DIR/3-snapshot-v0.IMGFMT' } }, { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio1', 'snapshot-file': 'TEST_DIR/3-snapshot-v1.IMGFMT' } } ] } } +{ 'execute': 'transaction', 'arguments': + {'actions': [ + { 'type': 'blockdev-snapshot-sync', 'data' : + { 'device': 'virtio0', + 'snapshot-file': 'TEST_DIR/3-snapshot-v0.IMGFMT' } }, + { 'type': 'blockdev-snapshot-sync', 'data' : + { 'device': 'virtio1', + 'snapshot-file': 'TEST_DIR/3-snapshot-v1.IMGFMT' } } ] + } } Formatting 'TEST_DIR/3-snapshot-v0.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 backing_file=TEST_DIR/2-snapshot-v0.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 Formatting 'TEST_DIR/3-snapshot-v1.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 backing_file=TEST_DIR/2-snapshot-v1.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 {"return": {}} -{ 'execute': 'transaction', 'arguments': {'actions': [ { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio0', 'snapshot-file': 'TEST_DIR/4-snapshot-v0.IMGFMT' } }, { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio1', 'snapshot-file': 'TEST_DIR/4-snapshot-v1.IMGFMT' } } ] } } +{ 'execute': 'transaction', 'arguments': + {'actions': [ + { 'type': 'blockdev-snapshot-sync', 'data' : + { 'device': 'virtio0', + 'snapshot-file': 'TEST_DIR/4-snapshot-v0.IMGFMT' } }, + { 'type': 'blockdev-snapshot-sync', 'data' : + { 'device': 'virtio1', + 'snapshot-file': 'TEST_DIR/4-snapshot-v1.IMGFMT' } } ] + } } Formatting 'TEST_DIR/4-snapshot-v0.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 backing_file=TEST_DIR/3-snapshot-v0.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 Formatting 'TEST_DIR/4-snapshot-v1.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 backing_file=TEST_DIR/3-snapshot-v1.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 {"return": {}} -{ 'execute': 'transaction', 'arguments': {'actions': [ { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio0', 'snapshot-file': 'TEST_DIR/5-snapshot-v0.IMGFMT' } }, { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio1', 'snapshot-file': 'TEST_DIR/5-snapshot-v1.IMGFMT' } } ] } } +{ 'execute': 'transaction', 'arguments': + {'actions': [ + { 'type': 'blockdev-snapshot-sync', 'data' : + { 'device': 'virtio0', + 'snapshot-file': 'TEST_DIR/5-snapshot-v0.IMGFMT' } }, + { 'type': 'blockdev-snapshot-sync', 'data' : + { 'device': 'virtio1', + 'snapshot-file': 'TEST_DIR/5-snapshot-v1.IMGFMT' } } ] + } } Formatting 'TEST_DIR/5-snapshot-v0.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 backing_file=TEST_DIR/4-snapshot-v0.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 Formatting 'TEST_DIR/5-snapshot-v1.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 backing_file=TEST_DIR/4-snapshot-v1.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 {"return": {}} -{ 'execute': 'transaction', 'arguments': {'actions': [ { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio0', 'snapshot-file': 'TEST_DIR/6-snapshot-v0.IMGFMT' } }, { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio1', 'snapshot-file': 'TEST_DIR/6-snapshot-v1.IMGFMT' } } ] } } +{ 'execute': 'transaction', 'arguments': + {'actions': [ + { 'type': 'blockdev-snapshot-sync', 'data' : + { 'device': 'virtio0', + 'snapshot-file': 'TEST_DIR/6-snapshot-v0.IMGFMT' } }, + { 'type': 'blockdev-snapshot-sync', 'data' : + { 'device': 'virtio1', + 'snapshot-file': 'TEST_DIR/6-snapshot-v1.IMGFMT' } } ] + } } Formatting 'TEST_DIR/6-snapshot-v0.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 backing_file=TEST_DIR/5-snapshot-v0.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 Formatting 'TEST_DIR/6-snapshot-v1.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 backing_file=TEST_DIR/5-snapshot-v1.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 {"return": {}} -{ 'execute': 'transaction', 'arguments': {'actions': [ { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio0', 'snapshot-file': 'TEST_DIR/7-snapshot-v0.IMGFMT' } }, { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio1', 'snapshot-file': 'TEST_DIR/7-snapshot-v1.IMGFMT' } } ] } } +{ 'execute': 'transaction', 'arguments': + {'actions': [ + { 'type': 'blockdev-snapshot-sync', 'data' : + { 'device': 'virtio0', + 'snapshot-file': 'TEST_DIR/7-snapshot-v0.IMGFMT' } }, + { 'type': 'blockdev-snapshot-sync', 'data' : + { 'device': 'virtio1', + 'snapshot-file': 'TEST_DIR/7-snapshot-v1.IMGFMT' } } ] + } } Formatting 'TEST_DIR/7-snapshot-v0.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 backing_file=TEST_DIR/6-snapshot-v0.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 Formatting 'TEST_DIR/7-snapshot-v1.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 backing_file=TEST_DIR/6-snapshot-v1.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 {"return": {}} -{ 'execute': 'transaction', 'arguments': {'actions': [ { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio0', 'snapshot-file': 'TEST_DIR/8-snapshot-v0.IMGFMT' } }, { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio1', 'snapshot-file': 'TEST_DIR/8-snapshot-v1.IMGFMT' } } ] } } +{ 'execute': 'transaction', 'arguments': + {'actions': [ + { 'type': 'blockdev-snapshot-sync', 'data' : + { 'device': 'virtio0', + 'snapshot-file': 'TEST_DIR/8-snapshot-v0.IMGFMT' } }, + { 'type': 'blockdev-snapshot-sync', 'data' : + { 'device': 'virtio1', + 'snapshot-file': 'TEST_DIR/8-snapshot-v1.IMGFMT' } } ] + } } Formatting 'TEST_DIR/8-snapshot-v0.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 backing_file=TEST_DIR/7-snapshot-v0.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 Formatting 'TEST_DIR/8-snapshot-v1.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 backing_file=TEST_DIR/7-snapshot-v1.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 {"return": {}} -{ 'execute': 'transaction', 'arguments': {'actions': [ { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio0', 'snapshot-file': 'TEST_DIR/9-snapshot-v0.IMGFMT' } }, { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio1', 'snapshot-file': 'TEST_DIR/9-snapshot-v1.IMGFMT' } } ] } } +{ 'execute': 'transaction', 'arguments': + {'actions': [ + { 'type': 'blockdev-snapshot-sync', 'data' : + { 'device': 'virtio0', + 'snapshot-file': 'TEST_DIR/9-snapshot-v0.IMGFMT' } }, + { 'type': 'blockdev-snapshot-sync', 'data' : + { 'device': 'virtio1', + 'snapshot-file': 'TEST_DIR/9-snapshot-v1.IMGFMT' } } ] + } } Formatting 'TEST_DIR/9-snapshot-v0.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 backing_file=TEST_DIR/8-snapshot-v0.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 Formatting 'TEST_DIR/9-snapshot-v1.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 backing_file=TEST_DIR/8-snapshot-v1.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 {"return": {}} -{ 'execute': 'transaction', 'arguments': {'actions': [ { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio0', 'snapshot-file': 'TEST_DIR/10-snapshot-v0.IMGFMT' } }, { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio1', 'snapshot-file': 'TEST_DIR/10-snapshot-v1.IMGFMT' } } ] } } +{ 'execute': 'transaction', 'arguments': + {'actions': [ + { 'type': 'blockdev-snapshot-sync', 'data' : + { 'device': 'virtio0', + 'snapshot-file': 'TEST_DIR/10-snapshot-v0.IMGFMT' } }, + { 'type': 'blockdev-snapshot-sync', 'data' : + { 'device': 'virtio1', + 'snapshot-file': 'TEST_DIR/10-snapshot-v1.IMGFMT' } } ] + } } Formatting 'TEST_DIR/10-snapshot-v0.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 backing_file=TEST_DIR/9-snapshot-v0.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 Formatting 'TEST_DIR/10-snapshot-v1.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 backing_file=TEST_DIR/9-snapshot-v1.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 {"return": {}} @@ -69,48 +148,84 @@ Formatting 'TEST_DIR/10-snapshot-v1.qcow2', fmt=qcow2 cluster_size=65536 extende === Create a couple of snapshots using blockdev-snapshot === Formatting 'TEST_DIR/11-snapshot-v0.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/10-snapshot-v0.IMGFMT backing_fmt=IMGFMT -{ 'execute': 'blockdev-add', 'arguments': { 'driver': 'IMGFMT', 'node-name': 'snap_11', 'backing': null, 'file': { 'driver': 'file', 'filename': 'TEST_DIR/11-snapshot-v0.IMGFMT', 'node-name': 'file_11' } } } +{ 'execute': 'blockdev-add', 'arguments': + { 'driver': 'IMGFMT', 'node-name': 'snap_11', 'backing': null, + 'file': + { 'driver': 'file', 'filename': 'TEST_DIR/11-snapshot-v0.IMGFMT', + 'node-name': 'file_11' } } } {"return": {}} -{ 'execute': 'blockdev-snapshot', 'arguments': { 'node': 'virtio0', 'overlay':'snap_11' } } +{ 'execute': 'blockdev-snapshot', + 'arguments': { 'node': 'virtio0', + 'overlay':'snap_11' } } {"return": {}} Formatting 'TEST_DIR/12-snapshot-v0.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/11-snapshot-v0.IMGFMT backing_fmt=IMGFMT -{ 'execute': 'blockdev-add', 'arguments': { 'driver': 'IMGFMT', 'node-name': 'snap_12', 'backing': null, 'file': { 'driver': 'file', 'filename': 'TEST_DIR/12-snapshot-v0.IMGFMT', 'node-name': 'file_12' } } } +{ 'execute': 'blockdev-add', 'arguments': + { 'driver': 'IMGFMT', 'node-name': 'snap_12', 'backing': null, + 'file': + { 'driver': 'file', 'filename': 'TEST_DIR/12-snapshot-v0.IMGFMT', + 'node-name': 'file_12' } } } {"return": {}} -{ 'execute': 'blockdev-snapshot', 'arguments': { 'node': 'virtio0', 'overlay':'snap_12' } } +{ 'execute': 'blockdev-snapshot', + 'arguments': { 'node': 'virtio0', + 'overlay':'snap_12' } } {"return": {}} === Invalid command - cannot create a snapshot using a file BDS === -{ 'execute': 'blockdev-snapshot', 'arguments': { 'node':'virtio0', 'overlay':'file_12' } } +{ 'execute': 'blockdev-snapshot', + 'arguments': { 'node':'virtio0', + 'overlay':'file_12' } + } {"error": {"class": "GenericError", "desc": "The overlay is already in use"}} === Invalid command - snapshot node used as active layer === -{ 'execute': 'blockdev-snapshot', 'arguments': { 'node': 'virtio0', 'overlay':'snap_12' } } +{ 'execute': 'blockdev-snapshot', + 'arguments': { 'node': 'virtio0', + 'overlay':'snap_12' } } {"error": {"class": "GenericError", "desc": "The overlay is already in use"}} -{ 'execute': 'blockdev-snapshot', 'arguments': { 'node':'virtio0', 'overlay':'virtio0' } } +{ 'execute': 'blockdev-snapshot', + 'arguments': { 'node':'virtio0', + 'overlay':'virtio0' } + } {"error": {"class": "GenericError", "desc": "The overlay is already in use"}} -{ 'execute': 'blockdev-snapshot', 'arguments': { 'node':'virtio0', 'overlay':'virtio1' } } +{ 'execute': 'blockdev-snapshot', + 'arguments': { 'node':'virtio0', + 'overlay':'virtio1' } + } {"error": {"class": "GenericError", "desc": "The overlay is already in use"}} === Invalid command - snapshot node used as backing hd === -{ 'execute': 'blockdev-snapshot', 'arguments': { 'node': 'virtio0', 'overlay':'snap_11' } } +{ 'execute': 'blockdev-snapshot', + 'arguments': { 'node': 'virtio0', + 'overlay':'snap_11' } } {"error": {"class": "GenericError", "desc": "The overlay is already in use"}} === Invalid command - snapshot node has a backing image === Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=134217728 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=IMGFMT -{ 'execute': 'blockdev-add', 'arguments': { 'driver': 'IMGFMT', 'node-name': 'snap_13', 'file': { 'driver': 'file', 'filename': 'TEST_DIR/t.IMGFMT', 'node-name': 'file_13' } } } -{"return": {}} -{ 'execute': 'blockdev-snapshot', 'arguments': { 'node': 'virtio0', 'overlay':'snap_13' } } +{ 'execute': 'blockdev-add', 'arguments': + { 'driver': 'IMGFMT', 'node-name': 'snap_13', + 'file': + { 'driver': 'file', 'filename': 'TEST_DIR/t.IMGFMT', + 'node-name': 'file_13' } } } +{"return": {}} +{ 'execute': 'blockdev-snapshot', + 'arguments': { 'node': 'virtio0', + 'overlay':'snap_13' } } {"error": {"class": "GenericError", "desc": "The overlay already has a backing image"}} === Invalid command - The node does not exist === -{ 'execute': 'blockdev-snapshot', 'arguments': { 'node': 'virtio0', 'overlay':'snap_14' } } +{ 'execute': 'blockdev-snapshot', + 'arguments': { 'node': 'virtio0', + 'overlay':'snap_14' } } {"error": {"class": "GenericError", "desc": "Cannot find device=snap_14 nor node_name=snap_14"}} -{ 'execute': 'blockdev-snapshot', 'arguments': { 'node':'nodevice', 'overlay':'snap_13' } } +{ 'execute': 'blockdev-snapshot', + 'arguments': { 'node':'nodevice', + 'overlay':'snap_13' } + } {"error": {"class": "GenericError", "desc": "Cannot find device=nodevice nor node_name=nodevice"}} *** done diff --git a/tests/qemu-iotests/094.out b/tests/qemu-iotests/094.out index 9b6c57b3e2..97f894cf8f 100644 --- a/tests/qemu-iotests/094.out +++ b/tests/qemu-iotests/094.out @@ -3,13 +3,19 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 Formatting 'TEST_DIR/source.IMGFMT', fmt=IMGFMT size=67108864 {'execute': 'qmp_capabilities'} {"return": {}} -{'execute': 'drive-mirror', 'arguments': {'device': 'src', 'target': 'nbd+unix:///?socket=SOCK_DIR/nbd', 'format': 'nbd', 'sync':'full', 'mode':'existing'}} +{'execute': 'drive-mirror', + 'arguments': {'device': 'src', + 'target': 'nbd+unix:///?socket=SOCK_DIR/nbd', + 'format': 'nbd', + 'sync':'full', + 'mode':'existing'}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "src"}} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "src", "len": 67108864, "offset": 67108864, "speed": 0, "type": "mirror"}} -{'execute': 'block-job-complete', 'arguments': {'device': 'src'}} +{'execute': 'block-job-complete', + 'arguments': {'device': 'src'}} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "src"}} diff --git a/tests/qemu-iotests/095.out b/tests/qemu-iotests/095.out index e66ced58f8..8257c5e1e6 100644 --- a/tests/qemu-iotests/095.out +++ b/tests/qemu-iotests/095.out @@ -12,7 +12,9 @@ virtual size: 5 MiB (5242880 bytes) { 'execute': 'qmp_capabilities' } {"return": {}} -{ 'execute': 'block-commit', 'arguments': { 'device': 'test', 'top': 'TEST_DIR/t.IMGFMT.snp1' } } +{ 'execute': 'block-commit', + 'arguments': { 'device': 'test', + 'top': 'TEST_DIR/t.IMGFMT.snp1' } } {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "test"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "test"}} {"return": {}} diff --git a/tests/qemu-iotests/109.out b/tests/qemu-iotests/109.out index ad739df46c..6e73406cdb 100644 --- a/tests/qemu-iotests/109.out +++ b/tests/qemu-iotests/109.out @@ -6,7 +6,9 @@ Formatting 'TEST_DIR/t.raw.src', fmt=IMGFMT size=67108864 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=SIZE { 'execute': 'qmp_capabilities' } {"return": {}} -{'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', 'mode': 'existing', 'sync': 'full'}} +{'execute':'drive-mirror', 'arguments':{ + 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', + 'mode': 'existing', 'sync': 'full'}} WARNING: Image format was not specified for 'TEST_DIR/t.raw' and probing guessed raw. Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted. Specify the 'raw' format explicitly to remove the restrictions. @@ -27,7 +29,9 @@ read 512/512 bytes at offset 0 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) { 'execute': 'qmp_capabilities' } {"return": {}} -{'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', 'format': 'IMGFMT', 'mode': 'existing', 'sync': 'full'}} +{'execute':'drive-mirror', 'arguments':{ + 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', 'format': 'IMGFMT', + 'mode': 'existing', 'sync': 'full'}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "src"}} {"return": {}} @@ -51,7 +55,9 @@ Formatting 'TEST_DIR/t.raw.src', fmt=IMGFMT size=67108864 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=SIZE { 'execute': 'qmp_capabilities' } {"return": {}} -{'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', 'mode': 'existing', 'sync': 'full'}} +{'execute':'drive-mirror', 'arguments':{ + 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', + 'mode': 'existing', 'sync': 'full'}} WARNING: Image format was not specified for 'TEST_DIR/t.raw' and probing guessed raw. Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted. Specify the 'raw' format explicitly to remove the restrictions. @@ -72,7 +78,9 @@ read 512/512 bytes at offset 0 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) { 'execute': 'qmp_capabilities' } {"return": {}} -{'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', 'format': 'IMGFMT', 'mode': 'existing', 'sync': 'full'}} +{'execute':'drive-mirror', 'arguments':{ + 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', 'format': 'IMGFMT', + 'mode': 'existing', 'sync': 'full'}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "src"}} {"return": {}} @@ -96,7 +104,9 @@ Formatting 'TEST_DIR/t.raw.src', fmt=IMGFMT size=67108864 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=SIZE { 'execute': 'qmp_capabilities' } {"return": {}} -{'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', 'mode': 'existing', 'sync': 'full'}} +{'execute':'drive-mirror', 'arguments':{ + 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', + 'mode': 'existing', 'sync': 'full'}} WARNING: Image format was not specified for 'TEST_DIR/t.raw' and probing guessed raw. Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted. Specify the 'raw' format explicitly to remove the restrictions. @@ -117,7 +127,9 @@ read 512/512 bytes at offset 0 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) { 'execute': 'qmp_capabilities' } {"return": {}} -{'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', 'format': 'IMGFMT', 'mode': 'existing', 'sync': 'full'}} +{'execute':'drive-mirror', 'arguments':{ + 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', 'format': 'IMGFMT', + 'mode': 'existing', 'sync': 'full'}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "src"}} {"return": {}} @@ -141,7 +153,9 @@ Formatting 'TEST_DIR/t.raw.src', fmt=IMGFMT size=67108864 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=SIZE { 'execute': 'qmp_capabilities' } {"return": {}} -{'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', 'mode': 'existing', 'sync': 'full'}} +{'execute':'drive-mirror', 'arguments':{ + 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', + 'mode': 'existing', 'sync': 'full'}} WARNING: Image format was not specified for 'TEST_DIR/t.raw' and probing guessed raw. Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted. Specify the 'raw' format explicitly to remove the restrictions. @@ -162,7 +176,9 @@ read 512/512 bytes at offset 0 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) { 'execute': 'qmp_capabilities' } {"return": {}} -{'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', 'format': 'IMGFMT', 'mode': 'existing', 'sync': 'full'}} +{'execute':'drive-mirror', 'arguments':{ + 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', 'format': 'IMGFMT', + 'mode': 'existing', 'sync': 'full'}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "src"}} {"return": {}} @@ -186,7 +202,9 @@ Formatting 'TEST_DIR/t.raw.src', fmt=IMGFMT size=67108864 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=SIZE { 'execute': 'qmp_capabilities' } {"return": {}} -{'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', 'mode': 'existing', 'sync': 'full'}} +{'execute':'drive-mirror', 'arguments':{ + 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', + 'mode': 'existing', 'sync': 'full'}} WARNING: Image format was not specified for 'TEST_DIR/t.raw' and probing guessed raw. Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted. Specify the 'raw' format explicitly to remove the restrictions. @@ -207,7 +225,9 @@ read 512/512 bytes at offset 0 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) { 'execute': 'qmp_capabilities' } {"return": {}} -{'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', 'format': 'IMGFMT', 'mode': 'existing', 'sync': 'full'}} +{'execute':'drive-mirror', 'arguments':{ + 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', 'format': 'IMGFMT', + 'mode': 'existing', 'sync': 'full'}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "src"}} {"return": {}} @@ -231,7 +251,9 @@ Formatting 'TEST_DIR/t.raw.src', fmt=IMGFMT size=67108864 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=SIZE { 'execute': 'qmp_capabilities' } {"return": {}} -{'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', 'mode': 'existing', 'sync': 'full'}} +{'execute':'drive-mirror', 'arguments':{ + 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', + 'mode': 'existing', 'sync': 'full'}} WARNING: Image format was not specified for 'TEST_DIR/t.raw' and probing guessed raw. Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted. Specify the 'raw' format explicitly to remove the restrictions. @@ -252,7 +274,9 @@ read 512/512 bytes at offset 0 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) { 'execute': 'qmp_capabilities' } {"return": {}} -{'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', 'format': 'IMGFMT', 'mode': 'existing', 'sync': 'full'}} +{'execute':'drive-mirror', 'arguments':{ + 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', 'format': 'IMGFMT', + 'mode': 'existing', 'sync': 'full'}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "src"}} {"return": {}} @@ -275,7 +299,9 @@ Images are identical. Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=SIZE { 'execute': 'qmp_capabilities' } {"return": {}} -{'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', 'mode': 'existing', 'sync': 'full'}} +{'execute':'drive-mirror', 'arguments':{ + 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', + 'mode': 'existing', 'sync': 'full'}} WARNING: Image format was not specified for 'TEST_DIR/t.raw' and probing guessed raw. Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted. Specify the 'raw' format explicitly to remove the restrictions. @@ -296,7 +322,9 @@ read 512/512 bytes at offset 0 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) { 'execute': 'qmp_capabilities' } {"return": {}} -{'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', 'format': 'IMGFMT', 'mode': 'existing', 'sync': 'full'}} +{'execute':'drive-mirror', 'arguments':{ + 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', 'format': 'IMGFMT', + 'mode': 'existing', 'sync': 'full'}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "src"}} {"return": {}} @@ -319,7 +347,9 @@ Images are identical. Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=SIZE { 'execute': 'qmp_capabilities' } {"return": {}} -{'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', 'mode': 'existing', 'sync': 'full'}} +{'execute':'drive-mirror', 'arguments':{ + 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', + 'mode': 'existing', 'sync': 'full'}} WARNING: Image format was not specified for 'TEST_DIR/t.raw' and probing guessed raw. Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted. Specify the 'raw' format explicitly to remove the restrictions. @@ -340,7 +370,9 @@ read 512/512 bytes at offset 0 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) { 'execute': 'qmp_capabilities' } {"return": {}} -{'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', 'format': 'IMGFMT', 'mode': 'existing', 'sync': 'full'}} +{'execute':'drive-mirror', 'arguments':{ + 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', 'format': 'IMGFMT', + 'mode': 'existing', 'sync': 'full'}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "src"}} {"return": {}} @@ -363,7 +395,9 @@ Images are identical. Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=SIZE { 'execute': 'qmp_capabilities' } {"return": {}} -{'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', 'mode': 'existing', 'sync': 'full'}} +{'execute':'drive-mirror', 'arguments':{ + 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', + 'mode': 'existing', 'sync': 'full'}} WARNING: Image format was not specified for 'TEST_DIR/t.raw' and probing guessed raw. Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted. Specify the 'raw' format explicitly to remove the restrictions. @@ -384,7 +418,9 @@ read 512/512 bytes at offset 0 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) { 'execute': 'qmp_capabilities' } {"return": {}} -{'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', 'format': 'IMGFMT', 'mode': 'existing', 'sync': 'full'}} +{'execute':'drive-mirror', 'arguments':{ + 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', 'format': 'IMGFMT', + 'mode': 'existing', 'sync': 'full'}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "src"}} {"return": {}} @@ -407,7 +443,9 @@ Images are identical. Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=SIZE { 'execute': 'qmp_capabilities' } {"return": {}} -{'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', 'mode': 'existing', 'sync': 'full'}} +{'execute':'drive-mirror', 'arguments':{ + 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', + 'mode': 'existing', 'sync': 'full'}} WARNING: Image format was not specified for 'TEST_DIR/t.raw' and probing guessed raw. Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted. Specify the 'raw' format explicitly to remove the restrictions. @@ -428,7 +466,9 @@ read 512/512 bytes at offset 0 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) { 'execute': 'qmp_capabilities' } {"return": {}} -{'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', 'format': 'IMGFMT', 'mode': 'existing', 'sync': 'full'}} +{'execute':'drive-mirror', 'arguments':{ + 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', 'format': 'IMGFMT', + 'mode': 'existing', 'sync': 'full'}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "src"}} {"return": {}} @@ -451,7 +491,9 @@ Images are identical. Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=SIZE { 'execute': 'qmp_capabilities' } {"return": {}} -{'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', 'mode': 'existing', 'sync': 'full'}} +{'execute':'drive-mirror', 'arguments':{ + 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', + 'mode': 'existing', 'sync': 'full'}} WARNING: Image format was not specified for 'TEST_DIR/t.raw' and probing guessed raw. Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted. Specify the 'raw' format explicitly to remove the restrictions. @@ -473,7 +515,9 @@ WARNING: Image format was not specified for 'TEST_DIR/t.raw' and probing guessed Images are identical. { 'execute': 'qmp_capabilities' } {"return": {}} -{'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', 'format': 'IMGFMT', 'mode': 'existing', 'sync': 'full'}} +{'execute':'drive-mirror', 'arguments':{ + 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', 'format': 'IMGFMT', + 'mode': 'existing', 'sync': 'full'}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "src"}} {"return": {}} diff --git a/tests/qemu-iotests/117.out b/tests/qemu-iotests/117.out index bb623dcc0a..735ffd25c6 100644 --- a/tests/qemu-iotests/117.out +++ b/tests/qemu-iotests/117.out @@ -2,11 +2,18 @@ QA output created by 117 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=65536 { 'execute': 'qmp_capabilities' } {"return": {}} -{ 'execute': 'blockdev-add', 'arguments': { 'node-name': 'protocol', 'driver': 'file', 'filename': 'TEST_DIR/t.IMGFMT' } } +{ 'execute': 'blockdev-add', + 'arguments': { 'node-name': 'protocol', + 'driver': 'file', + 'filename': 'TEST_DIR/t.IMGFMT' } } {"return": {}} -{ 'execute': 'blockdev-add', 'arguments': { 'node-name': 'format', 'driver': 'IMGFMT', 'file': 'protocol' } } +{ 'execute': 'blockdev-add', + 'arguments': { 'node-name': 'format', + 'driver': 'IMGFMT', + 'file': 'protocol' } } {"return": {}} -{ 'execute': 'human-monitor-command', 'arguments': { 'command-line': 'qemu-io format "write -P 42 0 64k"' } } +{ 'execute': 'human-monitor-command', + 'arguments': { 'command-line': 'qemu-io format "write -P 42 0 64k"' } } wrote 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) {"return": ""} diff --git a/tests/qemu-iotests/127.out b/tests/qemu-iotests/127.out index efd6cb327f..1685c4850a 100644 --- a/tests/qemu-iotests/127.out +++ b/tests/qemu-iotests/127.out @@ -6,13 +6,21 @@ wrote 42/42 bytes at offset 0 42 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) { 'execute': 'qmp_capabilities' } {"return": {}} -{ 'execute': 'drive-mirror', 'arguments': { 'job-id': 'mirror', 'device': 'source', 'target': 'TEST_DIR/t.IMGFMT.overlay1', 'mode': 'existing', 'sync': 'top' } } +{ 'execute': 'drive-mirror', + 'arguments': { + 'job-id': 'mirror', + 'device': 'source', + 'target': 'TEST_DIR/t.IMGFMT.overlay1', + 'mode': 'existing', + 'sync': 'top' + } } {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "mirror"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "mirror"}} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "mirror"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "mirror", "len": 65536, "offset": 65536, "speed": 0, "type": "mirror"}} -{ 'execute': 'block-job-complete', 'arguments': { 'device': 'mirror' } } +{ 'execute': 'block-job-complete', + 'arguments': { 'device': 'mirror' } } {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "mirror"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "mirror"}} diff --git a/tests/qemu-iotests/140.out b/tests/qemu-iotests/140.out index 62d9c3ab3c..312f76d5da 100644 --- a/tests/qemu-iotests/140.out +++ b/tests/qemu-iotests/140.out @@ -4,13 +4,17 @@ wrote 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) { 'execute': 'qmp_capabilities' } {"return": {}} -{ 'execute': 'nbd-server-start', 'arguments': { 'addr': { 'type': 'unix', 'data': { 'path': 'SOCK_DIR/nbd' }}}} +{ 'execute': 'nbd-server-start', + 'arguments': { 'addr': { 'type': 'unix', + 'data': { 'path': 'SOCK_DIR/nbd' }}}} {"return": {}} -{ 'execute': 'nbd-server-add', 'arguments': { 'device': 'drv' }} +{ 'execute': 'nbd-server-add', + 'arguments': { 'device': 'drv' }} {"return": {}} read 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -{ 'execute': 'eject', 'arguments': { 'device': 'drv' }} +{ 'execute': 'eject', + 'arguments': { 'device': 'drv' }} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_EXPORT_DELETED", "data": {"id": "drv"}} qemu-io: can't open device nbd+unix:///drv?socket=SOCK_DIR/nbd: Requested export not available server reported: export 'drv' not present diff --git a/tests/qemu-iotests/141.out b/tests/qemu-iotests/141.out index 08e0aecd65..6d8652e22b 100644 --- a/tests/qemu-iotests/141.out +++ b/tests/qemu-iotests/141.out @@ -7,105 +7,173 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 backing_file=TEST_DIR/m. === Testing drive-backup === -{'execute': 'blockdev-add', 'arguments': { 'node-name': 'drv0', 'driver': 'IMGFMT', 'file': { 'driver': 'file', 'filename': 'TEST_DIR/t.IMGFMT' }}} -{"return": {}} -{'execute': 'drive-backup', 'arguments': {'job-id': 'job0', 'device': 'drv0', 'target': 'TEST_DIR/o.IMGFMT', 'format': 'IMGFMT', 'sync': 'none'}} +{'execute': 'blockdev-add', + 'arguments': { + 'node-name': 'drv0', + 'driver': 'IMGFMT', + 'file': { + 'driver': 'file', + 'filename': 'TEST_DIR/t.IMGFMT' + }}} +{"return": {}} +{'execute': 'drive-backup', +'arguments': {'job-id': 'job0', +'device': 'drv0', +'target': 'TEST_DIR/o.IMGFMT', +'format': 'IMGFMT', +'sync': 'none'}} Formatting 'TEST_DIR/o.IMGFMT', fmt=IMGFMT size=1048576 backing_file=TEST_DIR/t.IMGFMT backing_fmt=IMGFMT {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "job0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "job0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "paused", "id": "job0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "job0"}} -{'execute': 'blockdev-del', 'arguments': {'node-name': 'drv0'}} +{'execute': 'blockdev-del', + 'arguments': {'node-name': 'drv0'}} {"error": {"class": "GenericError", "desc": "Node 'drv0' is busy: node is used as backing hd of 'NODE_NAME'"}} -{'execute': 'block-job-cancel', 'arguments': {'device': 'job0'}} +{'execute': 'block-job-cancel', + 'arguments': {'device': 'job0'}} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "aborting", "id": "job0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "job0", "len": 1048576, "offset": 0, "speed": 0, "type": "backup"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "job0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "job0"}} -{'execute': 'blockdev-del', 'arguments': {'node-name': 'drv0'}} +{'execute': 'blockdev-del', + 'arguments': {'node-name': 'drv0'}} {"return": {}} === Testing drive-mirror === -{'execute': 'blockdev-add', 'arguments': { 'node-name': 'drv0', 'driver': 'IMGFMT', 'file': { 'driver': 'file', 'filename': 'TEST_DIR/t.IMGFMT' }}} -{"return": {}} -{'execute': 'drive-mirror', 'arguments': {'job-id': 'job0', 'device': 'drv0', 'target': 'TEST_DIR/o.IMGFMT', 'format': 'IMGFMT', 'sync': 'none'}} +{'execute': 'blockdev-add', + 'arguments': { + 'node-name': 'drv0', + 'driver': 'IMGFMT', + 'file': { + 'driver': 'file', + 'filename': 'TEST_DIR/t.IMGFMT' + }}} +{"return": {}} +{'execute': 'drive-mirror', +'arguments': {'job-id': 'job0', +'device': 'drv0', +'target': 'TEST_DIR/o.IMGFMT', +'format': 'IMGFMT', +'sync': 'none'}} Formatting 'TEST_DIR/o.IMGFMT', fmt=IMGFMT size=1048576 backing_file=TEST_DIR/t.IMGFMT backing_fmt=IMGFMT {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "job0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "job0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "job0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "job0", "len": 0, "offset": 0, "speed": 0, "type": "mirror"}} -{'execute': 'blockdev-del', 'arguments': {'node-name': 'drv0'}} +{'execute': 'blockdev-del', + 'arguments': {'node-name': 'drv0'}} {"error": {"class": "GenericError", "desc": "Node 'drv0' is busy: block device is in use by block job: mirror"}} -{'execute': 'block-job-cancel', 'arguments': {'device': 'job0'}} +{'execute': 'block-job-cancel', + 'arguments': {'device': 'job0'}} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "job0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "job0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "job0", "len": 0, "offset": 0, "speed": 0, "type": "mirror"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "job0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "job0"}} -{'execute': 'blockdev-del', 'arguments': {'node-name': 'drv0'}} +{'execute': 'blockdev-del', + 'arguments': {'node-name': 'drv0'}} {"return": {}} === Testing active block-commit === -{'execute': 'blockdev-add', 'arguments': { 'node-name': 'drv0', 'driver': 'IMGFMT', 'file': { 'driver': 'file', 'filename': 'TEST_DIR/t.IMGFMT' }}} -{"return": {}} -{'execute': 'block-commit', 'arguments': {'job-id': 'job0', 'device': 'drv0'}} +{'execute': 'blockdev-add', + 'arguments': { + 'node-name': 'drv0', + 'driver': 'IMGFMT', + 'file': { + 'driver': 'file', + 'filename': 'TEST_DIR/t.IMGFMT' + }}} +{"return": {}} +{'execute': 'block-commit', +'arguments': {'job-id': 'job0', 'device': 'drv0'}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "job0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "job0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "job0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "job0", "len": 0, "offset": 0, "speed": 0, "type": "commit"}} -{'execute': 'blockdev-del', 'arguments': {'node-name': 'drv0'}} +{'execute': 'blockdev-del', + 'arguments': {'node-name': 'drv0'}} {"error": {"class": "GenericError", "desc": "Node 'drv0' is busy: block device is in use by block job: commit"}} -{'execute': 'block-job-cancel', 'arguments': {'device': 'job0'}} +{'execute': 'block-job-cancel', + 'arguments': {'device': 'job0'}} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "job0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "job0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "job0", "len": 0, "offset": 0, "speed": 0, "type": "commit"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "job0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "job0"}} -{'execute': 'blockdev-del', 'arguments': {'node-name': 'drv0'}} +{'execute': 'blockdev-del', + 'arguments': {'node-name': 'drv0'}} {"return": {}} === Testing non-active block-commit === wrote 1048576/1048576 bytes at offset 0 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -{'execute': 'blockdev-add', 'arguments': { 'node-name': 'drv0', 'driver': 'IMGFMT', 'file': { 'driver': 'file', 'filename': 'TEST_DIR/t.IMGFMT' }}} -{"return": {}} -{'execute': 'block-commit', 'arguments': {'job-id': 'job0', 'device': 'drv0', 'top': 'TEST_DIR/m.IMGFMT', 'speed': 1}} +{'execute': 'blockdev-add', + 'arguments': { + 'node-name': 'drv0', + 'driver': 'IMGFMT', + 'file': { + 'driver': 'file', + 'filename': 'TEST_DIR/t.IMGFMT' + }}} +{"return": {}} +{'execute': 'block-commit', +'arguments': {'job-id': 'job0', +'device': 'drv0', +'top': 'TEST_DIR/m.IMGFMT', +'speed': 1}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "job0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "job0"}} -{'execute': 'blockdev-del', 'arguments': {'node-name': 'drv0'}} +{'execute': 'blockdev-del', + 'arguments': {'node-name': 'drv0'}} {"error": {"class": "GenericError", "desc": "Node drv0 is in use"}} -{'execute': 'block-job-cancel', 'arguments': {'device': 'job0'}} +{'execute': 'block-job-cancel', + 'arguments': {'device': 'job0'}} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "aborting", "id": "job0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "job0", "len": 1048576, "offset": 524288, "speed": 1, "type": "commit"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "job0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "job0"}} -{'execute': 'blockdev-del', 'arguments': {'node-name': 'drv0'}} +{'execute': 'blockdev-del', + 'arguments': {'node-name': 'drv0'}} {"return": {}} === Testing block-stream === wrote 1048576/1048576 bytes at offset 0 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -{'execute': 'blockdev-add', 'arguments': { 'node-name': 'drv0', 'driver': 'IMGFMT', 'file': { 'driver': 'file', 'filename': 'TEST_DIR/t.IMGFMT' }}} -{"return": {}} -{'execute': 'block-stream', 'arguments': {'job-id': 'job0', 'device': 'drv0', 'speed': 1}} +{'execute': 'blockdev-add', + 'arguments': { + 'node-name': 'drv0', + 'driver': 'IMGFMT', + 'file': { + 'driver': 'file', + 'filename': 'TEST_DIR/t.IMGFMT' + }}} +{"return": {}} +{'execute': 'block-stream', +'arguments': {'job-id': 'job0', +'device': 'drv0', +'speed': 1}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "job0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "job0"}} -{'execute': 'blockdev-del', 'arguments': {'node-name': 'drv0'}} +{'execute': 'blockdev-del', + 'arguments': {'node-name': 'drv0'}} {"error": {"class": "GenericError", "desc": "Node drv0 is in use"}} -{'execute': 'block-job-cancel', 'arguments': {'device': 'job0'}} +{'execute': 'block-job-cancel', + 'arguments': {'device': 'job0'}} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "aborting", "id": "job0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "job0", "len": 1048576, "offset": 524288, "speed": 1, "type": "stream"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "job0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "job0"}} -{'execute': 'blockdev-del', 'arguments': {'node-name': 'drv0'}} +{'execute': 'blockdev-del', + 'arguments': {'node-name': 'drv0'}} {"return": {}} *** done diff --git a/tests/qemu-iotests/143.out b/tests/qemu-iotests/143.out index fc9c0a761f..9ec5888e0e 100644 --- a/tests/qemu-iotests/143.out +++ b/tests/qemu-iotests/143.out @@ -1,7 +1,9 @@ QA output created by 143 { 'execute': 'qmp_capabilities' } {"return": {}} -{ 'execute': 'nbd-server-start', 'arguments': { 'addr': { 'type': 'unix', 'data': { 'path': 'SOCK_DIR/nbd' }}}} +{ 'execute': 'nbd-server-start', + 'arguments': { 'addr': { 'type': 'unix', + 'data': { 'path': 'SOCK_DIR/nbd' }}}} {"return": {}} qemu-io: can't open device nbd+unix:///no_such_export?socket=SOCK_DIR/nbd: Requested export not available server reported: export 'no_such_export' not present diff --git a/tests/qemu-iotests/144.out b/tests/qemu-iotests/144.out index 13e0c4f5a7..b3b4812015 100644 --- a/tests/qemu-iotests/144.out +++ b/tests/qemu-iotests/144.out @@ -8,19 +8,33 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=536870912 { 'execute': 'qmp_capabilities' } {"return": {}} -{ 'execute': 'blockdev-snapshot-sync', 'arguments': { 'device': 'virtio0', 'snapshot-file':'TEST_DIR/tmp.IMGFMT', 'format': 'IMGFMT' } } +{ 'execute': 'blockdev-snapshot-sync', + 'arguments': { + 'device': 'virtio0', + 'snapshot-file':'TEST_DIR/tmp.IMGFMT', + 'format': 'IMGFMT' + } + } Formatting 'TEST_DIR/tmp.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=536870912 backing_file=TEST_DIR/t.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 {"return": {}} === Performing block-commit on active layer === -{ 'execute': 'block-commit', 'arguments': { 'device': 'virtio0' } } +{ 'execute': 'block-commit', + 'arguments': { + 'device': 'virtio0' + } + } {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "virtio0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "virtio0"}} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "virtio0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "virtio0", "len": 0, "offset": 0, "speed": 0, "type": "commit"}} -{ 'execute': 'block-job-complete', 'arguments': { 'device': 'virtio0' } } +{ 'execute': 'block-job-complete', + 'arguments': { + 'device': 'virtio0' + } + } {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "virtio0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "virtio0"}} @@ -30,7 +44,13 @@ Formatting 'TEST_DIR/tmp.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off co === Performing Live Snapshot 2 === -{ 'execute': 'blockdev-snapshot-sync', 'arguments': { 'device': 'virtio0', 'snapshot-file':'TEST_DIR/tmp2.IMGFMT', 'format': 'IMGFMT' } } +{ 'execute': 'blockdev-snapshot-sync', + 'arguments': { + 'device': 'virtio0', + 'snapshot-file':'TEST_DIR/tmp2.IMGFMT', + 'format': 'IMGFMT' + } + } Formatting 'TEST_DIR/tmp2.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=536870912 backing_file=TEST_DIR/t.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 {"return": {}} *** done diff --git a/tests/qemu-iotests/153.out b/tests/qemu-iotests/153.out index fcaa71aeee..ff8e55864a 100644 --- a/tests/qemu-iotests/153.out +++ b/tests/qemu-iotests/153.out @@ -425,7 +425,8 @@ _qemu_img_wrapper commit -b TEST_DIR/t.qcow2.b TEST_DIR/t.qcow2.c { 'execute': 'qmp_capabilities' } {"return": {}} Adding drive -{ 'execute': 'human-monitor-command', 'arguments': { 'command-line': 'drive_add 0 if=none,id=d0,file=TEST_DIR/t.IMGFMT' } } +{ 'execute': 'human-monitor-command', + 'arguments': { 'command-line': 'drive_add 0 if=none,id=d0,file=TEST_DIR/t.IMGFMT' } } {"return": "OKrn"} _qemu_io_wrapper TEST_DIR/t.qcow2 -c write 0 512 @@ -435,25 +436,30 @@ Creating overlay with qemu-img when the guest is running should be allowed _qemu_img_wrapper create -f qcow2 -b TEST_DIR/t.qcow2 -F qcow2 TEST_DIR/t.qcow2.overlay == Closing an image should unlock it == -{ 'execute': 'human-monitor-command', 'arguments': { 'command-line': 'drive_del d0' } } +{ 'execute': 'human-monitor-command', + 'arguments': { 'command-line': 'drive_del d0' } } {"return": ""} _qemu_io_wrapper TEST_DIR/t.qcow2 -c write 0 512 Adding two and closing one -{ 'execute': 'human-monitor-command', 'arguments': { 'command-line': 'drive_add 0 if=none,id=d0,file=TEST_DIR/t.IMGFMT,readonly=on' } } +{ 'execute': 'human-monitor-command', + 'arguments': { 'command-line': 'drive_add 0 if=none,id=d0,file=TEST_DIR/t.IMGFMT,readonly=on' } } {"return": "OKrn"} -{ 'execute': 'human-monitor-command', 'arguments': { 'command-line': 'drive_add 0 if=none,id=d1,file=TEST_DIR/t.IMGFMT,readonly=on' } } +{ 'execute': 'human-monitor-command', + 'arguments': { 'command-line': 'drive_add 0 if=none,id=d1,file=TEST_DIR/t.IMGFMT,readonly=on' } } {"return": "OKrn"} _qemu_img_wrapper info TEST_DIR/t.qcow2 -{ 'execute': 'human-monitor-command', 'arguments': { 'command-line': 'drive_del d0' } } +{ 'execute': 'human-monitor-command', + 'arguments': { 'command-line': 'drive_del d0' } } {"return": ""} _qemu_io_wrapper TEST_DIR/t.qcow2 -c write 0 512 qemu-io: can't open device TEST_DIR/t.qcow2: Failed to get "write" lock Is another process using the image [TEST_DIR/t.qcow2]? Closing the other -{ 'execute': 'human-monitor-command', 'arguments': { 'command-line': 'drive_del d1' } } +{ 'execute': 'human-monitor-command', + 'arguments': { 'command-line': 'drive_del d1' } } {"return": ""} _qemu_io_wrapper TEST_DIR/t.qcow2 -c write 0 512 diff --git a/tests/qemu-iotests/156.out b/tests/qemu-iotests/156.out index cce167b63f..4a22f0c41a 100644 --- a/tests/qemu-iotests/156.out +++ b/tests/qemu-iotests/156.out @@ -8,24 +8,37 @@ wrote 196608/196608 bytes at offset 65536 { 'execute': 'qmp_capabilities' } {"return": {}} Formatting 'TEST_DIR/t.IMGFMT.overlay', fmt=IMGFMT size=1048576 backing_file=TEST_DIR/t.IMGFMT backing_fmt=IMGFMT -{ 'execute': 'blockdev-snapshot-sync', 'arguments': { 'device': 'source', 'snapshot-file': 'TEST_DIR/t.IMGFMT.overlay', 'format': 'IMGFMT', 'mode': 'existing' } } +{ 'execute': 'blockdev-snapshot-sync', + 'arguments': { 'device': 'source', + 'snapshot-file': 'TEST_DIR/t.IMGFMT.overlay', + 'format': 'IMGFMT', + 'mode': 'existing' } } {"return": {}} -{ 'execute': 'human-monitor-command', 'arguments': { 'command-line': 'qemu-io source "write -P 3 128k 128k"' } } +{ 'execute': 'human-monitor-command', + 'arguments': { 'command-line': + 'qemu-io source "write -P 3 128k 128k"' } } wrote 131072/131072 bytes at offset 131072 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) {"return": ""} Formatting 'TEST_DIR/t.IMGFMT.target.overlay', fmt=IMGFMT size=1048576 backing_file=TEST_DIR/t.IMGFMT.target backing_fmt=IMGFMT -{ 'execute': 'drive-mirror', 'arguments': { 'device': 'source', 'target': 'TEST_DIR/t.IMGFMT.target.overlay', 'mode': 'existing', 'sync': 'top' } } +{ 'execute': 'drive-mirror', + 'arguments': { 'device': 'source', + 'target': 'TEST_DIR/t.IMGFMT.target.overlay', + 'mode': 'existing', + 'sync': 'top' } } {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "source"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "source"}} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "source"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "source", "len": 131072, "offset": 131072, "speed": 0, "type": "mirror"}} -{ 'execute': 'human-monitor-command', 'arguments': { 'command-line': 'qemu-io source "write -P 4 192k 64k"' } } +{ 'execute': 'human-monitor-command', + 'arguments': { 'command-line': + 'qemu-io source "write -P 4 192k 64k"' } } wrote 65536/65536 bytes at offset 196608 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) {"return": ""} -{ 'execute': 'block-job-complete', 'arguments': { 'device': 'source' } } +{ 'execute': 'block-job-complete', + 'arguments': { 'device': 'source' } } {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "source"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "source"}} @@ -33,19 +46,27 @@ wrote 65536/65536 bytes at offset 196608 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "source"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "source"}} -{ 'execute': 'human-monitor-command', 'arguments': { 'command-line': 'qemu-io source "read -P 1 0k 64k"' } } +{ 'execute': 'human-monitor-command', + 'arguments': { 'command-line': + 'qemu-io source "read -P 1 0k 64k"' } } read 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) {"return": ""} -{ 'execute': 'human-monitor-command', 'arguments': { 'command-line': 'qemu-io source "read -P 2 64k 64k"' } } +{ 'execute': 'human-monitor-command', + 'arguments': { 'command-line': + 'qemu-io source "read -P 2 64k 64k"' } } read 65536/65536 bytes at offset 65536 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) {"return": ""} -{ 'execute': 'human-monitor-command', 'arguments': { 'command-line': 'qemu-io source "read -P 3 128k 64k"' } } +{ 'execute': 'human-monitor-command', + 'arguments': { 'command-line': + 'qemu-io source "read -P 3 128k 64k"' } } read 65536/65536 bytes at offset 131072 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) {"return": ""} -{ 'execute': 'human-monitor-command', 'arguments': { 'command-line': 'qemu-io source "read -P 4 192k 64k"' } } +{ 'execute': 'human-monitor-command', + 'arguments': { 'command-line': + 'qemu-io source "read -P 4 192k 64k"' } } read 65536/65536 bytes at offset 196608 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) {"return": ""} diff --git a/tests/qemu-iotests/161.out b/tests/qemu-iotests/161.out index 3d8d89a9da..6cc285afcf 100644 --- a/tests/qemu-iotests/161.out +++ b/tests/qemu-iotests/161.out @@ -7,18 +7,23 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 backing_file=TEST_DIR/t. { 'execute': 'qmp_capabilities' } {"return": {}} -{ 'execute': 'human-monitor-command', 'arguments': { 'command-line': 'qemu-io none0 "reopen -o backing.detect-zeroes=on"' } } +{ 'execute': 'human-monitor-command', + 'arguments': { 'command-line': + 'qemu-io none0 "reopen -o backing.detect-zeroes=on"' } } {"return": ""} *** Stream and then change an option on the backing file { 'execute': 'qmp_capabilities' } {"return": {}} -{ 'execute': 'block-stream', 'arguments': { 'device': 'none0', 'base': 'TEST_DIR/t.IMGFMT.base' } } +{ 'execute': 'block-stream', 'arguments': { 'device': 'none0', + 'base': 'TEST_DIR/t.IMGFMT.base' } } {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "none0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "none0"}} {"return": {}} -{ 'execute': 'human-monitor-command', 'arguments': { 'command-line': 'qemu-io none0 "reopen -o backing.detect-zeroes=on"' } } +{ 'execute': 'human-monitor-command', + 'arguments': { 'command-line': + 'qemu-io none0 "reopen -o backing.detect-zeroes=on"' } } {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "none0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "none0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "none0", "len": 1048576, "offset": 1048576, "speed": 0, "type": "stream"}} @@ -33,11 +38,14 @@ Formatting 'TEST_DIR/t.IMGFMT.int', fmt=IMGFMT size=1048576 backing_file=TEST_DI Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 backing_file=TEST_DIR/t.IMGFMT.int backing_fmt=IMGFMT { 'execute': 'qmp_capabilities' } {"return": {}} -{ 'execute': 'block-commit', 'arguments': { 'device': 'none0', 'top': 'TEST_DIR/t.IMGFMT.int' } } +{ 'execute': 'block-commit', 'arguments': { 'device': 'none0', + 'top': 'TEST_DIR/t.IMGFMT.int' } } {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "none0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "none0"}} {"return": {}} -{ 'execute': 'human-monitor-command', 'arguments': { 'command-line': 'qemu-io none0 "reopen -o backing.detect-zeroes=on"' } } +{ 'execute': 'human-monitor-command', + 'arguments': { 'command-line': + 'qemu-io none0 "reopen -o backing.detect-zeroes=on"' } } {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "none0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "none0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "none0", "len": 1048576, "offset": 1048576, "speed": 0, "type": "commit"}} diff --git a/tests/qemu-iotests/173.out b/tests/qemu-iotests/173.out index b5114b5c79..2d6490d680 100644 --- a/tests/qemu-iotests/173.out +++ b/tests/qemu-iotests/173.out @@ -6,11 +6,30 @@ Formatting 'TEST_DIR/image.snp1', fmt=IMGFMT size=104857600 { 'execute': 'qmp_capabilities' } {"return": {}} -{ 'arguments': { 'device': 'disk2', 'format': 'IMGFMT', 'mode': 'existing', 'snapshot-file': 'TEST_DIR/image.snp1', 'snapshot-node-name': 'snp1' }, 'execute': 'blockdev-snapshot-sync' } +{ 'arguments': { + 'device': 'disk2', + 'format': 'IMGFMT', + 'mode': 'existing', + 'snapshot-file': 'TEST_DIR/image.snp1', + 'snapshot-node-name': 'snp1' + }, + 'execute': 'blockdev-snapshot-sync' + } {"return": {}} -{ 'arguments': { 'backing-file': 'image.base', 'device': 'disk2', 'image-node-name': 'snp1' }, 'execute': 'change-backing-file' } +{ 'arguments': { + 'backing-file': 'image.base', + 'device': 'disk2', + 'image-node-name': 'snp1' + }, + 'execute': 'change-backing-file' + } {"return": {}} -{ 'arguments': { 'base': 'TEST_DIR/image.base', 'device': 'disk2' }, 'execute': 'block-stream' } +{ 'arguments': { + 'base': 'TEST_DIR/image.base', + 'device': 'disk2' + }, + 'execute': 'block-stream' + } {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "disk2"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "disk2"}} {"return": {}} diff --git a/tests/qemu-iotests/182.out b/tests/qemu-iotests/182.out index ce23340670..57f7265458 100644 --- a/tests/qemu-iotests/182.out +++ b/tests/qemu-iotests/182.out @@ -10,16 +10,42 @@ Is another process using the image [TEST_DIR/t.qcow2]? {'execute': 'qmp_capabilities'} {"return": {}} -{'execute': 'blockdev-add', 'arguments': { 'node-name': 'node0', 'driver': 'file', 'filename': 'TEST_DIR/t.IMGFMT', 'locking': 'on' } } -{"return": {}} -{'execute': 'blockdev-snapshot-sync', 'arguments': { 'node-name': 'node0', 'snapshot-file': 'TEST_DIR/t.IMGFMT.overlay', 'snapshot-node-name': 'node1' } } +{'execute': 'blockdev-add', + 'arguments': { + 'node-name': 'node0', + 'driver': 'file', + 'filename': 'TEST_DIR/t.IMGFMT', + 'locking': 'on' + } } +{"return": {}} +{'execute': 'blockdev-snapshot-sync', + 'arguments': { + 'node-name': 'node0', + 'snapshot-file': 'TEST_DIR/t.IMGFMT.overlay', + 'snapshot-node-name': 'node1' + } } Formatting 'TEST_DIR/t.qcow2.overlay', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=197120 backing_file=TEST_DIR/t.qcow2 backing_fmt=file lazy_refcounts=off refcount_bits=16 {"return": {}} -{'execute': 'blockdev-add', 'arguments': { 'node-name': 'node1', 'driver': 'file', 'filename': 'TEST_DIR/t.IMGFMT', 'locking': 'on' } } -{"return": {}} -{'execute': 'nbd-server-start', 'arguments': { 'addr': { 'type': 'unix', 'data': { 'path': 'SOCK_DIR/nbd.socket' } } } } -{"return": {}} -{'execute': 'nbd-server-add', 'arguments': { 'device': 'node1' } } +{'execute': 'blockdev-add', + 'arguments': { + 'node-name': 'node1', + 'driver': 'file', + 'filename': 'TEST_DIR/t.IMGFMT', + 'locking': 'on' + } } +{"return": {}} +{'execute': 'nbd-server-start', + 'arguments': { + 'addr': { + 'type': 'unix', + 'data': { + 'path': 'SOCK_DIR/nbd.socket' + } } } } +{"return": {}} +{'execute': 'nbd-server-add', + 'arguments': { + 'device': 'node1' + } } {"return": {}} === Testing failure to loosen restrictions === diff --git a/tests/qemu-iotests/183.out b/tests/qemu-iotests/183.out index d4be2cb2de..fd9c2e52a5 100644 --- a/tests/qemu-iotests/183.out +++ b/tests/qemu-iotests/183.out @@ -11,18 +11,23 @@ Formatting 'TEST_DIR/t.IMGFMT.dest', fmt=IMGFMT size=67108864 === Write something on the source === -{ 'execute': 'human-monitor-command', 'arguments': { 'command-line': 'qemu-io disk "write -P 0x55 0 64k"' } } +{ 'execute': 'human-monitor-command', + 'arguments': { 'command-line': + 'qemu-io disk "write -P 0x55 0 64k"' } } wrote 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) {"return": ""} -{ 'execute': 'human-monitor-command', 'arguments': { 'command-line': 'qemu-io disk "read -P 0x55 0 64k"' } } +{ 'execute': 'human-monitor-command', + 'arguments': { 'command-line': + 'qemu-io disk "read -P 0x55 0 64k"' } } read 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) {"return": ""} === Do block migration to destination === -{ 'execute': 'migrate', 'arguments': { 'uri': 'unix:SOCK_DIR/migrate', 'blk': true } } +{ 'execute': 'migrate', + 'arguments': { 'uri': 'unix:SOCK_DIR/migrate', 'blk': true } } {"return": {}} { 'execute': 'query-status' } {"return": {"status": "postmigrate", "singlestep": false, "running": false}} @@ -32,11 +37,15 @@ read 65536/65536 bytes at offset 0 { 'execute': 'query-status' } {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "RESUME"} {"return": {"status": "running", "singlestep": false, "running": true}} -{ 'execute': 'human-monitor-command', 'arguments': { 'command-line': 'qemu-io disk "read -P 0x55 0 64k"' } } +{ 'execute': 'human-monitor-command', + 'arguments': { 'command-line': + 'qemu-io disk "read -P 0x55 0 64k"' } } read 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) {"return": ""} -{ 'execute': 'human-monitor-command', 'arguments': { 'command-line': 'qemu-io disk "write -P 0x66 1M 64k"' } } +{ 'execute': 'human-monitor-command', + 'arguments': { 'command-line': + 'qemu-io disk "write -P 0x66 1M 64k"' } } wrote 65536/65536 bytes at offset 1048576 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) {"return": ""} diff --git a/tests/qemu-iotests/185.out b/tests/qemu-iotests/185.out index 339438ac68..eab55d22bf 100644 --- a/tests/qemu-iotests/185.out +++ b/tests/qemu-iotests/185.out @@ -8,20 +8,34 @@ Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=67108864 === Creating backing chain === -{ 'execute': 'blockdev-snapshot-sync', 'arguments': { 'device': 'disk', 'snapshot-file': 'TEST_DIR/t.IMGFMT.mid', 'format': 'IMGFMT', 'mode': 'absolute-paths' } } +{ 'execute': 'blockdev-snapshot-sync', + 'arguments': { 'device': 'disk', + 'snapshot-file': 'TEST_DIR/t.IMGFMT.mid', + 'format': 'IMGFMT', + 'mode': 'absolute-paths' } } Formatting 'TEST_DIR/t.qcow2.mid', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=67108864 backing_file=TEST_DIR/t.qcow2.base backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 {"return": {}} -{ 'execute': 'human-monitor-command', 'arguments': { 'command-line': 'qemu-io disk "write 0 4M"' } } +{ 'execute': 'human-monitor-command', + 'arguments': { 'command-line': + 'qemu-io disk "write 0 4M"' } } wrote 4194304/4194304 bytes at offset 0 4 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) {"return": ""} -{ 'execute': 'blockdev-snapshot-sync', 'arguments': { 'device': 'disk', 'snapshot-file': 'TEST_DIR/t.IMGFMT', 'format': 'IMGFMT', 'mode': 'absolute-paths' } } +{ 'execute': 'blockdev-snapshot-sync', + 'arguments': { 'device': 'disk', + 'snapshot-file': 'TEST_DIR/t.IMGFMT', + 'format': 'IMGFMT', + 'mode': 'absolute-paths' } } Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=67108864 backing_file=TEST_DIR/t.qcow2.mid backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 {"return": {}} === Start commit job and exit qemu === -{ 'execute': 'block-commit', 'arguments': { 'device': 'disk', 'base':'TEST_DIR/t.IMGFMT.base', 'top': 'TEST_DIR/t.IMGFMT.mid', 'speed': 65536 } } +{ 'execute': 'block-commit', + 'arguments': { 'device': 'disk', + 'base':'TEST_DIR/t.IMGFMT.base', + 'top': 'TEST_DIR/t.IMGFMT.mid', + 'speed': 65536 } } {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "disk"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "disk"}} {"return": {}} @@ -34,7 +48,10 @@ Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off comp { 'execute': 'qmp_capabilities' } {"return": {}} -{ 'execute': 'block-commit', 'arguments': { 'device': 'disk', 'base':'TEST_DIR/t.IMGFMT.base', 'speed': 65536 } } +{ 'execute': 'block-commit', + 'arguments': { 'device': 'disk', + 'base':'TEST_DIR/t.IMGFMT.base', + 'speed': 65536 } } {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "disk"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "disk"}} {"return": {}} @@ -47,7 +64,12 @@ Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off comp { 'execute': 'qmp_capabilities' } {"return": {}} -{ 'execute': 'drive-mirror', 'arguments': { 'device': 'disk', 'target': 'TEST_DIR/t.IMGFMT.copy', 'format': 'IMGFMT', 'sync': 'full', 'speed': 65536 } } +{ 'execute': 'drive-mirror', + 'arguments': { 'device': 'disk', + 'target': 'TEST_DIR/t.IMGFMT.copy', + 'format': 'IMGFMT', + 'sync': 'full', + 'speed': 65536 } } Formatting 'TEST_DIR/t.qcow2.copy', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "disk"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "disk"}} @@ -61,7 +83,12 @@ Formatting 'TEST_DIR/t.qcow2.copy', fmt=qcow2 cluster_size=65536 extended_l2=off { 'execute': 'qmp_capabilities' } {"return": {}} -{ 'execute': 'drive-backup', 'arguments': { 'device': 'disk', 'target': 'TEST_DIR/t.IMGFMT.copy', 'format': 'IMGFMT', 'sync': 'full', 'speed': 65536 } } +{ 'execute': 'drive-backup', + 'arguments': { 'device': 'disk', + 'target': 'TEST_DIR/t.IMGFMT.copy', + 'format': 'IMGFMT', + 'sync': 'full', + 'speed': 65536 } } Formatting 'TEST_DIR/t.qcow2.copy', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "disk"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "disk"}} @@ -77,7 +104,9 @@ Formatting 'TEST_DIR/t.qcow2.copy', fmt=qcow2 cluster_size=65536 extended_l2=off { 'execute': 'qmp_capabilities' } {"return": {}} -{ 'execute': 'block-stream', 'arguments': { 'device': 'disk', 'speed': 65536 } } +{ 'execute': 'block-stream', + 'arguments': { 'device': 'disk', + 'speed': 65536 } } {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "disk"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "disk"}} {"return": {}} diff --git a/tests/qemu-iotests/191.out b/tests/qemu-iotests/191.out index 11aaf3b691..022021efab 100644 --- a/tests/qemu-iotests/191.out +++ b/tests/qemu-iotests/191.out @@ -16,7 +16,11 @@ wrote 65536/65536 bytes at offset 1048576 === Perform commit job === -{ 'execute': 'block-commit', 'arguments': { 'job-id': 'commit0', 'device': 'top', 'base':'TEST_DIR/t.IMGFMT.base', 'top': 'TEST_DIR/t.IMGFMT.mid' } } +{ 'execute': 'block-commit', + 'arguments': { 'job-id': 'commit0', + 'device': 'top', + 'base':'TEST_DIR/t.IMGFMT.base', + 'top': 'TEST_DIR/t.IMGFMT.mid' } } { "timestamp": { "seconds": TIMESTAMP, @@ -427,7 +431,11 @@ wrote 65536/65536 bytes at offset 1048576 === Perform commit job === -{ 'execute': 'block-commit', 'arguments': { 'job-id': 'commit0', 'device': 'top', 'base':'TEST_DIR/t.IMGFMT.base', 'top': 'TEST_DIR/t.IMGFMT.mid' } } +{ 'execute': 'block-commit', + 'arguments': { 'job-id': 'commit0', + 'device': 'top', + 'base':'TEST_DIR/t.IMGFMT.base', + 'top': 'TEST_DIR/t.IMGFMT.mid' } } { "timestamp": { "seconds": TIMESTAMP, diff --git a/tests/qemu-iotests/223.out b/tests/qemu-iotests/223.out index f6eac23f04..bbc85289e3 100644 --- a/tests/qemu-iotests/223.out +++ b/tests/qemu-iotests/223.out @@ -26,31 +26,48 @@ wrote 2097152/2097152 bytes at offset 2097152 {"execute":"qmp_capabilities"} {"return": {}} -{"execute":"blockdev-add", "arguments":{"driver":"IMGFMT", "node-name":"n", "file":{"driver":"file", "filename":"TEST_DIR/t.IMGFMT"}}} +{"execute":"blockdev-add", + "arguments":{"driver":"IMGFMT", "node-name":"n", + "file":{"driver":"file", "filename":"TEST_DIR/t.IMGFMT"}}} {"return": {}} -{"execute":"block-dirty-bitmap-disable", "arguments":{"node":"n", "name":"b"}} +{"execute":"block-dirty-bitmap-disable", + "arguments":{"node":"n", "name":"b"}} {"return": {}} === Set up NBD with normal access === -{"execute":"nbd-server-add", "arguments":{"device":"n"}} +{"execute":"nbd-server-add", + "arguments":{"device":"n"}} {"error": {"class": "GenericError", "desc": "NBD server not running"}} -{"execute":"nbd-server-start", "arguments":{"addr":{"type":"unix", "data":{"path":"SOCK_DIR/nbd"}}}} +{"execute":"nbd-server-start", + "arguments":{"addr":{"type":"unix", + "data":{"path":"SOCK_DIR/nbd"}}}} {"return": {}} -{"execute":"nbd-server-start", "arguments":{"addr":{"type":"unix", "data":{"path":"SOCK_DIR/nbd1"}}}} +{"execute":"nbd-server-start", + "arguments":{"addr":{"type":"unix", + "data":{"path":"SOCK_DIR/nbd1"}}}} {"error": {"class": "GenericError", "desc": "NBD server already running"}} exports available: 0 -{"execute":"nbd-server-add", "arguments":{"device":"n", "bitmap":"b"}} +{"execute":"nbd-server-add", + "arguments":{"device":"n", "bitmap":"b"}} {"return": {}} -{"execute":"nbd-server-add", "arguments":{"device":"nosuch"}} +{"execute":"nbd-server-add", + "arguments":{"device":"nosuch"}} {"error": {"class": "GenericError", "desc": "Cannot find device=nosuch nor node_name=nosuch"}} -{"execute":"nbd-server-add", "arguments":{"device":"n"}} +{"execute":"nbd-server-add", + "arguments":{"device":"n"}} {"error": {"class": "GenericError", "desc": "Block export id 'n' is already in use"}} -{"execute":"nbd-server-add", "arguments":{"device":"n", "name":"n2", "bitmap":"b2"}} +{"execute":"nbd-server-add", + "arguments":{"device":"n", "name":"n2", + "bitmap":"b2"}} {"error": {"class": "GenericError", "desc": "Enabled bitmap 'b2' incompatible with readonly export"}} -{"execute":"nbd-server-add", "arguments":{"device":"n", "name":"n2", "bitmap":"b3"}} +{"execute":"nbd-server-add", + "arguments":{"device":"n", "name":"n2", + "bitmap":"b3"}} {"error": {"class": "GenericError", "desc": "Bitmap 'b3' is not found"}} -{"execute":"nbd-server-add", "arguments":{"device":"n", "name":"n2", "writable":true, "description":"some text", "bitmap":"b2"}} +{"execute":"nbd-server-add", + "arguments":{"device":"n", "name":"n2", "writable":true, + "description":"some text", "bitmap":"b2"}} {"return": {}} exports available: 2 export: 'n' @@ -99,12 +116,15 @@ read 2097152/2097152 bytes at offset 2097152 === End qemu NBD server === -{"execute":"nbd-server-remove", "arguments":{"name":"n"}} +{"execute":"nbd-server-remove", + "arguments":{"name":"n"}} {"return": {}} -{"execute":"nbd-server-remove", "arguments":{"name":"n2"}} +{"execute":"nbd-server-remove", + "arguments":{"name":"n2"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_EXPORT_DELETED", "data": {"id": "n"}} {"return": {}} -{"execute":"nbd-server-remove", "arguments":{"name":"n2"}} +{"execute":"nbd-server-remove", + "arguments":{"name":"n2"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_EXPORT_DELETED", "data": {"id": "n2"}} {"error": {"class": "GenericError", "desc": "Export 'n2' is not found"}} {"execute":"nbd-server-stop"} @@ -114,26 +134,41 @@ read 2097152/2097152 bytes at offset 2097152 === Set up NBD with iothread access === -{"execute":"x-blockdev-set-iothread", "arguments":{"node-name":"n", "iothread":"io0"}} +{"execute":"x-blockdev-set-iothread", + "arguments":{"node-name":"n", "iothread":"io0"}} {"return": {}} -{"execute":"nbd-server-add", "arguments":{"device":"n"}} +{"execute":"nbd-server-add", + "arguments":{"device":"n"}} {"error": {"class": "GenericError", "desc": "NBD server not running"}} -{"execute":"nbd-server-start", "arguments":{"addr":{"type":"unix", "data":{"path":"SOCK_DIR/nbd"}}}} +{"execute":"nbd-server-start", + "arguments":{"addr":{"type":"unix", + "data":{"path":"SOCK_DIR/nbd"}}}} {"return": {}} -{"execute":"nbd-server-start", "arguments":{"addr":{"type":"unix", "data":{"path":"SOCK_DIR/nbd1"}}}} +{"execute":"nbd-server-start", + "arguments":{"addr":{"type":"unix", + "data":{"path":"SOCK_DIR/nbd1"}}}} {"error": {"class": "GenericError", "desc": "NBD server already running"}} exports available: 0 -{"execute":"nbd-server-add", "arguments":{"device":"n", "bitmap":"b"}} +{"execute":"nbd-server-add", + "arguments":{"device":"n", "bitmap":"b"}} {"return": {}} -{"execute":"nbd-server-add", "arguments":{"device":"nosuch"}} +{"execute":"nbd-server-add", + "arguments":{"device":"nosuch"}} {"error": {"class": "GenericError", "desc": "Cannot find device=nosuch nor node_name=nosuch"}} -{"execute":"nbd-server-add", "arguments":{"device":"n"}} +{"execute":"nbd-server-add", + "arguments":{"device":"n"}} {"error": {"class": "GenericError", "desc": "Block export id 'n' is already in use"}} -{"execute":"nbd-server-add", "arguments":{"device":"n", "name":"n2", "bitmap":"b2"}} +{"execute":"nbd-server-add", + "arguments":{"device":"n", "name":"n2", + "bitmap":"b2"}} {"error": {"class": "GenericError", "desc": "Enabled bitmap 'b2' incompatible with readonly export"}} -{"execute":"nbd-server-add", "arguments":{"device":"n", "name":"n2", "bitmap":"b3"}} +{"execute":"nbd-server-add", + "arguments":{"device":"n", "name":"n2", + "bitmap":"b3"}} {"error": {"class": "GenericError", "desc": "Bitmap 'b3' is not found"}} -{"execute":"nbd-server-add", "arguments":{"device":"n", "name":"n2", "writable":true, "description":"some text", "bitmap":"b2"}} +{"execute":"nbd-server-add", + "arguments":{"device":"n", "name":"n2", "writable":true, + "description":"some text", "bitmap":"b2"}} {"return": {}} exports available: 2 export: 'n' @@ -182,12 +217,15 @@ read 2097152/2097152 bytes at offset 2097152 === End qemu NBD server === -{"execute":"nbd-server-remove", "arguments":{"name":"n"}} +{"execute":"nbd-server-remove", + "arguments":{"name":"n"}} {"return": {}} -{"execute":"nbd-server-remove", "arguments":{"name":"n2"}} +{"execute":"nbd-server-remove", + "arguments":{"name":"n2"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_EXPORT_DELETED", "data": {"id": "n"}} {"return": {}} -{"execute":"nbd-server-remove", "arguments":{"name":"n2"}} +{"execute":"nbd-server-remove", + "arguments":{"name":"n2"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_EXPORT_DELETED", "data": {"id": "n2"}} {"error": {"class": "GenericError", "desc": "Export 'n2' is not found"}} {"execute":"nbd-server-stop"} diff --git a/tests/qemu-iotests/229.out b/tests/qemu-iotests/229.out index 7eed393013..7d2bfbfbe6 100644 --- a/tests/qemu-iotests/229.out +++ b/tests/qemu-iotests/229.out @@ -8,7 +8,14 @@ wrote 2097152/2097152 bytes at offset 0 === Starting drive-mirror, causing error & stop === -{'execute': 'drive-mirror', 'arguments': {'device': 'testdisk', 'format': 'IMGFMT', 'target': 'blkdebug:TEST_DIR/blkdebug.conf:TEST_DIR/t.IMGFMT.dest', 'sync': 'full', 'mode': 'existing', 'on-source-error': 'stop', 'on-target-error': 'stop' }} +{'execute': 'drive-mirror', + 'arguments': {'device': 'testdisk', + 'format': 'IMGFMT', + 'target': 'blkdebug:TEST_DIR/blkdebug.conf:TEST_DIR/t.IMGFMT.dest', + 'sync': 'full', + 'mode': 'existing', + 'on-source-error': 'stop', + 'on-target-error': 'stop' }} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "testdisk"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "testdisk"}} {"return": {}} @@ -17,7 +24,9 @@ wrote 2097152/2097152 bytes at offset 0 === Force cancel job paused in error state === -{'execute': 'block-job-cancel', 'arguments': { 'device': 'testdisk', 'force': true}} +{'execute': 'block-job-cancel', + 'arguments': { 'device': 'testdisk', + 'force': true}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "testdisk"}} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "aborting", "id": "testdisk"}} diff --git a/tests/qemu-iotests/249.out b/tests/qemu-iotests/249.out index 85acda4635..92ec81db03 100644 --- a/tests/qemu-iotests/249.out +++ b/tests/qemu-iotests/249.out @@ -7,24 +7,29 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 backing_file=TEST_DIR/t. === Send a write command to a drive opened in read-only mode (1) -{ 'execute': 'human-monitor-command', 'arguments': {'command-line': 'qemu-io none0 "aio_write 0 2k"'}} +{ 'execute': 'human-monitor-command', + 'arguments': {'command-line': 'qemu-io none0 "aio_write 0 2k"'}} {"return": "Block node is read-onlyrn"} === Run block-commit on base using an invalid filter node name -{ 'execute': 'block-commit', 'arguments': {'job-id': 'job0', 'device': 'none1', 'top-node': 'int', 'filter-node-name': '1234'}} +{ 'execute': 'block-commit', + 'arguments': {'job-id': 'job0', 'device': 'none1', 'top-node': 'int', + 'filter-node-name': '1234'}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "job0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "job0"}} {"error": {"class": "GenericError", "desc": "Invalid node name"}} === Send a write command to a drive opened in read-only mode (2) -{ 'execute': 'human-monitor-command', 'arguments': {'command-line': 'qemu-io none0 "aio_write 0 2k"'}} +{ 'execute': 'human-monitor-command', + 'arguments': {'command-line': 'qemu-io none0 "aio_write 0 2k"'}} {"return": "Block node is read-onlyrn"} === Run block-commit on base using the default filter node name -{ 'execute': 'block-commit', 'arguments': {'job-id': 'job0', 'device': 'none1', 'top-node': 'int'}} +{ 'execute': 'block-commit', + 'arguments': {'job-id': 'job0', 'device': 'none1', 'top-node': 'int'}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "job0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "job0"}} {"return": {}} @@ -36,6 +41,7 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 backing_file=TEST_DIR/t. === Send a write command to a drive opened in read-only mode (3) -{ 'execute': 'human-monitor-command', 'arguments': {'command-line': 'qemu-io none0 "aio_write 0 2k"'}} +{ 'execute': 'human-monitor-command', + 'arguments': {'command-line': 'qemu-io none0 "aio_write 0 2k"'}} {"return": "Block node is read-onlyrn"} *** done diff --git a/tests/qemu-iotests/308.out b/tests/qemu-iotests/308.out index b93aceed2e..466e7e0267 100644 --- a/tests/qemu-iotests/308.out +++ b/tests/qemu-iotests/308.out @@ -5,42 +5,91 @@ wrote 67108864/67108864 bytes at offset 0 64 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) {'execute': 'qmp_capabilities'} {"return": {}} -{'execute': 'blockdev-add', 'arguments': { 'driver': 'file', 'node-name': 'node-protocol', 'filename': 'TEST_DIR/t.IMGFMT' } } +{'execute': 'blockdev-add', + 'arguments': { + 'driver': 'file', + 'node-name': 'node-protocol', + 'filename': 'TEST_DIR/t.IMGFMT' + } } {"return": {}} -{'execute': 'blockdev-add', 'arguments': { 'driver': 'IMGFMT', 'node-name': 'node-format', 'file': 'node-protocol' } } +{'execute': 'blockdev-add', + 'arguments': { + 'driver': 'IMGFMT', + 'node-name': 'node-format', + 'file': 'node-protocol' + } } {"return": {}} === Mountpoint not present === -{'execute': 'block-export-add', 'arguments': { 'type': 'fuse', 'id': 'export-err', 'node-name': 'node-format', 'mountpoint': 'TEST_DIR/t.IMGFMT.fuse' } } +{'execute': 'block-export-add', + 'arguments': { + 'type': 'fuse', + 'id': 'export-err', + 'node-name': 'node-format', + 'mountpoint': 'TEST_DIR/t.IMGFMT.fuse' + } } {"error": {"class": "GenericError", "desc": "Failed to stat 'TEST_DIR/t.IMGFMT.fuse': No such file or directory"}} === Mountpoint is a directory === -{'execute': 'block-export-add', 'arguments': { 'type': 'fuse', 'id': 'export-err', 'node-name': 'node-format', 'mountpoint': 'TEST_DIR/t.IMGFMT.fuse' } } +{'execute': 'block-export-add', + 'arguments': { + 'type': 'fuse', + 'id': 'export-err', + 'node-name': 'node-format', + 'mountpoint': 'TEST_DIR/t.IMGFMT.fuse' + } } {"error": {"class": "GenericError", "desc": "'TEST_DIR/t.IMGFMT.fuse' is not a regular file"}} === Mountpoint is a regular file === -{'execute': 'block-export-add', 'arguments': { 'type': 'fuse', 'id': 'export-mp', 'node-name': 'node-format', 'mountpoint': 'TEST_DIR/t.IMGFMT.fuse' } } +{'execute': 'block-export-add', + 'arguments': { + 'type': 'fuse', + 'id': 'export-mp', + 'node-name': 'node-format', + 'mountpoint': 'TEST_DIR/t.IMGFMT.fuse' + } } {"return": {}} Images are identical. === Mount over existing file === -{'execute': 'block-export-add', 'arguments': { 'type': 'fuse', 'id': 'export-img', 'node-name': 'node-format', 'mountpoint': 'TEST_DIR/t.IMGFMT' } } +{'execute': 'block-export-add', + 'arguments': { + 'type': 'fuse', + 'id': 'export-img', + 'node-name': 'node-format', + 'mountpoint': 'TEST_DIR/t.IMGFMT' + } } {"return": {}} Images are identical. === Double export === -{'execute': 'block-export-add', 'arguments': { 'type': 'fuse', 'id': 'export-err', 'node-name': 'node-format', 'mountpoint': 'TEST_DIR/t.IMGFMT.fuse' } } +{'execute': 'block-export-add', + 'arguments': { + 'type': 'fuse', + 'id': 'export-err', + 'node-name': 'node-format', + 'mountpoint': 'TEST_DIR/t.IMGFMT.fuse' + } } {"error": {"class": "GenericError", "desc": "There already is a FUSE export on 'TEST_DIR/t.IMGFMT.fuse'"}} === Remove export === virtual size: 64 MiB (67108864 bytes) -{'execute': 'block-export-del', 'arguments': { 'id': 'export-mp' } } +{'execute': 'block-export-del', + 'arguments': { + 'id': 'export-mp' + } } {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_EXPORT_DELETED", "data": {"id": "export-mp"}} virtual size: 0 B (0 bytes) === Writable export === -{'execute': 'block-export-add', 'arguments': { 'type': 'fuse', 'id': 'export-mp', 'node-name': 'node-format', 'mountpoint': 'TEST_DIR/t.IMGFMT.fuse', 'writable': true } } +{'execute': 'block-export-add', + 'arguments': { + 'type': 'fuse', + 'id': 'export-mp', + 'node-name': 'node-format', + 'mountpoint': 'TEST_DIR/t.IMGFMT.fuse', 'writable': true + } } {"return": {}} write failed: Permission denied wrote 65536/65536 bytes at offset 1048576 @@ -49,15 +98,30 @@ wrote 65536/65536 bytes at offset 1048576 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) === Resizing exports === -{'execute': 'block-export-del', 'arguments': { 'id': 'export-mp' } } +{'execute': 'block-export-del', + 'arguments': { + 'id': 'export-mp' + } } {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_EXPORT_DELETED", "data": {"id": "export-mp"}} -{'execute': 'block-export-del', 'arguments': { 'id': 'export-img' } } +{'execute': 'block-export-del', + 'arguments': { + 'id': 'export-img' + } } {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_EXPORT_DELETED", "data": {"id": "export-img"}} -{'execute': 'blockdev-del', 'arguments': { 'node-name': 'node-format' } } +{'execute': 'blockdev-del', + 'arguments': { + 'node-name': 'node-format' + } } {"return": {}} -{'execute': 'block-export-add', 'arguments': { 'type': 'fuse', 'id': 'export-mp', 'node-name': 'node-protocol', 'mountpoint': 'TEST_DIR/t.IMGFMT.fuse', 'writable': true } } +{'execute': 'block-export-add', + 'arguments': { + 'type': 'fuse', + 'id': 'export-mp', + 'node-name': 'node-protocol', + 'mountpoint': 'TEST_DIR/t.IMGFMT.fuse', 'writable': true + } } {"return": {}} --- Try growing non-growable export --- @@ -72,10 +136,19 @@ OK: Post-truncate image size is as expected OK: Disk usage grew with fallocate --- Try growing growable export --- -{'execute': 'block-export-del', 'arguments': { 'id': 'export-mp' } } +{'execute': 'block-export-del', + 'arguments': { + 'id': 'export-mp' + } } {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_EXPORT_DELETED", "data": {"id": "export-mp"}} -{'execute': 'block-export-add', 'arguments': { 'type': 'fuse', 'id': 'export-mp', 'node-name': 'node-protocol', 'mountpoint': 'TEST_DIR/t.IMGFMT.fuse', 'writable': true, 'growable': true } } +{'execute': 'block-export-add', + 'arguments': { + 'type': 'fuse', + 'id': 'export-mp', + 'node-name': 'node-protocol', + 'mountpoint': 'TEST_DIR/t.IMGFMT.fuse', 'writable': true, 'growable': true + } } {"return": {}} 65536+0 records in 65536+0 records out diff --git a/tests/qemu-iotests/312.out b/tests/qemu-iotests/312.out index cdd5c40e08..5615146b5c 100644 --- a/tests/qemu-iotests/312.out +++ b/tests/qemu-iotests/312.out @@ -52,13 +52,19 @@ read 65536/65536 bytes at offset 2424832 { 'execute': 'qmp_capabilities' } {"return": {}} -{'execute': 'drive-mirror', 'arguments': {'device': 'virtio0', 'format': 'IMGFMT', 'target': 'TEST_DIR/t.IMGFMT.3', 'sync': 'full', 'mode': 'existing' }} +{'execute': 'drive-mirror', + 'arguments': {'device': 'virtio0', + 'format': 'IMGFMT', + 'target': 'TEST_DIR/t.IMGFMT.3', + 'sync': 'full', + 'mode': 'existing' }} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "virtio0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "virtio0"}} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "virtio0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "virtio0", "len": 10485760, "offset": 10485760, "speed": 0, "type": "mirror"}} -{ 'execute': 'block-job-complete', 'arguments': { 'device': 'virtio0' } } +{ 'execute': 'block-job-complete', + 'arguments': { 'device': 'virtio0' } } {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "virtio0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "virtio0"}} diff --git a/tests/qemu-iotests/common.qemu b/tests/qemu-iotests/common.qemu index de680cf1c7..ef105dfc39 100644 --- a/tests/qemu-iotests/common.qemu +++ b/tests/qemu-iotests/common.qemu @@ -146,14 +146,9 @@ _send_qemu_cmd() count=${qemu_cmd_repeat} use_error="no" fi - # This array element extraction is done to accommodate pathnames with spaces - if [ -z "${success_or_failure}" ]; then - cmd=${@: 1:${#@}-1} - shift $(($# - 1)) - else - cmd=${@: 1:${#@}-2} - shift $(($# - 2)) - fi + + cmd=$1 + shift # Display QMP being sent, but not HMP (since HMP already echoes its # input back to output); decide based on leading '{'