Patchwork [1/3] vmstate.h: introduce VMSTATE_BUFFER_POINTER_UNSAFE macro

login
register
mail settings
Submitter Igor Mitsyanko
Date March 10, 2013, 1:47 p.m.
Message ID <1362923278-4080-2-git-send-email-i.mitsyanko@gmail.com>
Download mbox | patch
Permalink /patch/226435/
State New
Headers show

Comments

Igor Mitsyanko - March 10, 2013, 1:47 p.m.
Macro could be used to migrate a dynamically allocated buffer of known size.

Signed-off-by: Igor Mitsyanko <i.mitsyanko@gmail.com>
---
 include/migration/vmstate.h |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

Patch

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index f27276c..e127ed8 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -404,6 +404,15 @@  extern const VMStateInfo vmstate_info_bitmap;
     .offset     = offsetof(_state, _field),                          \
 }
 
+#define VMSTATE_BUFFER_POINTER_UNSAFE(_field, _state, _version, _size) { \
+    .name       = (stringify(_field)),                               \
+    .version_id = (_version),                                        \
+    .size       = (_size),                                           \
+    .info       = &vmstate_info_buffer,                              \
+    .flags      = VMS_BUFFER|VMS_POINTER,                            \
+    .offset     = offsetof(_state, _field),                          \
+}
+
 #define VMSTATE_UNUSED_BUFFER(_test, _version, _size) {              \
     .name         = "unused",                                        \
     .field_exists = (_test),                                         \