All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhao Liu <zhao1.liu@intel.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org, qemu-rust@nongnu.org
Subject: Re: [PATCH 07/10] rust: qemu_api: add vmstate_struct
Date: Wed, 22 Jan 2025 21:17:26 +0800	[thread overview]
Message-ID: <Z5Dv5pQYiXxMA7w+@intel.com> (raw)
In-Reply-To: <20250117090046.1045010-8-pbonzini@redhat.com>

On Fri, Jan 17, 2025 at 10:00:43AM +0100, Paolo Bonzini wrote:
> Date: Fri, 17 Jan 2025 10:00:43 +0100
> From: Paolo Bonzini <pbonzini@redhat.com>
> Subject: [PATCH 07/10] rust: qemu_api: add vmstate_struct
> X-Mailer: git-send-email 2.47.1
> 
> It is not type safe, but it's the best that can be done without
> const_refs_static.  It can also be used with BqlCell and BqlRefCell.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  rust/qemu-api/src/vmstate.rs | 33 +++++++++++++++++++++++++++++++++
>  1 file changed, 33 insertions(+)

...

> +#[doc(alias = "VMSTATE_STRUCT")]
> +#[macro_export]
> +macro_rules! vmstate_struct {
> +    ($struct_name:ty, $field_name:ident $([0 .. $num:ident $(* $factor:expr)?])?, $vmsd:expr, $type:ty $(,)?) => {
> +        $crate::bindings::VMStateField {
> +            name: ::core::concat!(::core::stringify!($field_name), "\0")
> +                .as_bytes()
> +                .as_ptr() as *const ::std::os::raw::c_char,
> +            $(.num_offset: $crate::offset_of!($struct_name, $num),)?
> +            offset: {
> +                $crate::assert_field_type!($struct_name, $field_name, $type);
> +                $crate::offset_of!($struct_name, $field_name)
> +            },
> +            size: ::core::mem::size_of::<$type>(),
> +            flags: $crate::bindings::VMStateFlags::VMS_STRUCT,
> +            vmsd: unsafe { $vmsd },

Yes, this `unsafe` is fitting.

> +            ..$crate::zeroable::Zeroable::ZERO $(
> +                .with_varray_flag($crate::call_func_with_field!(
> +                    $crate::vmstate::vmstate_varray_flag,
> +                    $struct_name,
> +                    $num))
> +               $(.with_varray_multiply($factor))?)?
> +        }
> +    };
> +}
> +

Reviewed-by: Zhao Liu <zhao1.liu@intel.com>



  reply	other threads:[~2025-01-22 12:58 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-17  9:00 [PATCH 00/10] rust: (mostly) type safe VMState Paolo Bonzini
2025-01-17  9:00 ` [PATCH 01/10] rust: vmstate: add new type safe implementation Paolo Bonzini
2025-01-17  9:00 ` [PATCH 02/10] rust: vmstate: implement VMState for non-leaf types Paolo Bonzini
2025-01-22 10:49   ` Zhao Liu
2025-01-17  9:00 ` [PATCH 03/10] rust: vmstate: add varray support to vmstate_of! Paolo Bonzini
2025-01-22 11:44   ` Zhao Liu
2025-01-17  9:00 ` [PATCH 04/10] rust: vmstate: implement Zeroable for VMStateField Paolo Bonzini
2025-01-17  9:00 ` [PATCH 05/10] rust: vmstate: implement VMState for scalar types Paolo Bonzini
2025-01-22 12:33   ` Zhao Liu
2025-01-22 17:28     ` Paolo Bonzini
2025-01-17  9:00 ` [PATCH 06/10] rust: vmstate: add public utility macros to implement VMState Paolo Bonzini
2025-01-17  9:00 ` [PATCH 07/10] rust: qemu_api: add vmstate_struct Paolo Bonzini
2025-01-22 13:17   ` Zhao Liu [this message]
2025-01-17  9:00 ` [PATCH 08/10] rust: pl011: switch vmstate to new-style macros Paolo Bonzini
2025-01-17  9:00 ` [PATCH 09/10] rust: vmstate: remove translation of C vmstate macros Paolo Bonzini
2025-01-17  9:00 ` [PATCH 10/10] rust: vmstate: make order of parameters consistent in vmstate_clock Paolo Bonzini
2025-01-22 10:37   ` Philippe Mathieu-Daudé
2025-01-22 13:18   ` Zhao Liu

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=Z5Dv5pQYiXxMA7w+@intel.com \
    --to=zhao1.liu@intel.com \
    --cc=pbonzini@redhat.com \
    --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.