[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 10/30] migration: Fix possible infinite loop of ram save process
From: |
Juan Quintela |
Subject: |
[PULL 10/30] migration: Fix possible infinite loop of ram save process |
Date: |
Tue, 15 Nov 2022 16:34:54 +0100 |
From: Peter Xu <peterx@redhat.com>
When starting ram saving procedure (especially at the completion phase),
always set last_seen_block to non-NULL to make sure we can always correctly
detect the case where "we've migrated all the dirty pages".
Then we'll guarantee both last_seen_block and pss.block will be valid
always before the loop starts.
See the comment in the code for some details.
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
migration/ram.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/migration/ram.c b/migration/ram.c
index bb4f08bfed..c0f5d6d287 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -2574,14 +2574,22 @@ static int ram_find_and_save_block(RAMState *rs)
return pages;
}
+ /*
+ * Always keep last_seen_block/last_page valid during this procedure,
+ * because find_dirty_block() relies on these values (e.g., we compare
+ * last_seen_block with pss.block to see whether we searched all the
+ * ramblocks) to detect the completion of migration. Having NULL value
+ * of last_seen_block can conditionally cause below loop to run forever.
+ */
+ if (!rs->last_seen_block) {
+ rs->last_seen_block = QLIST_FIRST_RCU(&ram_list.blocks);
+ rs->last_page = 0;
+ }
+
pss.block = rs->last_seen_block;
pss.page = rs->last_page;
pss.complete_round = false;
- if (!pss.block) {
- pss.block = QLIST_FIRST_RCU(&ram_list.blocks);
- }
-
do {
again = true;
found = get_queued_page(rs, &pss);
--
2.38.1
- [PULL 00/30] Next patches, Juan Quintela, 2022/11/15
- [PULL 01/30] migration/channel-block: fix return value for qio_channel_block_{readv, writev}, Juan Quintela, 2022/11/15
- [PULL 02/30] migration/multifd/zero-copy: Create helper function for flushing, Juan Quintela, 2022/11/15
- [PULL 08/30] Update AVX512 support for xbzrle_encode_buffer, Juan Quintela, 2022/11/15
- [PULL 10/30] migration: Fix possible infinite loop of ram save process,
Juan Quintela <=
- [PULL 07/30] migration: Export ram_release_page(), Juan Quintela, 2022/11/15
- [PULL 03/30] migration: check magic value for deciding the mapping of channels, Juan Quintela, 2022/11/15
- [PULL 04/30] multifd: Create page_size fields into both MultiFD{Recv, Send}Params, Juan Quintela, 2022/11/15
- [PULL 06/30] migration: Export ram_transferred_ram(), Juan Quintela, 2022/11/15
- [PULL 05/30] multifd: Create page_count fields into both MultiFD{Recv, Send}Params, Juan Quintela, 2022/11/15
- [PULL 09/30] Unit test code and benchmark code, Juan Quintela, 2022/11/15
- [PULL 13/30] migration: Use non-atomic ops for clear log bitmap, Juan Quintela, 2022/11/15
- [PULL 12/30] migration: Disallow postcopy preempt to be used with compress, Juan Quintela, 2022/11/15
- [PULL 11/30] migration: Fix race on qemu_file_shutdown(), Juan Quintela, 2022/11/15
- [PULL 14/30] migration: Disable multifd explicitly with compression, Juan Quintela, 2022/11/15