diff mbox

[qemu] migration/vmstate: document VMStateFlags

Message ID 87y4a8a598.fsf@oc4731375738.ibm.com
State New
Headers show

Commit Message

Sascha Silbe Feb. 25, 2016, 8:45 p.m. UTC
Dear Amit,

> Amit Shah <amit.shah@redhat.com> 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 <amit.shah@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Sascha Silbe <silbe@linux.vnet.ibm.com>
---
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(-)

Comments

Amit Shah Feb. 26, 2016, 5:27 a.m. UTC | #1
On (Thu) 25 Feb 2016 [21:45:23], Sascha Silbe wrote:
> Dear Amit,
> 
> > Amit Shah <amit.shah@redhat.com> 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.

Thanks, can you please post this as a standalone email?  Easier for me
to apply.

Thanks,

		Amit
Sascha Silbe Feb. 26, 2016, 8:19 a.m. UTC | #2
Dear Amit,

Amit Shah <amit.shah@redhat.com> writes:

>> FWIW, here's the version based on current master. As mentioned before;
>> I'm happy to rebase on your version if you prefer.
>
> Thanks, can you please post this as a standalone email?  Easier for me
> to apply.

Sure.

Sascha
diff mbox

Patch

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 {
 };
 
 enum VMStateFlags {
+    /* Ignored */
     VMS_SINGLE           = 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          = 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            = 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           = 0x008,
-    VMS_VARRAY_INT32     = 0x010,  /* Array with size in int32_t field*/
-    VMS_BUFFER           = 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     = 0x010,
+
+    /* Ignored */
+    VMS_BUFFER           = 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 = 0x040,
-    VMS_VARRAY_UINT16    = 0x080,  /* Array with size in uint16_t field */
-    VMS_VBUFFER          = 0x100,  /* Buffer with size in int32_t field */
-    VMS_MULTIPLY         = 0x200,  /* multiply "size" field by field_size */
-    VMS_VARRAY_UINT8     = 0x400,  /* Array with size in uint8_t field*/
-    VMS_VARRAY_UINT32    = 0x800,  /* Array with size in uint32_t field*/
-    VMS_MUST_EXIST       = 0x1000, /* Field must exist in input */
-    VMS_ALLOC            = 0x2000, /* Alloc a buffer on the destination */
-    VMS_MULTIPLY_ELEMENTS = 0x4000, /* multiply varray size by field->num */
+
+    /* 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    = 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          = 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         = 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     = 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    = 0x800,
+
+    /* Fail loading the serialised VM state if this field is missing
+     * from the input. */
+    VMS_MUST_EXIST       = 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            = 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 = 0x4000,
 };
 
 typedef struct {