From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52376) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aY5IK-0003Lj-Ov for qemu-devel@nongnu.org; Tue, 23 Feb 2016 00:13:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aY5IJ-0007oW-Po for qemu-devel@nongnu.org; Tue, 23 Feb 2016 00:13:56 -0500 References: <1456132310-4826-1-git-send-email-zxq_yx_007@163.com> <56CAE2DB.3080702@163.com> From: hitmoon Message-ID: <56CBEA1C.4060900@163.com> Date: Tue, 23 Feb 2016 13:11:56 +0800 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH v4 5/9] hw/timer: QOM'ify m48txx_sysbus (pass 2) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Igor Mitsyanko , Mark Cave-Ayland , QEMU Developers , Michael Walle , qemu-arm , "Edgar E. Iglesias" , Guan Xuetao , =?UTF-8?Q?Andreas_F=c3=a4rber?= 在 2016年02月22日 19:03, Peter Maydell 写道: > On 22 February 2016 at 10:28, hitmoon wrote: >> 在 2016年02月22日 17:24, Peter Maydell 写道: >>> Just noticed this won't work as it is -- the vmstate >>> struct is for the M48t59State*, but the ISA and >>> Sysbus wrappers have their own structs which are >>> what the dc->vmsd will be wanting to operate on. >>> You'd need extra VMState structs I think and >>> somebody who knows migration better than me to say >>> whether that is a migration compat break. >> It seems that the old code also use the same vmstate structure. Maybe it's a >> common structure which will not be used at the same time. > The old code passes vmstate_register() a pointer to the > M48t59State, and so the offsets in the vmstate line up correctly > with the fields it wants to access. If you use dc->vmsd then the > pointer that is (implicitly) used is the pointer to the device > structure itself, which is not the same address as the > M48t59State embedded inside that struct. > > You'd basically need to have extra VMState structures for the > devices themselves which just said "inside this M48txxISAState > is an M48t59State", and "inside this M48txxSysBusState is a > M48t59State" and referred to the existing vmstate for the > M48t59State. > > thanks > -- PMM I add a new structure for m48t59_isa as follows: static const VMStateDescription vmstate_m48t59_isa = { .name = "m48t59-isa", .version_id = 1, .minimum_version_id = 1, .fields = (VMStateField[]) { VMSTATE_UINT8(state.lock, M48txxISAState), VMSTATE_UINT16(state.addr, M48txxISAState), VMSTATE_VBUFFER_UINT32(state.buffer, M48txxISAState, 0, NULL, 0, state.size), VMSTATE_END_OF_LIST() } }; is this correct?