* [Qemu-devel] [PATCH 1/6] savevm: Add VMSTATE_UINT64_EQUAL helpers
2013-03-12 3:05 [Qemu-devel] [0/6] Simple extensions to VMStateDescription features David Gibson
@ 2013-03-12 3:06 ` David Gibson
2013-03-12 3:06 ` [Qemu-devel] [PATCH 2/6] savevm: Add VMSTATE_UINTTL_EQUAL helper David Gibson
` (5 subsequent siblings)
6 siblings, 0 replies; 12+ messages in thread
From: David Gibson @ 2013-03-12 3:06 UTC (permalink / raw)
To: aliguori, quintela; +Cc: David Gibson, qemu-devel, agraf
The savevm code already includes a number of *_EQUAL helpers which act as
sanity checks verifying that the configuration of the saved state matches
that of the machine we're loading into to work. Variants already exist
for 8 bit 16 bit and 32 bit integers, but not 64 bit integers. This patch
fills that hole, adding a UINT64 version.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
v2: Added missing braces
---
include/migration/vmstate.h | 7 +++++++
savevm.c | 21 +++++++++++++++++++++
2 files changed, 28 insertions(+)
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index a64db94..cdb6af7 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -145,6 +145,7 @@ extern const VMStateInfo vmstate_info_uint8_equal;
extern const VMStateInfo vmstate_info_uint16_equal;
extern const VMStateInfo vmstate_info_int32_equal;
extern const VMStateInfo vmstate_info_uint32_equal;
+extern const VMStateInfo vmstate_info_uint64_equal;
extern const VMStateInfo vmstate_info_int32_le;
extern const VMStateInfo vmstate_info_uint8;
@@ -517,6 +518,12 @@ extern const VMStateInfo vmstate_info_bitmap;
#define VMSTATE_UINT32_EQUAL(_f, _s) \
VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint32_equal, uint32_t)
+#define VMSTATE_UINT64_EQUAL_V(_f, _s, _v) \
+ VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint64_equal, uint64_t)
+
+#define VMSTATE_UINT64_EQUAL(_f, _s) \
+ VMSTATE_UINT64_EQUAL_V(_f, _s, 0)
+
#define VMSTATE_INT32_LE(_f, _s) \
VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_le, int32_t)
diff --git a/savevm.c b/savevm.c
index 147e2d2..5dc678e 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1072,6 +1072,27 @@ const VMStateInfo vmstate_info_uint64 = {
.put = put_uint64,
};
+/* 64 bit unsigned int. See that the received value is the same than the one
+ in the field */
+
+static int get_uint64_equal(QEMUFile *f, void *pv, size_t size)
+{
+ uint64_t *v = pv;
+ uint64_t v2;
+ qemu_get_be64s(f, &v2);
+
+ if (*v == v2) {
+ return 0;
+ }
+ return -EINVAL;
+}
+
+const VMStateInfo vmstate_info_uint64_equal = {
+ .name = "int64 equal",
+ .get = get_uint64_equal,
+ .put = put_uint64,
+};
+
/* 8 bit int. See that the received value is the same than the one
in the field */
--
1.7.10.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Qemu-devel] [PATCH 2/6] savevm: Add VMSTATE_UINTTL_EQUAL helper
2013-03-12 3:05 [Qemu-devel] [0/6] Simple extensions to VMStateDescription features David Gibson
2013-03-12 3:06 ` [Qemu-devel] [PATCH 1/6] savevm: Add VMSTATE_UINT64_EQUAL helpers David Gibson
@ 2013-03-12 3:06 ` David Gibson
2013-03-12 3:06 ` [Qemu-devel] [PATCH 3/6] savevm: Add VMSTATE_FLOAT64 helpers David Gibson
` (4 subsequent siblings)
6 siblings, 0 replies; 12+ messages in thread
From: David Gibson @ 2013-03-12 3:06 UTC (permalink / raw)
To: aliguori, quintela; +Cc: David Gibson, qemu-devel, agraf
This adds an _EQUAL VMSTATE helper for target_ulongs, defined in terms of
VMSTATE_UINT32_EQUAL or VMSTATE_UINT64_EQUAL as appropriate.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
hw/hw.h | 6 ++++++
include/migration/vmstate.h | 7 +++++--
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/hw/hw.h b/hw/hw.h
index 1553e54..1fb9afa 100644
--- a/hw/hw.h
+++ b/hw/hw.h
@@ -52,16 +52,22 @@ int qemu_boot_set(const char *boot_devices);
#if TARGET_LONG_BITS == 64
#define VMSTATE_UINTTL_V(_f, _s, _v) \
VMSTATE_UINT64_V(_f, _s, _v)
+#define VMSTATE_UINTTL_EQUAL_V(_f, _s, _v) \
+ VMSTATE_UINT64_EQUAL_V(_f, _s, _v)
#define VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, _v) \
VMSTATE_UINT64_ARRAY_V(_f, _s, _n, _v)
#else
#define VMSTATE_UINTTL_V(_f, _s, _v) \
VMSTATE_UINT32_V(_f, _s, _v)
+#define VMSTATE_UINTTL_EQUAL_V(_f, _s, _v) \
+ VMSTATE_UINT32_EQUAL_V(_f, _s, _v)
#define VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, _v) \
VMSTATE_UINT32_ARRAY_V(_f, _s, _n, _v)
#endif
#define VMSTATE_UINTTL(_f, _s) \
VMSTATE_UINTTL_V(_f, _s, 0)
+#define VMSTATE_UINTTL_EQUAL(_f, _s) \
+ VMSTATE_UINTTL_EQUAL_V(_f, _s, 0)
#define VMSTATE_UINTTL_ARRAY(_f, _s, _n) \
VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, 0)
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index cdb6af7..f65e65f 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -515,8 +515,11 @@ extern const VMStateInfo vmstate_info_bitmap;
#define VMSTATE_INT32_EQUAL(_f, _s) \
VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_equal, int32_t)
-#define VMSTATE_UINT32_EQUAL(_f, _s) \
- VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint32_equal, uint32_t)
+#define VMSTATE_UINT32_EQUAL_V(_f, _s, _v) \
+ VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint32_equal, uint32_t)
+
+#define VMSTATE_UINT32_EQUAL(_f, _s) \
+ VMSTATE_UINT32_EQUAL_V(_f, _s, 0)
#define VMSTATE_UINT64_EQUAL_V(_f, _s, _v) \
VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint64_equal, uint64_t)
--
1.7.10.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Qemu-devel] [PATCH 3/6] savevm: Add VMSTATE_FLOAT64 helpers
2013-03-12 3:05 [Qemu-devel] [0/6] Simple extensions to VMStateDescription features David Gibson
2013-03-12 3:06 ` [Qemu-devel] [PATCH 1/6] savevm: Add VMSTATE_UINT64_EQUAL helpers David Gibson
2013-03-12 3:06 ` [Qemu-devel] [PATCH 2/6] savevm: Add VMSTATE_UINTTL_EQUAL helper David Gibson
@ 2013-03-12 3:06 ` David Gibson
2013-03-12 3:06 ` [Qemu-devel] [PATCH 4/6] savevm: Add VMSTATE_STRUCT_VARRAY_POINTER_UINT32 David Gibson
` (3 subsequent siblings)
6 siblings, 0 replies; 12+ messages in thread
From: David Gibson @ 2013-03-12 3:06 UTC (permalink / raw)
To: aliguori, quintela; +Cc: David Gibson, qemu-devel, agraf
The current savevm code includes VMSTATE helpers for a number of commonly
used data types, but not for the float64 type used by the internal floating
point emulation code. This patch fixes the deficiency.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
include/migration/vmstate.h | 15 +++++++++++++++
savevm.c | 23 +++++++++++++++++++++++
2 files changed, 38 insertions(+)
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index f65e65f..f0a6374 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -153,6 +153,8 @@ extern const VMStateInfo vmstate_info_uint16;
extern const VMStateInfo vmstate_info_uint32;
extern const VMStateInfo vmstate_info_uint64;
+extern const VMStateInfo vmstate_info_float64;
+
extern const VMStateInfo vmstate_info_timer;
extern const VMStateInfo vmstate_info_buffer;
extern const VMStateInfo vmstate_info_unused_buffer;
@@ -539,6 +541,13 @@ extern const VMStateInfo vmstate_info_bitmap;
#define VMSTATE_UINT32_TEST(_f, _s, _t) \
VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint32, uint32_t)
+
+#define VMSTATE_FLOAT64_V(_f, _s, _v) \
+ VMSTATE_SINGLE(_f, _s, _v, vmstate_info_float64, float64)
+
+#define VMSTATE_FLOAT64(_f, _s) \
+ VMSTATE_FLOAT64_V(_f, _s, 0)
+
#define VMSTATE_TIMER_TEST(_f, _s, _test) \
VMSTATE_POINTER_TEST(_f, _s, _test, vmstate_info_timer, QEMUTimer *)
@@ -605,6 +614,12 @@ extern const VMStateInfo vmstate_info_bitmap;
#define VMSTATE_INT64_ARRAY(_f, _s, _n) \
VMSTATE_INT64_ARRAY_V(_f, _s, _n, 0)
+#define VMSTATE_FLOAT64_ARRAY_V(_f, _s, _n, _v) \
+ VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_float64, float64)
+
+#define VMSTATE_FLOAT64_ARRAY(_f, _s, _n) \
+ VMSTATE_FLOAT64_ARRAY_V(_f, _s, _n, 0)
+
#define VMSTATE_BUFFER_V(_f, _s, _v) \
VMSTATE_STATIC_BUFFER(_f, _s, _v, NULL, 0, sizeof(typeof_field(_s, _f)))
diff --git a/savevm.c b/savevm.c
index 5dc678e..55b0305 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1133,6 +1133,29 @@ const VMStateInfo vmstate_info_uint16_equal = {
.put = put_uint16,
};
+/* floating point */
+
+static int get_float64(QEMUFile *f, void *pv, size_t size)
+{
+ float64 *v = pv;
+
+ *v = make_float64(qemu_get_be64(f));
+ return 0;
+}
+
+static void put_float64(QEMUFile *f, void *pv, size_t size)
+{
+ uint64_t *v = pv;
+
+ qemu_put_be64(f, float64_val(*v));
+}
+
+const VMStateInfo vmstate_info_float64 = {
+ .name = "float64",
+ .get = get_float64,
+ .put = put_float64,
+};
+
/* timers */
static int get_timer(QEMUFile *f, void *pv, size_t size)
--
1.7.10.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Qemu-devel] [PATCH 4/6] savevm: Add VMSTATE_STRUCT_VARRAY_POINTER_UINT32
2013-03-12 3:05 [Qemu-devel] [0/6] Simple extensions to VMStateDescription features David Gibson
` (2 preceding siblings ...)
2013-03-12 3:06 ` [Qemu-devel] [PATCH 3/6] savevm: Add VMSTATE_FLOAT64 helpers David Gibson
@ 2013-03-12 3:06 ` David Gibson
2013-03-14 12:40 ` Juan Quintela
2013-03-12 3:06 ` [Qemu-devel] [PATCH 5/6] savevm: Fix bugs in the VMSTATE_VBUFFER_MULTIPLY definition David Gibson
` (2 subsequent siblings)
6 siblings, 1 reply; 12+ messages in thread
From: David Gibson @ 2013-03-12 3:06 UTC (permalink / raw)
To: aliguori, quintela; +Cc: David Gibson, qemu-devel, agraf
Currently the savevm code contains a VMSTATE_STRUCT_VARRAY_POINTER_INT32
helper (a variably sized array with the number of elements in an int32_t),
but not VMSTATE_STRUCT_VARRAY_POINTER_UINT32 (... with the number of
elements in a uint32_t). This patch (trivially) fixes the deficiency.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
include/migration/vmstate.h | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index f0a6374..fe39cd9 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -339,6 +339,16 @@ extern const VMStateInfo vmstate_info_bitmap;
.offset = vmstate_offset_pointer(_state, _field, _type), \
}
+#define VMSTATE_STRUCT_VARRAY_POINTER_UINT32(_field, _state, _field_num, _vmsd, _type) { \
+ .name = (stringify(_field)), \
+ .version_id = 0, \
+ .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\
+ .size = sizeof(_type), \
+ .vmsd = &(_vmsd), \
+ .flags = VMS_POINTER | VMS_VARRAY_INT32 | VMS_STRUCT, \
+ .offset = vmstate_offset_pointer(_state, _field, _type), \
+}
+
#define VMSTATE_STRUCT_VARRAY_POINTER_UINT16(_field, _state, _field_num, _vmsd, _type) { \
.name = (stringify(_field)), \
.version_id = 0, \
--
1.7.10.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [Qemu-devel] [PATCH 4/6] savevm: Add VMSTATE_STRUCT_VARRAY_POINTER_UINT32
2013-03-12 3:06 ` [Qemu-devel] [PATCH 4/6] savevm: Add VMSTATE_STRUCT_VARRAY_POINTER_UINT32 David Gibson
@ 2013-03-14 12:40 ` Juan Quintela
2013-03-15 5:36 ` David Gibson
0 siblings, 1 reply; 12+ messages in thread
From: Juan Quintela @ 2013-03-14 12:40 UTC (permalink / raw)
To: David Gibson; +Cc: aliguori, qemu-devel, agraf
David Gibson <david@gibson.dropbear.id.au> wrote:
> Currently the savevm code contains a VMSTATE_STRUCT_VARRAY_POINTER_INT32
> helper (a variably sized array with the number of elements in an int32_t),
> but not VMSTATE_STRUCT_VARRAY_POINTER_UINT32 (... with the number of
> elements in a uint32_t). This patch (trivially) fixes the deficiency.
>
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> include/migration/vmstate.h | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
> index f0a6374..fe39cd9 100644
> --- a/include/migration/vmstate.h
> +++ b/include/migration/vmstate.h
> @@ -339,6 +339,16 @@ extern const VMStateInfo vmstate_info_bitmap;
> .offset = vmstate_offset_pointer(_state, _field, _type), \
> }
>
> +#define VMSTATE_STRUCT_VARRAY_POINTER_UINT32(_field, _state, _field_num, _vmsd, _type) { \
> + .name = (stringify(_field)), \
> + .version_id = 0, \
> + .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\
> + .size = sizeof(_type), \
> + .vmsd = &(_vmsd), \
> + .flags = VMS_POINTER | VMS_VARRAY_INT32 | VMS_STRUCT, \
We are overridding VMS_VARRAYS_INT32 here, but if we have so many
elements in the array, we have other problems to fix O:-)
> + .offset = vmstate_offset_pointer(_state, _field, _type), \
> +}
> +
> #define VMSTATE_STRUCT_VARRAY_POINTER_UINT16(_field, _state, _field_num, _vmsd, _type) { \
> .name = (stringify(_field)), \
> .version_id = 0, \
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Qemu-devel] [PATCH 4/6] savevm: Add VMSTATE_STRUCT_VARRAY_POINTER_UINT32
2013-03-14 12:40 ` Juan Quintela
@ 2013-03-15 5:36 ` David Gibson
0 siblings, 0 replies; 12+ messages in thread
From: David Gibson @ 2013-03-15 5:36 UTC (permalink / raw)
To: Juan Quintela; +Cc: aliguori, qemu-devel, agraf
[-- Attachment #1: Type: text/plain, Size: 1989 bytes --]
On Thu, Mar 14, 2013 at 01:40:37PM +0100, Juan Quintela wrote:
> David Gibson <david@gibson.dropbear.id.au> wrote:
> > Currently the savevm code contains a VMSTATE_STRUCT_VARRAY_POINTER_INT32
> > helper (a variably sized array with the number of elements in an int32_t),
> > but not VMSTATE_STRUCT_VARRAY_POINTER_UINT32 (... with the number of
> > elements in a uint32_t). This patch (trivially) fixes the deficiency.
> >
> > Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> > ---
> > include/migration/vmstate.h | 10 ++++++++++
> > 1 file changed, 10 insertions(+)
> >
> > diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
> > index f0a6374..fe39cd9 100644
> > --- a/include/migration/vmstate.h
> > +++ b/include/migration/vmstate.h
> > @@ -339,6 +339,16 @@ extern const VMStateInfo vmstate_info_bitmap;
> > .offset = vmstate_offset_pointer(_state, _field, _type), \
> > }
> >
> > +#define VMSTATE_STRUCT_VARRAY_POINTER_UINT32(_field, _state, _field_num, _vmsd, _type) { \
> > + .name = (stringify(_field)), \
> > + .version_id = 0, \
> > + .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\
> > + .size = sizeof(_type), \
> > + .vmsd = &(_vmsd), \
> > + .flags = VMS_POINTER | VMS_VARRAY_INT32 | VMS_STRUCT, \
>
> We are overridding VMS_VARRAYS_INT32 here, but if we have so many
> elements in the array, we have other problems to fix O:-)
More to the point, negative numbers of elements make no sense, so in
practice the only sensible interpretation of the field is unsigned
anyway.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Qemu-devel] [PATCH 5/6] savevm: Fix bugs in the VMSTATE_VBUFFER_MULTIPLY definition
2013-03-12 3:05 [Qemu-devel] [0/6] Simple extensions to VMStateDescription features David Gibson
` (3 preceding siblings ...)
2013-03-12 3:06 ` [Qemu-devel] [PATCH 4/6] savevm: Add VMSTATE_STRUCT_VARRAY_POINTER_UINT32 David Gibson
@ 2013-03-12 3:06 ` David Gibson
2013-03-12 3:06 ` [Qemu-devel] [PATCH 6/6] savevm: Implement VMS_DIVIDE flag David Gibson
2013-03-14 12:42 ` [Qemu-devel] [0/6] Simple extensions to VMStateDescription features Juan Quintela
6 siblings, 0 replies; 12+ messages in thread
From: David Gibson @ 2013-03-12 3:06 UTC (permalink / raw)
To: aliguori, quintela; +Cc: David Gibson, qemu-devel, agraf
The VMSTATE_BUFFER_MULTIPLY macro is misnamed - it actually specifies
a variably sized buffer with VMS_VBUFFER, so should be named
VMSTATE_VBUFFER_MULTIPLY. This patch fixes this (the macro had no current
users under either name).
In addition, unlike the other VMSTATE_VBUFFER variants, this macro did not
specify VMS_POINTER. This patch fixes this bug as well.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
include/migration/vmstate.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index fe39cd9..249e76f 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -389,14 +389,14 @@ extern const VMStateInfo vmstate_info_bitmap;
.offset = vmstate_offset_buffer(_state, _field) + _start, \
}
-#define VMSTATE_BUFFER_MULTIPLY(_field, _state, _version, _test, _start, _field_size, _multiply) { \
+#define VMSTATE_VBUFFER_MULTIPLY(_field, _state, _version, _test, _start, _field_size, _multiply) { \
.name = (stringify(_field)), \
.version_id = (_version), \
.field_exists = (_test), \
.size_offset = vmstate_offset_value(_state, _field_size, uint32_t),\
.size = (_multiply), \
.info = &vmstate_info_buffer, \
- .flags = VMS_VBUFFER|VMS_MULTIPLY, \
+ .flags = VMS_VBUFFER|VMS_POINTER|VMS_MULTIPLY, \
.offset = offsetof(_state, _field), \
.start = (_start), \
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Qemu-devel] [PATCH 6/6] savevm: Implement VMS_DIVIDE flag
2013-03-12 3:05 [Qemu-devel] [0/6] Simple extensions to VMStateDescription features David Gibson
` (4 preceding siblings ...)
2013-03-12 3:06 ` [Qemu-devel] [PATCH 5/6] savevm: Fix bugs in the VMSTATE_VBUFFER_MULTIPLY definition David Gibson
@ 2013-03-12 3:06 ` David Gibson
2013-03-14 12:42 ` [Qemu-devel] [0/6] Simple extensions to VMStateDescription features Juan Quintela
6 siblings, 0 replies; 12+ messages in thread
From: David Gibson @ 2013-03-12 3:06 UTC (permalink / raw)
To: aliguori, quintela; +Cc: David Gibson, qemu-devel, agraf
The vmstate infrastructure includes a VMS_MULTIPY flag, and associated
VMSTATE_VBUFFER_MULTIPLY helper macro. These can be used to save a
variably sized buffer where the size in bytes of the buffer isn't directly
accessible as a structure field, but an element count from which the size
can be derived is.
This patch adds an analogous VMS_DIVIDE option, which handles a variably
sized buffer whose size is a submultiple of a field, rather than a
multiple. For example a buffer containing per-page structures whose size
is derived from a field storing the total address space described by the
structures could use this construct.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
include/migration/vmstate.h | 13 +++++++++++++
savevm.c | 8 ++++++++
2 files changed, 21 insertions(+)
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 249e76f..9de79d6 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -98,6 +98,7 @@ enum VMStateFlags {
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_DIVIDE = 0x1000, /* divide "size" field by field_size */
};
typedef struct {
@@ -401,6 +402,18 @@ extern const VMStateInfo vmstate_info_bitmap;
.start = (_start), \
}
+#define VMSTATE_VBUFFER_DIVIDE(_field, _state, _version, _test, _start, _field_size, _divide) { \
+ .name = (stringify(_field)), \
+ .version_id = (_version), \
+ .field_exists = (_test), \
+ .size_offset = vmstate_offset_value(_state, _field_size, uint32_t),\
+ .size = (_divide), \
+ .info = &vmstate_info_buffer, \
+ .flags = VMS_VBUFFER|VMS_POINTER|VMS_DIVIDE, \
+ .offset = offsetof(_state, _field), \
+ .start = (_start), \
+}
+
#define VMSTATE_VBUFFER(_field, _state, _version, _test, _start, _field_size) { \
.name = (stringify(_field)), \
.version_id = (_version), \
diff --git a/savevm.c b/savevm.c
index 55b0305..8eb44c4 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1529,6 +1529,10 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
if (field->flags & VMS_MULTIPLY) {
size *= field->size;
}
+ if (field->flags & VMS_DIVIDE) {
+ assert((size % field->size) == 0);
+ size /= field->size;
+ }
}
if (field->flags & VMS_ARRAY) {
n_elems = field->num;
@@ -1593,6 +1597,10 @@ void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd,
if (field->flags & VMS_MULTIPLY) {
size *= field->size;
}
+ if (field->flags & VMS_DIVIDE) {
+ assert((size % field->size) == 0);
+ size /= field->size;
+ }
}
if (field->flags & VMS_ARRAY) {
n_elems = field->num;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [Qemu-devel] [0/6] Simple extensions to VMStateDescription features
2013-03-12 3:05 [Qemu-devel] [0/6] Simple extensions to VMStateDescription features David Gibson
` (5 preceding siblings ...)
2013-03-12 3:06 ` [Qemu-devel] [PATCH 6/6] savevm: Implement VMS_DIVIDE flag David Gibson
@ 2013-03-14 12:42 ` Juan Quintela
2013-03-15 5:37 ` David Gibson
2013-04-08 4:55 ` David Gibson
6 siblings, 2 replies; 12+ messages in thread
From: Juan Quintela @ 2013-03-14 12:42 UTC (permalink / raw)
To: David Gibson; +Cc: aliguori, qemu-devel, agraf
David Gibson <david@gibson.dropbear.id.au> wrote:
> Jean, Anthony,
>
> This series contains a bunch of straightforward extensions to the
> suite of functions and macros for using in VMStateDescription
> structures. Mostly these fill fairly obvious gaps in the existing
> set, though the last adds genuinely new feature (but is still pretty
> simple).
>
> Obviously, these aren't being used in the savevm code already in the
> tree, but I need them for my work-in-progress patches fixing / adding
> savevm support for ppc guests.
>
> Please apply.
Reviewed-by: Juan Quintela <quintela@redhat.com>
Will include them in the next migration pull.
Thanks,
PD. I guess that I am who you are referring by "Jean" O:-)
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Qemu-devel] [0/6] Simple extensions to VMStateDescription features
2013-03-14 12:42 ` [Qemu-devel] [0/6] Simple extensions to VMStateDescription features Juan Quintela
@ 2013-03-15 5:37 ` David Gibson
2013-04-08 4:55 ` David Gibson
1 sibling, 0 replies; 12+ messages in thread
From: David Gibson @ 2013-03-15 5:37 UTC (permalink / raw)
To: Juan Quintela; +Cc: aliguori, qemu-devel, agraf
[-- Attachment #1: Type: text/plain, Size: 1100 bytes --]
On Thu, Mar 14, 2013 at 01:42:24PM +0100, Juan Quintela wrote:
> David Gibson <david@gibson.dropbear.id.au> wrote:
> > Jean, Anthony,
> >
> > This series contains a bunch of straightforward extensions to the
> > suite of functions and macros for using in VMStateDescription
> > structures. Mostly these fill fairly obvious gaps in the existing
> > set, though the last adds genuinely new feature (but is still pretty
> > simple).
> >
> > Obviously, these aren't being used in the savevm code already in the
> > tree, but I need them for my work-in-progress patches fixing / adding
> > savevm support for ppc guests.
> >
> > Please apply.
>
> Reviewed-by: Juan Quintela <quintela@redhat.com>
>
> Will include them in the next migration pull.
Thanks.
> PD. I guess that I am who you are referring by "Jean" O:-)
*facepalm* Uh, yes. Sorry. Typo, or thinko, or something.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Qemu-devel] [0/6] Simple extensions to VMStateDescription features
2013-03-14 12:42 ` [Qemu-devel] [0/6] Simple extensions to VMStateDescription features Juan Quintela
2013-03-15 5:37 ` David Gibson
@ 2013-04-08 4:55 ` David Gibson
1 sibling, 0 replies; 12+ messages in thread
From: David Gibson @ 2013-04-08 4:55 UTC (permalink / raw)
To: Juan Quintela; +Cc: aliguori, qemu-devel, agraf
[-- Attachment #1: Type: text/plain, Size: 1077 bytes --]
On Thu, Mar 14, 2013 at 01:42:24PM +0100, Juan Quintela wrote:
> David Gibson <david@gibson.dropbear.id.au> wrote:
> > Jean, Anthony,
> >
> > This series contains a bunch of straightforward extensions to the
> > suite of functions and macros for using in VMStateDescription
> > structures. Mostly these fill fairly obvious gaps in the existing
> > set, though the last adds genuinely new feature (but is still pretty
> > simple).
> >
> > Obviously, these aren't being used in the savevm code already in the
> > tree, but I need them for my work-in-progress patches fixing / adding
> > savevm support for ppc guests.
> >
> > Please apply.
>
> Reviewed-by: Juan Quintela <quintela@redhat.com>
>
> Will include them in the next migration pull.
I see these have gone in now, thanks.
Except for the VMS_DIVIDE patch. Is there a particular reason for
that?
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread