Skip to contentSkip to conversation

VMState infrastructure

PATCH Applied Juan Quintela 3 participants 16 messages Mar 10, 2011 – Mar 22, 2011

lore
Share & tools
lore
#0 lore raw

cover VMState infrastructure

Hi

This is the infrastructure that I pushed on my previous series. Anthony don't like 58 patches series (why? O:-) And then split the series in three.

This are the infrastructure patches needed for the other two series.

Anthony, please apply.

Later, Juan.

Juan Quintela (9):
vmstate: add VMSTATE_UINT32_EQUAL
vmstate: Fix varrays with uint8 indexes
vmstate: add UINT32 VARRAYS
vmstate: add VMSTATE_STRUCT_VARRAY_INT32
vmstate: add VMSTATE_INT64_ARRAY
vmstate: add VMSTATE_STRUCT_VARRAY_UINT32
vmstate: Add a way to send a partial array
vmstate: be able to store/save a pci device from a pointer
vmstate: move timers to use test instead of version

 hw/hw.h  |   78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 savevm.c |   25 ++++++++++++++++++++
 2 files changed, 98 insertions(+), 5 deletions(-)
Signature · 1 line
1.7.4
#1 lore raw

PATCH 1/9 vmstate: add VMSTATE_UINT32_EQUAL

---
 hw/hw.h  |    4 ++++
 savevm.c |   21 +++++++++++++++++++++
 2 files changed, 25 insertions(+), 0 deletions(-)
hw/hw.h +4 -0
index 4e2d592..0299207 100644
@@ -343,6 +343,7 @@ extern const VMStateInfo vmstate_info_int64;
 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_int32_le;
 
 extern const VMStateInfo vmstate_info_uint8;
@@ -704,6 +705,9 @@ extern const VMStateDescription vmstate_usb_device;
 #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_INT32_LE(_f, _s)                                   \
     VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_le, int32_t)
 
savevm.c +21 -0
index a50fd31..ce063d1 100644
@@ -882,6 +882,27 @@ const VMStateInfo vmstate_info_uint32 = {
     .put  = put_uint32,
 };
 
+/* 32 bit uint. See that the received value is the same than the one
+   in the field */
+
+static int get_uint32_equal(QEMUFile *f, void *pv, size_t size)
+{
+    uint32_t *v = pv;
+    uint32_t v2;
+    qemu_get_be32s(f, &v2);
+
+    if (*v == v2) {
+        return 0;
+    }
+    return -EINVAL;
+}
+
+const VMStateInfo vmstate_info_uint32_equal = {
+    .name = "uint32 equal",
+    .get  = get_uint32_equal,
+    .put  = put_uint32,
+};
+
 /* 64 bit unsigned int */
 
 static int get_uint64(QEMUFile *f, void *pv, size_t size)
Signature · 1 line
1.7.4
#2 lore raw

PATCH 2/9 vmstate: Fix varrays with uint8 indexes

In reply to Juan Quintela
---
 hw/hw.h  |    5 +++--
 savevm.c |    2 ++
 2 files changed, 5 insertions(+), 2 deletions(-)
hw/hw.h +3 -2
index 0299207..40c6396 100644
@@ -298,6 +298,7 @@ enum VMStateFlags {
     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*/
 };
 
 typedef struct {
@@ -489,11 +490,11 @@ extern const VMStateInfo vmstate_info_unused_buffer;
 
 #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),  \
+    .num_offset = vmstate_offset_value(_state, _field_num, uint8_t), \
     .version_id = (_version),                                        \
     .vmsd       = &(_vmsd),                                          \
     .size       = sizeof(_type),                                     \
-    .flags      = VMS_STRUCT|VMS_VARRAY_INT32,                       \
+    .flags      = VMS_STRUCT|VMS_VARRAY_UINT8,                       \
     .offset     = offsetof(_state, _field),                          \
 }
 
savevm.c +2 -0
index ce063d1..4db036b 100644
@@ -1331,6 +1331,8 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
                 n_elems = *(int32_t *)(opaque+field->num_offset);
             } else if (field->flags & VMS_VARRAY_UINT16) {
                 n_elems = *(uint16_t *)(opaque+field->num_offset);
+            } else if (field->flags & VMS_VARRAY_UINT8) {
+                n_elems = *(uint8_t *)(opaque+field->num_offset);
             }
             if (field->flags & VMS_POINTER) {
                 base_addr = *(void **)base_addr + field->start;
Signature · 1 line
1.7.4
#3 lore raw

Re: [Qemu-devel] [PATCH 2/9] vmstate: Fix varrays with uint8 indexes

Juan, Anthony,

It seems this patch broke live migration in my environment. The guest hangs after switching to remote. The following is parameters of the guest.

-L /usr/local/seabios --enable-kvm -M pc -m 512 -smp 1 -monitor stdio -localtime -boot c -drive file=/vm/fedora13.img,if=virtio -net nic,macaddr=54:52:00:47:a5:a8,model=virtio -net tap -parallel none -usb -vnc :0

Have you seen similar issues?

Thanks,

Yoshi

2011/3/10 Juan Quintela <[email protected]>:

Quoted 50 lines

---
 hw/hw.h  |    5 +++--
 savevm.c |    2 ++

 2 files changed, 5 insertions(+), 2 deletions(-)
hw/hw.h +0 -0
index 0299207..40c6396 100644
@@ -298,6 +298,7 @@ enum VMStateFlags {

    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*/ };

 typedef struct {

hw/hw.h +2 -2
@@ -489,11 +490,11 @@ extern const VMStateInfo vmstate_info_unused_buffer;
 
  #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),  \
+    .num_offset = vmstate_offset_value(_state, _field_num, uint8_t), \
     .version_id = (_version),                                        \
     .vmsd       = &(_vmsd),                                          \
     .size       = sizeof(_type),                                     \
-    .flags      = VMS_STRUCT|VMS_VARRAY_INT32,                       \
+    .flags      = VMS_STRUCT|VMS_VARRAY_UINT8,                       \
     .offset     = offsetof(_state, _field),                          \
  }
 
savevm.c +2 -1
index ce063d1..4db036b 100644
@@ -1331,6 +1331,8 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
                 n_elems = *(int32_t *)(opaque+field->num_offset);
             } else if (field->flags & VMS_VARRAY_UINT16) {
                 n_elems = *(uint16_t *)(opaque+field->num_offset);
+            } else if (field->flags & VMS_VARRAY_UINT8) {
+                n_elems = *(uint8_t *)(opaque+field->num_offset);
             }
             if (field->flags & VMS_POINTER) {
                 base_addr = *(void **)base_addr + field->start;
--

1.7.4

#4 lore raw

[Qemu-devel] Re: [PATCH 2/9] vmstate: Fix varrays with uint8 indexes

Quoted 11 lines · Yoshiaki Tamura

Juan, Anthony,

It seems this patch broke live migration in my environment. The guest hangs after switching to remote. The following is parameters of the guest.

(quoted diff) +0 -2
-L /usr/local/seabios --enable-kvm -M pc -m 512 -smp 1 -monitor stdio
-localtime -boot c -drive file=/vm/fedora13.img,if=virtio -net

nic,macaddr=54:52:00:47:a5:a8,model=virtio -net tap -parallel none -usb -vnc :0

Quoted 1 line

Have you seen similar issues?

Fix sent to the list, waiting for Anthony to apply it.

Subject: [PATCH] Fix migration uint8 arrys handled

Anthony, please apply that one.

Later, Juan.

#5 lore raw

Re: [Qemu-devel] Re: [PATCH 2/9] vmstate: Fix varrays with uint8 indexes

Ah, now I see what the problem was.

Yoshi

2011/3/18 Juan Quintela <[email protected]>:

Quoted 23 lines
Quoted 11 lines · Yoshiaki Tamura

Juan, Anthony,

It seems this patch broke live migration in my environment.  The guest hangs after switching to remote.  The following is parameters of the guest.

(quoted diff) +0 -2
-L /usr/local/seabios --enable-kvm -M pc -m 512 -smp 1 -monitor stdio
-localtime -boot c -drive file=/vm/fedora13.img,if=virtio -net

nic,macaddr=54:52:00:47:a5:a8,model=virtio -net tap -parallel none -usb  -vnc :0

Quoted 1 line

Have you seen similar issues?

Fix sent to the list, waiting for Anthony to apply it.

Subject: [PATCH] Fix migration uint8 arrys handled

Anthony, please apply that one.

Later, Juan.

#6 lore raw

Re: [Qemu-devel] Re: [PATCH 2/9] vmstate: Fix varrays with uint8 indexes

In reply to Juan Quintela

2011/3/18 Juan Quintela <[email protected]>:

Quoted 12 lines
Quoted 11 lines · Yoshiaki Tamura

Juan, Anthony,

It seems this patch broke live migration in my environment.  The guest hangs after switching to remote.  The following is parameters of the guest.

(quoted diff) +0 -2
-L /usr/local/seabios --enable-kvm -M pc -m 512 -smp 1 -monitor stdio
-localtime -boot c -drive file=/vm/fedora13.img,if=virtio -net

nic,macaddr=54:52:00:47:a5:a8,model=virtio -net tap -parallel none -usb  -vnc :0

Quoted 7 lines
Quoted 1 line

Have you seen similar issues?

Fix sent to the list, waiting for Anthony to apply it.

Subject: [PATCH] Fix migration uint8 arrys handled

Anthony, please apply that one.

This patch (commit:b784421ce4cc860315f4ec31bbc3d67e91984074) actually fixed the problem, but it got broken again by the merge after the commit...

Yoshi

Quoted 4 lines

Later, Juan.

#7 lore raw

PATCH 3/9 vmstate: add UINT32 VARRAYS

In reply to Juan Quintela
---
 hw/hw.h  |   11 +++++++++++
 savevm.c |    2 ++
 2 files changed, 13 insertions(+), 0 deletions(-)
hw/hw.h +11 -0
index 40c6396..6e78fa9 100644
@@ -299,6 +299,7 @@ enum VMStateFlags {
     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*/
 };
 
 typedef struct {
@@ -438,6 +439,16 @@ extern const VMStateInfo vmstate_info_unused_buffer;
     .offset     = vmstate_offset_pointer(_state, _field, _type),     \
 }
 
+#define VMSTATE_VARRAY_UINT32(_field, _state, _field_num, _version, _info, _type) {\
+    .name       = (stringify(_field)),                               \
+    .version_id = (_version),                                        \
+    .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\
+    .info       = &(_info),                                          \
+    .size       = sizeof(_type),                                     \
+    .flags      = VMS_VARRAY_UINT32|VMS_POINTER,                     \
+    .offset     = vmstate_offset_pointer(_state, _field, _type),     \
+}
+
 #define VMSTATE_VARRAY_UINT16_UNSAFE(_field, _state, _field_num, _version, _info, _type) {\
     .name       = (stringify(_field)),                               \
     .version_id = (_version),                                        \
savevm.c +2 -0
index 4db036b..60d2f2a 100644
@@ -1329,6 +1329,8 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
                 n_elems = field->num;
             } else if (field->flags & VMS_VARRAY_INT32) {
                 n_elems = *(int32_t *)(opaque+field->num_offset);
+            } else if (field->flags & VMS_VARRAY_UINT32) {
+                n_elems = *(uint32_t *)(opaque+field->num_offset);
             } else if (field->flags & VMS_VARRAY_UINT16) {
                 n_elems = *(uint16_t *)(opaque+field->num_offset);
             } else if (field->flags & VMS_VARRAY_UINT8) {
Signature · 1 line
1.7.4
#8 lore raw

PATCH 4/9 vmstate: add VMSTATE_STRUCT_VARRAY_INT32

In reply to Juan Quintela
---
 hw/hw.h |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
hw/hw.h +10 -0
index 6e78fa9..0ed63c5 100644
@@ -529,6 +529,16 @@ extern const VMStateInfo vmstate_info_unused_buffer;
     .offset     = vmstate_offset_pointer(_state, _field, _type),     \
 }
 
+#define VMSTATE_STRUCT_VARRAY_INT32(_field, _state, _field_num, _version, _vmsd, _type) { \
+    .name       = (stringify(_field)),                               \
+    .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \
+    .version_id = (_version),                                        \
+    .vmsd       = &(_vmsd),                                          \
+    .size       = sizeof(_type),                                     \
+    .flags      = VMS_STRUCT|VMS_VARRAY_INT32,                       \
+    .offset     = offsetof(_state, _field),                          \
+}
+
 #define VMSTATE_STATIC_BUFFER(_field, _state, _version, _test, _start, _size) { \
     .name         = (stringify(_field)),                             \
     .version_id   = (_version),                                      \
Signature · 1 line
1.7.4
#9 lore raw

PATCH 5/9 vmstate: add VMSTATE_INT64_ARRAY

In reply to Juan Quintela
---
 hw/hw.h |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
hw/hw.h +6 -0
index 0ed63c5..d801694 100644
@@ -802,6 +802,12 @@ extern const VMStateDescription vmstate_usb_device;
 #define VMSTATE_UINT32_ARRAY(_f, _s, _n)                              \
     VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0)
 
+#define VMSTATE_INT64_ARRAY_V(_f, _s, _n, _v)                         \
+    VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int64, int64_t)
+
+#define VMSTATE_INT64_ARRAY(_f, _s, _n)                               \
+    VMSTATE_INT64_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)))
 
Signature · 1 line
1.7.4
#10 lore raw

PATCH 6/9 vmstate: add VMSTATE_STRUCT_VARRAY_UINT32

In reply to Juan Quintela
---
 hw/hw.h |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
hw/hw.h +10 -0
index d801694..c198ce8 100644
@@ -539,6 +539,16 @@ extern const VMStateInfo vmstate_info_unused_buffer;
     .offset     = offsetof(_state, _field),                          \
 }
 
+#define VMSTATE_STRUCT_VARRAY_UINT32(_field, _state, _field_num, _version, _vmsd, _type) { \
+    .name       = (stringify(_field)),                               \
+    .num_offset = vmstate_offset_value(_state, _field_num, uint32_t), \
+    .version_id = (_version),                                        \
+    .vmsd       = &(_vmsd),                                          \
+    .size       = sizeof(_type),                                     \
+    .flags      = VMS_STRUCT|VMS_VARRAY_UINT32,                      \
+    .offset     = offsetof(_state, _field),                          \
+}
+
 #define VMSTATE_STATIC_BUFFER(_field, _state, _version, _test, _start, _size) { \
     .name         = (stringify(_field)),                             \
     .version_id   = (_version),                                      \
Signature · 1 line
1.7.4
#11 lore raw

PATCH 7/9 vmstate: Add a way to send a partial array

In reply to Juan Quintela
---
 hw/hw.h |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
hw/hw.h +9 -0
index c198ce8..9df1c2c 100644
@@ -429,6 +429,15 @@ extern const VMStateInfo vmstate_info_unused_buffer;
     .offset     = vmstate_offset_sub_array(_state, _field, _type, _start), \
 }
 
+#define VMSTATE_ARRAY_INT32_UNSAFE(_field, _state, _field_num, _info, _type) {\
+    .name       = (stringify(_field)),                               \
+    .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \
+    .info       = &(_info),                                          \
+    .size       = sizeof(_type),                                     \
+    .flags      = VMS_VARRAY_INT32,                                  \
+    .offset     = offsetof(_state, _field),                          \
+}
+
 #define VMSTATE_VARRAY_INT32(_field, _state, _field_num, _version, _info, _type) {\
     .name       = (stringify(_field)),                               \
     .version_id = (_version),                                        \
Signature · 1 line
1.7.4
#12 lore raw

PATCH 8/9 vmstate: be able to store/save a pci device from a pointer

In reply to Juan Quintela
---
 hw/hw.h |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
hw/hw.h +8 -0
index 9df1c2c..4e09f18 100644
@@ -629,6 +629,14 @@ extern const VMStateDescription vmstate_pci_device;
     .offset     = vmstate_offset_value(_state, _field, PCIDevice),   \
 }
 
+#define VMSTATE_PCI_DEVICE_POINTER(_field, _state) {                 \
+    .name       = (stringify(_field)),                               \
+    .size       = sizeof(PCIDevice),                                 \
+    .vmsd       = &vmstate_pci_device,                               \
+    .flags      = VMS_STRUCT|VMS_POINTER,                            \
+    .offset     = vmstate_offset_pointer(_state, _field, PCIDevice), \
+}
+
 extern const VMStateDescription vmstate_pcie_device;
 
 #define VMSTATE_PCIE_DEVICE(_field, _state) {                        \
Signature · 1 line
1.7.4
#13 lore raw

PATCH 9/9 vmstate: move timers to use test instead of version

In reply to Juan Quintela
---
 hw/hw.h |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)
hw/hw.h +12 -3
index 4e09f18..1b09039 100644
@@ -399,6 +399,15 @@ extern const VMStateInfo vmstate_info_unused_buffer;
     .offset     = vmstate_offset_value(_state, _field, _type),       \
 }
 
+#define VMSTATE_POINTER_TEST(_field, _state, _test, _info, _type) {  \
+    .name       = (stringify(_field)),                               \
+    .info       = &(_info),                                          \
+    .field_exists = (_test),                                         \
+    .size       = sizeof(_type),                                     \
+    .flags      = VMS_SINGLE|VMS_POINTER,                            \
+    .offset     = vmstate_offset_value(_state, _field, _type),       \
+}
+
 #define VMSTATE_ARRAY(_field, _state, _num, _version, _info, _type) {\
     .name       = (stringify(_field)),                               \
     .version_id = (_version),                                        \
@@ -766,11 +775,11 @@ extern const VMStateDescription vmstate_usb_device;
 #define VMSTATE_UINT32_TEST(_f, _s, _t)                                  \
     VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint32, uint32_t)
 
-#define VMSTATE_TIMER_V(_f, _s, _v)                                   \
-    VMSTATE_POINTER(_f, _s, _v, vmstate_info_timer, QEMUTimer *)
+#define VMSTATE_TIMER_TEST(_f, _s, _test)                             \
+    VMSTATE_POINTER_TEST(_f, _s, _test, vmstate_info_timer, QEMUTimer *)
 
 #define VMSTATE_TIMER(_f, _s)                                         \
-    VMSTATE_TIMER_V(_f, _s, 0)
+    VMSTATE_TIMER_TEST(_f, _s, NULL)
 
 #define VMSTATE_TIMER_ARRAY(_f, _s, _n)                              \
     VMSTATE_ARRAY_OF_POINTER(_f, _s, _n, 0, vmstate_info_timer, QEMUTimer *)
Signature · 1 line
1.7.4
#14 lore raw
In reply to Juan Quintela
Quoted 5 lines · Juan Quintela

Hi

This is the infrastructure that I pushed on my previous series. Anthony don't like 58 patches series (why? O:-) And then split the series in three.

Yeah, my intention was that you not send all series at once though :-)

At any rate this series looks good.

Regards,

Anthony Liguori

Quoted 21 lines

This are the infrastructure patches needed for the other two series.

Anthony, please apply.

Later, Juan.

Juan Quintela (9):
vmstate: add VMSTATE_UINT32_EQUAL
vmstate: Fix varrays with uint8 indexes
vmstate: add UINT32 VARRAYS
vmstate: add VMSTATE_STRUCT_VARRAY_INT32
vmstate: add VMSTATE_INT64_ARRAY
vmstate: add VMSTATE_STRUCT_VARRAY_UINT32
vmstate: Add a way to send a partial array
vmstate: be able to store/save a pci device from a pointer
vmstate: move timers to use test instead of version

  hw/hw.h  |   78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
  savevm.c |   25 ++++++++++++++++++++
  2 files changed, 98 insertions(+), 5 deletions(-)
#15 lore raw
In reply to Juan Quintela
Quoted 9 lines · Juan Quintela

Hi

This is the infrastructure that I pushed on my previous series. Anthony don't like 58 patches series (why? O:-) And then split the series in three.

This are the infrastructure patches needed for the other two series.

Anthony, please apply.

Applied. Thanks.

Regards,

Anthony Liguori

Quoted 17 lines

Later, Juan.

Juan Quintela (9):
vmstate: add VMSTATE_UINT32_EQUAL
vmstate: Fix varrays with uint8 indexes
vmstate: add UINT32 VARRAYS
vmstate: add VMSTATE_STRUCT_VARRAY_INT32
vmstate: add VMSTATE_INT64_ARRAY
vmstate: add VMSTATE_STRUCT_VARRAY_UINT32
vmstate: Add a way to send a partial array
vmstate: be able to store/save a pci device from a pointer
vmstate: move timers to use test instead of version

  hw/hw.h  |   78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
  savevm.c |   25 ++++++++++++++++++++
  2 files changed, 98 insertions(+), 5 deletions(-)