Patchwork [v2,08/17] savevm: add error parameter to qemu_savevm_state_begin()

login
register
mail settings
Submitter Pavel Hrdina
Date Dec. 13, 2012, 3:40 p.m.
Message ID <70bb440d178e3ebcaefa27f5817ea4f096e8e259.1355404685.git.phrdina@redhat.com>
Download mbox | patch
Permalink /patch/206165/
State New
Headers show

Comments

Pavel Hrdina - Dec. 13, 2012, 3:40 p.m.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
 migration.c | 2 +-
 savevm.c    | 7 +++++--
 sysemu.h    | 3 ++-
 3 files changed, 8 insertions(+), 4 deletions(-)
Luiz Capitulino - Dec. 14, 2012, 4:45 p.m.
On Thu, 13 Dec 2012 16:40:42 +0100
Pavel Hrdina <phrdina@redhat.com> wrote:

> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> ---
>  migration.c | 2 +-
>  savevm.c    | 7 +++++--
>  sysemu.h    | 3 ++-
>  3 files changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/migration.c b/migration.c
> index 73ce170..bf51a07 100644
> --- a/migration.c
> +++ b/migration.c
> @@ -451,7 +451,7 @@ void migrate_fd_connect(MigrationState *s)
>      s->file = qemu_fopen_ops_buffered(s);
>  
>      DPRINTF("beginning savevm\n");
> -    ret = qemu_savevm_state_begin(s->file, &s->params);
> +    ret = qemu_savevm_state_begin(s->file, &s->params, NULL);
>      if (ret < 0) {
>          DPRINTF("failed, %d\n", ret);
>          migrate_fd_error(s);
> diff --git a/savevm.c b/savevm.c
> index 3ee7da5..633a697 100644
> --- a/savevm.c
> +++ b/savevm.c
> @@ -1601,7 +1601,8 @@ bool qemu_savevm_state_blocked(Error **errp)
>  }
>  
>  int qemu_savevm_state_begin(QEMUFile *f,
> -                            const MigrationParams *params)
> +                            const MigrationParams *params,
> +                            Error **errp)
>  {
>      SaveStateEntry *se;
>      int ret;
> @@ -1641,12 +1642,14 @@ int qemu_savevm_state_begin(QEMUFile *f,
>  
>          ret = se->ops->save_live_setup(f, se->opaque);
>          if (ret < 0) {
> +            error_setg(errp, "Failed to begin vmstate save.");

If possible, it would be nice to say why.

>              qemu_savevm_state_cancel(f);
>              return ret;
>          }
>      }
>      ret = qemu_file_get_error(f);
>      if (ret != 0) {
> +        error_setg(errp, "%s", strerror(errno));

We have error_setg_errno().

>          qemu_savevm_state_cancel(f);
>      }
>  
> @@ -1783,7 +1786,7 @@ static int qemu_savevm_state(QEMUFile *f)
>          goto out;
>      }
>  
> -    ret = qemu_savevm_state_begin(f, &params);
> +    ret = qemu_savevm_state_begin(f, &params, NULL);
>      if (ret < 0)
>          goto out;
>  
> diff --git a/sysemu.h b/sysemu.h
> index 1b6add2..07c5322 100644
> --- a/sysemu.h
> +++ b/sysemu.h
> @@ -74,7 +74,8 @@ void qemu_announce_self(void);
>  
>  bool qemu_savevm_state_blocked(Error **errp);
>  int qemu_savevm_state_begin(QEMUFile *f,
> -                            const MigrationParams *params);
> +                            const MigrationParams *params,
> +                            Error **errp);
>  int qemu_savevm_state_iterate(QEMUFile *f);
>  int qemu_savevm_state_complete(QEMUFile *f);
>  void qemu_savevm_state_cancel(QEMUFile *f);

Patch

diff --git a/migration.c b/migration.c
index 73ce170..bf51a07 100644
--- a/migration.c
+++ b/migration.c
@@ -451,7 +451,7 @@  void migrate_fd_connect(MigrationState *s)
     s->file = qemu_fopen_ops_buffered(s);
 
     DPRINTF("beginning savevm\n");
-    ret = qemu_savevm_state_begin(s->file, &s->params);
+    ret = qemu_savevm_state_begin(s->file, &s->params, NULL);
     if (ret < 0) {
         DPRINTF("failed, %d\n", ret);
         migrate_fd_error(s);
diff --git a/savevm.c b/savevm.c
index 3ee7da5..633a697 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1601,7 +1601,8 @@  bool qemu_savevm_state_blocked(Error **errp)
 }
 
 int qemu_savevm_state_begin(QEMUFile *f,
-                            const MigrationParams *params)
+                            const MigrationParams *params,
+                            Error **errp)
 {
     SaveStateEntry *se;
     int ret;
@@ -1641,12 +1642,14 @@  int qemu_savevm_state_begin(QEMUFile *f,
 
         ret = se->ops->save_live_setup(f, se->opaque);
         if (ret < 0) {
+            error_setg(errp, "Failed to begin vmstate save.");
             qemu_savevm_state_cancel(f);
             return ret;
         }
     }
     ret = qemu_file_get_error(f);
     if (ret != 0) {
+        error_setg(errp, "%s", strerror(errno));
         qemu_savevm_state_cancel(f);
     }
 
@@ -1783,7 +1786,7 @@  static int qemu_savevm_state(QEMUFile *f)
         goto out;
     }
 
-    ret = qemu_savevm_state_begin(f, &params);
+    ret = qemu_savevm_state_begin(f, &params, NULL);
     if (ret < 0)
         goto out;
 
diff --git a/sysemu.h b/sysemu.h
index 1b6add2..07c5322 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -74,7 +74,8 @@  void qemu_announce_self(void);
 
 bool qemu_savevm_state_blocked(Error **errp);
 int qemu_savevm_state_begin(QEMUFile *f,
-                            const MigrationParams *params);
+                            const MigrationParams *params,
+                            Error **errp);
 int qemu_savevm_state_iterate(QEMUFile *f);
 int qemu_savevm_state_complete(QEMUFile *f);
 void qemu_savevm_state_cancel(QEMUFile *f);