From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55473) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aGn7y-0007xt-VS for qemu-devel@nongnu.org; Wed, 06 Jan 2016 07:23:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aGn7t-0004NV-Vy for qemu-devel@nongnu.org; Wed, 06 Jan 2016 07:23:46 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60183) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aGn7t-0004ND-Qs for qemu-devel@nongnu.org; Wed, 06 Jan 2016 07:23:41 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 0FAE9C1090B4 for ; Wed, 6 Jan 2016 12:23:41 +0000 (UTC) From: "Dr. David Alan Gilbert (git)" Date: Wed, 6 Jan 2016 12:23:38 +0000 Message-Id: <1452083019-15141-1-git-send-email-dgilbert@redhat.com> Subject: [Qemu-devel] [PATCH 1/2] Add VMSTATE_STRUCT_VARRAY_KNOWN List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: amit.shah@redhat.com, mst@redhat.com, quintela@redhat.com From: "Dr. David Alan Gilbert" At the moment we have VMSTATE_STRUCT_ARRAY that requires the field is declared as an array of fixed size. We also have VMSTATE_STRUCT_VARRAY_UINT* that allows a field declared as a pointer, but requires that the length is a field member in the structure being loaded/saved. VMSTATE_STRUCT_VARRAY_KNOWN is for arrays defined as pointers yet we somehow know the length of. Signed-off-by: Dr. David Alan Gilbert --- include/migration/vmstate.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 7267e38..97d44d3 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -374,6 +374,19 @@ extern const VMStateInfo vmstate_info_bitmap; .offset = vmstate_offset_array(_state, _field, _type, _num),\ } +/* a variable length array (i.e. _type *_field) but we know the + * length + */ +#define VMSTATE_STRUCT_VARRAY_KNOWN(_field, _state, _num, _version, _vmsd, _type) { \ + .name = (stringify(_field)), \ + .num = (_num), \ + .version_id = (_version), \ + .vmsd = &(_vmsd), \ + .size = sizeof(_type), \ + .flags = VMS_STRUCT|VMS_ARRAY, \ + .offset = offsetof(_state, _field), \ +} + #define VMSTATE_STRUCT_VARRAY_UINT8(_field, _state, _field_num, _version, _vmsd, _type) { \ .name = (stringify(_field)), \ .num_offset = vmstate_offset_value(_state, _field_num, uint8_t), \ -- 2.5.0