qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: Juan Quintela <quintela@redhat.com>
Cc: qemu-devel@nongnu.org, Fabiano Rosas <farosas@suse.de>,
	Leonardo Bras <leobras@redhat.com>
Subject: Re: [PATCH v3 1/1] migration: vmstate_register() check that instance_id is valid
Date: Tue, 24 Oct 2023 11:32:07 -0400	[thread overview]
Message-ID: <ZTfjd3AFVFaMiAqm@x1n> (raw)
In-Reply-To: <20231024150336.89632-2-quintela@redhat.com>

On Tue, Oct 24, 2023 at 05:03:36PM +0200, Juan Quintela wrote:
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
>  include/migration/vmstate.h | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
> index 9821918631..c48cd8bb68 100644
> --- a/include/migration/vmstate.h
> +++ b/include/migration/vmstate.h
> @@ -28,6 +28,7 @@
>  #define QEMU_VMSTATE_H
>  
>  #include "hw/vmstate-if.h"
> +#include "qemu/error-report.h"
>  
>  typedef struct VMStateInfo VMStateInfo;
>  typedef struct VMStateField VMStateField;
> @@ -1226,6 +1227,11 @@ static inline int vmstate_register(VMStateIf *obj, int instance_id,
>                                     const VMStateDescription *vmsd,
>                                     void *opaque)
>  {
> +    if (instance_id == VMSTATE_INSTANCE_ID_ANY) {
> +        error_report("vmstate_register: Invalid device: %s instance_id: %d",
> +                     vmsd->name, instance_id);
> +        return -1;
> +    }
>      return vmstate_register_with_alias_id(obj, instance_id, vmsd,
>                                            opaque, -1, 0, NULL);
>  }

Juan, could you remind me what's the benefit of failing it like that?

IIUC you want to suggest using vmstate_register_any(), but I think it's all
fine to do vmstate_register(VMSTATE_INSTANCE_ID_ANY)?  You didn't have a
commit message, so I am guessing..

Even if that is wanted, the current error message can be confusing to a
developer adding a new vmstate_register(VMSTATE_INSTANCE_ID_ANY) call.
Maybe directly suggest vmstate_register_any() in the error message?  But
again, I don't see a benefit, vmstate_register(VMSTATE_INSTANCE_ID_ANY)
should still work if without this patch?  Where did I miss?

Thanks,

-- 
Peter Xu



  reply	other threads:[~2023-10-24 15:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-24 15:03 [PATCH v3 0/1] migration: Check for duplicates on vmstate_register() Juan Quintela
2023-10-24 15:03 ` [PATCH v3 1/1] migration: vmstate_register() check that instance_id is valid Juan Quintela
2023-10-24 15:32   ` Peter Xu [this message]
2023-10-24 16:08     ` Juan Quintela
2023-10-24 16:50       ` Peter Xu
2023-10-25  8:54         ` Juan Quintela

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=ZTfjd3AFVFaMiAqm@x1n \
    --to=peterx@redhat.com \
    --cc=farosas@suse.de \
    --cc=leobras@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.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).