[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH COLO-Frame v15 26/38] savevm: Introduce two helper f
From: |
zhanghailiang |
Subject: |
[Qemu-devel] [PATCH COLO-Frame v15 26/38] savevm: Introduce two helper functions for save/find loadvm_handlers entry |
Date: |
Mon, 22 Feb 2016 10:40:20 +0800 |
For COLO's checkpoint process, we will do savevm/loadvm repeatedly.
So every time we call qemu_loadvm_section_start_full(), we will
add all sections information into loadvm_handlers list for one time.
There will be many instances in loadvm_handlers for one section,
and this will lead to memory leak.
We need to check if we have the section info in loadvm_handlers list
before save it. For normal migration, it is harmless.
Signed-off-by: zhanghailiang <address@hidden>
Reviewed-by: Dr. David Alan Gilbert <address@hidden>
---
v14:
- Add Reviewed-by tag
-
v13:
- New patch
---
migration/savevm.c | 56 ++++++++++++++++++++++++++++++++++++++----------------
1 file changed, 40 insertions(+), 16 deletions(-)
diff --git a/migration/savevm.c b/migration/savevm.c
index 94f2894..9e3c18a 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -1718,6 +1718,37 @@ void loadvm_free_handlers(MigrationIncomingState *mis)
}
}
+static LoadStateEntry *loadvm_save_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)
{
@@ -1753,16 +1784,12 @@ qemu_loadvm_section_start_full(QEMUFile *f,
MigrationIncomingState *mis)
version_id, idstr, se->version_id);
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_save_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);
@@ -1785,12 +1812,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 COLO-Frame v15 17/38] COLO failover: Introduce a new command to trigger a failover, (continued)
- [Qemu-devel] [PATCH COLO-Frame v15 17/38] COLO failover: Introduce a new command to trigger a failover, zhanghailiang, 2016/02/21
- [Qemu-devel] [PATCH COLO-Frame v15 25/38] COLO: Update the global runstate after going into colo state, zhanghailiang, 2016/02/21
- [Qemu-devel] [PATCH COLO-Frame v15 30/38] COLO: Split qemu_savevm_state_begin out of checkpoint process, zhanghailiang, 2016/02/21
- [Qemu-devel] [PATCH COLO-Frame v15 18/38] COLO failover: Introduce state to record failover process, zhanghailiang, 2016/02/21
- [Qemu-devel] [PATCH COLO-Frame v15 24/38] COLO: Process shutdown command for VM in COLO state, zhanghailiang, 2016/02/21
- [Qemu-devel] [PATCH COLO-Frame v15 29/38] COLO: Separate the process of saving/loading ram and device state, zhanghailiang, 2016/02/21
- [Qemu-devel] [PATCH COLO-Frame v15 33/38] net: Add notifier/callback for netdev init, zhanghailiang, 2016/02/21
- [Qemu-devel] [PATCH COLO-Frame v15 13/38] COLO: Load VMState into qsb before restore it, zhanghailiang, 2016/02/21
- [Qemu-devel] [PATCH COLO-Frame v15 32/38] filter-buffer: Accept zero interval, zhanghailiang, 2016/02/21
- [Qemu-devel] [PATCH COLO-Frame v15 35/38] COLO: manage the status of buffer filters for PVM, zhanghailiang, 2016/02/21
- [Qemu-devel] [PATCH COLO-Frame v15 26/38] savevm: Introduce two helper functions for save/find loadvm_handlers entry,
zhanghailiang <=
- [Qemu-devel] [PATCH COLO-Frame v15 34/38] COLO/filter: add each netdev a buffer filter, zhanghailiang, 2016/02/21
- [Qemu-devel] [PATCH COLO-Frame v15 21/38] qmp event: Add COLO_EXIT event to notify users while exited from COLO, zhanghailiang, 2016/02/21
- [Qemu-devel] [PATCH COLO-Frame v15 31/38] net/filter: Add a 'status' property for filter object, zhanghailiang, 2016/02/21
- [Qemu-devel] [PATCH COLO-Frame v15 38/38] COLO: Add block replication into colo process, zhanghailiang, 2016/02/21
- [Qemu-devel] [PATCH COLO-Frame v15 22/38] COLO failover: Shutdown related socket fd when do failover, zhanghailiang, 2016/02/21
- [Qemu-devel] [PATCH COLO-Frame v15 36/38] filter-buffer: make filter_buffer_flush() public, zhanghailiang, 2016/02/21
- [Qemu-devel] [PATCH COLO-Frame v15 37/38] COLO: flush buffered packets in checkpoint process or exit COLO, zhanghailiang, 2016/02/21
- [Qemu-devel] [PATCH COLO-Frame v15 16/38] COLO: synchronize PVM's state to SVM periodically, zhanghailiang, 2016/02/21
- [Qemu-devel] [PATCH COLO-Frame v15 27/38] migration/savevm: Add new helpers to process the different stages of loadvm, zhanghailiang, 2016/02/21