[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v10 7/9] rust: add crate to expose bindings and interfaces
From: |
Junjie Mao |
Subject: |
Re: [PATCH v10 7/9] rust: add crate to expose bindings and interfaces |
Date: |
Sat, 14 Sep 2024 13:41:54 +0800 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) |
Manos Pitsidianakis <manos.pitsidianakis@linaro.org> writes:
> Add rust/qemu-api, which exposes rust-bindgen generated FFI bindings and
> provides some declaration macros for symbols visible to the rest of
> QEMU.
>
> Co-authored-by: Junjie Mao <junjie.mao@intel.com>
> Co-authored-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Junjie Mao <junjie.mao@intel.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
> ---
[snip]
> diff --git a/rust/qemu-api/src/device_class.rs
> b/rust/qemu-api/src/device_class.rs
> new file mode 100644
> index
> 0000000000000000000000000000000000000000..69ee912c333c3dce8bc127a286acaadd57ca20b3
> --- /dev/null
> +++ b/rust/qemu-api/src/device_class.rs
> @@ -0,0 +1,128 @@
> +// Copyright 2024, Linaro Limited
> +// Author(s): Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +
> +use std::sync::OnceLock;
> +
> +use crate::bindings::Property;
> +
> +#[macro_export]
> +macro_rules! device_class_init {
> + ($func:ident, props => $props:ident, realize_fn => $realize_fn:expr,
> reset_fn => $reset_fn:expr, vmsd => $vmsd:ident$(,)*) => {
> + #[no_mangle]
> + pub unsafe extern "C" fn $func(
> + klass: *mut $crate::bindings::ObjectClass,
> + _: *mut ::core::ffi::c_void,
> + ) {
> + let mut dc =
> +
> ::core::ptr::NonNull::new(klass.cast::<$crate::bindings::DeviceClass>()).unwrap();
> + dc.as_mut().realize = $realize_fn;
> + dc.as_mut().reset = $reset_fn;
A recent change to qdev-core.h [1] renames reset to legacy_reset. You
may want to rebase the series and update this to
dc.as_mut().legacy_reset accordingly.
[1]
https://lore.kernel.org/qemu-devel/20240913151411.2167922-9-peter.maydell@linaro.org/
--
Best Regards
Junjie Mao
- [PATCH v10 0/9] Add Rust build support, ARM PL011 device impl, Manos Pitsidianakis, 2024/09/10
- [PATCH v10 2/9] build-sys: Add rust feature option, Manos Pitsidianakis, 2024/09/10
- [PATCH v10 3/9] configure, meson: detect Rust toolchain, Manos Pitsidianakis, 2024/09/10
- [PATCH v10 4/9] rust: add bindgen step as a meson dependency, Manos Pitsidianakis, 2024/09/10
- [PATCH v10 5/9] .gitattributes: add Rust diff and merge attributes, Manos Pitsidianakis, 2024/09/10
- [PATCH v10 1/9] Require meson version 1.5.0, Manos Pitsidianakis, 2024/09/10
- [PATCH v10 6/9] meson.build: add HAVE_GLIB_WITH_ALIGNED_ALLOC flag, Manos Pitsidianakis, 2024/09/10
- [PATCH v10 7/9] rust: add crate to expose bindings and interfaces, Manos Pitsidianakis, 2024/09/10
- [PATCH v10 8/9] rust: add utility procedural macro crate, Manos Pitsidianakis, 2024/09/10
- [PATCH v10 9/9] rust: add PL011 device model, Manos Pitsidianakis, 2024/09/10