From: Bjoern Walk <bwalk@linux.ibm.com>
To: qemu-devel@nongnu.org
Cc: "Steffen Eiden" <seiden@linux.ibm.com>,
"Andreas Grapentin" <gra@linux.ibm.com>,
"Bjoern Walk" <bwalk@linux.ibm.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"David Hildenbrand" <david@kernel.org>,
"Igor Mammedov" <imammedo@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"David Woodhouse" <dwmw2@infradead.org>,
"Paul Durrant" <paul@xen.org>, "Song Gao" <17746591750@163.com>,
"Bibo Mao" <maobibo@loongson.cn>,
"Xianglai Li" <lixianglai@loongson.cn>,
"Jiaxun Yang" <jiaxun.yang@flygoat.com>,
"Matthew Rosato" <mjrosato@linux.ibm.com>,
"Farhan Ali" <alifm@linux.ibm.com>,
"Eric Farman" <farman@linux.ibm.com>,
"Cornelia Huck" <cohuck@redhat.com>,
"Halil Pasic" <pasic@linux.ibm.com>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>,
"Ilya Leoshkevich" <iii@linux.ibm.com>,
"Alex Williamson" <alex@shazbot.org>,
"Cédric Le Goater" <clg@redhat.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Marcelo Tosatti" <mtosatti@redhat.com>,
"Zhao Liu" <zhao1.liu@intel.com>,
"Nicholas Piggin" <npiggin@gmail.com>,
"Harsh Prateek Bora" <harshpb@linux.ibm.com>,
"Amit Machhiwal" <amachhiw@linux.ibm.com>,
"Chinmay Rath" <rathc@linux.ibm.com>,
"Glenn Miles" <milesg@linux.ibm.com>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Alistair Francis" <alistair.francis@wdc.com>,
"Weiwei Li" <liwei1518@gmail.com>,
"Daniel Henrique Barboza" <daniel.barboza@oss.qualcomm.com>,
"Liu Zhiwei" <zhiwei_liu@linux.alibaba.com>,
"Chao Liu" <chao.liu@processmission.com>,
"Peter Xu" <peterx@redhat.com>, "Fabiano Rosas" <farosas@suse.de>,
"Laurent Vivier" <lvivier@redhat.com>,
kvm@vger.kernel.org (open list:Overall KVM CPUs),
qemu-s390x@nongnu.org (open list:S390 PCI),
qemu-arm@nongnu.org (open list:ARM TCG CPUs),
qemu-ppc@nongnu.org (open list:PowerPC TCG CPUs),
qemu-riscv@nongnu.org (open list:RISC-V TCG CPUs)
Subject: [RFC Patch 3/8] kvm: Prefer including "system/kvm.h" over <linux/kvm.h>
Date: Mon, 9 Nov 2026 18:10:29 +0100 [thread overview]
Message-ID: <20261109171036.3806884-4-bwalk@linux.ibm.com> (raw)
In-Reply-To: <20261109171036.3806884-1-bwalk@linux.ibm.com>
"system/kvm.h" provides scaffolding around usage of KVM definitions from
<linux/kvm.h> and can act as the central include for KVM-related definitions.
Signed-off-by: Bjoern Walk <bwalk@linux.ibm.com>
---
accel/kvm/kvm-accel-ops.c | 1 -
accel/kvm/kvm-all.c | 2 +-
backends/hostmem-memfd.c | 1 -
hw/hyperv/hyperv.c | 1 -
hw/i386/kvm/clock.c | 1 -
hw/i386/kvm/i8254.c | 1 -
hw/i386/kvm/xen_evtchn.c | 1 -
hw/i386/kvm/xen_overlay.c | 1 -
hw/intc/loongarch_dintc_kvm.c | 1 -
hw/intc/loongarch_extioi_kvm.c | 1 -
hw/s390x/s390-pci-kvm.c | 2 +-
hw/vfio/kvm-helpers.c | 1 -
hw/vfio/kvm-spapr.c | 2 +-
include/system/kvm.h | 1 +
target/arm/kvm-consts.h | 3 ++-
target/arm/kvm.c | 2 --
target/i386/kvm/kvm.c | 2 +-
target/i386/kvm/kvm_i386.h | 2 --
target/i386/sev.c | 1 -
target/loongarch/cpu.c | 3 ---
target/loongarch/kvm/kvm.c | 1 -
target/ppc/kvm.c | 2 --
target/riscv/kvm/kvm-cpu.c | 2 --
target/s390x/kvm/kvm.c | 2 +-
target/s390x/kvm/pv.c | 2 --
tests/qtest/migration/framework.c | 2 +-
tests/qtest/migration/migration-util.c | 2 +-
27 files changed, 10 insertions(+), 33 deletions(-)
diff --git a/accel/kvm/kvm-accel-ops.c b/accel/kvm/kvm-accel-ops.c
index 47244d33..df29c130 100644
--- a/accel/kvm/kvm-accel-ops.c
+++ b/accel/kvm/kvm-accel-ops.c
@@ -25,7 +25,6 @@
#include "qemu/guest-random.h"
#include "qapi/error.h"
-#include <linux/kvm.h>
#include "kvm-cpus.h"
static void *kvm_vcpu_thread_fn(void *arg)
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 411f28dd..178788d2 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -17,7 +17,7 @@
#include <sys/ioctl.h>
#include <poll.h>
-#include <linux/kvm.h>
+#include "system/kvm.h"
#include "qemu/atomic.h"
#include "qemu/option.h"
diff --git a/backends/hostmem-memfd.c b/backends/hostmem-memfd.c
index 46489212..9341169e 100644
--- a/backends/hostmem-memfd.c
+++ b/backends/hostmem-memfd.c
@@ -20,7 +20,6 @@
#include "qom/object.h"
#include "migration/cpr.h"
#include "system/kvm.h"
-#include <linux/kvm.h>
#include "qapi/qapi-type-infos-common.h"
OBJECT_DECLARE_SIMPLE_TYPE(HostMemoryBackendMemfd, MEMORY_BACKEND_MEMFD)
diff --git a/hw/hyperv/hyperv.c b/hw/hyperv/hyperv.c
index 900ff802..0db87a5b 100644
--- a/hw/hyperv/hyperv.c
+++ b/hw/hyperv/hyperv.c
@@ -15,7 +15,6 @@
#include "system/memory.h"
#include "exec/target_page.h"
#include "exec/cpu-common.h"
-#include "linux/kvm.h"
#include "system/kvm.h"
#include "system/physmem.h"
#include "qemu/bitops.h"
diff --git a/hw/i386/kvm/clock.c b/hw/i386/kvm/clock.c
index e3dad136..3c2601a7 100644
--- a/hw/i386/kvm/clock.c
+++ b/hw/i386/kvm/clock.c
@@ -27,7 +27,6 @@
#include "exec/cpu-common.h"
#include "qapi/error.h"
-#include <linux/kvm.h>
#include "qom/object.h"
#define TYPE_KVM_CLOCK "kvmclock"
diff --git a/hw/i386/kvm/i8254.c b/hw/i386/kvm/i8254.c
index 70e8fd83..d99ee462 100644
--- a/hw/i386/kvm/i8254.c
+++ b/hw/i386/kvm/i8254.c
@@ -24,7 +24,6 @@
*/
#include "qemu/osdep.h"
-#include <linux/kvm.h>
#include "qapi/qapi-types-machine.h"
#include "qapi/error.h"
#include "qemu/module.h"
diff --git a/hw/i386/kvm/xen_evtchn.c b/hw/i386/kvm/xen_evtchn.c
index 9379383e..b8982548 100644
--- a/hw/i386/kvm/xen_evtchn.c
+++ b/hw/i386/kvm/xen_evtchn.c
@@ -43,7 +43,6 @@
#include "system/kvm.h"
#include "system/kvm_xen.h"
-#include <linux/kvm.h>
#include <sys/eventfd.h>
#include "hw/xen/interface/memory.h"
diff --git a/hw/i386/kvm/xen_overlay.c b/hw/i386/kvm/xen_overlay.c
index 74cadffb..4cb16e31 100644
--- a/hw/i386/kvm/xen_overlay.c
+++ b/hw/i386/kvm/xen_overlay.c
@@ -25,7 +25,6 @@
#include "system/kvm.h"
#include "system/kvm_xen.h"
-#include <linux/kvm.h>
#include "hw/xen/interface/memory.h"
diff --git a/hw/intc/loongarch_dintc_kvm.c b/hw/intc/loongarch_dintc_kvm.c
index 1137bcd9..9bacf5e7 100644
--- a/hw/intc/loongarch_dintc_kvm.c
+++ b/hw/intc/loongarch_dintc_kvm.c
@@ -7,7 +7,6 @@
#include "qemu/osdep.h"
#include "hw/intc/loongarch_dintc.h"
-#include "linux/kvm.h"
#include "qapi/error.h"
#include "system/kvm.h"
diff --git a/hw/intc/loongarch_extioi_kvm.c b/hw/intc/loongarch_extioi_kvm.c
index aa2e8c75..d17d0511 100644
--- a/hw/intc/loongarch_extioi_kvm.c
+++ b/hw/intc/loongarch_extioi_kvm.c
@@ -7,7 +7,6 @@
#include "qemu/osdep.h"
#include "hw/intc/loongarch_extioi.h"
-#include "linux/kvm.h"
#include "qapi/error.h"
#include "system/kvm.h"
diff --git a/hw/s390x/s390-pci-kvm.c b/hw/s390x/s390-pci-kvm.c
index 9eef4fc3..12b6e8ba 100644
--- a/hw/s390x/s390-pci-kvm.c
+++ b/hw/s390x/s390-pci-kvm.c
@@ -11,7 +11,7 @@
#include "qemu/osdep.h"
-#include <linux/kvm.h>
+#include "system/kvm.h"
#include "kvm/kvm_s390x.h"
#include "target/s390x/kvm/pv.h"
diff --git a/hw/vfio/kvm-helpers.c b/hw/vfio/kvm-helpers.c
index 5e73dddc..429e266e 100644
--- a/hw/vfio/kvm-helpers.c
+++ b/hw/vfio/kvm-helpers.c
@@ -21,7 +21,6 @@
#include "qemu/osdep.h"
#include <sys/ioctl.h>
-#include <linux/kvm.h>
#include "system/kvm.h"
#include "exec/cpu-common.h"
#include "hw/vfio/vfio-device.h"
diff --git a/hw/vfio/kvm-spapr.c b/hw/vfio/kvm-spapr.c
index ad71c5a8..beb53651 100644
--- a/hw/vfio/kvm-spapr.c
+++ b/hw/vfio/kvm-spapr.c
@@ -7,7 +7,7 @@
#include "qemu/osdep.h"
#include <sys/ioctl.h>
#include <linux/vfio.h>
-#include <linux/kvm.h>
+#include "system/kvm.h"
#include "hw/vfio/vfio-container-legacy.h"
#include "hw/vfio/kvm-spapr.h"
diff --git a/include/system/kvm.h b/include/system/kvm.h
index 5d7c0f98..84c2efe9 100644
--- a/include/system/kvm.h
+++ b/include/system/kvm.h
@@ -29,6 +29,7 @@
# endif
#else
# define CONFIG_KVM_IS_POSSIBLE
+# include <linux/kvm.h>
#endif
#ifdef CONFIG_KVM_IS_POSSIBLE
diff --git a/target/arm/kvm-consts.h b/target/arm/kvm-consts.h
index 9fba3e88..1e4eb9e7 100644
--- a/target/arm/kvm-consts.h
+++ b/target/arm/kvm-consts.h
@@ -14,9 +14,10 @@
#ifndef ARM_KVM_CONSTS_H
#define ARM_KVM_CONSTS_H
+#include "system/kvm.h"
+
#ifdef COMPILING_PER_TARGET
#ifdef CONFIG_KVM
-#include <linux/kvm.h>
#include <linux/psci.h>
#define MISMATCH_CHECK(X, Y) QEMU_BUILD_BUG_ON(X != Y)
#endif
diff --git a/target/arm/kvm.c b/target/arm/kvm.c
index df86ad38..99d8f503 100644
--- a/target/arm/kvm.c
+++ b/target/arm/kvm.c
@@ -13,8 +13,6 @@
#include "qemu/osdep.h"
#include <sys/ioctl.h>
-#include <linux/kvm.h>
-
#include "qemu/timer.h"
#include "qemu/error-report.h"
#include "qemu/main-loop.h"
diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index e29ecaba..47ee0590 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -24,7 +24,7 @@
#include <sys/syscall.h>
#include <sys/resource.h>
-#include <linux/kvm.h>
+#include "system/kvm.h"
#include <linux/kvm_para.h>
#include "standard-headers/asm-x86/kvm_para.h"
#include "hw/xen/interface/arch-x86/cpuid.h"
diff --git a/target/i386/kvm/kvm_i386.h b/target/i386/kvm/kvm_i386.h
index 2b653442..7166353b 100644
--- a/target/i386/kvm/kvm_i386.h
+++ b/target/i386/kvm/kvm_i386.h
@@ -44,8 +44,6 @@ void kvm_request_xsave_components(X86CPU *cpu, uint64_t mask);
#ifdef CONFIG_KVM
-#include <linux/kvm.h>
-
typedef struct KvmCpuidInfo {
struct kvm_cpuid2 cpuid;
struct kvm_cpuid_entry2 entries[KVM_MAX_CPUID_ENTRIES];
diff --git a/target/i386/sev.c b/target/i386/sev.c
index 604c2255..3e19f6ec 100644
--- a/target/i386/sev.c
+++ b/target/i386/sev.c
@@ -13,7 +13,6 @@
#include "qemu/osdep.h"
-#include <linux/kvm.h>
#include <linux/kvm_para.h>
#include <linux/psp-sev.h>
diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c
index 1f302226..5f242e19 100644
--- a/target/loongarch/cpu.c
+++ b/target/loongarch/cpu.c
@@ -25,9 +25,6 @@
#include "system/reset.h"
#endif
#include "vec.h"
-#ifdef CONFIG_KVM
-#include <linux/kvm.h>
-#endif
#include "tcg/tcg_loongarch.h"
#include "disas/capstone.h"
diff --git a/target/loongarch/kvm/kvm.c b/target/loongarch/kvm/kvm.c
index 957e73eb..5100024e 100644
--- a/target/loongarch/kvm/kvm.c
+++ b/target/loongarch/kvm/kvm.c
@@ -8,7 +8,6 @@
#include "qemu/osdep.h"
#include "exec/target_long.h"
#include <sys/ioctl.h>
-#include <linux/kvm.h>
#include "asm-loongarch/kvm_para.h"
#include "qapi/error.h"
#include "qemu/timer.h"
diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
index cd19f7a6..ac49a3dd 100644
--- a/target/ppc/kvm.c
+++ b/target/ppc/kvm.c
@@ -19,8 +19,6 @@
#include <sys/ioctl.h>
#include <sys/vfs.h>
-#include <linux/kvm.h>
-
#include "qapi/error.h"
#include "qemu/error-report.h"
#include "cpu.h"
diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c
index 5beb6023..eba1b96a 100644
--- a/target/riscv/kvm/kvm-cpu.c
+++ b/target/riscv/kvm/kvm-cpu.c
@@ -20,8 +20,6 @@
#include <sys/ioctl.h>
#include <sys/prctl.h>
-#include <linux/kvm.h>
-
#include "qemu/timer.h"
#include "qapi/error.h"
#include "qapi/qapi-builtin-type-infos.h"
diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c
index 76dd1e67..bd824fad 100644
--- a/target/s390x/kvm/kvm.c
+++ b/target/s390x/kvm/kvm.c
@@ -21,7 +21,7 @@
#include "qemu/osdep.h"
#include <sys/ioctl.h>
-#include <linux/kvm.h>
+#include "system/kvm.h"
#include <asm/ptrace.h>
#include "cpu.h"
diff --git a/target/s390x/kvm/pv.c b/target/s390x/kvm/pv.c
index 3d508165..afea9e3f 100644
--- a/target/s390x/kvm/pv.c
+++ b/target/s390x/kvm/pv.c
@@ -11,8 +11,6 @@
*/
#include "qemu/osdep.h"
-#include <linux/kvm.h>
-
#include "qemu/units.h"
#include "qapi/error.h"
#include "qemu/error-report.h"
diff --git a/tests/qtest/migration/framework.c b/tests/qtest/migration/framework.c
index b7aef6b2..60f85b72 100644
--- a/tests/qtest/migration/framework.c
+++ b/tests/qtest/migration/framework.c
@@ -27,7 +27,7 @@
#include "qemu/sockets.h"
#ifdef CONFIG_LINUX
-#include <linux/kvm.h>
+#include "system/kvm.h"
#include <sys/ioctl.h>
#endif
diff --git a/tests/qtest/migration/migration-util.c b/tests/qtest/migration/migration-util.c
index db66d8b2..e145c3f8 100644
--- a/tests/qtest/migration/migration-util.c
+++ b/tests/qtest/migration/migration-util.c
@@ -35,7 +35,7 @@
/* For dirty ring test; so far only x86_64 is supported */
#if defined(__linux__) && defined(HOST_X86_64)
-#include "linux/kvm.h"
+#include "system/kvm.h"
#endif
GQueue *tests;
--
2.56.0
next prev parent reply other threads:[~2026-11-09 17:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20261109171036.3806884-1-bwalk@linux.ibm.com>
2026-11-09 17:10 ` [RFC Patch 2/8] kvm: Add header dependency in system/kvm.h explicitly Bjoern Walk
2026-11-09 17:10 ` Bjoern Walk [this message]
2026-11-09 17:10 ` [RFC Patch 6/8] linux-headers: Update to post-processed KVM headers Bjoern Walk
2026-11-09 17:10 ` [RFC Patch 7/8] kvm: Adjust system/kvm.h for updated KVM kernel headers Bjoern Walk
2026-11-09 17:10 ` [RFC Patch 8/8] kvm: Explicitly include ARM-specific KVM UAPI headers Bjoern Walk
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=20261109171036.3806884-4-bwalk@linux.ibm.com \
--to=bwalk@linux.ibm.com \
--cc=17746591750@163.com \
--cc=alex@shazbot.org \
--cc=alifm@linux.ibm.com \
--cc=alistair.francis@wdc.com \
--cc=amachhiw@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=chao.liu@processmission.com \
--cc=clg@redhat.com \
--cc=cohuck@redhat.com \
--cc=daniel.barboza@oss.qualcomm.com \
--cc=david@kernel.org \
--cc=dwmw2@infradead.org \
--cc=farman@linux.ibm.com \
--cc=farosas@suse.de \
--cc=gra@linux.ibm.com \
--cc=harshpb@linux.ibm.com \
--cc=iii@linux.ibm.com \
--cc=imammedo@redhat.com \
--cc=jiaxun.yang@flygoat.com \
--cc=kvm@vger.kernel.org \
--cc=liwei1518@gmail.com \
--cc=lixianglai@loongson.cn \
--cc=lvivier@redhat.com \
--cc=maobibo@loongson.cn \
--cc=milesg@linux.ibm.com \
--cc=mjrosato@linux.ibm.com \
--cc=mst@redhat.com \
--cc=mtosatti@redhat.com \
--cc=npiggin@gmail.com \
--cc=palmer@dabbelt.com \
--cc=pasic@linux.ibm.com \
--cc=paul@xen.org \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=peterx@redhat.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=rathc@linux.ibm.com \
--cc=richard.henderson@linaro.org \
--cc=seiden@linux.ibm.com \
--cc=zhao1.liu@intel.com \
--cc=zhiwei_liu@linux.alibaba.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox