qemu-rust.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: marcandre.lureau@redhat.com
To: qemu-devel@nongnu.org
Cc: qemu-rust@nongnu.org, "Daniel P. Berrangé" <berrange@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	pbonzini@redhat.com,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Manos Pitsidianakis" <manos.pitsidianakis@linaro.org>
Subject: [PATCH 09/22] rust: move Cell vmstate impl
Date: Wed, 27 Aug 2025 14:41:31 +0400	[thread overview]
Message-ID: <20250827104147.717203-10-marcandre.lureau@redhat.com> (raw)
In-Reply-To: <20250827104147.717203-1-marcandre.lureau@redhat.com>

From: Marc-André Lureau <marcandre.lureau@redhat.com>

This will allow to split vmstate to a standalone crate next.

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]
-- 
2.50.1



  parent reply	other threads:[~2025-08-27 10:43 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-27 10:41 [PATCH 00/22] rust: split qemu-api marcandre.lureau
2025-08-27 10:41 ` [PATCH 01/22] docs/rust: update msrv marcandre.lureau
2025-08-27 14:37   ` Zhao Liu
2025-08-27 10:41 ` [PATCH 02/22] rust: remove unused global qemu "allocator" marcandre.lureau
2025-08-27 14:55   ` Zhao Liu
2025-08-27 10:41 ` [PATCH 03/22] rust: add workspace authors marcandre.lureau
2025-08-27 14:56   ` Zhao Liu
2025-08-27 10:41 ` [PATCH 04/22] rust: make build.rs generic over various ./rust/projects marcandre.lureau
2025-08-27 15:06   ` Zhao Liu
2025-08-28  7:14   ` Zhao Liu
2025-08-27 10:41 ` [PATCH 05/22] rust: split Rust-only "common" crate marcandre.lureau
2025-08-27 15:20   ` Zhao Liu
2025-08-27 10:41 ` [PATCH 06/22] rust: split "util" crate marcandre.lureau
2025-08-28  7:10   ` Zhao Liu
2025-08-27 10:41 ` [PATCH 07/22] rust: move vmstate_clock!() to qdev module marcandre.lureau
2025-08-29  8:11   ` Zhao Liu
2025-08-27 10:41 ` [PATCH 08/22] rust: move VMState handling to QOM module marcandre.lureau
2025-08-29  8:12   ` Zhao Liu
2025-08-27 10:41 ` marcandre.lureau [this message]
2025-08-29  8:22   ` [PATCH 09/22] rust: move Cell vmstate impl Zhao Liu
2025-08-27 10:41 ` [PATCH 10/22] rust: split "migration" crate marcandre.lureau
2025-08-29  8:59   ` Zhao Liu
2025-08-29 11:50     ` Marc-André Lureau
2025-08-29 11:54       ` Daniel P. Berrangé
2025-08-27 10:41 ` [PATCH 11/22] rust: split "bql" crate marcandre.lureau
2025-08-29  9:13   ` Zhao Liu
2025-08-27 10:41 ` [PATCH 12/22] rust: split "qom" crate marcandre.lureau
2025-08-27 10:41 ` [PATCH 13/22] rust: split "chardev" crate marcandre.lureau
2025-08-27 10:41 ` [PATCH 14/22] rust: split "system" crate marcandre.lureau
2025-08-27 10:41 ` [PATCH 15/22] rust: split "hwcore" crate marcandre.lureau
2025-08-27 10:41 ` [PATCH 16/22] rust: rename qemu_api_macros -> qemu_macros marcandre.lureau
2025-08-27 10:41 ` [PATCH 17/22] rust/hpet: drop now unneeded qemu_api dep marcandre.lureau
2025-08-27 10:41 ` [PATCH 18/22] rust/pl011: drop dependency on qemu_api marcandre.lureau
2025-08-27 10:41 ` [PATCH 19/22] rust: repurpose qemu_api -> tests marcandre.lureau
2025-08-27 10:41 ` [PATCH 20/22] rust: re-export qemu_macros internal helper in "bits" marcandre.lureau
2025-08-27 10:41 ` [PATCH 21/22] rust: re-export qemu macros from common/qom/hwcore marcandre.lureau
2025-08-27 10:41 ` [PATCH 22/22] docs: update rust.rst marcandre.lureau
2025-08-27 17:25 ` [PATCH 00/22] rust: split qemu-api Paolo Bonzini

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=20250827104147.717203-10-marcandre.lureau@redhat.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).