qemu-kvm/kvm-blkdebug-Add-delay-ns-option.patch
Miroslav Rezanina 12bff683cd * Wed Aug 05 2026 Miroslav Rezanina <mrezanin@redhat.com> - 10.1.0-23
- kvm-scsi-change-buf_size-to-unsigned-int-in-scsi_SG_IO.patch [RHEL-158244]
- kvm-scsi-handle-reservation-changes-across-migration.patch [RHEL-158244]
- kvm-blkdebug-Add-delay-ns-option.patch [RHEL-190701]
- kvm-block-Add-blk_co_start-end_request-and-BDRV_REQ_NO_Q.patch [RHEL-190701]
- kvm-block-Add-flags-parameter-to-blk_-_pdiscard.patch [RHEL-190701]
- kvm-ide-Minimal-fix-for-deadlock-between-TRIM-and-drain.patch [RHEL-190701]
- kvm-ide-Clean-up-ide_trim_co_entry-to-be-idiomatic-corou.patch [RHEL-190701]
- kvm-ide-test-Factor-out-wait_dma_completion.patch [RHEL-190701]
- kvm-ide-test-Test-reset-during-TRIM.patch [RHEL-190701]
- kvm-spec-Install-qtests-into-qemu-kvm-tests-package.patch [RHEL-190701]
- kvm-migration-introduce-MIGRATION_STATUS_FAILING.patch [RHEL-45628]
- kvm-s390x-css-limit-number-of-CHPIDs-in-description.patch [RHEL-193033]
- kvm-s390x-ioinst-Require-strict-length-and-format-for-SE.patch [RHEL-193033]
- kvm-s390x-pci-Shrink-RPCIT-ranges-to-registered-window.patch [RHEL-193033]
- kvm-s390x-pci-Tighten-region-detection-for-BAR-read-writ.patch [RHEL-193033]
- kvm-s390x-sclp-reject-invalid-write-event-data-headers.patch [RHEL-193033]
- kvm-s390x-kvm-clamp-stsi-3.2.2-size.patch [RHEL-193033]
- kvm-s390x-sclp-prevent-re-reading-the-sclp-header.patch [RHEL-193033]
- kvm-s390x-sclpcpi-check-event-length-field-before-readin.patch [RHEL-193033]
- kvm-s390x-css-firm-up-handling-of-chained-TIC-CCWs.patch [RHEL-193033]
- Resolves: RHEL-158244
  (live migration failed or get failed WSFC test result during WSFC testing [rhel-9.9])
- Resolves: RHEL-190701
  (qemu-kvm hung during drain after double pause [rhel-9])
- Resolves: RHEL-45628
  (qemu-kvm crashes after kill virtproxyd on destination host during migration [RHEL-9.9])
- Resolves: RHEL-193033
  (RHEL9.4 - qemu s390x: interface harding fixes)
2026-08-05 08:51:47 +02:00

122 lines
4.2 KiB
Diff

From da41d89e727efc77a8345efc21aa917dbe738d25 Mon Sep 17 00:00:00 2001
From: Kevin Wolf <kwolf@redhat.com>
Date: Tue, 21 Apr 2026 18:11:26 +0200
Subject: [PATCH 03/20] blkdebug: Add 'delay-ns' option
RH-Author: Kevin Wolf <kwolf@redhat.com>
RH-MergeRequest: 507: ide: Fix deadlock between TRIM and drain
RH-Jira: RHEL-190701
RH-Acked-by: German Maglione <None>
RH-Acked-by: Hanna Czenczek <hreitz@redhat.com>
RH-Commit: [1/8] 73c3e2cec511b8ed1e5853220869bda34de7fc8a (kmwolf/centos-qemu-kvm)
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=0, which allows the request to succeed
after the delay.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-ID: <20260421161132.99878-2-kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit d5e4090177ad382e01084a1594a1a60a69f4c1cd)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/blkdebug.c | 15 ++++++++++++++-
qapi/block-core.json | 4 ++++
2 files changed, 18 insertions(+), 1 deletion(-)
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 = {
.name = "immediately",
.type = QEMU_OPT_BOOL,
},
+ {
+ .name = "delay-ns",
+ .type = QEMU_OPT_NUMBER,
+ },
{ /* end of list */ }
},
};
@@ -216,6 +221,8 @@ static int add_rule(void *opaque, QemuOpts *opts, Error **errp)
rule->options.inject.once = qemu_opt_get_bool(opts, "once", 0);
rule->options.inject.immediately =
qemu_opt_get_bool(opts, "immediately", 0);
+ rule->options.inject.delay_ns =
+ qemu_opt_get_number(opts, "delay-ns", 0);
sector = qemu_opt_get_number(opts, "sector", -1);
rule->options.inject.offset =
sector == -1 ? -1 : sector * BDRV_SECTOR_SIZE;
@@ -594,6 +601,7 @@ static int coroutine_fn rule_check(BlockDriverState *bs, uint64_t offset,
BlkdebugRule *rule = NULL;
int error;
bool immediately;
+ int64_t delay_ns;
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,
}
}
- if (!rule || !rule->options.inject.error) {
+ if (!rule) {
qemu_mutex_unlock(&s->lock);
return 0;
}
immediately = rule->options.inject.immediately;
error = rule->options.inject.error;
+ delay_ns = rule->options.inject.delay_ns;
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 *bs, uint64_t offset,
}
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_self());
qemu_coroutine_yield();
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 0236936139..6cf8c1b9c8 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -3909,6 +3909,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"
#
@@ -3924,6 +3927,7 @@
'*state': 'int',
'*iotype': 'BlkdebugIOType',
'*errno': 'int',
+ '*delay-ns': 'int',
'*sector': 'int',
'*once': 'bool',
'*immediately': 'bool' } }
--
2.52.0