From: Juan Quintela <quintela@redhat.com>
To: Peter Xu <peterx@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: Wed, 25 Oct 2023 10:54:59 +0200 [thread overview]
Message-ID: <87h6mff5ek.fsf@secure.mitica> (raw)
In-Reply-To: <ZTf1yoZ0GSlRfxSN@x1n> (Peter Xu's message of "Tue, 24 Oct 2023 12:50:18 -0400")
Peter Xu <peterx@redhat.com> wrote:
>> > 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..
>>
>> This is v3. v1 and v2 had much more messages, so I thought this was not
>> necessary.
>>
>> We had lots of places that had vmstate_register(..., 0, ...) where it
>> should have s/0/VMSTATE_INSTANCE_ID_ANY/
>>
>> The idea here is that we use vmstate_register_any(...) when we don't
>> care about the number and we know there is only to be one device.
>>
>> On my tree, I started with the test:
>>
>> if (instance_id < 0) {
>> error_report("vmstate_register: Invalid device: %s instance_id: %d",
>> vmsd->name, instance_id);
>> return -1;
>> }
>>
>> But then ppc abuses this interface and passes an uint32_t where it
>> should be an int, so I have to check only for that specific value.
>>
>> > 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?
>>
>> You are right, using the other interface.
>>
>> Initial version on this series, I split vmstate_register() into:
>> - vmstate_register_any()
>> - vmstate_register_id() /* the difference with vmstate_register() was
>> just this test */
>>
>> After auditing all the callers, I decided that using
>> vmstate_register_id() didn't brough we a lot, so I just dropped that
>> patches but left the test.
>>
>> Forcing to use vmstate_register_any() makes easier to grep for the
>> places that try to use the vmstate_register(), but perhaps that is not
>> enough convenient.
>
> IMHO if we have the dup check in vmstate_register_with_alias_id(),
> instance_id isn't a problem anymore; no abuse should happen without failing
> that already.
>
> Personally I tend to just drop this one. If to keep it, maybe change the
> error message to suggest the right one, then let it still proceed? Because
> it still works. The error will only be a hint but help not so much, IMHO.
> What do you think?
I would preffer it, but not enough to fight for it, so dropping it.
Thanks, Juan.
prev parent reply other threads:[~2023-10-25 8:56 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
2023-10-24 16:08 ` Juan Quintela
2023-10-24 16:50 ` Peter Xu
2023-10-25 8:54 ` Juan Quintela [this message]
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=87h6mff5ek.fsf@secure.mitica \
--to=quintela@redhat.com \
--cc=farosas@suse.de \
--cc=leobras@redhat.com \
--cc=peterx@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 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).