Patchwork [37/41] block-migration: Switch meaning of return value

login
register
mail settings
Submitter Juan Quintela
Date Sept. 21, 2012, 8:47 a.m.
Message ID <1348217255-22441-38-git-send-email-quintela@redhat.com>
Download mbox | patch
Permalink /patch/185665/
State New
Headers show

Comments

Juan Quintela - Sept. 21, 2012, 8:47 a.m.
Make consistent the result of blk_mig_save_dirty_block() and
mig_save_device_dirty()

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 block-migration.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
Paolo Bonzini - Sept. 21, 2012, 12:51 p.m.
Il 21/09/2012 10:47, Juan Quintela ha scritto:
> Make consistent the result of blk_mig_save_dirty_block() and
> mig_save_device_dirty()
> 
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
>  block-migration.c | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/block-migration.c b/block-migration.c
> index a822bb2..565628f 100644
> --- a/block-migration.c
> +++ b/block-migration.c
> @@ -429,14 +429,18 @@ error:
>      return 0;
>  }
> 
> +/* return value:
> + * 0: too much data for max_downtime
> + * 1: few enough data for max_downtime
> +*/
>  static int blk_mig_save_dirty_block(QEMUFile *f, int is_async)
>  {
>      BlkMigDevState *bmds;
> -    int ret = 0;
> +    int ret = 1;
> 
>      QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {
> -        if (mig_save_device_dirty(f, bmds, is_async) == 0) {
> -            ret = 1;
> +        ret = mig_save_device_dirty(f, bmds, is_async);
> +        if (ret == 0) {
>              break;
>          }
>      }
> @@ -594,7 +598,7 @@ static int block_save_iterate(QEMUFile *f, void *opaque)
>                  block_mig_state.bulk_completed = 1;
>              }
>          } else {
> -            if (blk_mig_save_dirty_block(f, 1) == 0) {
> +            if (blk_mig_save_dirty_block(f, 1) != 0) {
>                  /* no more dirty blocks */
>                  break;
>              }
> @@ -631,7 +635,7 @@ static int block_save_complete(QEMUFile *f, void *opaque)
>         all async read completed */
>      assert(block_mig_state.submitted == 0);
> 
> -    while (blk_mig_save_dirty_block(f, 0) != 0) {
> +    while (blk_mig_save_dirty_block(f, 0) == 0) {
>          /* Do nothing */
>      }
>      blk_mig_cleanup();
> 

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

Patch

diff --git a/block-migration.c b/block-migration.c
index a822bb2..565628f 100644
--- a/block-migration.c
+++ b/block-migration.c
@@ -429,14 +429,18 @@  error:
     return 0;
 }

+/* return value:
+ * 0: too much data for max_downtime
+ * 1: few enough data for max_downtime
+*/
 static int blk_mig_save_dirty_block(QEMUFile *f, int is_async)
 {
     BlkMigDevState *bmds;
-    int ret = 0;
+    int ret = 1;

     QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {
-        if (mig_save_device_dirty(f, bmds, is_async) == 0) {
-            ret = 1;
+        ret = mig_save_device_dirty(f, bmds, is_async);
+        if (ret == 0) {
             break;
         }
     }
@@ -594,7 +598,7 @@  static int block_save_iterate(QEMUFile *f, void *opaque)
                 block_mig_state.bulk_completed = 1;
             }
         } else {
-            if (blk_mig_save_dirty_block(f, 1) == 0) {
+            if (blk_mig_save_dirty_block(f, 1) != 0) {
                 /* no more dirty blocks */
                 break;
             }
@@ -631,7 +635,7 @@  static int block_save_complete(QEMUFile *f, void *opaque)
        all async read completed */
     assert(block_mig_state.submitted == 0);

-    while (blk_mig_save_dirty_block(f, 0) != 0) {
+    while (blk_mig_save_dirty_block(f, 0) == 0) {
         /* Do nothing */
     }
     blk_mig_cleanup();