]> git.proxmox.com Git - mirror_qemu.git/commitdiff
migration: Simplify ram_find_and_save_block()
authorJuan Quintela <quintela@redhat.com>
Tue, 21 Jun 2022 11:20:35 +0000 (13:20 +0200)
committerJuan Quintela <quintela@redhat.com>
Sat, 11 Feb 2023 15:51:09 +0000 (16:51 +0100)
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

index b966e148c228533fbcaeef452198e9df930a3716..dd809fec1f3d1cf764a9fc430bdcc60a3d79963a 100644 (file)
@@ -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) {
-            pages = ram_save_host_page(rs, pss);
+            bool again = true;
+            if (!find_dirty_block(rs, pss, &again)) {
+                if (!again) {
+                    break;
+                }
+            }
         }
-    } while (!pages && again);
+        pages = ram_save_host_page(rs, pss);
+    } while (!pages);
 
     rs->last_seen_block = pss->block;
     rs->last_page = pss->page;