All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Daniel Henrique Barboza <danielhb413@gmail.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: Question about vmstate_register(), dc->vmsd and instance_id
Date: Sat, 19 Mar 2022 20:43:23 +1100	[thread overview]
Message-ID: <YjWluwTn8GtjfQgT@yekko> (raw)
In-Reply-To: <caff9323-89c8-a44b-bf7a-882711efd5a6@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3321 bytes --]

On Fri, Mar 18, 2022 at 04:51:10PM -0300, Daniel Henrique Barboza wrote:
> 
> 
> On 3/18/22 00:43, David Gibson wrote:
> > On Thu, Mar 17, 2022 at 04:29:14PM +0000, Dr. David Alan Gilbert wrote:
> > > * Peter Maydell (peter.maydell@linaro.org) wrote:
> > > > On Thu, 17 Mar 2022 at 14:03, Daniel Henrique Barboza
> > > > <danielhb413@gmail.com> wrote:
> > > > > I've been looking into converting some vmstate_register() calls to use dc->vmsd,
> > > > > using as a base the docs in docs/devel/migration.rst. This doc mentions that we
> > > > > can either register the vmsd by using vmstate_register() or we can use dc->vmsd
> > > > > for qdev-based devices.
> > > > > 
> > > > > When trying to convert this vmstate() call for the qdev alternative (hw/ppc/spapr_drc.c,
> > > > > drc_realize()) I found this:
> > > > > 
> > > > >       vmstate_register(VMSTATE_IF(drc), spapr_drc_index(drc), &vmstate_spapr_drc,
> > > > >                        drc);
> > > > > 
> > > > > spapr_drc_index() is an unique identifier for these DRC devices and it's being used
> > > > > as instance_id. It is not clear to me how we can keep using this same instance_id when
> > > > > using the dc->vmsd alternative. By looking a bit into migration files I understood
> > > > > that if dc->vmsd is being used the instance_id is always autogenerated. Is that correct?
> > > > 
> > > > Not entirely. It is the intended common setup, but because changing
> > > > the ID value breaks migration compatibility there is a mechanism
> > > > for saying "my device is special and needs to set the instance ID
> > > > to something else" -- qdev_set_legacy_instance_id().
> > > 
> > > Yes, this is normally only an issue for 'system' or memory mapped
> > > devices;  for things hung off a bus that has it's own device naming,
> > > then each instance of a device has it's own device due to the bus name
> > > so instance_id's aren't used.  Where you've got a few of the
> > > same device with the same name, and no bus for them to be named by, then
> > > the instance_id is used to uniquify them.
> 
> 
> Thanks for the info. qdev_set_legacy_instance_id() was the missing piece I was
> looking for to continue with the dc->vmsd transition I'd like to do.
> 
> 
> > 
> > Thanks for the information.  I remember deciding at the time that just
> > using vmsd wouldn't work for the DRCs because we needed this fixed
> > index.  At the time either qdev_set_legacy_instance_id() didn't exist,
> > or I didn't know about it, hence the explicit vmstate_register() call
> > so that an explicit instance id could be supplied.
> > 
> 
> This is the commit that introduced DRC migration:
> 
> 
> commit a50919dddf148b0a2008db4a0593dbe69e1059c0
> Author: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
> Date:   Mon May 22 16:35:49 2017 -0300
> 
>     hw/ppc: migrating the DRC state of hotplugged devices
> 
> 
> I'd say you can cut yourself some slack this time. Blame that guy
> instead.

Man, not that guy again! ;-)

I think I must have done something similar with some other migration
component.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2022-03-19 10:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-17 13:58 Question about vmstate_register(), dc->vmsd and instance_id Daniel Henrique Barboza
2022-03-17 15:04 ` Peter Maydell
2022-03-17 16:29   ` Dr. David Alan Gilbert
2022-03-18  3:43     ` David Gibson
2022-03-18 19:51       ` Daniel Henrique Barboza
2022-03-19  9:43         ` David Gibson [this message]
2022-03-23 21:39     ` Daniel Henrique Barboza

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=YjWluwTn8GtjfQgT@yekko \
    --to=david@gibson.dropbear.id.au \
    --cc=danielhb413@gmail.com \
    --cc=dgilbert@redhat.com \
    --cc=peter.maydell@linaro.org \
    --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.