From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54911) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aZ2mz-0004dD-Hk for qemu-devel@nongnu.org; Thu, 25 Feb 2016 15:45:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aZ2mv-0003nR-UC for qemu-devel@nongnu.org; Thu, 25 Feb 2016 15:45:33 -0500 Received: from e06smtp14.uk.ibm.com ([195.75.94.110]:58339) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aZ2mv-0003mu-HX for qemu-devel@nongnu.org; Thu, 25 Feb 2016 15:45:29 -0500 Received: from localhost by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 25 Feb 2016 20:45:26 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 1A40417D8056 for ; Thu, 25 Feb 2016 20:45:47 +0000 (GMT) Received: from d06av04.portsmouth.uk.ibm.com (d06av04.portsmouth.uk.ibm.com [9.149.37.216]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u1PKjOUR65143006 for ; Thu, 25 Feb 2016 20:45:24 GMT Received: from d06av04.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av04.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u1PKjOmc024828 for ; Thu, 25 Feb 2016 13:45:24 -0700 From: Sascha Silbe In-Reply-To: <871t80bkqw.fsf@oc4731375738.ibm.com> References: <20160115092419.GA2432@work-vm> <1453408767-4905-1-git-send-email-silbe@linux.vnet.ibm.com> <20160225050552.GL10967@grmbl.mre> <871t80bkqw.fsf@oc4731375738.ibm.com> Date: Thu, 25 Feb 2016 21:45:23 +0100 Message-ID: <87y4a8a598.fsf@oc4731375738.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH qemu] migration/vmstate: document VMStateFlags List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Amit Shah Cc: "Michael S. Tsirkin" , qemu-devel@nongnu.org, "Dr. David Alan Gilbert" , Juan Quintela Dear Amit, > Amit Shah writes: > >> On (Thu) 21 Jan 2016 [21:39:27], Sascha Silbe wrote: >>> The VMState API is rather sparsely documented. Start by describing the >>> meaning of all VMStateFlags. > >> Thanks, I've pulled this in my queue. >> >> There's one new flag added: VMS_MULTIPLY_ELEMENTS. Do you want to >> send a follow-up patch to add a description to that one as well? > > I can either send a new version with the conflicts resolved and > VMS_MULTIPLY_ELEMENTS documented (i.e. rebased on current master), or a > follow-up patch with just the differences to your version if you point > me at your git repo. Whatever works best for you. FWIW, here's the version based on current master. As mentioned before; I'm happy to rebase on your version if you prefer. Sascha --->8--->8--->8--->8--->8--->8--->8--->8--->8--->8--->8--->8--- Subject: [PATCH v2] migration/vmstate: document VMStateFlags The VMState API is rather sparsely documented. Start by describing the meaning of all VMStateFlags. Reviewed-by: Amit Shah Reviewed-by: Juan Quintela Signed-off-by: Sascha Silbe --- v1->v2: - rebased on current devel - documented VMS_MULTIPLY_ELEMENTS (including references to VMS_MULTIPLY_ELEMENTS in the VMS_VARRAY* description) - fixed up VMS_VARRAY* reference in VMS_VBUFFER - included Amit's and Juan's Reviewed-By (based on v1) --- include/migration/vmstate.h | 100 +++++++++++++++++++++++++++++++++++++++-= ---- 1 file changed, 90 insertions(+), 10 deletions(-) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 7246f29..84ee355 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -88,21 +88,101 @@ struct VMStateInfo { }; =20 enum VMStateFlags { + /* Ignored */ VMS_SINGLE =3D 0x001, + + /* The struct member at opaque + VMStateField.offset is a pointer + * to the actual field (e.g. struct a { uint8_t *b; + * }). Dereference the pointer before using it as basis for + * further pointer arithmetic (see e.g. VMS_ARRAY). Does not + * affect the meaning of VMStateField.num_offset or + * VMStateField.size_offset; see VMS_VARRAY* and VMS_VBUFFER for + * those. */ VMS_POINTER =3D 0x002, + + /* The field is an array of fixed size. VMStateField.num contains + * the number of entries in the array. The size of each entry is + * given by VMStateField.size and / or opaque + + * VMStateField.size_offset; see VMS_VBUFFER and + * VMS_MULTIPLY. Each array entry will be processed individually + * (VMStateField.info.get()/put() if VMS_STRUCT is not set, + * recursion into VMStateField.vmsd if VMS_STRUCT is set). May not + * be combined with VMS_VARRAY*. */ VMS_ARRAY =3D 0x004, + + /* The field is itself a struct, containing one or more + * fields. Recurse into VMStateField.vmsd. Most useful in + * combination with VMS_ARRAY / VMS_VARRAY*, recursing into each + * array entry. */ VMS_STRUCT =3D 0x008, - VMS_VARRAY_INT32 =3D 0x010, /* Array with size in int32_t field*/ - VMS_BUFFER =3D 0x020, /* static sized buffer */ + + /* The field is an array of variable size. The int32_t at opaque + + * VMStateField.num_offset contains the number of entries in the + * array. See the VMS_ARRAY description regarding array handling + * in general. May not be combined with VMS_ARRAY or any other + * VMS_VARRAY*. */ + VMS_VARRAY_INT32 =3D 0x010, + + /* Ignored */ + VMS_BUFFER =3D 0x020, + + /* The field is a (fixed-size or variable-size) array of pointers + * (e.g. struct a { uint8_t *b[]; }). Dereference each array entry + * before using it. Note: Does not imply any one of VMS_ARRAY / + * VMS_VARRAY*; these need to be set explicitly. */ VMS_ARRAY_OF_POINTER =3D 0x040, - VMS_VARRAY_UINT16 =3D 0x080, /* Array with size in uint16_t field = */ - VMS_VBUFFER =3D 0x100, /* Buffer with size in int32_t field = */ - VMS_MULTIPLY =3D 0x200, /* multiply "size" field by field_siz= e */ - VMS_VARRAY_UINT8 =3D 0x400, /* Array with size in uint8_t field*/ - VMS_VARRAY_UINT32 =3D 0x800, /* Array with size in uint32_t field*/ - VMS_MUST_EXIST =3D 0x1000, /* Field must exist in input */ - VMS_ALLOC =3D 0x2000, /* Alloc a buffer on the destination = */ - VMS_MULTIPLY_ELEMENTS =3D 0x4000, /* multiply varray size by field->nu= m */ + + /* The field is an array of variable size. The uint16_t at opaque + * + VMStateField.num_offset (subject to VMS_MULTIPLY_ELEMENTS) + * contains the number of entries in the array. See the VMS_ARRAY + * description regarding array handling in general. May not be + * combined with VMS_ARRAY or any other VMS_VARRAY*. */ + VMS_VARRAY_UINT16 =3D 0x080, + + /* The size of the individual entries (a single array entry if + * VMS_ARRAY or any of VMS_VARRAY* are set, or the field itself if + * neither is set) is variable (i.e. not known at compile-time), + * but the same for all entries. Use the int32_t at opaque + + * VMStateField.size_offset (subject to VMS_MULTIPLY) to determine + * the size of each (and every) entry. */ + VMS_VBUFFER =3D 0x100, + + /* Multiply the entry size given by the int32_t at opaque + + * VMStateField.size_offset (see VMS_VBUFFER description) with + * VMStateField.size to determine the number of bytes to be + * allocated. Only valid in combination with VMS_VBUFFER. */ + VMS_MULTIPLY =3D 0x200, + + /* The field is an array of variable size. The uint8_t at opaque + + * VMStateField.num_offset (subject to VMS_MULTIPLY_ELEMENTS) + * contains the number of entries in the array. See the VMS_ARRAY + * description regarding array handling in general. May not be + * combined with VMS_ARRAY or any other VMS_VARRAY*. */ + VMS_VARRAY_UINT8 =3D 0x400, + + /* The field is an array of variable size. The uint32_t at opaque + * + VMStateField.num_offset (subject to VMS_MULTIPLY_ELEMENTS) + * contains the number of entries in the array. See the VMS_ARRAY + * description regarding array handling in general. May not be + * combined with VMS_ARRAY or any other VMS_VARRAY*. */ + VMS_VARRAY_UINT32 =3D 0x800, + + /* Fail loading the serialised VM state if this field is missing + * from the input. */ + VMS_MUST_EXIST =3D 0x1000, + + /* When loading serialised VM state, allocate memory for the + * (entire) field. Only valid in combination with + * VMS_POINTER. Note: Not all combinations with other flags are + * currently supported, e.g. VMS_ALLOC|VMS_ARRAY_OF_POINTER won't + * cause the individual entries to be allocated. */ + VMS_ALLOC =3D 0x2000, + + /* Multiply the number of entries given by the integer at opaque + + * VMStateField.num_offset (see VMS_VARRAY*) with VMStateField.num + * to determine the number of entries in the array. Only valid in + * combination with one of VMS_VARRAY*. */ + VMS_MULTIPLY_ELEMENTS =3D 0x4000, }; =20 typedef struct { --=20 Softwareentwicklung Sascha Silbe, Niederhofenstra=C3=9Fe 5/1, 71229 Leonberg https://se-silbe.de/ USt-IdNr. DE281696641