Patchwork [15/25] vmstate: Add VMSTATE_BUFFER_UNUSED

login
register
mail settings
Submitter Juan Quintela
Date Oct. 19, 2009, 6:43 p.m.
Message ID <28c9f5c692bd834877505225b0be01c65f857458.1255976538.git.quintela@redhat.com>
Download mbox | patch
Permalink /patch/36405/
State New
Headers show

Comments

Juan Quintela - Oct. 19, 2009, 6:43 p.m.
It allows to have 'things' in savevm format not backed in the device state

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/hw.h  |   18 ++++++++++++++++++
 savevm.c |   20 ++++++++++++++++++++
 2 files changed, 38 insertions(+), 0 deletions(-)

Patch

diff --git a/hw/hw.h b/hw/hw.h
index 3feb9df..d3bf0a7 100644
--- a/hw/hw.h
+++ b/hw/hw.h
@@ -335,6 +335,7 @@  extern const VMStateInfo vmstate_info_uint64;
 extern const VMStateInfo vmstate_info_timer;
 extern const VMStateInfo vmstate_info_ptimer;
 extern const VMStateInfo vmstate_info_buffer;
+extern const VMStateInfo vmstate_info_unused_buffer;

 #define type_check_array(t1,t2,n) ((t1(*)[n])0 - (t2*)0)
 #define type_check_pointer(t1,t2) ((t1**)0 - (t2*)0)
@@ -470,6 +471,14 @@  extern const VMStateInfo vmstate_info_buffer;
     .offset     = vmstate_offset_buffer(_state, _field) + _start,    \
 }

+#define VMSTATE_UNUSED_BUFFER(_test, _version, _size) {              \
+    .name         = "unused",                                        \
+    .field_exists = (_test),                                         \
+    .version_id   = (_version),                                      \
+    .size         = (_size),                                         \
+    .info         = &vmstate_info_unused_buffer,                     \
+    .flags        = VMS_BUFFER,                                      \
+}
 extern const VMStateDescription vmstate_pci_device;

 #define VMSTATE_PCI_DEVICE(_field, _state) {                         \
@@ -617,6 +626,15 @@  extern const VMStateDescription vmstate_i2c_slave;
 #define VMSTATE_BUFFER_START_MIDDLE(_f, _s, _start) \
     VMSTATE_STATIC_BUFFER(_f, _s, 0, _start, sizeof(typeof_field(_s, _f)))

+#define VMSTATE_UNUSED_V(_v, _size)                                   \
+    VMSTATE_UNUSED_BUFFER(NULL, _v, _size)
+
+#define VMSTATE_UNUSED(_size)                                         \
+    VMSTATE_UNUSED_V(0, _size)
+
+#define VMSTATE_UNUSED_TEST(_test, _size)                             \
+    VMSTATE_UNUSED_BUFFER(_test, 0, _size)
+
 #ifdef NEED_CPU_H
 #if TARGET_LONG_BITS == 64
 #define VMSTATE_UINTTL_V(_f, _s, _v)                                  \
diff --git a/savevm.c b/savevm.c
index f377bfe..ed16cea 100644
--- a/savevm.c
+++ b/savevm.c
@@ -930,6 +930,26 @@  const VMStateInfo vmstate_info_buffer = {
     .put  = put_buffer,
 };

+/* unused buffers: space that was used for some fields that are
+   not usefull anymore */
+
+static int get_unused_buffer(QEMUFile *f, void *pv, size_t size)
+{
+    qemu_fseek(f, size, SEEK_CUR);
+    return 0;
+}
+
+static void put_unused_buffer(QEMUFile *f, void *pv, size_t size)
+{
+    qemu_fseek(f, size, SEEK_CUR);
+}
+
+const VMStateInfo vmstate_info_unused_buffer = {
+    .name = "unused_buffer",
+    .get  = get_unused_buffer,
+    .put  = put_unused_buffer,
+};
+
 typedef struct SaveStateEntry {
     QTAILQ_ENTRY(SaveStateEntry) entry;
     char idstr[256];