aboutsummaryrefslogtreecommitdiff
path: root/savevm.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2012-10-30 07:45:12 +0000
committerPeter Maydell <peter.maydell@linaro.org>2012-10-30 07:45:12 +0000
commit08e99e296fbe695d13c8ac944867d9def7f7c5d0 (patch)
treefc266bd4dfbc4b0ad01a94656c052a0b338f9e35 /savevm.c
parentf2d189d38436a8ccdedd94de01673b04aa008e11 (diff)
downloadqemu-08e99e296fbe695d13c8ac944867d9def7f7c5d0.zip
qemu-08e99e296fbe695d13c8ac944867d9def7f7c5d0.tar.gz
qemu-08e99e296fbe695d13c8ac944867d9def7f7c5d0.tar.bz2
vmstate: Add support for saving/loading bitmaps
Add support for saving/loading bitmap.h bitmaps in vmstate. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Tested-by: Igor Mitsyanko <i.mitsyanko@samsung.com> Reviewed-by: Juan Quintela <quintela@redhat.com>
Diffstat (limited to 'savevm.c')
-rw-r--r--savevm.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/savevm.c b/savevm.c
index b080d37..43d3d1b 100644
--- a/savevm.c
+++ b/savevm.c
@@ -86,6 +86,7 @@
#include "memory.h"
#include "qmp-commands.h"
#include "trace.h"
+#include "bitops.h"
#define SELF_ANNOUNCE_ROUNDS 5
@@ -1132,6 +1133,46 @@ const VMStateInfo vmstate_info_unused_buffer = {
.put = put_unused_buffer,
};
+/* bitmaps (as defined by bitmap.h). Note that size here is the size
+ * of the bitmap in bits. The on-the-wire format of a bitmap is 64
+ * bit words with the bits in big endian order. The in-memory format
+ * is an array of 'unsigned long', which may be either 32 or 64 bits.
+ */
+/* This is the number of 64 bit words sent over the wire */
+#define BITS_TO_U64S(nr) DIV_ROUND_UP(nr, 64)
+static int get_bitmap(QEMUFile *f, void *pv, size_t size)
+{
+ unsigned long *bmp = pv;
+ int i, idx = 0;
+ for (i = 0; i < BITS_TO_U64S(size); i++) {
+ uint64_t w = qemu_get_be64(f);
+ bmp[idx++] = w;
+ if (sizeof(unsigned long) == 4 && idx < BITS_TO_LONGS(size)) {
+ bmp[idx++] = w >> 32;
+ }
+ }
+ return 0;
+}
+
+static void put_bitmap(QEMUFile *f, void *pv, size_t size)
+{
+ unsigned long *bmp = pv;
+ int i, idx = 0;
+ for (i = 0; i < BITS_TO_U64S(size); i++) {
+ uint64_t w = bmp[idx++];
+ if (sizeof(unsigned long) == 4 && idx < BITS_TO_LONGS(size)) {
+ w |= ((uint64_t)bmp[idx++]) << 32;
+ }
+ qemu_put_be64(f, w);
+ }
+}
+
+const VMStateInfo vmstate_info_bitmap = {
+ .name = "bitmap",
+ .get = get_bitmap,
+ .put = put_bitmap,
+};
+
typedef struct CompatEntry {
char idstr[256];
int instance_id;