[RFC v2 08/26] rust/bindings/util-sys: Include rcu.h in bindings wrapper

Zhao Liu <[email protected]> Wed, 8 Jul 2026 16:10:34 +0800
Newsgroups org.nongnu.qemu-rust,org.nongnu.qemu-devel
Message-ID <[email protected]>
rcu.h is transitively included by several crates'
wrapper.h files (e.g. hwcore via hw/core/qdev.h, system via
system/memory.h).

Because several structs (e.g. BusChild/FlatView/AddressSpace) embed
struct rcu_head, bindgen automatically generates a rcu_head definition
in each crate that references it.

Explicitly add rcu.h to util-sys/wrapper.h.  With the allowlist-then-
blocklist logic in generate_bindgen_args.py, this makes util-sys the
only owner of rcu.h bindings. Then rcu.h is blocked in hwcore-sys and
system-sys, thus it's necessary to import rcu_head from util_sys in
hwcore-sys/lib.rs and system-sys/lib.rs.

Signed-off-by: Zhao Liu <[email protected]>
---
Changes since v1:
 * New commit.
---
 rust/bindings/hwcore-sys/lib.rs  | 2 +-
 rust/bindings/system-sys/lib.rs  | 2 +-
 rust/bindings/util-sys/wrapper.h | 1 +
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/rust/bindings/hwcore-sys/lib.rs b/rust/bindings/hwcore-sys/lib.rs
index 8cef4a796193..9414c6639e2a 100644
--- a/rust/bindings/hwcore-sys/lib.rs
+++ b/rust/bindings/hwcore-sys/lib.rs
@@ -26,7 +26,7 @@
     InterfaceClass, Object, ObjectClass, ObjectProperty, ObjectPropertyAccessor,
     ObjectPropertyRelease,
 };
-use util_sys::{Error, QDict, QList};
+use util_sys::{rcu_head, Error, QDict, QList};
 
 #[cfg(MESON)]
 include!("bindings.inc.rs");
diff --git a/rust/bindings/system-sys/lib.rs b/rust/bindings/system-sys/lib.rs
index 30adf683c355..8feaa76ca165 100644
--- a/rust/bindings/system-sys/lib.rs
+++ b/rust/bindings/system-sys/lib.rs
@@ -21,7 +21,7 @@
 use common::Zeroable;
 use hwcore_sys::{qemu_irq, DeviceClass, DeviceState};
 use qom_sys::{Object, ObjectClass};
-use util_sys::{Error, EventNotifier, QEMUBH};
+use util_sys::{rcu_head, Error, EventNotifier, QEMUBH};
 
 #[cfg(MESON)]
 include!("bindings.inc.rs");
diff --git a/rust/bindings/util-sys/wrapper.h b/rust/bindings/util-sys/wrapper.h
index e9c433e7dc14..5d3cf7792b92 100644
--- a/rust/bindings/util-sys/wrapper.h
+++ b/rust/bindings/util-sys/wrapper.h
@@ -27,6 +27,7 @@ typedef struct Visitor Visitor;
 #include "qemu/module.h"
 #include "qemu/option.h"
 #include "qemu/timer.h"
+#include "qemu/rcu.h"
 #include "qapi/visitor.h"
 #include "qobject/qbool.h"
 #include "qobject/qdict.h"
-- 
2.34.1