public inbox for qemu-devel@nongnu.org
 help / color / mirror / Atom feed
From: Fabiano Rosas <farosas@suse.de>
To: Alexander Mikhalitsyn <alexander@mihalicyn.com>,
	Peter Xu <peterx@redhat.com>
Cc: qemu-devel@nongnu.org, "Jesper Devantier" <foss@defmacro.it>,
	"Kevin Wolf" <kwolf@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Hanna Reitz" <hreitz@redhat.com>,
	qemu-block@nongnu.org, "Stéphane Graber" <stgraber@stgraber.org>,
	"Keith Busch" <kbusch@kernel.org>,
	"Stefan Hajnoczi" <stefanha@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Fam Zheng" <fam@euphon.net>, "Klaus Jensen" <its@irrelevant.dk>,
	"Zhao Liu" <zhao1.liu@intel.com>,
	"Alexander Mikhalitsyn" <aleksandr.mikhalitsyn@futurfusion.io>
Subject: Re: [PATCH v4 1/8] migration/vmstate: introduce vmstate_{load, save}_field helpers
Date: Mon, 16 Mar 2026 11:57:01 -0300	[thread overview]
Message-ID: <87y0jrrfeq.fsf@suse.de> (raw)
In-Reply-To: <CAJqdLroNDwNk4N4Kszyptu7vgOwQfERM8AtAxQhjqfRhCt_W3w@mail.gmail.com>

Alexander Mikhalitsyn via qemu development <qemu-devel@nongnu.org>
writes:

> Am Fr., 13. März 2026 um 17:27 Uhr schrieb Peter Xu <peterx@redhat.com>:
>>
>> On Fri, Mar 13, 2026 at 03:12:14PM +0100, Alexander Mikhalitsyn wrote:
>> > From: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@futurfusion.io>
>> >
>> > Let's introduce vmstate_{load,save}_field() helpers, they will
>> > be used in next patches to support fully-dynamic arrays with NULLs.
>> >
>> > Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@futurfusion.io>
>>
>
> Hi Peter,
>
>> Feel free to rebase to Vladimir's series here, Fabiano already queued it:
>>
>> https://lore.kernel.org/all/20260304212303.667141-11-vsementsov@yandex-team.ru/#t
>
> I've tried, but I can't see it anywhere
> https://gitlab.com/farosas/qemu/-/commits/migration-next
> doesn't contain it. As of now, last commit is
> 472f455cfbb0c5f84a7d48228d5226eaf6c7a61b.
>

I think we usually just take the patches from the list and apply
directly instead of taking any branch*. I don't keep migration-next
stable.

I pushed migration-staging which you can use. It'll collect the patches
that will be merged at the start of the next development cycle, after
the release.

* I use:
b4 am -3 -c -o <patches/dir> <lore.kernel.org link>
(you'd need to solve any conflicts with the base branch yourself)

> Also, patchew tells that that series has conflicts with master:
> https://patchew.org/QEMU/20260304212303.667141-1-vsementsov@yandex-team.ru/
>
> Should I manually download mbox, apply/resolve conflicts with master,
> then rebase my stuff and resend?
>
> Kind regards,
> Alex
>
>>
>> These codes weren't touched that frequent, it's interesting to see such
>> coinsidence happens. :)
>>
>> > ---
>> >  include/migration/vmstate.h |  4 ++
>> >  migration/vmstate.c         | 84 +++++++++++++++++++++++--------------
>> >  2 files changed, 56 insertions(+), 32 deletions(-)
>> >
>> > diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
>> > index 62c2abd0c49..5d7dfe70643 100644
>> > --- a/include/migration/vmstate.h
>> > +++ b/include/migration/vmstate.h
>> > @@ -1240,8 +1240,12 @@ extern const VMStateInfo vmstate_info_qlist;
>> >          .flags = VMS_END, \
>> >      }
>> >
>> > +int vmstate_load_field(QEMUFile *f, void *pv, size_t size,
>> > +                       const VMStateField *field, Error **errp);
>> >  int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
>> >                         void *opaque, int version_id, Error **errp);
>> > +int vmstate_save_field(QEMUFile *f, void *pv, size_t size,
>> > +                       const VMStateField *field, JSONWriter *vmdesc, Error **errp);
>> >  int vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd,
>> >                         void *opaque, JSONWriter *vmdesc, Error **errp);
>> >  int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vmsd,
>> > diff --git a/migration/vmstate.c b/migration/vmstate.c
>> > index 4d28364f7ba..8d192bcaa27 100644
>> > --- a/migration/vmstate.c
>> > +++ b/migration/vmstate.c
>> > @@ -131,6 +131,32 @@ static void vmstate_handle_alloc(void *ptr, const VMStateField *field,
>> >      }
>> >  }
>> >
>> > +int vmstate_load_field(QEMUFile *f, void *pv, size_t size,
>> > +                       const VMStateField *field, Error **errp)
>> > +{
>> > +    int ret = 0;
>> > +
>> > +    if (field->flags & VMS_STRUCT) {
>> > +        ret = vmstate_load_state(f, field->vmsd, pv,
>> > +                                 field->vmsd->version_id,
>> > +                                 errp);
>> > +    } else if (field->flags & VMS_VSTRUCT) {
>> > +        ret = vmstate_load_state(f, field->vmsd, pv,
>> > +                                 field->struct_version_id,
>> > +                                 errp);
>> > +    } else {
>> > +        ret = field->info->get(f, pv, size, field);
>> > +        if (ret < 0) {
>> > +            error_setg(errp,
>> > +                       "Failed to load element of type %s for %s: "
>> > +                       "%d", field->info->name,
>> > +                       field->name, ret);
>> > +        }
>> > +    }
>> > +
>> > +    return ret;
>> > +}
>> > +
>> >  int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
>> >                         void *opaque, int version_id, Error **errp)
>> >  {
>> > @@ -203,24 +229,7 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
>> >                      inner_field = field;
>> >                  }
>> >
>> > -                if (inner_field->flags & VMS_STRUCT) {
>> > -                    ret = vmstate_load_state(f, inner_field->vmsd, curr_elem,
>> > -                                             inner_field->vmsd->version_id,
>> > -                                             errp);
>> > -                } else if (inner_field->flags & VMS_VSTRUCT) {
>> > -                    ret = vmstate_load_state(f, inner_field->vmsd, curr_elem,
>> > -                                             inner_field->struct_version_id,
>> > -                                             errp);
>> > -                } else {
>> > -                    ret = inner_field->info->get(f, curr_elem, size,
>> > -                                                 inner_field);
>> > -                    if (ret < 0) {
>> > -                        error_setg(errp,
>> > -                                   "Failed to load element of type %s for %s: "
>> > -                                   "%d", inner_field->info->name,
>> > -                                   inner_field->name, ret);
>> > -                    }
>> > -                }
>> > +                ret = vmstate_load_field(f, curr_elem, size, inner_field, errp);
>> >
>> >                  /* If we used a fake temp field.. free it now */
>> >                  if (inner_field != field) {
>> > @@ -427,6 +436,29 @@ int vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd,
>> >      return vmstate_save_state_v(f, vmsd, opaque, vmdesc_id, vmsd->version_id, errp);
>> >  }
>> >
>> > +int vmstate_save_field(QEMUFile *f, void *pv, size_t size,
>> > +                       const VMStateField *field, JSONWriter *vmdesc, Error **errp)
>> > +{
>> > +    int ret = 0;
>> > +
>> > +    if (field->flags & VMS_STRUCT) {
>> > +        ret = vmstate_save_state(f, field->vmsd, pv, vmdesc, errp);
>> > +    } else if (field->flags & VMS_VSTRUCT) {
>> > +        ret = vmstate_save_state_v(f, field->vmsd, pv, vmdesc,
>> > +                                   field->struct_version_id, errp);
>> > +    } else {
>> > +        ret = field->info->put(f, pv, size, field, vmdesc);
>> > +        if (ret < 0) {
>> > +            error_setg(errp,
>> > +                       "Failed to save element of type %s for %s: "
>> > +                       "%d", field->info->name,
>> > +                       field->name, ret);
>> > +        }
>> > +    }
>> > +
>> > +    return ret;
>> > +}
>> > +
>> >  int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vmsd,
>> >                           void *opaque, JSONWriter *vmdesc, int version_id, Error **errp)
>> >  {
>> > @@ -528,19 +560,7 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vmsd,
>> >                  vmsd_desc_field_start(vmsd, vmdesc_loop, inner_field,
>> >                                        i, max_elems);
>> >
>> > -                if (inner_field->flags & VMS_STRUCT) {
>> > -                    ret = vmstate_save_state(f, inner_field->vmsd,
>> > -                                             curr_elem, vmdesc_loop, errp);
>> > -                } else if (inner_field->flags & VMS_VSTRUCT) {
>> > -                    ret = vmstate_save_state_v(f, inner_field->vmsd,
>> > -                                               curr_elem, vmdesc_loop,
>> > -                                               inner_field->struct_version_id,
>> > -                                               errp);
>> > -                } else {
>> > -                    ret = inner_field->info->put(f, curr_elem, size,
>> > -                                                 inner_field, vmdesc_loop);
>> > -                }
>> > -
>> > +                ret = vmstate_save_field(f, curr_elem, size, inner_field, vmdesc_loop, errp);
>> >                  written_bytes = qemu_file_transferred(f) - old_offset;
>> >                  vmsd_desc_field_end(vmsd, vmdesc_loop, inner_field,
>> >                                      written_bytes);
>> > @@ -551,7 +571,7 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vmsd,
>> >                  }
>> >
>> >                  if (ret) {
>> > -                    error_setg(errp, "Save of field %s/%s failed",
>> > +                    error_prepend(errp, "Save of field %s/%s failed: ",
>> >                                  vmsd->name, field->name);
>> >                      if (vmsd->post_save) {
>> >                          vmsd->post_save(opaque);
>> > --
>> > 2.47.3
>> >
>>
>> --
>> Peter Xu
>>


  reply	other threads:[~2026-03-16 14:57 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-13 14:12 [PATCH v4 0/8] hw/nvme: add basic live migration support Alexander Mikhalitsyn
2026-03-13 14:12 ` [PATCH v4 1/8] migration/vmstate: introduce vmstate_{load, save}_field helpers Alexander Mikhalitsyn via qemu development
2026-03-13 16:27   ` [PATCH v4 1/8] migration/vmstate: introduce vmstate_{load,save}_field helpers Peter Xu
2026-03-16 11:09     ` [PATCH v4 1/8] migration/vmstate: introduce vmstate_{load, save}_field helpers Alexander Mikhalitsyn via qemu development
2026-03-16 14:57       ` Fabiano Rosas [this message]
2026-03-16 15:11         ` Alexander Mikhalitsyn
2026-03-13 14:12 ` [PATCH v4 2/8] migration: add VMSTATE_VARRAY_OF_POINTER_TO_STRUCT_UINT{8, 32}_ALLOC Alexander Mikhalitsyn
2026-03-13 14:12 ` [PATCH v4 3/8] tests/unit/test-vmstate: add tests for VMS_ARRAY_OF_POINTER_ALLOW_NULL Alexander Mikhalitsyn
2026-03-13 14:12 ` [PATCH v4 4/8] tests/functional/migration: add VM launch/configure hooks Alexander Mikhalitsyn
2026-03-13 14:12 ` [PATCH v4 5/8] hw/nvme: add migration blockers for non-supported cases Alexander Mikhalitsyn
2026-03-13 14:12 ` [PATCH v4 6/8] hw/nvme: split nvme_init_sq/nvme_init_cq into helpers Alexander Mikhalitsyn
2026-03-13 14:12 ` [PATCH v4 7/8] hw/nvme: add basic live migration support Alexander Mikhalitsyn
2026-03-13 14:12 ` [PATCH v4 8/8] tests/functional/x86_64: add migration test for NVMe device Alexander Mikhalitsyn

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=87y0jrrfeq.fsf@suse.de \
    --to=farosas@suse.de \
    --cc=aleksandr.mikhalitsyn@futurfusion.io \
    --cc=alexander@mihalicyn.com \
    --cc=fam@euphon.net \
    --cc=foss@defmacro.it \
    --cc=hreitz@redhat.com \
    --cc=its@irrelevant.dk \
    --cc=kbusch@kernel.org \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=stgraber@stgraber.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