Patchwork [v4,05/11] savevm: add error parameter to qemu_savevm_state_complete()

login
register
mail settings
Submitter Pavel Hrdina
Date March 29, 2013, 2:12 p.m.
Message ID <e8ecd237e473f6b881dba87a5009f780e87e483c.1364565637.git.phrdina@redhat.com>
Download mbox | patch
Permalink /patch/232426/
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>
---
 include/sysemu/sysemu.h | 2 +-
 migration.c             | 2 +-
 savevm.c                | 5 +++--
 3 files changed, 5 insertions(+), 4 deletions(-)
Markus Armbruster - April 9, 2013, 1:56 p.m.
Pavel Hrdina <phrdina@redhat.com> writes:

> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> Reviewed-by: Eric Blake <eblake@redhat.com>
> ---
>  include/sysemu/sysemu.h | 2 +-
>  migration.c             | 2 +-
>  savevm.c                | 5 +++--
>  3 files changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
> index af4f699..9e6a4a9 100644
> --- a/include/sysemu/sysemu.h
> +++ b/include/sysemu/sysemu.h
> @@ -77,7 +77,7 @@ void qemu_savevm_state_begin(QEMUFile *f,
>                               const MigrationParams *params,
>                               Error **errp);
>  int qemu_savevm_state_iterate(QEMUFile *f, Error **errp);
> -void qemu_savevm_state_complete(QEMUFile *f);
> +void qemu_savevm_state_complete(QEMUFile *f, Error **errp);
>  void qemu_savevm_state_cancel(void);
>  uint64_t qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size);
>  int qemu_loadvm_state(QEMUFile *f);
> diff --git a/migration.c b/migration.c
> index e9d2f40..c891a45 100644
> --- a/migration.c
> +++ b/migration.c
> @@ -525,7 +525,7 @@ static void *migration_thread(void *opaque)
>                  old_vm_running = runstate_is_running();
>                  vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);
>                  qemu_file_set_rate_limit(s->file, INT_MAX);
> -                qemu_savevm_state_complete(s->file);
> +                qemu_savevm_state_complete(s->file, NULL);
>                  qemu_mutex_unlock_iothread();
>                  if (!qemu_file_get_error(s->file)) {
>                      migrate_finish_set_state(s, MIG_STATE_COMPLETED);
> diff --git a/savevm.c b/savevm.c
> index 575f1b2..7598934 100644
> --- a/savevm.c
> +++ b/savevm.c
> @@ -1823,7 +1823,7 @@ int qemu_savevm_state_iterate(QEMUFile *f, Error **errp)
>      return ret;
>  }
>  
> -void qemu_savevm_state_complete(QEMUFile *f)
> +void qemu_savevm_state_complete(QEMUFile *f, Error **errp)
>  {
>      SaveStateEntry *se;
>      int ret;
> @@ -1848,6 +1848,7 @@ void qemu_savevm_state_complete(QEMUFile *f)
>          trace_savevm_section_end(se->section_id);
>          if (ret < 0) {
>              qemu_file_set_error(f, ret);
> +            error_setg(errp, "failed to complete vmstate save");
>              return;
>          }
>      }

Unlike PATCH 3+4, this one returns an error via the Error parameter on
qemu_file_set_error().

If I remember correctly, qemu_file_set_error() takes a -errno argument,
here: ret.  error_setg_errno(), perhaps?

> @@ -1933,7 +1934,7 @@ static int qemu_savevm_state(QEMUFile *f)
>  
>      ret = qemu_file_get_error(f);
>      if (ret == 0) {
> -        qemu_savevm_state_complete(f);
> +        qemu_savevm_state_complete(f, NULL);
>          ret = qemu_file_get_error(f);
>      }
>      if (ret != 0) {

Patch

diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index af4f699..9e6a4a9 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -77,7 +77,7 @@  void qemu_savevm_state_begin(QEMUFile *f,
                              const MigrationParams *params,
                              Error **errp);
 int qemu_savevm_state_iterate(QEMUFile *f, Error **errp);
-void qemu_savevm_state_complete(QEMUFile *f);
+void qemu_savevm_state_complete(QEMUFile *f, Error **errp);
 void qemu_savevm_state_cancel(void);
 uint64_t qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size);
 int qemu_loadvm_state(QEMUFile *f);
diff --git a/migration.c b/migration.c
index e9d2f40..c891a45 100644
--- a/migration.c
+++ b/migration.c
@@ -525,7 +525,7 @@  static void *migration_thread(void *opaque)
                 old_vm_running = runstate_is_running();
                 vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);
                 qemu_file_set_rate_limit(s->file, INT_MAX);
-                qemu_savevm_state_complete(s->file);
+                qemu_savevm_state_complete(s->file, NULL);
                 qemu_mutex_unlock_iothread();
                 if (!qemu_file_get_error(s->file)) {
                     migrate_finish_set_state(s, MIG_STATE_COMPLETED);
diff --git a/savevm.c b/savevm.c
index 575f1b2..7598934 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1823,7 +1823,7 @@  int qemu_savevm_state_iterate(QEMUFile *f, Error **errp)
     return ret;
 }
 
-void qemu_savevm_state_complete(QEMUFile *f)
+void qemu_savevm_state_complete(QEMUFile *f, Error **errp)
 {
     SaveStateEntry *se;
     int ret;
@@ -1848,6 +1848,7 @@  void qemu_savevm_state_complete(QEMUFile *f)
         trace_savevm_section_end(se->section_id);
         if (ret < 0) {
             qemu_file_set_error(f, ret);
+            error_setg(errp, "failed to complete vmstate save");
             return;
         }
     }
@@ -1933,7 +1934,7 @@  static int qemu_savevm_state(QEMUFile *f)
 
     ret = qemu_file_get_error(f);
     if (ret == 0) {
-        qemu_savevm_state_complete(f);
+        qemu_savevm_state_complete(f, NULL);
         ret = qemu_file_get_error(f);
     }
     if (ret != 0) {