On 5 March 2011 14:59, Paolo Bonzini <pbonz...@redhat.com> wrote: > On 03/05/2011 01:34 PM, Peter Maydell wrote: >> Can you give an example/explanation? docs/migration.txt doesn't >> seem to cover this... > > Sure, sorry for being terse. It simply needs to be: > > VMSTATE_UINT32_V(sys_cfgdata, arm_sysctl_state, 2), > VMSTATE_UINT32_V(sys_cfgctrl, arm_sysctl_state, 2), > VMSTATE_UINT32_V(sys_cfgstat, arm_sysctl_state, 2), > > Also, minimum_version_id needs to remain 1 since you do support loading > version 1 saved virtual machines.
Ah. I was just following Juan's suggestion: > - if you don't care about backward compatibility, just add +1 to all the > version fields and you are done. but I guess if it's that trivial we might as well support it. (My guess is that basically nobody is doing any kind of migration of ARM TCG VMs, so I think it's all a bit moot.) What do the new fields get set to when you do a load from a v1 snapshot? Other random snapshot/vmstate questions while I'm here: (1) Is there supposed to be any kind of guard on trying to do a vmsave on a system with devices that don't implement save/load? IME it just produces a snapshot which doesn't work when you reload it... (2) How do you track incompatible changes at the machine level? For instance, suppose we accidentally forgot to model a NOT gate in an IRQ line, so we add a qemu_irq_invert() to the machine init function. None of the devices have changed, but you can't load the state of an old version of the machine into a new version, because then the devices on either end of the inverter would be inconsistent about the state of the line. But there's no version number for a machine as far as I can see. I've appended a draft of a suggested extra section for docs/migration.txt so you can tell me if I've misunderstood it all :-) ---begin--- === Adding state fields to a device === If you make a bugfix or enhancement to a device which requires the addition of extra state, you need to add these new state fields to the VMStateDescription so that: (1) they are saved and loaded correctly (2) migration between the new and old versions either works or fails cleanly. If the change is such that migration between versions would not work anyway, you can just add the new fields using the usual VMSTATE_* macros, increment the version_id and set the minimum_version_id to be the same as the version_id. Migration from the old version to the new version can be supported if it is OK for the new fields to remain in their default state [XXX is this right? are they zeroed, or do they get the value the device's reset function sets them to, or something else?] when the state of an old-version snapshot is loaded. To implement this you need to use the VMSTATE_*_V macros which let you specify the version in which a field was introduced, for instance: VMSTATE_UINT32_V(sys_cfgdata, arm_sysctl_state, 2) for a field introduced in version 2. You should also increment the version_id, but leave the minimum_version_id unchanged. Newly added VMSTATE_*_V fields should go at the end of the VMState description. ---endit--- thanks -- PMM