]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
rust: use glib-sys
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Wed, 24 Sep 2025 13:56:38 +0000 (17:56 +0400)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 3 Oct 2025 13:14:48 +0000 (15:14 +0200)
Don't generate FFI for glib, rely on glib-sys crate.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
28 files changed:
include/hw/core/cpu.h
meson.build
rust/Cargo.lock
rust/Cargo.toml
rust/bql/Cargo.toml
rust/bql/meson.build
rust/bql/src/bindings.rs
rust/chardev/Cargo.toml
rust/chardev/meson.build
rust/chardev/src/bindings.rs
rust/hw/char/pl011/Cargo.toml
rust/hw/char/pl011/meson.build
rust/hw/char/pl011/src/bindings.rs
rust/hw/core/Cargo.toml
rust/hw/core/meson.build
rust/hw/core/src/bindings.rs
rust/migration/Cargo.toml
rust/migration/meson.build
rust/migration/src/bindings.rs
rust/qom/Cargo.toml
rust/qom/meson.build
rust/qom/src/bindings.rs
rust/system/Cargo.toml
rust/system/meson.build
rust/system/src/bindings.rs
rust/util/Cargo.toml
rust/util/meson.build
rust/util/src/bindings.rs

index c9f40c25392e5cf3352ff2723be643571058c3e6..4196293ba1ca6a4c5b0c7c8b2b1099d9cd0b941e 100644 (file)
@@ -169,7 +169,7 @@ struct CPUClass {
     vaddr (*gdb_adjust_breakpoint)(CPUState *cpu, vaddr addr);
 
     const char *gdb_core_xml_file;
-    const gchar * (*gdb_arch_name)(CPUState *cpu);
+    const char * (*gdb_arch_name)(CPUState *cpu);
     const char * (*gdb_get_core_xml_file)(CPUState *cpu);
 
     void (*disas_set_info)(CPUState *cpu, disassemble_info *info);
index 55c8202a4d8b1a908399990dc5c865ab10aca916..62766c0f19cc9d6292caa119105a79ace7821968 100644 (file)
@@ -4239,6 +4239,7 @@ if have_rust
     '--no-prepend-enum-name',
     '--allowlist-file', meson.project_source_root() + '/include/.*',
     '--allowlist-file', meson.project_build_root() + '/.*',
+    '--blocklist-file', glib_pc.get_variable('includedir') + '/glib-2.0/.*',
     ]
   if not rustfmt.found()
     if bindgen.version().version_compare('<0.65.0')
index 444ef516a70af7b308a76ec437f0471a388db2e4..110851334905c6f0a71accdd98bca1a1b3faa524 100644 (file)
@@ -58,15 +58,27 @@ dependencies = [
 name = "bql"
 version = "0.1.0"
 dependencies = [
+ "glib-sys",
  "migration",
 ]
 
+[[package]]
+name = "cfg-expr"
+version = "0.20.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1a2c5f3bf25ec225351aa1c8e230d04d880d3bd89dea133537dafad4ae291e5c"
+dependencies = [
+ "smallvec",
+ "target-lexicon",
+]
+
 [[package]]
 name = "chardev"
 version = "0.1.0"
 dependencies = [
  "bql",
  "common",
+ "glib-sys",
  "migration",
  "qom",
  "util",
@@ -86,6 +98,12 @@ version = "1.12.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b"
 
+[[package]]
+name = "equivalent"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
+
 [[package]]
 name = "foreign"
 version = "0.3.1"
@@ -95,6 +113,28 @@ dependencies = [
  "libc",
 ]
 
+[[package]]
+name = "glib-sys"
+version = "0.21.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d09d3d0fddf7239521674e57b0465dfbd844632fec54f059f7f56112e3f927e1"
+dependencies = [
+ "libc",
+ "system-deps",
+]
+
+[[package]]
+name = "hashbrown"
+version = "0.16.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d"
+
+[[package]]
+name = "heck"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
+
 [[package]]
 name = "hpet"
 version = "0.1.0"
@@ -115,6 +155,7 @@ dependencies = [
  "bql",
  "chardev",
  "common",
+ "glib-sys",
  "migration",
  "qemu_macros",
  "qom",
@@ -122,6 +163,16 @@ dependencies = [
  "util",
 ]
 
+[[package]]
+name = "indexmap"
+version = "2.11.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4b0f83760fb341a774ed326568e19f5a863af4a952def8c39f9ab92fd95b88e5"
+dependencies = [
+ "equivalent",
+ "hashbrown",
+]
+
 [[package]]
 name = "itertools"
 version = "0.11.0"
@@ -137,14 +188,27 @@ version = "0.2.162"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398"
 
+[[package]]
+name = "memchr"
+version = "2.7.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273"
+
 [[package]]
 name = "migration"
 version = "0.1.0"
 dependencies = [
  "common",
+ "glib-sys",
  "util",
 ]
 
+[[package]]
+name = "pkg-config"
+version = "0.3.32"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c"
+
 [[package]]
 name = "pl011"
 version = "0.1.0"
@@ -155,6 +219,7 @@ dependencies = [
  "bql",
  "chardev",
  "common",
+ "glib-sys",
  "hwcore",
  "migration",
  "qom",
@@ -211,6 +276,7 @@ version = "0.1.0"
 dependencies = [
  "bql",
  "common",
+ "glib-sys",
  "migration",
  "qemu_macros",
  "util",
@@ -225,6 +291,50 @@ dependencies = [
  "proc-macro2",
 ]
 
+[[package]]
+name = "serde"
+version = "1.0.226"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0dca6411025b24b60bfa7ec1fe1f8e710ac09782dca409ee8237ba74b51295fd"
+dependencies = [
+ "serde_core",
+]
+
+[[package]]
+name = "serde_core"
+version = "1.0.226"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ba2ba63999edb9dac981fb34b3e5c0d111a69b0924e253ed29d83f7c99e966a4"
+dependencies = [
+ "serde_derive",
+]
+
+[[package]]
+name = "serde_derive"
+version = "1.0.226"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8db53ae22f34573731bafa1db20f04027b2d25e02d8205921b569171699cdb33"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "serde_spanned"
+version = "0.6.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3"
+dependencies = [
+ "serde",
+]
+
+[[package]]
+name = "smallvec"
+version = "1.15.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
+
 [[package]]
 name = "syn"
 version = "2.0.104"
@@ -241,10 +351,30 @@ name = "system"
 version = "0.1.0"
 dependencies = [
  "common",
+ "glib-sys",
  "qom",
  "util",
 ]
 
+[[package]]
+name = "system-deps"
+version = "7.0.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e4be53aa0cba896d2dc615bd42bbc130acdcffa239e0a2d965ea5b3b2a86ffdb"
+dependencies = [
+ "cfg-expr",
+ "heck",
+ "pkg-config",
+ "toml",
+ "version-compare",
+]
+
+[[package]]
+name = "target-lexicon"
+version = "0.13.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e502f78cdbb8ba4718f566c418c52bc729126ffd16baee5baa718cf25dd5a69a"
+
 [[package]]
 name = "tests"
 version = "0.1.0"
@@ -259,6 +389,40 @@ dependencies = [
  "util",
 ]
 
+[[package]]
+name = "toml"
+version = "0.8.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362"
+dependencies = [
+ "serde",
+ "serde_spanned",
+ "toml_datetime",
+ "toml_edit",
+]
+
+[[package]]
+name = "toml_datetime"
+version = "0.6.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c"
+dependencies = [
+ "serde",
+]
+
+[[package]]
+name = "toml_edit"
+version = "0.22.27"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a"
+dependencies = [
+ "indexmap",
+ "serde",
+ "serde_spanned",
+ "toml_datetime",
+ "winnow",
+]
+
 [[package]]
 name = "trace"
 version = "0.1.0"
@@ -279,11 +443,27 @@ dependencies = [
  "anyhow",
  "common",
  "foreign",
+ "glib-sys",
  "libc",
 ]
 
+[[package]]
+name = "version-compare"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "852e951cb7832cb45cb1169900d19760cfa39b82bc0ea9c0e5a14ae88411c98b"
+
 [[package]]
 name = "version_check"
 version = "0.9.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
+
+[[package]]
+name = "winnow"
+version = "0.7.13"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "21a0236b59786fed61e2a80582dd500fe61f18b5dca67a4a067d0bc9039339cf"
+dependencies = [
+ "memchr",
+]
index f372d7dbf7022f2af476e2aaa4338965ed663a31..783e626802c92e7fd99f0588f541011299de816f 100644 (file)
@@ -29,6 +29,7 @@ authors = ["The QEMU Project Developers <qemu-devel@nongnu.org>"]
 anyhow = "~1.0"
 foreign = "~0.3.1"
 libc = "0.2.162"
+glib-sys = { version = "0.21.2", features = ["v2_66"] }
 
 [workspace.lints.rust]
 unexpected_cfgs = { level = "deny", check-cfg = ['cfg(MESON)'] }
index 1041bd4ea93d8fee79b5546ca37e624191daac72..d5177e5f8e2a9e3c478dfd43c0dc2a1f1a5baa55 100644 (file)
@@ -14,6 +14,7 @@ rust-version.workspace = true
 
 [dependencies]
 migration = { path = "../migration" }
+glib-sys.workspace = true
 
 [features]
 default = ["debug_cell"]
index bc51c7f160be12682370f68413a0b5421ef705bc..22d7c9b8776f125010d92cbc8cd737a76c4a369f 100644 (file)
@@ -38,6 +38,7 @@ _bql_rs = static_library(
   rust_abi: 'rust',
   rust_args: _bql_cfg,
   link_with: [_migration_rs],
+  dependencies: [glib_sys_rs],
 )
 
 bql_rs = declare_dependency(link_with: [_bql_rs],
index 9ffff12cded80b70e52107464daacf5891237346..8c70f3a87ce18ef8c5c763a0549e3f2ececebea8 100644 (file)
     clippy::too_many_arguments
 )]
 
+use glib_sys::{
+    guint, GArray, GHashTable, GHashTableIter, GList, GPollFD, GPtrArray, GQueue, GSList, GSource,
+};
+
 #[cfg(MESON)]
 include!("bindings.inc.rs");
 
index 3e77972546eb63fc603678c8f7453735815b8afc..f105189dccbb3cc44172c02e594c349e56190537 100644 (file)
@@ -13,6 +13,7 @@ repository.workspace = true
 rust-version.workspace = true
 
 [dependencies]
+glib-sys = { workspace = true }
 common = { path = "../common" }
 bql = { path = "../bql" }
 migration = { path = "../migration" }
index e7ce02b3bc23d267f313feca2f409933cbe719a9..d365d8dd0f456943aeed2bba0eecfecfa2e3844e 100644 (file)
@@ -36,7 +36,7 @@ _chardev_rs = static_library(
   override_options: ['rust_std=2021', 'build.rust_std=2021'],
   rust_abi: 'rust',
   link_with: [_bql_rs, _migration_rs, _qom_rs, _util_rs],
-  dependencies: [common_rs, qemu_macros],
+  dependencies: [glib_sys_rs, common_rs, qemu_macros],
 )
 
 chardev_rs = declare_dependency(link_with: [_chardev_rs], dependencies: [chardev, qemuutil])
index 2d98026d62752a0d0c79098b26f707d1d59b6226..c95dc89c56dcb6f260b2ef4d0d2ea0fc45ef7271 100644 (file)
 )]
 
 use common::Zeroable;
+use glib_sys::{
+    gboolean, guint, GArray, GHashTable, GHashTableIter, GIOCondition, GList, GMainContext,
+    GPollFD, GPtrArray, GQueue, GSList, GSource, GSourceFunc,
+};
 
 #[cfg(MESON)]
 include!("bindings.inc.rs");
index dc41d0e499e16a41e4cfaac3eb23c7025e355a33..5b319455ee30a140c3cb6bb89910274e1e26be8d 100644 (file)
@@ -13,6 +13,7 @@ repository.workspace = true
 rust-version.workspace = true
 
 [dependencies]
+glib-sys.workspace = true
 bilge = { version = "0.2.0" }
 bilge-impl = { version = "0.2.0" }
 bits = { path = "../../../bits" }
index 07b3da17e83198b326c7f1786ba8c5f94a35ab1f..33b91f21911c559787e713b77fc6da0c7412fae3 100644 (file)
@@ -33,6 +33,7 @@ _libpl011_rs = static_library(
     bilge_impl_rs,
     bits_rs,
     common_rs,
+    glib_sys_rs,
     util_rs,
     migration_rs,
     bql_rs,
index bd5ea840cb2b17d8594656b704a356da9c9735a8..52a76d0de5cbaa8a9151947e958ae642d6ec55a5 100644 (file)
 
 //! `bindgen`-generated declarations.
 
+use glib_sys::{
+    gboolean, guint, GArray, GByteArray, GHashTable, GHashTableIter, GIOCondition, GList,
+    GMainContext, GPollFD, GPtrArray, GQueue, GSList, GSource, GSourceFunc, GString,
+};
+
 #[cfg(MESON)]
 include!("bindings.inc.rs");
 
index 9a9aa517082ed64773598f69bebc2696861c7cea..ecfb56471843d8a5e19f9d467c7d3b9c530a06e3 100644 (file)
@@ -13,6 +13,7 @@ repository.workspace = true
 rust-version.workspace = true
 
 [dependencies]
+glib-sys.workspace = true
 qemu_macros = { path = "../../qemu-macros" }
 common = { path = "../../common" }
 bql = { path = "../../bql" }
index e1ae95ed61e3914bd43b7cf54890912db2fdaef0..1560dd20c6b2296e8497ec61fc6acaeb38f98b1b 100644 (file)
@@ -59,7 +59,7 @@ _hwcore_rs = static_library(
   override_options: ['rust_std=2021', 'build.rust_std=2021'],
   rust_abi: 'rust',
   link_with: [_bql_rs, _chardev_rs, _migration_rs, _qom_rs, _system_rs, _util_rs],
-  dependencies: [qemu_macros, common_rs],
+  dependencies: [glib_sys_rs, qemu_macros, common_rs],
 )
 
 hwcore_rs = declare_dependency(link_with: [_hwcore_rs],
index 919c02b56aea65d27ab8d03979c79f8229d3790a..65b9aae75360edf5bfe88f578d78ef4798cbe126 100644 (file)
@@ -20,6 +20,9 @@
 
 use chardev::bindings::Chardev;
 use common::Zeroable;
+use glib_sys::{
+    GArray, GByteArray, GHashTable, GHashTableIter, GList, GPtrArray, GQueue, GSList, GString,
+};
 use migration::bindings::VMStateDescription;
 use qom::bindings::ObjectClass;
 use system::bindings::MemoryRegion;
index 708bfaaa68256f8d626e3f17a207ead05f2a9cef..94504f3625c92fd045a19fb88be537d607feff19 100644 (file)
@@ -15,6 +15,7 @@ rust-version.workspace = true
 [dependencies]
 common = { path = "../common" }
 util = { path = "../util" }
+glib-sys.workspace = true
 
 [lints]
 workspace = true
index ddf5c2f51d5048b07f9235ac950f34863b22d043..18be65c92cf001a049efa348e3432bdf873569c8 100644 (file)
@@ -38,7 +38,7 @@ _migration_rs = static_library(
   override_options: ['rust_std=2021', 'build.rust_std=2021'],
   rust_abi: 'rust',
   link_with: [_util_rs],
-  dependencies: [common_rs],
+  dependencies: [common_rs, glib_sys_rs],
 )
 
 migration_rs = declare_dependency(link_with: [_migration_rs],
index 8ce13a9000ef2f21ccb6a7763d5c09531774bf8e..24503eb69bd6823d7949ec60e8058d3c51d459d6 100644 (file)
@@ -19,6 +19,7 @@
 )]
 
 use common::Zeroable;
+use glib_sys::{GHashTable, GHashTableIter, GList, GPtrArray, GQueue, GSList};
 
 #[cfg(MESON)]
 include!("bindings.inc.rs");
index 060ad2ec349da491e562c96997ae1115fb8ac33f..4be3c2541b612e07a31422dd23378f555ba89fe2 100644 (file)
@@ -18,6 +18,7 @@ bql = { path = "../bql" }
 migration = { path = "../migration" }
 qemu_macros = { path = "../qemu-macros" }
 util = { path = "../util" }
+glib-sys.workspace = true
 
 [lints]
 workspace = true
index 71fdac696c3c39f14792c463fa3bf9ecc2cc17e9..e50f41858d61850c39ae1589c7bfdfe97b330d0c 100644 (file)
@@ -29,7 +29,7 @@ _qom_rs = static_library(
   override_options: ['rust_std=2021', 'build.rust_std=2021'],
   rust_abi: 'rust',
   link_with: [_bql_rs, _migration_rs],
-  dependencies: [common_rs, qemu_macros],
+  dependencies: [common_rs, glib_sys_rs, qemu_macros],
 )
 
 qom_rs = declare_dependency(link_with: [_qom_rs], dependencies: [qemu_macros, qom])
index 9ffff12cded80b70e52107464daacf5891237346..91de42f2426726bcc926242d515a750a407ca517 100644 (file)
@@ -18,6 +18,8 @@
     clippy::too_many_arguments
 )]
 
+use glib_sys::{GHashTable, GHashTableIter, GList, GPtrArray, GQueue, GSList};
+
 #[cfg(MESON)]
 include!("bindings.inc.rs");
 
index 7fd369b9e32399173c4e8ea413c89809c16454f8..186ea00bfff9ce791aa0695817235e7530264a06 100644 (file)
@@ -16,6 +16,7 @@ rust-version.workspace = true
 common = { path = "../common" }
 qom = { path = "../qom" }
 util = { path = "../util" }
+glib-sys.workspace = true
 
 [lints]
 workspace = true
index 0859f3974535eef376e1b204a07680024d672bf2..73d61991146ac7ff42a0962cf5fe8ec436284340 100644 (file)
@@ -36,7 +36,7 @@ _system_rs = static_library(
   override_options: ['rust_std=2021', 'build.rust_std=2021'],
   rust_abi: 'rust',
   link_with: [_bql_rs, _migration_rs, _qom_rs, _util_rs],
-  dependencies: [common_rs, qemu_macros],
+  dependencies: [glib_sys_rs, common_rs, qemu_macros],
 )
 
 system_rs = declare_dependency(link_with: [_system_rs],
index 43edd98807adb22a20f44cda8fa469691bcab705..6cbb588de3d9c6b30d54d3b4a304b337faf9c806 100644 (file)
 )]
 
 use common::Zeroable;
+use glib_sys::{
+    guint, GArray, GByteArray, GHashTable, GHashTableIter, GList, GPollFD, GPtrArray, GQueue,
+    GSList, GString,
+};
 
 #[cfg(MESON)]
 include!("bindings.inc.rs");
index 1f6767ed9d102161baaf316289aba1b35e5ce801..85f914365450d85cd4209fcc20396ff2dbf2c468 100644 (file)
@@ -15,6 +15,7 @@ rust-version.workspace = true
 [dependencies]
 anyhow = { workspace = true }
 foreign = { workspace = true }
+glib-sys = { workspace = true }
 libc = { workspace = true }
 common = { path = "../common" }
 
index 094b43355aa2bb705c6ad4d5643f70ff68258dee..b0b75e93ff655266491fd1be404cf3b314b1e242 100644 (file)
@@ -40,7 +40,7 @@ _util_rs = static_library(
   ),
   override_options: ['rust_std=2021', 'build.rust_std=2021'],
   rust_abi: 'rust',
-  dependencies: [anyhow_rs, libc_rs, foreign_rs, common_rs, qom, qemuutil],
+  dependencies: [anyhow_rs, libc_rs, foreign_rs, glib_sys_rs, common_rs, qom, qemuutil],
 )
 
 util_rs = declare_dependency(link_with: [_util_rs], dependencies: [qemuutil, qom])
index 9ffff12cded80b70e52107464daacf5891237346..c277a295add3d06f920e4f535bdd5ce5aa6fbb72 100644 (file)
@@ -18,6 +18,8 @@
     clippy::too_many_arguments
 )]
 
+use glib_sys::{guint, GList, GPollFD, GQueue, GSList, GString};
+
 #[cfg(MESON)]
 include!("bindings.inc.rs");