>From ecb789cf7f383b112da3cce33eb9822a94b9497a Mon Sep 17 00:00:00 2001
From: Li Zhijian
Date: Tue, 24 Mar 2015 21:53:26 -0400
Subject: [PATCH] check pc.ram block md5sum between migration Source and
Destination
Signed-off-by: Li Zhijian
---
savevm.c | 42 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
mode change 100644 => 100755 savevm.c
diff --git a/savevm.c b/savevm.c
old mode 100644
new mode 100755
index 3b0e222..3d431dc
--- a/savevm.c
+++ b/savevm.c
@@ -51,6 +51,26 @@
#define ARP_PTYPE_IP 0x0800
#define ARP_OP_REQUEST_REV 0x3
+#include "qemu/rcu_queue.h"
+#include
+
+static void check_host_md5(void)
+{
+ int i;
+ unsigned char md[MD5_DIGEST_LENGTH];
+ MD5_CTX ctx;
+ RAMBlock *block = QLIST_FIRST_RCU(&ram_list.blocks);/* Only check 'pc.ram' block */
+
+ MD5_Init(&ctx);
+ MD5_Update(&ctx, (void *)block->host, block->used_length);
+ MD5_Final(md, &ctx);
+ printf("md_host : ");
+ for(i = 0; i < MD5_DIGEST_LENGTH; i++) {
+ fprintf(stderr, "%02x", md[i]);
+ }
+ fprintf(stderr, "\n");
+}
+
static int announce_self_create(uint8_t *buf,
uint8_t *mac_addr)
{
@@ -741,7 +761,13 @@ void qemu_savevm_state_complete(QEMUFile *f)
qemu_put_byte(f, QEMU_VM_SECTION_END);
qemu_put_be32(f, se->section_id);
+ printf("before saving %s complete\n", se->idstr);
+ check_host_md5();
+
ret = se->ops->save_live_complete(f, se->opaque);
+ printf("after saving %s complete\n", se->idstr);
+ check_host_md5();
+
trace_savevm_section_end(se->idstr, se->section_id, ret);
if (ret < 0) {
qemu_file_set_error(f, ret);
@@ -1007,6 +1033,13 @@ int qemu_loadvm_state(QEMUFile *f)
QLIST_INSERT_HEAD(&loadvm_handlers, le, entry);
ret = vmstate_load(f, le->se, le->version_id);
+#if 0
+ if (section_type == QEMU_VM_SECTION_FULL) {
+ printf("QEMU_VM_SECTION_FULL, after loading %s\n", le->se->idstr);
+ check_host_md5();
+ }
+#endif
+
if (ret < 0) {
error_report("error while loading state for instance 0x%x of"
" device '%s'", instance_id, idstr);
@@ -1030,6 +1063,11 @@ int qemu_loadvm_state(QEMUFile *f)
}
ret = vmstate_load(f, le->se, le->version_id);
+ if (section_type == QEMU_VM_SECTION_END) {
+ printf("QEMU_VM_SECTION_END, after loading %s\n", le->se->idstr);
+ check_host_md5();
+ }
+
if (ret < 0) {
error_report("error while loading state section id %d(%s)",
section_id, le->se->idstr);
@@ -1061,7 +1099,11 @@ int qemu_loadvm_state(QEMUFile *f)
g_free(buf);
}
+ printf("after loading all vmstate\n");
+ check_host_md5();
cpu_synchronize_all_post_init();
+ printf("after cpu_synchronize_all_post_init\n");
+ check_host_md5();
ret = 0;
--
1.7.12.4