All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hanna Czenczek <hreitz@redhat.com>
To: qemu-block@nongnu.org
Cc: qemu-devel@nongnu.org, Hanna Czenczek <hreitz@redhat.com>,
	Kevin Wolf <kwolf@redhat.com>, John Snow <jsnow@redhat.com>,
	"Denis V . Lunev" <den@openvz.org>,
	Eric Blake <eblake@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: [PATCH v2 05/12] qapi/run-state: Add io-hang state
Date: Mon, 19 Oct 2026 20:20:21 +0200	[thread overview]
Message-ID: <20261019182028.45305-6-hreitz@redhat.com> (raw)
In-Reply-To: <20261019182028.45305-1-hreitz@redhat.com>

This state is similar to io-error, but is not entered on I/O errors but
instead when a request takes longer than a user-defined time (set via
the delay-stop-ns property on a block device, which is not yet available
but will be added by a future patch in this series).

In contrast to other stop states, this state does not drain block
devices.  That is because it is entered only when a request hangs, which
means that draining would be counter-productive.

Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
---
 qapi/run-state.json |  7 ++++++-
 system/runstate.c   | 25 ++++++++++++++++++-------
 2 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/qapi/run-state.json b/qapi/run-state.json
index 8bbd9884087..cf3f43579de 100644
--- a/qapi/run-state.json
+++ b/qapi/run-state.json
@@ -53,12 +53,17 @@
 # @colo: guest is paused to save/restore VM state under colo
 #     checkpoint, VM can not get into this state unless colo
 #     capability is enabled for migration.  (since 2.8)
+#
+# @io-hang: An I/O operation has been delayed for too long and the
+#     device is configured to stop the VM when that happens.  In
+#     contrast to other paused states, the VM's block devices will not
+#     be drained when entering this run state.  (since 11.2)
 ##
 { 'enum': 'RunState',
   'data': [ 'debug', 'inmigrate', 'internal-error', 'io-error', 'paused',
             'postmigrate', 'prelaunch', 'finish-migrate', 'restore-vm',
             'running', 'save-vm', 'shutdown', 'suspended', 'watchdog',
-            'guest-panicked', 'colo' ] }
+            'guest-panicked', 'colo', 'io-hang' ] }
 
 ##
 # @ShutdownCause:
diff --git a/system/runstate.c b/system/runstate.c
index 7b3233f77f6..c5b56308735 100644
--- a/system/runstate.c
+++ b/system/runstate.c
@@ -98,6 +98,7 @@ static const RunStateTransition runstate_transitions_def[] = {
     { RUN_STATE_INMIGRATE, RUN_STATE_PRELAUNCH },
     { RUN_STATE_INMIGRATE, RUN_STATE_POSTMIGRATE },
     { RUN_STATE_INMIGRATE, RUN_STATE_COLO },
+    { RUN_STATE_INMIGRATE, RUN_STATE_IO_HANG },
 
     { RUN_STATE_INTERNAL_ERROR, RUN_STATE_PAUSED },
     { RUN_STATE_INTERNAL_ERROR, RUN_STATE_FINISH_MIGRATE },
@@ -135,6 +136,7 @@ static const RunStateTransition runstate_transitions_def[] = {
     { RUN_STATE_FINISH_MIGRATE, RUN_STATE_SUSPENDED },
     { RUN_STATE_FINISH_MIGRATE, RUN_STATE_WATCHDOG },
     { RUN_STATE_FINISH_MIGRATE, RUN_STATE_GUEST_PANICKED },
+    { RUN_STATE_FINISH_MIGRATE, RUN_STATE_IO_HANG },
 
     { RUN_STATE_RESTORE_VM, RUN_STATE_RUNNING },
     { RUN_STATE_RESTORE_VM, RUN_STATE_PRELAUNCH },
@@ -155,6 +157,7 @@ static const RunStateTransition runstate_transitions_def[] = {
     { RUN_STATE_RUNNING, RUN_STATE_WATCHDOG },
     { RUN_STATE_RUNNING, RUN_STATE_GUEST_PANICKED },
     { RUN_STATE_RUNNING, RUN_STATE_COLO},
+    { RUN_STATE_RUNNING, RUN_STATE_IO_HANG },
 
     { RUN_STATE_SAVE_VM, RUN_STATE_RUNNING },
     { RUN_STATE_SAVE_VM, RUN_STATE_SUSPENDED },
@@ -175,6 +178,7 @@ static const RunStateTransition runstate_transitions_def[] = {
     { RUN_STATE_SUSPENDED, RUN_STATE_RESTORE_VM },
     { RUN_STATE_SUSPENDED, RUN_STATE_SHUTDOWN },
     { RUN_STATE_SUSPENDED, RUN_STATE_IO_ERROR },
+    { RUN_STATE_SUSPENDED, RUN_STATE_IO_HANG },
 
     { RUN_STATE_WATCHDOG, RUN_STATE_RUNNING },
     { RUN_STATE_WATCHDOG, RUN_STATE_FINISH_MIGRATE },
@@ -185,6 +189,11 @@ static const RunStateTransition runstate_transitions_def[] = {
     { RUN_STATE_GUEST_PANICKED, RUN_STATE_FINISH_MIGRATE },
     { RUN_STATE_GUEST_PANICKED, RUN_STATE_PRELAUNCH },
 
+    { RUN_STATE_IO_HANG, RUN_STATE_RUNNING },
+    { RUN_STATE_IO_HANG, RUN_STATE_FINISH_MIGRATE },
+    { RUN_STATE_IO_HANG, RUN_STATE_PRELAUNCH },
+    { RUN_STATE_IO_HANG, RUN_STATE_SUSPENDED },
+
     { RUN_STATE__MAX, RUN_STATE__MAX },
 };
 
@@ -445,13 +454,15 @@ static int do_vm_stop(RunState state, bool send_stop)
         }
     }
 
-    bdrv_drain_all();
-    /*
-     * Even if vm_state_notify() return failure,
-     * it would be better to flush as before.
-     */
-    ret |= bdrv_flush_all();
-    trace_vm_stop_flush_all(ret);
+    if (state != RUN_STATE_IO_HANG) {
+        bdrv_drain_all();
+        /*
+         * Even if vm_state_notify() return failure,
+         * it would be better to flush as before.
+         */
+        ret |= bdrv_flush_all();
+        trace_vm_stop_flush_all(ret);
+    }
 
     return ret;
 }
-- 
2.55.0



  parent reply	other threads:[~2026-10-19 18:22 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-19 18:20 [PATCH v2 00/12] block: BLOCK_IO_DELAY event Hanna Czenczek
2026-10-19 18:20 ` [PATCH v2 01/12] qapi/common: Clarify what IoOperationType is for Hanna Czenczek
2026-10-20  5:58   ` Markus Armbruster
2026-10-19 18:20 ` [PATCH v2 02/12] qapi/block: Add IoAccountingOperation enum Hanna Czenczek
2026-10-20  5:59   ` Markus Armbruster
2026-10-19 18:20 ` [PATCH v2 03/12] runstate: Allow IO_ERROR/SUSPENDED transitions Hanna Czenczek
2026-10-19 18:20 ` [PATCH v2 04/12] iotests: PC-only test for I/O errors during suspend Hanna Czenczek
2026-10-19 18:20 ` Hanna Czenczek [this message]
2026-10-20  6:02   ` [PATCH v2 05/12] qapi/run-state: Add io-hang state Markus Armbruster
2026-10-19 18:20 ` [PATCH v2 06/12] qapi/block: Add BLOCK_IO_DELAY event Hanna Czenczek
2026-10-20  6:49   ` Markus Armbruster
2026-10-19 18:20 ` [PATCH v2 07/12] qapi/block: Add BLOCK_IO_DONE event Hanna Czenczek
2026-10-20  6:55   ` Markus Armbruster
2026-10-19 18:20 ` [PATCH v2 08/12] block-backend: Public blk_get_attached_dev_path() Hanna Czenczek
2026-10-19 18:20 ` [PATCH v2 09/12] host-utils: Add u{add,sub}{32,64}_saturate() Hanna Czenczek
2026-10-19 18:20 ` [PATCH v2 10/12] block: Per-request delay tracker Hanna Czenczek
2026-10-19 18:20 ` [PATCH v2 11/12] block: Add delay-report-ns and delay-stop-ns props Hanna Czenczek
2026-10-19 18:20 ` [PATCH v2 12/12] iotests: Add io-delay-reporting test Hanna Czenczek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261019182028.45305-6-hreitz@redhat.com \
    --to=hreitz@redhat.com \
    --cc=armbru@redhat.com \
    --cc=den@openvz.org \
    --cc=eblake@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.