From nobody Tue Aug 25 10:48:03 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1779486998; cv=none; d=zohomail.com; s=zohoarc; b=oGcXSBpzG93E3nSBlChYBovK2sxOg6XfuJfrMos2T/BOLfqw1t+PKgEFuJixG7YZJU7t6fefmx9+HV/6UbBYqNTYPY8/p8Df3Ndnvj8IOzXzJHjnOcTi3PrH+0VENQPzH0GLMJbKPNlunu7mpVWkgybWuyoSvGm2goSNhMrqyW0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779486998; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4a4Oc98w2bwdQgHgKjyHvAWQSkn/vXww3Li/67/URXU=; b=YK2CcW72+eB5k7NwCXq2nT2SU2Hst1X4JmbI0iHZ9cqQlI174xWhTbmx1PS5Y2uvnOQZenrHgTd1daKuYIPlyXSiakyYyr/s38eOpjcIgBtWGGYtV+N4OlrLWKtRZ+k3hVG+8JrLnSSiKUmvi1bbiWRVmPvC6Z0XoXKgQQr7Lkw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779486998493855.8804040678742; Fri, 22 May 2026 14:56:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQXna-00076P-54; Fri, 22 May 2026 17:52:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQXnX-0006ro-GQ; Fri, 22 May 2026 17:52:51 -0400 Received: from isrv.corpit.ru ([212.248.84.144]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQXnU-0004av-Uq; Fri, 22 May 2026 17:52:51 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 7653A1AFB7E; Sat, 23 May 2026 00:49:21 +0300 (MSK) Received: from think4mjt.tls.msk.ru (mjtthink.wg.tls.msk.ru [192.168.177.146]) by tsrv.corpit.ru (Postfix) with ESMTP id 9F91F3B71CD; Sat, 23 May 2026 00:49:25 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tls.msk.ru; s=202602; t=1779486561; bh=2EvzDU4SkBQ2rke12IQoCQvpnW/uRQEwCvfnq/wNd4M=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=WS8/IUfSEzk1xGJb0gIVnujAmaIuxoz79ncmRNbAxuAhCcRJFQHcI98zIrCqFWqHA hDtANDhxWPvBYqRF42hqgewIoUDvWOb/oHNOX8aGIVaT2COk9cR2YfyONzhBw5+GDW mZ/bWAnDnp74u48kQa8PKz1dBAXOUgkEbq4EuA5EBz2o5XwGcd7xHjUPjY8hBt+GXe P5DXacpAtW4z/O5Mjntv4VdSZOErF2M3aQukZc9M/W977xKB1u6JLOnG+7duw0QlTU q3KpYTH1RHdb10CFN4AsPCEW7tbRSuVVqypYjyJQn2c6gra6b2fJ2rPa/ZybZfKOij 7AVC2fXtnSYfg== From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Kevin Wolf , Michael Tokarev Subject: [Stable-10.2.3 136/149] blkdebug: Add 'delay-ns' option Date: Sat, 23 May 2026 00:49:08 +0300 Message-ID: <20260522214923.807017-37-mjt@tls.msk.ru> X-Mailer: git-send-email 2.47.3 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=212.248.84.144; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @tls.msk.ru) X-ZM-MESSAGEID: 1779486998864158500 Content-Type: text/plain; charset="utf-8" From: Kevin Wolf Sometimes reproducing a problem for debugging involves slow I/O, so let's add something to blkdebug to make I/O slow when we need it. This can be used either together with an error so that the request fails after the delay, or with errno=3D0, which allows the request to succeed after the delay. Signed-off-by: Kevin Wolf Message-ID: <20260421161132.99878-2-kwolf@redhat.com> Signed-off-by: Kevin Wolf (cherry picked from commit d5e4090177ad382e01084a1594a1a60a69f4c1cd) Signed-off-by: Michael Tokarev diff --git a/block/blkdebug.c b/block/blkdebug.c index c54aee0c84..8954fc2977 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -95,6 +95,7 @@ typedef struct BlkdebugRule { int immediately; int once; int64_t offset; + int64_t delay_ns; } inject; struct { int new_state; @@ -144,6 +145,10 @@ static QemuOptsList inject_error_opts =3D { .name =3D "immediately", .type =3D QEMU_OPT_BOOL, }, + { + .name =3D "delay-ns", + .type =3D QEMU_OPT_NUMBER, + }, { /* end of list */ } }, }; @@ -216,6 +221,8 @@ static int add_rule(void *opaque, QemuOpts *opts, Error= **errp) rule->options.inject.once =3D qemu_opt_get_bool(opts, "once", 0); rule->options.inject.immediately =3D qemu_opt_get_bool(opts, "immediately", 0); + rule->options.inject.delay_ns =3D + qemu_opt_get_number(opts, "delay-ns", 0); sector =3D qemu_opt_get_number(opts, "sector", -1); rule->options.inject.offset =3D sector =3D=3D -1 ? -1 : sector * BDRV_SECTOR_SIZE; @@ -594,6 +601,7 @@ static int coroutine_fn rule_check(BlockDriverState *bs= , uint64_t offset, BlkdebugRule *rule =3D NULL; int error; bool immediately; + int64_t delay_ns; =20 qemu_mutex_lock(&s->lock); QSIMPLEQ_FOREACH(rule, &s->active_rules, active_next) { @@ -608,13 +616,14 @@ static int coroutine_fn rule_check(BlockDriverState *= bs, uint64_t offset, } } =20 - if (!rule || !rule->options.inject.error) { + if (!rule) { qemu_mutex_unlock(&s->lock); return 0; } =20 immediately =3D rule->options.inject.immediately; error =3D rule->options.inject.error; + delay_ns =3D rule->options.inject.delay_ns; =20 if (rule->options.inject.once) { QSIMPLEQ_REMOVE(&s->active_rules, rule, BlkdebugRule, active_next); @@ -622,6 +631,10 @@ static int coroutine_fn rule_check(BlockDriverState *b= s, uint64_t offset, } =20 qemu_mutex_unlock(&s->lock); + + if (delay_ns) { + qemu_co_sleep_ns(QEMU_CLOCK_REALTIME, delay_ns); + } if (!immediately) { aio_co_schedule(qemu_get_current_aio_context(), qemu_coroutine_sel= f()); qemu_coroutine_yield(); diff --git a/qapi/block-core.json b/qapi/block-core.json index 4118d884f4..b7b5e8bad6 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -3914,6 +3914,9 @@ # # @errno: error identifier (errno) to be returned; defaults to EIO # +# @delay-ns: request delay before completion in nanoseconds +# (default: 0, since: 11.1) +# # @sector: specifies the sector index which has to be affected in # order to actually trigger the event; defaults to "any sector" # @@ -3929,6 +3932,7 @@ '*state': 'int', '*iotype': 'BlkdebugIOType', '*errno': 'int', + '*delay-ns': 'int', '*sector': 'int', '*once': 'bool', '*immediately': 'bool' } } --=20 2.47.3