summaryrefslogtreecommitdiffstats
path: root/migration/vmstate.c
diff options
context:
space:
mode:
authorPeter Maydell2017-02-13 19:49:26 +0100
committerPeter Maydell2017-02-13 19:49:26 +0100
commitec7a9bd5bb2c46c60cc0ec9b9d9f2ce404226ec0 (patch)
treeae717012129be5c9c27827e1eab623ff467ddb1c /migration/vmstate.c
parentMerge remote-tracking branch 'remotes/stefanha/tags/tracing-pull-request' int... (diff)
parentvirtio/migration: Migrate virtio-net to VMState (diff)
downloadqemu-ec7a9bd5bb2c46c60cc0ec9b9d9f2ce404226ec0.tar.gz
qemu-ec7a9bd5bb2c46c60cc0ec9b9d9f2ce404226ec0.tar.xz
qemu-ec7a9bd5bb2c46c60cc0ec9b9d9f2ce404226ec0.zip
Merge remote-tracking branch 'remotes/dgilbert/tags/pull-migration-20170213a' into staging
Migration Amit: migration: remove myself as maintainer MAINTAINERS: update my email address Ashijeet: migrate: Introduce zero RAM checks to skip RAM migration Pavel: Postcopy release RAM Halil: consolidate VMStateField.start Hailiang: COLO: fix setting checkpoint-delay not working properly COLO: Shutdown related socket fd while do failover COLO: Don't process failover request while loading VM's state Me: migration: Add VMSTATE_UNUSED_VARRAY_UINT32 migration: Add VMSTATE_WITH_TMP tests/migration: Add test for VMSTATE_WITH_TMP virtio-net VMState conversion and new VMSTATE macros # gpg: Signature made Mon 13 Feb 2017 17:36:39 GMT # gpg: using RSA key 0x0516331EBC5BFDE7 # gpg: Good signature from "Dr. David Alan Gilbert (RH2) <dgilbert@redhat.com>" # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: 45F5 C71B 4A0C B7FB 977A 9FA9 0516 331E BC5B FDE7 * remotes/dgilbert/tags/pull-migration-20170213a: virtio/migration: Migrate virtio-net to VMState tests/migration: Add test for VMSTATE_WITH_TMP migration: Add VMSTATE_WITH_TMP migration: Add VMSTATE_UNUSED_VARRAY_UINT32 COLO: Don't process failover request while loading VM's state COLO: Shutdown related socket fd while do failover COLO: fix setting checkpoint-delay not working properly migration: consolidate VMStateField.start migrate: Introduce zero RAM checks to skip RAM migration migration: discard non-dirty ram pages after the start of postcopy add 'release-ram' migrate capability migration: add MigrationState arg for ram_save_/compressed_/page() MAINTAINERS: update my email address migration: remove myself as maintainer Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'migration/vmstate.c')
-rw-r--r--migration/vmstate.c44
1 files changed, 42 insertions, 2 deletions
diff --git a/migration/vmstate.c b/migration/vmstate.c
index 2b2b3a58e6..b4d8ae982a 100644
--- a/migration/vmstate.c
+++ b/migration/vmstate.c
@@ -68,10 +68,10 @@ static void *vmstate_base_addr(void *opaque, VMStateField *field, bool alloc)
}
}
if (size) {
- *((void **)base_addr + field->start) = g_malloc(size);
+ *(void **)base_addr = g_malloc(size);
}
}
- base_addr = *(void **)base_addr + field->start;
+ base_addr = *(void **)base_addr;
}
return base_addr;
@@ -935,6 +935,46 @@ const VMStateInfo vmstate_info_unused_buffer = {
.put = put_unused_buffer,
};
+/* vmstate_info_tmp, see VMSTATE_WITH_TMP, the idea is that we allocate
+ * a temporary buffer and the pre_load/pre_save methods in the child vmsd
+ * copy stuff from the parent into the child and do calculations to fill
+ * in fields that don't really exist in the parent but need to be in the
+ * stream.
+ */
+static int get_tmp(QEMUFile *f, void *pv, size_t size, VMStateField *field)
+{
+ int ret;
+ const VMStateDescription *vmsd = field->vmsd;
+ int version_id = field->version_id;
+ void *tmp = g_malloc(size);
+
+ /* Writes the parent field which is at the start of the tmp */
+ *(void **)tmp = pv;
+ ret = vmstate_load_state(f, vmsd, tmp, version_id);
+ g_free(tmp);
+ return ret;
+}
+
+static int put_tmp(QEMUFile *f, void *pv, size_t size, VMStateField *field,
+ QJSON *vmdesc)
+{
+ const VMStateDescription *vmsd = field->vmsd;
+ void *tmp = g_malloc(size);
+
+ /* Writes the parent field which is at the start of the tmp */
+ *(void **)tmp = pv;
+ vmstate_save_state(f, vmsd, tmp, vmdesc);
+ g_free(tmp);
+
+ return 0;
+}
+
+const VMStateInfo vmstate_info_tmp = {
+ .name = "tmp",
+ .get = get_tmp,
+ .put = put_tmp,
+};
+
/* 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