From: Tao Cui <cui.tao@linux.dev>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, armbru@redhat.com, eblake@redhat.com,
kvm@vger.kernel.org, Tao Cui <cuitao@kylinos.cn>
Subject: [PATCH v1 1/2] qapi: add KVM_VCPU_ERROR event
Date: Wed, 8 Jul 2026 14:12:19 +0800 [thread overview]
Message-ID: <20260708061220.53507-2-cui.tao@linux.dev> (raw)
In-Reply-To: <20260708061220.53507-1-cui.tao@linux.dev>
From: Tao Cui <cuitao@kylinos.cn>
When a KVM vCPU exits with an unrecoverable error (KVM_EXIT_INTERNAL_ERROR,
KVM_EXIT_UNKNOWN, or a failed KVM_RUN ioctl), QEMU currently only logs to
stderr and stops the VM with run state "internal-error". The management
layer must infer what happened from the subsequent STOP event, with no
indication of which vCPU failed or why.
Add a KVM_VCPU_ERROR event, emitted before the VM is stopped, that carries
the failing vCPU (cpu-index, qom-path), an error category
(KvmVcpuErrorReason) and, for KVM_EXIT_INTERNAL_ERROR, the kernel suberror
and extra data words.
Signed-off-by: Tao Cui <cuitao@kylinos.cn>
---
qapi/run-state.json | 57 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 57 insertions(+)
diff --git a/qapi/run-state.json b/qapi/run-state.json
index a5771ad468..c9993ad9ac 100644
--- a/qapi/run-state.json
+++ b/qapi/run-state.json
@@ -732,6 +732,63 @@
'data': { 'action-required': 'bool',
'recursive': 'bool'} }
+##
+# @KvmVcpuErrorReason:
+#
+# Categorizes a KVM vCPU run error reported through @KVM_VCPU_ERROR.
+#
+# @ioctl-failed: the KVM_RUN ioctl failed; see stderr for the errno.
+#
+# @unknown: KVM_EXIT_UNKNOWN; the hardware exit reason is logged to
+# stderr.
+#
+# @internal-error: KVM_EXIT_INTERNAL_ERROR; see @suberror and
+# @exit-data for details.
+#
+# Since: 11.2
+##
+{ 'enum': 'KvmVcpuErrorReason',
+ 'data': [ 'ioctl-failed', 'unknown', 'internal-error' ] }
+
+##
+# @KVM_VCPU_ERROR:
+#
+# Emitted when a KVM vCPU exits with an unrecoverable error, before
+# the VM is stopped with run state ``internal-error``. Lets the
+# management layer learn which vCPU failed and why, instead of
+# inferring it from the subsequent STOP event.
+#
+# @cpu-index: index of the vCPU that failed.
+#
+# @qom-path: the QOM path of the vCPU that failed.
+#
+# @reason: error category.
+#
+# @suberror: KVM internal suberror. Present only when @reason is
+# @internal-error.
+#
+# @exit-data: extra KVM data words. Present only when @reason is
+# @internal-error and the kernel provided extra data.
+#
+# Since: 11.2
+#
+# .. qmp-example::
+#
+# <- { "event": "KVM_VCPU_ERROR",
+# "data": { "cpu-index": 0,
+# "qom-path": "/machine/unattached/device[0]",
+# "reason": "internal-error",
+# "suberror": 1,
+# "exit-data": [ 0 ] },
+# "timestamp": { "seconds": 1267061043, "microseconds": 959568 } }
+##
+{ 'event': 'KVM_VCPU_ERROR',
+ 'data': { 'cpu-index': 'int',
+ 'qom-path': 'str',
+ 'reason': 'KvmVcpuErrorReason',
+ '*suberror': 'int',
+ '*exit-data': ['uint64'] } }
+
##
# @NotifyVmexitOption:
#
--
2.43.0
next prev parent reply other threads:[~2026-07-08 6:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-08 6:12 [PATCH v1 0/2] accel/kvm: notify management of vCPU run errors Tao Cui
2026-07-08 6:12 ` Tao Cui [this message]
2026-07-08 6:12 ` [PATCH v1 2/2] accel/kvm: emit KVM_VCPU_ERROR on unrecoverable vCPU exits Tao Cui
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=20260708061220.53507-2-cui.tao@linux.dev \
--to=cui.tao@linux.dev \
--cc=armbru@redhat.com \
--cc=cuitao@kylinos.cn \
--cc=eblake@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox