From: "Marc-André Lureau" <marcandre.lureau@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org, "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 07/18] rust: move Cell vmstate impl
Date: Tue, 26 Aug 2025 23:06:08 +0400 [thread overview]
Message-ID: <CAMxuvayw7zLYB0OY3=rR5QeEUj_p_d443zJkcExDDb43ha+8XA@mail.gmail.com> (raw)
In-Reply-To: <456e56b3-00d5-48af-b757-79037ab8185a@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 4373 bytes --]
Hi
On Tue, Aug 26, 2025 at 10:28 PM Paolo Bonzini <pbonzini@redhat.com> wrote:
> On 8/26/25 16:04, marcandre.lureau@redhat.com wrote:
> > From: Marc-André Lureau <marcandre.lureau@redhat.com>
> >
> > This will allow to split vmstate to a standalone crate next.
>
> Can you explain why this is needed? Could "migration" depend on "bql"
> (or even, "bql" could stay in util), and keep the implementation of
> VMState for cells, just like you do for Opaque?
>
vmstate doesn't require bql. Why should we enforce it at rust level?
If we merge bql in util, then sure we can make vmstate keep the VMState
impl for BqlCells. But why should we do that? To save one crate? I think it
will more future proof if we have a lower-level util crate without bql, and
higher-level crates that rely on it. Perhaps "bql" should be renamed though
(qemu-loop/iothread or something?)
>
> Thanks,
>
> Paolo
>
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> > rust/qemu-api/src/cell.rs | 5 ++++-
> > rust/qemu-api/src/vmstate.rs | 16 +++++++---------
> > 2 files changed, 11 insertions(+), 10 deletions(-)
> >
> > diff --git a/rust/qemu-api/src/cell.rs b/rust/qemu-api/src/cell.rs
> > index 98d720caf9..4bce526e45 100644
> > --- a/rust/qemu-api/src/cell.rs
> > +++ b/rust/qemu-api/src/cell.rs
> > @@ -152,7 +152,7 @@
> > ptr::NonNull,
> > };
> >
> > -use crate::bindings;
> > +use crate::{bindings, impl_vmstate_transparent};
> >
> > /// An internal function that is used by doctests.
> > pub fn bql_start_test() {
> > @@ -866,3 +866,6 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) ->
> fmt::Result {
> > (**self).fmt(f)
> > }
> > }
> > +
> > +impl_vmstate_transparent!(BqlCell<T> where T: VMState);
> > +impl_vmstate_transparent!(BqlRefCell<T> where T: VMState);
> > diff --git a/rust/qemu-api/src/vmstate.rs b/rust/qemu-api/src/vmstate.rs
> > index c1e2b06390..9d33997c57 100644
> > --- a/rust/qemu-api/src/vmstate.rs
> > +++ b/rust/qemu-api/src/vmstate.rs
> > @@ -29,8 +29,7 @@
> >
> > use common::{callbacks::FnCall, Zeroable};
> >
> > -use crate::bindings::VMStateFlags;
> > -pub use crate::bindings::{VMStateDescription, VMStateField};
> > +pub use crate::bindings::{VMStateDescription, VMStateField,
> VMStateFlags};
> >
> > /// This macro is used to call a function with a generic argument bound
> > /// to the type of a field. The function must take a
> > @@ -325,15 +324,16 @@ unsafe impl $crate::vmstate::VMState for $tuple {
> >
> > // Transparent wrappers: just use the internal type
> >
> > +#[macro_export]
> > macro_rules! impl_vmstate_transparent {
> > ($type:ty where $base:tt: VMState $($where:tt)*) => {
> > - unsafe impl<$base> VMState for $type where $base: VMState
> $($where)* {
> > - const SCALAR_TYPE: VMStateFieldType = <$base as
> VMState>::SCALAR_TYPE;
> > - const BASE: VMStateField = VMStateField {
> > + unsafe impl<$base> $crate::vmstate::VMState for $type where
> $base: $crate::vmstate::VMState $($where)* {
> > + const SCALAR_TYPE: $crate::vmstate::VMStateFieldType =
> <$base as $crate::vmstate::VMState>::SCALAR_TYPE;
> > + const BASE: $crate::vmstate::VMStateField =
> $crate::vmstate::VMStateField {
> > size: mem::size_of::<$type>(),
> > - ..<$base as VMState>::BASE
> > + ..<$base as $crate::vmstate::VMState>::BASE
> > };
> > - const VARRAY_FLAG: VMStateFlags = <$base as
> VMState>::VARRAY_FLAG;
> > + const VARRAY_FLAG: $crate::vmstate::VMStateFlags = <$base
> as $crate::vmstate::VMState>::VARRAY_FLAG;
> > }
> > };
> > }
> > @@ -341,8 +341,6 @@ unsafe impl<$base> VMState for $type where $base:
> VMState $($where)* {
> > impl_vmstate_transparent!(std::cell::Cell<T> where T: VMState);
> > impl_vmstate_transparent!(std::cell::UnsafeCell<T> where T: VMState);
> > impl_vmstate_transparent!(std::pin::Pin<T> where T: VMState);
> > -impl_vmstate_transparent!(crate::cell::BqlCell<T> where T: VMState);
> > -impl_vmstate_transparent!(crate::cell::BqlRefCell<T> where T: VMState);
> > impl_vmstate_transparent!(::common::Opaque<T> where T: VMState);
> >
> > #[macro_export]
>
>
[-- Attachment #2: Type: text/html, Size: 6446 bytes --]
next prev parent reply other threads:[~2025-08-26 19:07 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 [this message]
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
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='CAMxuvayw7zLYB0OY3=rR5QeEUj_p_d443zJkcExDDb43ha+8XA@mail.gmail.com' \
--to=marcandre.lureau@redhat.com \
--cc=berrange@redhat.com \
--cc=manos.pitsidianakis@linaro.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).