All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: Alexander Mikhalitsyn <alexander@mihalicyn.com>
Cc: qemu-devel@nongnu.org, Juraj Marcin <jmarcin@redhat.com>,
	Fabiano Rosas <farosas@suse.de>
Subject: Re: [PATCH RFC 09/10] vmstate: Implement VMS_ARRAY_OF_POINTER_AUTO_ALLOC
Date: Thu, 19 Mar 2026 10:10:32 -0400	[thread overview]
Message-ID: <abwD2N2UhDfSnFYV@x1.local> (raw)
In-Reply-To: <CAJqdLrpXBDJ4SxCBjiO6wtQebK+4N8Z-2Yj2_A7J8PjGtha34Q@mail.gmail.com>

On Wed, Mar 18, 2026 at 11:00:02AM +0100, Alexander Mikhalitsyn wrote:
> Am Mi., 18. März 2026 um 00:23 Uhr schrieb Peter Xu <peterx@redhat.com>:
> >
> > Introduce a new flag, VMS_ARRAY_OF_POINTER_AUTO_ALLOC, for VMSD field.  It
> > must be used together with VMS_ARRAY_OF_POINTER.
> >
> > It can be used to allow migration of an array of pointers where the
> > pointers may point to NULLs.
> >
> > Note that we used to allow migration of a NULL pointer within an array that
> > is being migrated. That corresponds to the code around vmstate_info_nullptr
> > where we may get/put one byte showing that the element of an array is NULL.
> >
> > That usage is fine but very limited, it's because even if it will migrate a
> > NULL pointer with a marker, it still works in a way that both src and dest
> > QEMUs must know exactly which elements of the array are non-NULL, so
> > instead of dynamically loading an array (which can have NULL pointers), it
> > actually only verifies the known NULL pointers are still NULL pointers
> > after migration.
> >
> > Also, in that case since dest QEMU knows exactly which element is NULL,
> > which is not NULL, dest QEMU's device code will manage all allocations for
> > the elements before invoking vmstate_load_vmsd().
> >
> > That's not enough per evolving needs of new device states that may want to
> > provide real dynamic array of pointers, like what Alexander proposed here
> > with the NVMe device migration:
> >
> > https://lore.kernel.org/r/20260317102708.126725-1-alexander@mihalicyn.com
> >
> > This patch is an alternative approach to address the problem.
> >
> > Along with the flag, introduce two new macros:
> >
> >   VMSTATE_VARRAY_OF_POINTER_TO_STRUCT_UINT{8|32}_ALLOC()
> >
> > Which will be used very soon in the NVMe series.
> >
> > Signed-off-by: Peter Xu <peterx@redhat.com>
> 
> Amazing, thank you, Peter!
> 
> Except small nitpicks I've left as inline comment in this patch, it is LGTM.
> 
> Reviewed-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@futurfusion.io>
> Tested-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@futurfusion.io>
> 
> Also, I've rebased my NVMe series on top and tested everything
> locally. No regressions were found.

Thanks for the quick review and update.  I'll wait for a few more days
before a non-RFC respin.

[...]

> > +/*
> > + * For migrating a dynamically allocated uint{8,32}-indexed array of
> > + * pointers to structures (with NULL entries and with auto memory
> > + * allocation).
> > + *
> > + * _type: type of structure pointed to
> > + * _vmsd: VMSD for structure _type (when VMS_STRUCT is set)
> > + * _info: VMStateInfo for _type (when VMS_STRUCT is not set)
> 
> nit: probably these are outdated now
> 
> > + * start: size of (_type) pointed to (for auto memory allocation)
> 
> nit: I guess we need to drop this line about "start" field.

Yep I'll fix those, thanks.

-- 
Peter Xu



  reply	other threads:[~2026-03-19 14:10 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-17 23:23 [PATCH RFC 00/10] vmstate: Implement VMS_ARRAY_OF_POINTER_AUTO_ALLOC Peter Xu
2026-03-17 23:23 ` [PATCH RFC 01/10] vmstate: Pass in struct itself for VMSTATE_ARRAY_OF_POINTER Peter Xu
2026-03-18  9:36   ` Alexander Mikhalitsyn
2026-03-17 23:23 ` [PATCH RFC 02/10] vmstate: Pass in struct itself for VMSTATE_VARRAY_OF_POINTER_UINT32 Peter Xu
2026-03-18  9:37   ` Alexander Mikhalitsyn
2026-03-17 23:23 ` [PATCH RFC 03/10] vmstate: Do not set size for VMS_ARRAY_OF_POINTER Peter Xu
2026-03-18  9:37   ` Alexander Mikhalitsyn
2026-03-17 23:23 ` [PATCH RFC 04/10] vmstate: Limit the vmdesc_loop dedup trick to compressable field Peter Xu
2026-03-18  9:43   ` Alexander Mikhalitsyn
2026-03-26 19:27   ` Peter Xu
2026-03-17 23:23 ` [PATCH RFC 05/10] vmstate: Rename VMS_NULLPTR_MARKER to VMS_MARKER_PTR_NULL Peter Xu
2026-03-18  9:38   ` Alexander Mikhalitsyn
2026-03-17 23:23 ` [PATCH RFC 06/10] vmstate: Introduce vmstate_save_field_with_vmdesc() Peter Xu
2026-03-18  9:39   ` Alexander Mikhalitsyn
2026-03-19 20:36   ` Fabiano Rosas
2026-03-17 23:23 ` [PATCH RFC 07/10] vmstate: Allow vmstate_info_nullptr to emit non-NULL markers Peter Xu
2026-03-18  9:40   ` Alexander Mikhalitsyn
2026-03-19 20:46   ` Fabiano Rosas
2026-03-26 19:25     ` Peter Xu
2026-03-26 21:19       ` Fabiano Rosas
2026-03-17 23:23 ` [PATCH RFC 08/10] vmstate: Implement load of ptr marker in vmstate core Peter Xu
2026-03-18  9:48   ` Alexander Mikhalitsyn
2026-03-19 20:56   ` Fabiano Rosas
2026-03-19 21:57     ` Peter Xu
2026-03-19 22:07       ` Alexander Graf
2026-03-20 13:03       ` Fabiano Rosas
2026-03-20 14:51         ` Peter Xu
2026-03-17 23:23 ` [PATCH RFC 09/10] vmstate: Implement VMS_ARRAY_OF_POINTER_AUTO_ALLOC Peter Xu
2026-03-18 10:00   ` Alexander Mikhalitsyn
2026-03-19 14:10     ` Peter Xu [this message]
2026-03-19 22:06   ` Fabiano Rosas
2026-03-20 14:42   ` Fabiano Rosas
2026-03-20 15:37     ` Peter Xu
2026-03-17 23:23 ` [PATCH RFC 10/10] tests/unit/test-vmstate: add tests for VMS_ARRAY_OF_POINTER_ALLOW_NULL Peter Xu

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=abwD2N2UhDfSnFYV@x1.local \
    --to=peterx@redhat.com \
    --cc=alexander@mihalicyn.com \
    --cc=farosas@suse.de \
    --cc=jmarcin@redhat.com \
    --cc=qemu-devel@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.