Received: from eggs.gnu.org ([2001:4830:134:3::10]:49011) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAHzv-0004yy-8w for qemu-devel@nongnu.org; Tue, 07 Jun 2016 10:28:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bAHzr-0007Ir-4x for qemu-devel@nongnu.org; Tue, 07 Jun 2016 10:28:50 -0400 Received: from mail-qk0-x22c.google.com ([2607:f8b0:400d:c09::22c]:32788) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAHzr-0007Ih-13 for qemu-devel@nongnu.org; Tue, 07 Jun 2016 10:28:47 -0400 Received: by mail-qk0-x22c.google.com with SMTP id u63so24193473qkh.0 for ; Tue, 07 Jun 2016 07:28:46 -0700 (PDT) Sender: Richard Henderson References: <1465209480-71364-1-git-send-email-rolnik@amazon.com> <1465209480-71364-2-git-send-email-rolnik@amazon.com> From: Richard Henderson Message-ID: <5dd40eba-a9e8-681c-20c1-be61c3aca01f@twiddle.net> Date: Tue, 7 Jun 2016 07:28:43 -0700 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v4 1/9] target-avr: AVR cores support is added. 1. basic CPU structure 2. registers 3. no instructions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Michael Rolnik Cc: QEMU Developers , Michael Rolnik On 06/06/2016 11:32 PM, Michael Rolnik wrote: > Hi Richard, > > /Consider making the vm save state reflect the actual hardware format. That > way you can change the qemu internal format while retaining migration > compatibility./ > > How it can be done? how can I modify a value passed to VMSTATE_UINT32? There are two different ways. You can see both of them in use in target-i386. The first is to manually describe the field, using custom get and put fields. For example: static const VMStateInfo vmstate_fpreg = { .name = "fpreg", .get = get_fpreg, .put = put_fpreg, }; The second is to reserve extra space for the external representation and then use the pre_save / post_load hooks. For i386, see the cpu_pre_save, where we take the fpus, fpstt, and fptags fields and store them into the fpus_vmstate field. It is then the vmstate field that is mentioned in vmstate_x86_cpu. I personally prefer the get/put fields, but I admit they can be tricky to use. r~