diff mbox series

[3/5] migration: Simplify ram_find_and_save_block()

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

Commit Message

Juan Quintela June 21, 2022, 2:05 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>
---
 migration/ram.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

Comments

Dr. David Alan Gilbert July 5, 2022, 12:51 p.m. UTC | #1
* Juan Quintela (quintela@redhat.com) wrote:
> 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>

> ---
>  migration/ram.c | 20 +++++++++-----------
>  1 file changed, 9 insertions(+), 11 deletions(-)
> 
> diff --git a/migration/ram.c b/migration/ram.c
> index 35816a3a0a..1d4ff3185b 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -2256,7 +2256,6 @@ static int ram_find_and_save_block(RAMState *rs)
>  {
>      PageSearchStatus pss;
>      int pages = 0;
> -    bool again, found;
>  
>      /* No dirty page as there is zero RAM */
>      if (!ram_bytes_total()) {
> @@ -2272,18 +2271,17 @@ static int ram_find_and_save_block(RAMState *rs)
>      }
>  
>      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);
> +            bool again = true;
> +            if (!find_dirty_block(rs, &pss, &again)) {
> +                if (!again) {
> +                    break;
> +                }
> +            }
>          }
> -
> -        if (found) {
> -            pages = ram_save_host_page(rs, &pss);
> -        }
> -    } while (!pages && again);
> +        pages = ram_save_host_page(rs, &pss);
> +    } while (!pages);
>  
>      rs->last_seen_block = pss.block;
>      rs->last_page = pss.page;
> -- 
> 2.34.1
>
diff mbox series

Patch

diff --git a/migration/ram.c b/migration/ram.c
index 35816a3a0a..1d4ff3185b 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -2256,7 +2256,6 @@  static int ram_find_and_save_block(RAMState *rs)
 {
     PageSearchStatus pss;
     int pages = 0;
-    bool again, found;
 
     /* No dirty page as there is zero RAM */
     if (!ram_bytes_total()) {
@@ -2272,18 +2271,17 @@  static int ram_find_and_save_block(RAMState *rs)
     }
 
     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);
+            bool again = true;
+            if (!find_dirty_block(rs, &pss, &again)) {
+                if (!again) {
+                    break;
+                }
+            }
         }
-
-        if (found) {
-            pages = ram_save_host_page(rs, &pss);
-        }
-    } while (!pages && again);
+        pages = ram_save_host_page(rs, &pss);
+    } while (!pages);
 
     rs->last_seen_block = pss.block;
     rs->last_page = pss.page;