All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: Roman Kiryanov <rkir@google.com>
Cc: qemu-devel@nongnu.org, whollins@google.com, jansene@google.com,
	jpcottin@google.com, Fabiano Rosas <farosas@suse.de>
Subject: Re: [PATCH] vmstate: assert that VMStateDescription::fields is not NULL
Date: Tue, 10 Mar 2026 12:31:23 -0400	[thread overview]
Message-ID: <abBHWwiqu59wCAOY@x1.local> (raw)
In-Reply-To: <20260309223116.3233668-1-rkir@google.com>

On Mon, Mar 09, 2026 at 10:31:16PM +0000, Roman Kiryanov wrote:
> The vmstate_save_state_v() function does not
> support NULL in VMStateDescription::fields
> and will crash if one is provided.
> 
> Signed-off-by: Roman Kiryanov <rkir@google.com>

Thanks for the patch.

Yeah I think assert it is fine, but maybe unnecessary, because we have a
lot of such in QEMU (and IIUC in most userspace apps, likely even kernel is
the same..) where we assert by directly reference it as a pointer..

Here, the assert() only helps to crash slightly earlier, rather than the
field->name reference later..  While in both cases it'll be crystal clear
on what has happened when a QEMU coredump is generated, either at assert(),
or a few instructions later.

PS: please always copy Fabiano when sending migration patches.

Thanks,

> ---
>  migration/vmstate.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/migration/vmstate.c b/migration/vmstate.c
> index 4d28364f7b..5cb173ea25 100644
> --- a/migration/vmstate.c
> +++ b/migration/vmstate.c
> @@ -433,6 +433,7 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vmsd,
>      ERRP_GUARD();
>      int ret = 0;
>      const VMStateField *field = vmsd->fields;
> +    assert(field);
>  
>      trace_vmstate_save_state_top(vmsd->name);
>  
> -- 
> 2.53.0.851.ga537e3e6e9-goog
> 

-- 
Peter Xu



  reply	other threads:[~2026-03-10 16:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-09 22:31 [PATCH] vmstate: assert that VMStateDescription::fields is not NULL Roman Kiryanov
2026-03-10 16:31 ` Peter Xu [this message]
2026-03-10 18:44   ` Fabiano Rosas
2026-03-12 20:42     ` Roman Kiryanov

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=abBHWwiqu59wCAOY@x1.local \
    --to=peterx@redhat.com \
    --cc=farosas@suse.de \
    --cc=jansene@google.com \
    --cc=jpcottin@google.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rkir@google.com \
    --cc=whollins@google.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 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.