[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 11/18] savevm: split save/find loadvm_handlers en
From: |
zhanghailiang |
Subject: |
[Qemu-devel] [PATCH v2 11/18] savevm: split save/find loadvm_handlers entry into two helper functions |
Date: |
Sat, 22 Apr 2017 16:25:51 +0800 |
COLO's checkpoint process is based on migration process,
everytime we do checkpoint we will repeat the process of savevm and loadvm.
So we will call qemu_loadvm_section_start_full() repeatedly, It will
add all migration sections information into loadvm_handlers list everytime,
which will lead to memory leak.
To fix it, we split the process of saving and finding section entry into two
helper functions, we will check if section info was exist in loadvm_handlers
list before save it.
This modifications have no side effect for normal migration.
Cc: Juan Quintela <address@hidden>
Signed-off-by: zhanghailiang <address@hidden>
Reviewed-by: Dr. David Alan Gilbert <address@hidden>
---
migration/savevm.c | 55 +++++++++++++++++++++++++++++++++++++++---------------
1 file changed, 40 insertions(+), 15 deletions(-)
diff --git a/migration/savevm.c b/migration/savevm.c
index 03ae1bd..f87cd8d 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -1836,6 +1836,37 @@ void loadvm_free_handlers(MigrationIncomingState *mis)
}
}
+static LoadStateEntry *loadvm_add_section_entry(MigrationIncomingState *mis,
+ SaveStateEntry *se,
+ uint32_t section_id,
+ uint32_t version_id)
+{
+ LoadStateEntry *le;
+
+ /* Add entry */
+ le = g_malloc0(sizeof(*le));
+
+ le->se = se;
+ le->section_id = section_id;
+ le->version_id = version_id;
+ QLIST_INSERT_HEAD(&mis->loadvm_handlers, le, entry);
+ return le;
+}
+
+static LoadStateEntry *loadvm_find_section_entry(MigrationIncomingState *mis,
+ uint32_t section_id)
+{
+ LoadStateEntry *le;
+
+ QLIST_FOREACH(le, &mis->loadvm_handlers, entry) {
+ if (le->section_id == section_id) {
+ break;
+ }
+ }
+
+ return le;
+}
+
static int
qemu_loadvm_section_start_full(QEMUFile *f, MigrationIncomingState *mis)
{
@@ -1878,15 +1909,12 @@ qemu_loadvm_section_start_full(QEMUFile *f,
MigrationIncomingState *mis)
return -EINVAL;
}
- /* Add entry */
- le = g_malloc0(sizeof(*le));
-
- le->se = se;
- le->section_id = section_id;
- le->version_id = version_id;
- QLIST_INSERT_HEAD(&mis->loadvm_handlers, le, entry);
-
- ret = vmstate_load(f, le->se, le->version_id);
+ /* Check if we have saved this section info before, if not, save it */
+ le = loadvm_find_section_entry(mis, section_id);
+ if (!le) {
+ le = loadvm_add_section_entry(mis, se, section_id, version_id);
+ }
+ ret = vmstate_load(f, se, version_id);
if (ret < 0) {
error_report("error while loading state for instance 0x%x of"
" device '%s'", instance_id, idstr);
@@ -1909,12 +1937,9 @@ qemu_loadvm_section_part_end(QEMUFile *f,
MigrationIncomingState *mis)
section_id = qemu_get_be32(f);
trace_qemu_loadvm_state_section_partend(section_id);
- QLIST_FOREACH(le, &mis->loadvm_handlers, entry) {
- if (le->section_id == section_id) {
- break;
- }
- }
- if (le == NULL) {
+
+ le = loadvm_find_section_entry(mis, section_id);
+ if (!le) {
error_report("Unknown savevm section %d", section_id);
return -EINVAL;
}
--
1.8.3.1
- [Qemu-devel] [PATCH v2 00/18] COLO: integrate colo frame with block replication and net compare, zhanghailiang, 2017/04/22
- [Qemu-devel] [PATCH v2 09/18] COLO: Flush memory data from ram cache, zhanghailiang, 2017/04/22
- [Qemu-devel] [PATCH v2 12/18] savevm: split the process of different stages for loadvm/savevm, zhanghailiang, 2017/04/22
- [Qemu-devel] [PATCH v2 04/18] COLO: integrate colo compare with colo frame, zhanghailiang, 2017/04/22
- [Qemu-devel] [PATCH v2 08/18] ram/COLO: Record the dirty pages that SVM received, zhanghailiang, 2017/04/22
- [Qemu-devel] [PATCH v2 11/18] savevm: split save/find loadvm_handlers entry into two helper functions,
zhanghailiang <=
- [Qemu-devel] [PATCH v2 13/18] COLO: Separate the process of saving/loading ram and device state, zhanghailiang, 2017/04/22
- [Qemu-devel] [PATCH v2 06/18] COLO: Add block replication into colo process, zhanghailiang, 2017/04/22
- [Qemu-devel] [PATCH v2 14/18] COLO: Split qemu_savevm_state_begin out of checkpoint process, zhanghailiang, 2017/04/22
- [Qemu-devel] [PATCH v2 15/18] COLO: flush host dirty ram from cache, zhanghailiang, 2017/04/22
- [Qemu-devel] [PATCH v2 02/18] colo-compare: implement the process of checkpoint, zhanghailiang, 2017/04/22
- [Qemu-devel] [PATCH v2 01/18] net/colo: Add notifier/callback related helpers for filter, zhanghailiang, 2017/04/22
- [Qemu-devel] [PATCH v2 16/18] filter: Add handle_event method for NetFilterClass, zhanghailiang, 2017/04/22
- [Qemu-devel] [PATCH v2 17/18] filter-rewriter: handle checkpoint and failover event, zhanghailiang, 2017/04/22
- [Qemu-devel] [PATCH v2 07/18] COLO: Load dirty pages into SVM's RAM cache firstly, zhanghailiang, 2017/04/22
- [Qemu-devel] [PATCH v2 10/18] qmp event: Add COLO_EXIT event to notify users while exited COLO, zhanghailiang, 2017/04/22