qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Marc-André Lureau" <marcandre.lureau@redhat.com>
To: Zhao Liu <zhao1.liu@intel.com>
Cc: qemu-devel@nongnu.org, qemu-rust@nongnu.org,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	pbonzini@redhat.com,
	"Manos Pitsidianakis" <manos.pitsidianakis@linaro.org>
Subject: Re: [PATCH 10/22] rust: split "migration" crate
Date: Fri, 29 Aug 2025 15:50:02 +0400	[thread overview]
Message-ID: <CAMxuvaz6n1bhsknnyfgvgw9sha13sEicAfZ6hsNX-vX7v7eDsw@mail.gmail.com> (raw)
In-Reply-To: <aLFr3u+r8P5GGZRJ@intel.com>

[-- Attachment #1: Type: text/plain, Size: 4013 bytes --]

Hi

On Fri, Aug 29, 2025 at 12:37 PM Zhao Liu <zhao1.liu@intel.com> wrote:

> Hi Marc-Andre,
>
> On Wed, Aug 27, 2025 at 02:41:32PM +0400, marcandre.lureau@redhat.com
> wrote:
> > Date: Wed, 27 Aug 2025 14:41:32 +0400
> > From: marcandre.lureau@redhat.com
> > Subject: [PATCH 10/22] rust: split "migration" crate
> >
> > From: Marc-André Lureau <marcandre.lureau@redhat.com>
> >
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
>
> ...
>
> > @@ -0,0 +1,51 @@
> > +/*
> > + * QEMU System Emulator
> > + *
> > + * Copyright (c) 2024 Linaro Ltd.
> > + *
> > + * Authors: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
> > + *
> > + * Permission is hereby granted, free of charge, to any person
> obtaining a copy
> > + * of this software and associated documentation files (the
> "Software"), to deal
> > + * in the Software without restriction, including without limitation
> the rights
> > + * to use, copy, modify, merge, publish, distribute, sublicense, and/or
> sell
> > + * copies of the Software, and to permit persons to whom the Software is
> > + * furnished to do so, subject to the following conditions:
> > + *
> > + * The above copyright notice and this permission notice shall be
> included in
> > + * all copies or substantial portions of the Software.
> > + *
> > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> EXPRESS OR
> > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> MERCHANTABILITY,
> > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
> SHALL
> > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
> OTHER
> > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
> ARISING FROM,
> > + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
> DEALINGS IN
> > + * THE SOFTWARE.
> > + */
>
> Could we use /* SPDX-License-Identifier: GPL-2.0-or-later */ directly ?
>
> [snip]
>

I guess we could. Probably for a future cleanup though.


>
> > +// using extension traits would be nicer, unfortunately it doesn't
> allow const
> > +// fn yet
> > +pub struct VMStateFieldHelper(pub VMStateField);
> >
> >  // Add a couple builder-style methods to VMStateField, allowing
> >  // easy derivation of VMStateField constants from other types.
>
> A question: Sorry I didn't get your point about why we need
> VMStateFieldHelper?
>
> For its use case:
>
> > -        vmstate_struct!(FooB, arr_a[0 .. num_a], &VMSTATE_FOOA,
> FooA).with_version_id(1),
> > -        vmstate_struct!(FooB, arr_a_mul[0 .. num_a_mul * 32],
> &VMSTATE_FOOA, FooA).with_version_id(2),
> > +        VMStateFieldHelper(vmstate_struct!(FooB, arr_a[0 .. num_a],
> &VMSTATE_FOOA, FooA)).with_version_id(1).0,
> > +        VMStateFieldHelper(vmstate_struct!(FooB, arr_a_mul[0 ..
> num_a_mul * 32], &VMSTATE_FOOA, FooA)).with_version_id(2).0,
>
> It seems VMStateFieldHelper add another wrapper around vmstate_struct
> (and vmstate_of).
>
> The builder pattern is good, but I'm afraid this builder makes the use of
> vmstate_struct! more complex.
>
> > -impl VMStateField {
> > +impl VMStateFieldHelper {
> >      #[must_use]
> >      pub const fn with_version_id(mut self, version_id: i32) -> Self {
> >          assert!(version_id >= 0);
> > -        self.version_id = version_id;
> > +        self.0.version_id = version_id;
> >          self
> >      }
>
> If we could have a build() method then user doesn't need to write ".0"
> at the end.
>
> >  }
>
> And there's another VMStateDescriptionBuilder:
>
>
> https://lore.kernel.org/qemu-devel/20250505100854.73936-4-pbonzini@redhat.com/#t
>
> I think Paolo has the plan to merge it with v1.83 support. So if this
> VMStateFieldHelper is necessary, it's better seperate this into another
> patch and base it over VMStateDescriptionBuilder if possible.
>
>
Paolo rebased it and dropped the need for the VMStateFieldHelper.

[-- Attachment #2: Type: text/html, Size: 5426 bytes --]

  reply	other threads:[~2025-08-30 15:21 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 ` [PATCH 09/22] rust: move Cell vmstate impl marcandre.lureau
2025-08-29  8:22   ` 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 [this message]
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=CAMxuvaz6n1bhsknnyfgvgw9sha13sEicAfZ6hsNX-vX7v7eDsw@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 \
    --cc=zhao1.liu@intel.com \
    /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).