Patchwork [v4,10/11] savevm: update return value from qemu_savevm_state

login
register
mail settings
Submitter Pavel Hrdina
Date March 29, 2013, 2:12 p.m.
Message ID <f35fc82e4fe577aa49e628ac949bdbb56ccbe150.1364565637.git.phrdina@redhat.com>
Download mbox | patch
Permalink /patch/232429/
State New
Headers show

Comments

Pavel Hrdina - March 29, 2013, 2:12 p.m.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 savevm.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
Markus Armbruster - April 9, 2013, 4:32 p.m.
Pavel Hrdina <phrdina@redhat.com> writes:

> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> Reviewed-by: Eric Blake <eblake@redhat.com>
> ---
>  savevm.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/savevm.c b/savevm.c
> index 6ac4ece..75f64d1 100644
> --- a/savevm.c
> +++ b/savevm.c
> @@ -1910,7 +1910,7 @@ void qemu_savevm_state_cancel(void)
>      }
>  }
>  
> -static int qemu_savevm_state(QEMUFile *f, Error **errp)
> +static void qemu_savevm_state(QEMUFile *f, Error **errp)
>  {
>      int ret;
>      MigrationParams params = {
> @@ -1919,7 +1919,7 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp)
>      };
>  
>      if (qemu_savevm_state_blocked(errp)) {
> -        return -EINVAL;
> +        return;
>      }
>  
>      qemu_mutex_unlock_iothread();
> @@ -1940,7 +1940,6 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp)
       ret = qemu_file_get_error(f);
       if (ret == 0) {
           qemu_savevm_state_complete(f, errp);
           ret = qemu_file_get_error(f);
       }
>      if (ret != 0) {
>          qemu_savevm_state_cancel();
>      }
> -    return ret;
>  }
>  

Could be simplified to:

    if (!qemu_file_get_error(f)) {
        qemu_savevm_state_complete(f, errp);
    }
    if (qemu_file_get_error(f)) {
        qemu_savevm_state_cancel();
    }

>  static int qemu_save_device_state(QEMUFile *f)
> @@ -2327,10 +2326,10 @@ SnapshotInfo *qmp_vm_snapshot_save(bool has_name, const char *name,
>          error_setg(errp, "failed to open '%s' file", bdrv_get_device_name(bs));
>          goto the_end;
>      }
> -    ret = qemu_savevm_state(f, &local_err);
> +    qemu_savevm_state(f, &local_err);
>      vm_state_size = qemu_ftell(f);
>      qemu_fclose(f);
> -    if (ret < 0) {
> +    if (error_is_set(&local_err)) {
>          error_propagate(errp, local_err);
>          goto the_end;
>      }

Patch

diff --git a/savevm.c b/savevm.c
index 6ac4ece..75f64d1 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1910,7 +1910,7 @@  void qemu_savevm_state_cancel(void)
     }
 }
 
-static int qemu_savevm_state(QEMUFile *f, Error **errp)
+static void qemu_savevm_state(QEMUFile *f, Error **errp)
 {
     int ret;
     MigrationParams params = {
@@ -1919,7 +1919,7 @@  static int qemu_savevm_state(QEMUFile *f, Error **errp)
     };
 
     if (qemu_savevm_state_blocked(errp)) {
-        return -EINVAL;
+        return;
     }
 
     qemu_mutex_unlock_iothread();
@@ -1940,7 +1940,6 @@  static int qemu_savevm_state(QEMUFile *f, Error **errp)
     if (ret != 0) {
         qemu_savevm_state_cancel();
     }
-    return ret;
 }
 
 static int qemu_save_device_state(QEMUFile *f)
@@ -2327,10 +2326,10 @@  SnapshotInfo *qmp_vm_snapshot_save(bool has_name, const char *name,
         error_setg(errp, "failed to open '%s' file", bdrv_get_device_name(bs));
         goto the_end;
     }
-    ret = qemu_savevm_state(f, &local_err);
+    qemu_savevm_state(f, &local_err);
     vm_state_size = qemu_ftell(f);
     qemu_fclose(f);
-    if (ret < 0) {
+    if (error_is_set(&local_err)) {
         error_propagate(errp, local_err);
         goto the_end;
     }