@@ -3920,13 +3920,15 @@ common_all = static_library('common',
dependencies: common_ss.all_dependencies())
if have_rust and have_system
+ # We would like to use --generate-cstr, but it is only available
+ # starting with bindgen 0.66.0. The oldest supported versions
+ # are in Ubuntu 22.04 (0.59.1) and Debian 12 (0.60.1).
bindgen_args = [
'--disable-header-comment',
'--raw-line', '// @generated',
'--ctypes-prefix', 'std::os::raw',
'--formatter', 'rustfmt',
'--generate-block',
- '--generate-cstr',
'--impl-debug',
'--merge-extern-blocks',
'--no-doc-comments',
@@ -13,6 +13,7 @@
bindings::{self, *},
c_str,
definitions::ObjectImpl,
+ device_class::TYPE_SYS_BUS_DEVICE,
with_offsets,
};
@@ -2,7 +2,9 @@
// Author(s): Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
// SPDX-License-Identifier: GPL-2.0-or-later
-use crate::bindings::Property;
+use std::ffi::CStr;
+
+use crate::bindings::{self, Property};
#[macro_export]
macro_rules! device_class_init {
@@ -129,3 +131,7 @@ macro_rules! vm_state_description {
};
}
}
+
+// workaround until we can use --generate-cstr in bindgen.
+pub const TYPE_SYS_BUS_DEVICE: &CStr =
+ unsafe { CStr::from_bytes_with_nul_unchecked(bindings::TYPE_SYS_BUS_DEVICE) };
--generate-cstr is a good idea and generally the right thing to do, but it is not available in Debian 12 and Ubuntu 22.04. Work around the absence. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> --- meson.build | 4 +++- rust/hw/char/pl011/src/device.rs | 1 + rust/qemu-api/src/device_class.rs | 8 +++++++- 3 files changed, 11 insertions(+), 2 deletions(-)