{"id":2225811,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2225811/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260421161132.99878-2-kwolf@redhat.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/1.2/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260421161132.99878-2-kwolf@redhat.com>","list_archive_url":null,"date":"2026-04-21T16:11:26","name":"[1/7] blkdebug: Add 'delay-ns' option","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"810f843558da7ea04768b0591067d7314b8cfaee","submitter":{"id":2714,"url":"http://patchwork.ozlabs.org/api/1.2/people/2714/?format=json","name":"Kevin Wolf","email":"kwolf@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260421161132.99878-2-kwolf@redhat.com/mbox/","series":[{"id":500847,"url":"http://patchwork.ozlabs.org/api/1.2/series/500847/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=500847","date":"2026-04-21T16:11:27","name":"ide: Fix deadlock between TRIM and drain","version":1,"mbox":"http://patchwork.ozlabs.org/series/500847/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2225811/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2225811/checks/","tags":{},"related":[],"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=TqPoyZi1;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists1p.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g0S8F0pPZz1yCv\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 02:13:33 +1000 (AEST)","from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists1p.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1wFDi0-0001MS-ST; Tue, 21 Apr 2026 12:12:20 -0400","from eggs.gnu.org ([2001:470:142:3::10])\n by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <kwolf@redhat.com>) id 1wFDhy-0001Km-21\n for qemu-devel@nongnu.org; Tue, 21 Apr 2026 12:12:18 -0400","from us-smtp-delivery-124.mimecast.com ([170.10.133.124])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <kwolf@redhat.com>) id 1wFDht-0000Eg-2A\n for qemu-devel@nongnu.org; Tue, 21 Apr 2026 12:12:17 -0400","from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com\n (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-610-wArqpyo3OeKZeu5asFJLMg-1; Tue,\n 21 Apr 2026 12:12:05 -0400","from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id E737C1800366; Tue, 21 Apr 2026 16:12:03 +0000 (UTC)","from merkur.fritz.box (unknown [10.44.49.173])\n by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP\n id EDBA9180045E; Tue, 21 Apr 2026 16:12:01 +0000 (UTC)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1776787931;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=jo+ubSRf8Apw+IWgJ8yH3iKGU+qjmtNGJAAVsB8BsNg=;\n b=TqPoyZi1hgCpxA1AAZmzBaBF1PxntSO2uO3xHUhpLQWWukJuzZ+D1msHrT02Ph96Xya4me\n YZpVDRfKLryzHbxZjag1ByLQnrQcjzYVmzUOS5yWCjaVBH5coy+88XaN+SnOgH+4BR15mJ\n kYYKmDgSKaqVQiSLDovdCnDbAD/vIdg=","X-MC-Unique":"wArqpyo3OeKZeu5asFJLMg-1","X-Mimecast-MFC-AGG-ID":"wArqpyo3OeKZeu5asFJLMg_1776787924","From":"Kevin Wolf <kwolf@redhat.com>","To":"qemu-block@nongnu.org","Cc":"kwolf@redhat.com, hreitz@redhat.com, jsnow@redhat.com,\n qemu-devel@nongnu.org, qemu-stable@nongnu.org","Subject":"[PATCH 1/7] blkdebug: Add 'delay-ns' option","Date":"Tue, 21 Apr 2026 18:11:26 +0200","Message-ID":"<20260421161132.99878-2-kwolf@redhat.com>","In-Reply-To":"<20260421161132.99878-1-kwolf@redhat.com>","References":"<20260421161132.99878-1-kwolf@redhat.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-Scanned-By":"MIMEDefang 3.4.1 on 10.30.177.111","Received-SPF":"pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com;\n 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,\n DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001,\n 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 <qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<https://lists.nongnu.org/archive/html/qemu-devel>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"},"content":"Sometimes reproducing a problem for debugging involves slow I/O, so\nlet's add something to blkdebug to make I/O slow when we need it. This\ncan be used either together with an error so that the request fails\nafter the delay, or with errno=0, which allows the request to succeed\nafter the delay.\n\nSigned-off-by: Kevin Wolf <kwolf@redhat.com>\n---\n qapi/block-core.json |  4 ++++\n block/blkdebug.c     | 15 ++++++++++++++-\n 2 files changed, 18 insertions(+), 1 deletion(-)","diff":"diff --git a/qapi/block-core.json b/qapi/block-core.json\nindex 508b081ac16..0efd51787b4 100644\n--- a/qapi/block-core.json\n+++ b/qapi/block-core.json\n@@ -3919,6 +3919,9 @@\n #\n # @errno: error identifier (errno) to be returned; defaults to EIO\n #\n+# @delay-ns: request delay before completion in nanoseconds\n+#            (default: 0, since: 11.1)\n+#\n # @sector: specifies the sector index which has to be affected in\n #     order to actually trigger the event; defaults to \"any sector\"\n #\n@@ -3934,6 +3937,7 @@\n             '*state': 'int',\n             '*iotype': 'BlkdebugIOType',\n             '*errno': 'int',\n+            '*delay-ns': 'int',\n             '*sector': 'int',\n             '*once': 'bool',\n             '*immediately': 'bool' } }\ndiff --git a/block/blkdebug.c b/block/blkdebug.c\nindex 8a4a8cb85ea..b07c67611a5 100644\n--- a/block/blkdebug.c\n+++ b/block/blkdebug.c\n@@ -95,6 +95,7 @@ typedef struct BlkdebugRule {\n             int immediately;\n             int once;\n             int64_t offset;\n+            int64_t delay_ns;\n         } inject;\n         struct {\n             int new_state;\n@@ -144,6 +145,10 @@ static QemuOptsList inject_error_opts = {\n             .name = \"immediately\",\n             .type = QEMU_OPT_BOOL,\n         },\n+        {\n+            .name = \"delay-ns\",\n+            .type = QEMU_OPT_NUMBER,\n+        },\n         { /* end of list */ }\n     },\n };\n@@ -216,6 +221,8 @@ static int add_rule(void *opaque, QemuOpts *opts, Error **errp)\n         rule->options.inject.once  = qemu_opt_get_bool(opts, \"once\", 0);\n         rule->options.inject.immediately =\n             qemu_opt_get_bool(opts, \"immediately\", 0);\n+        rule->options.inject.delay_ns =\n+            qemu_opt_get_number(opts, \"delay-ns\", 0);\n         sector = qemu_opt_get_number(opts, \"sector\", -1);\n         rule->options.inject.offset =\n             sector == -1 ? -1 : sector * BDRV_SECTOR_SIZE;\n@@ -594,6 +601,7 @@ static int coroutine_fn rule_check(BlockDriverState *bs, uint64_t offset,\n     BlkdebugRule *rule = NULL;\n     int error;\n     bool immediately;\n+    int64_t delay_ns;\n \n     qemu_mutex_lock(&s->lock);\n     QSIMPLEQ_FOREACH(rule, &s->active_rules, active_next) {\n@@ -608,13 +616,14 @@ static int coroutine_fn rule_check(BlockDriverState *bs, uint64_t offset,\n         }\n     }\n \n-    if (!rule || !rule->options.inject.error) {\n+    if (!rule) {\n         qemu_mutex_unlock(&s->lock);\n         return 0;\n     }\n \n     immediately = rule->options.inject.immediately;\n     error = rule->options.inject.error;\n+    delay_ns  = rule->options.inject.delay_ns;\n \n     if (rule->options.inject.once) {\n         QSIMPLEQ_REMOVE(&s->active_rules, rule, BlkdebugRule, active_next);\n@@ -622,6 +631,10 @@ static int coroutine_fn rule_check(BlockDriverState *bs, uint64_t offset,\n     }\n \n     qemu_mutex_unlock(&s->lock);\n+\n+    if (delay_ns) {\n+        qemu_co_sleep_ns(QEMU_CLOCK_REALTIME, delay_ns);\n+    }\n     if (!immediately) {\n         aio_co_schedule(qemu_get_current_aio_context(), qemu_coroutine_self());\n         qemu_coroutine_yield();\n","prefixes":["1/7"]}