Received: from [140.186.70.92] (port=34462 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q2Keg-0006P5-Rr for qemu-devel@nongnu.org; Wed, 23 Mar 2011 05:47:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q2Kee-00055M-KJ for qemu-devel@nongnu.org; Wed, 23 Mar 2011 05:47:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33934) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q2Kee-00055F-3V for qemu-devel@nongnu.org; Wed, 23 Mar 2011 05:47:04 -0400 From: Juan Quintela In-Reply-To: (Peter Maydell's message of "Tue, 22 Mar 2011 20:32:48 +0000") References: <1299270860-8927-1-git-send-email-peter.maydell@linaro.org> <1299270860-8927-2-git-send-email-peter.maydell@linaro.org> <4D722880.6090103@redhat.com> <4D724FB5.1040601@redhat.com> Date: Wed, 23 Mar 2011 10:44:51 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] Re: [PATCH v2 1/2] hw/arm_sysctl.c: Add the Versatile Express system registers Reply-To: quintela@redhat.com List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Paolo Bonzini , Amit Mahajan , Dawid =?utf-8?Q?Ci=C4=99=C5=BCarkiewicz?= , Bahadir Balban , qemu-devel@nongnu.org Peter Maydell wrote: > On 22 March 2011 19:53, Juan Quintela wrote: >> Peter Maydell wrote: >>> 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?] >> >> You can initialize in your init function at the value that you want, or >> use foo_post_load() function (that receives the version as a parameter) >> to assign to any correct values that you need. > > To check I understand this, this means an incoming migration is > always done to a fresh, never-been-used-before device that has had > its init called but not its reset? > >>> 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: >>> >>> =C2=A0VMSTATE_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. >> >> Just to make things more complicated, this has been "deprecated" O:-) > > It has? Your examples below still use it... as Paolo says, it should be rare that you need it. >> - We know that old device was wrong, and that there is no way we can >> =C2=A0load (reliabely) from version 0. =C2=A0Then we just increase the v= ersion: > > If you're increasing the version can you also clean up by > converting any old VMSTATE_*_V() into plain VMSTATE_*() at this > point, since we can't migrate from those old versions any more? >From vl.c qemu_system_reset(); if (loadvm) { if (load_vmstate(loadvm) < 0) { autostart =3D 0; } } if (incoming) { int ret =3D qemu_start_incoming_migration(incoming); if (ret < 0) { fprintf(stderr, "Migration failed. Exit code %s(%d), exiting.\n= ", incoming, ret); exit(ret); } } else if (autostart) { vm_start(); } reset is always called after init, before both incoming migration and normal start. >> - We know that we can load from v1. =C2=A0But that we want to always sent >> =C2=A0bar2 for migration, then we just increase versions to: >> >> >> const VMStateDescription vmstate_foo =3D { >> =C2=A0 =C2=A0.name =3D "foo", >> =C2=A0 =C2=A0.version_id =3D 2, >> =C2=A0 =C2=A0.minimum_version_id =3D 1, >> =C2=A0 =C2=A0.minimum_version_id_old =3D 1, >> =C2=A0 =C2=A0.fields =C2=A0 =C2=A0 =C2=A0=3D (VMStateField []) { >> =C2=A0 =C2=A0 =C2=A0 =C2=A0VMSTATE_INT32(bar, FOOState), >> =C2=A0 =C2=A0 =C2=A0 =C2=A0VMSTATE_INT32_V(bar2, FOOState, 1), >> =C2=A0 =C2=A0 =C2=A0 =C2=A0VMSTATE_END_OF_LIST() >> =C2=A0 =C2=A0} >> }; >> >> And we are done. =C2=A0We are able to receive state 0 and 1, and we would >> always sent version 1. > > Your numbers in the struct and the text don't seem to match? > My guess is you meant to write version_id =3D 1, minimum_version* =3D 0 ? My fault. copy paste :-( >> Have I manage to explain myself a little bit? > > Yes, thanks, that's very helpful. You are welcome. Later, Juan.