From: Zhao Liu <zhao1.liu@intel.com>
To: marcandre.lureau@redhat.com
Cc: qemu-devel@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
qemu-rust@nongnu.org,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Manos Pitsidianakis" <manos.pitsidianakis@linaro.org>
Subject: Re: [RFC 10/18] rust: split "qom" crate
Date: Wed, 27 Aug 2025 14:55:12 +0800 [thread overview]
Message-ID: <aK6r0AytZGSOkWYF@intel.com> (raw)
In-Reply-To: <20250826140449.4190022-11-marcandre.lureau@redhat.com>
> diff --git a/rust/hw/char/pl011/src/device.rs b/rust/hw/char/pl011/src/device.rs
> index 7cffb894a8..a3bcd1297a 100644
> --- a/rust/hw/char/pl011/src/device.rs
> +++ b/rust/hw/char/pl011/src/device.rs
> @@ -21,10 +21,13 @@
> memory::{hwaddr, MemoryRegion, MemoryRegionOps, MemoryRegionOpsBuilder},
> prelude::*,
> qdev::{Clock, ClockEvent, DeviceImpl, DeviceState, Property, ResetType, ResettablePhasesImpl},
> - qom::{ObjectImpl, Owned, ParentField, ParentInit},
> sysbus::{SysBusDevice, SysBusDeviceImpl},
> vmstate_clock,
> };
> +use qom::{
> + qom_isa, IsA, Object, ObjectClassMethods, ObjectDeref, ObjectImpl, ObjectMethods, ObjectType,
> + Owned, ParentField, ParentInit,
> +};
These QOM parts are frequently used and very common. at least for qom,
I think prelude would help a lot.
A qom prelude could help reduce the changes in other parts (pl011/
hpet/memory...).
> diff --git a/rust/qom/meson.build b/rust/qom/meson.build
> new file mode 100644
> index 0000000000..6e95d75fa0
> --- /dev/null
> +++ b/rust/qom/meson.build
> @@ -0,0 +1,61 @@
> +_qom_cfg = run_command(rustc_args,
> + '--config-headers', config_host_h, '--features', files('Cargo.toml'),
> + capture: true, check: true).stdout().strip().splitlines()
> +
> +# TODO: Remove this comment when the clang/libclang mismatch issue is solved.
> +#
> +# Rust bindings generation with `bindgen` might fail in some cases where the
> +# detected `libclang` does not match the expected `clang` version/target. In
> +# this case you must pass the path to `clang` and `libclang` to your build
> +# command invocation using the environment variables CLANG_PATH and
> +# LIBCLANG_PATH
> +_qom_bindings_inc_rs = rust.bindgen(
> + input: 'wrapper.h',
> + dependencies: common_ss.all_dependencies(),
> + output: 'bindings.inc.rs',
There're many binding files with the same name. What about adding a prefix
like "qom-bindings" to distinguish it? This can help search and locate
specific binding file.
> + include_directories: bindings_incdir,
> + bindgen_version: ['>=0.60.0'],
> + args: bindgen_args_common,
> +)
...
> diff --git a/rust/qom/tests/tests.rs b/rust/qom/tests/tests.rs
> new file mode 100644
> index 0000000000..49f1cbecf5
> --- /dev/null
> +++ b/rust/qom/tests/tests.rs
> @@ -0,0 +1,47 @@
> +use std::{ffi::CStr, sync::LazyLock};
LazyLock is useful, but it became stable since v1.80. So if Paolo
decide pick this series after v1.83 support, it's fine.
> +use qom::{qom_isa, Object, ObjectClassMethods, ObjectImpl, ObjectType, ParentField};
> +use util::bindings::{module_call_init, module_init_type};
...
> +fn init_qom() {
> + static ONCE: LazyLock<()> = LazyLock::new(|| unsafe {
> + module_call_init(module_init_type::MODULE_INIT_QOM);
> + });
But for now, we can still use a static BqlCell<bool> as the workaround,
just like rust/hwcore/tests/tests.rs did, to decouple with MSRV
dependency.
And it seems rust/hwcore/tests/tests.rs has already covered this test
case, do we still need this test?
If so, then it's better to add this new test in a seperate patch, which
makes current patch focus on the splitting :-).
> + bql::start_test();
> + LazyLock::force(&ONCE);
> +}
> +
Otherwise, LGTM,
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
next prev parent reply other threads:[~2025-08-27 6:33 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-26 14:04 [RFC 00/18] rust: split qemu-api marcandre.lureau
2025-08-26 14:04 ` [RFC 01/18] rust: remove unused global qemu "allocator" marcandre.lureau
2025-08-26 14:04 ` [RFC 02/18] rust: add workspace authors marcandre.lureau
2025-08-26 14:04 ` [RFC 03/18] rust: split Rust-only "common" crate marcandre.lureau
2025-08-26 14:04 ` [RFC 04/18] rust: split "util" crate marcandre.lureau
2025-08-26 14:04 ` [RFC 05/18] rust: move vmstate_clock!() to qdev module marcandre.lureau
2025-08-26 14:04 ` [RFC 06/18] rust: move VMState handling to QOM module marcandre.lureau
2025-08-26 14:04 ` [RFC 07/18] rust: move Cell vmstate impl marcandre.lureau
2025-08-26 18:28 ` Paolo Bonzini
2025-08-26 19:06 ` Marc-André Lureau
2025-08-27 7:35 ` Paolo Bonzini
2025-08-26 14:04 ` [RFC 08/18] rust: split "migration" crate marcandre.lureau
2025-08-26 14:04 ` [RFC 09/18] rust: split "bql" crate marcandre.lureau
2025-08-26 14:04 ` [RFC 10/18] rust: split "qom" crate marcandre.lureau
2025-08-27 6:55 ` Zhao Liu [this message]
2025-08-27 8:57 ` Marc-André Lureau
2025-08-27 9:49 ` Paolo Bonzini
2025-08-26 14:04 ` [RFC 11/18] rust: split "chardev" crate marcandre.lureau
2025-08-26 14:04 ` [RFC 12/18] rust: split "system" crate marcandre.lureau
2025-08-26 14:04 ` [RFC 13/18] rust: split "hwcore" crate marcandre.lureau
2025-08-26 14:04 ` [RFC 14/18] rust: rename qemu_api_macros -> qemu_macros marcandre.lureau
2025-08-26 14:53 ` Paolo Bonzini
2025-08-26 20:30 ` Marc-André Lureau
2025-08-26 14:04 ` [RFC 15/18] rust/hpet: drop now unneeded qemu_api dep marcandre.lureau
2025-08-26 14:04 ` [RFC 16/18] rust/pl011: drop dependency on qemu_api marcandre.lureau
2025-08-26 14:04 ` [RFC 17/18] rust: repurpose qemu_api -> tests marcandre.lureau
2025-08-26 14:04 ` [RFC 18/18] docs: update rust.rst marcandre.lureau
2025-08-26 14:44 ` [RFC 00/18] rust: split qemu-api Paolo Bonzini
2025-08-26 14:55 ` Manos Pitsidianakis
2025-08-26 15:22 ` Marc-André Lureau
2025-08-26 15:33 ` Paolo Bonzini
2025-08-26 15:15 ` Marc-André Lureau
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=aK6r0AytZGSOkWYF@intel.com \
--to=zhao1.liu@intel.com \
--cc=berrange@redhat.com \
--cc=manos.pitsidianakis@linaro.org \
--cc=marcandre.lureau@redhat.com \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-rust@nongnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.