diff mbox series

[v3,3/6] migration: Simplify ram_find_and_save_block()

Message ID 20230208133010.17323-4-quintela@redhat.com
State New
Headers show
Series Eliminate multifd flush | expand

Commit Message

Juan Quintela Feb. 8, 2023, 1:30 p.m. UTC
We will need later that find_dirty_block() return errors, so
simplify the loop.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 migration/ram.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/migration/ram.c b/migration/ram.c
index 0f0fd5c36a..5c406f2c1d 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -2542,7 +2542,6 @@  static int ram_find_and_save_block(RAMState *rs)
 {
     PageSearchStatus *pss = &rs->pss[RAM_CHANNEL_PRECOPY];
     int pages = 0;
-    bool again, found;
 
     /* No dirty page as there is zero RAM */
     if (!ram_bytes_total()) {
@@ -2564,18 +2563,17 @@  static int ram_find_and_save_block(RAMState *rs)
     pss_init(pss, rs->last_seen_block, rs->last_page);
 
     do {
-        again = true;
-        found = get_queued_page(rs, pss);
-
-        if (!found) {
+        if (!get_queued_page(rs, pss)) {
             /* priority queue empty, so just search for something dirty */
-            found = find_dirty_block(rs, pss, &again);
-        }
-
-        if (found) {
+            bool again = true;
+            if (!find_dirty_block(rs, pss, &again)) {
+                if (!again) {
+                    break;
+                }
+            }
             pages = ram_save_host_page(rs, pss);
         }
-    } while (!pages && again);
+    } while (!pages);
 
     rs->last_seen_block = pss->block;
     rs->last_page = pss->page;