qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: qemu-devel@nongnu.org
Cc: alex.williamson@redhat.com, cam@cs.ualberta.ca, quintela@redhat.com
Subject: [Qemu-devel] [PATCH RESEND 5/6] savevm: Allow set_params and save_live_state to error
Date: Fri, 05 Nov 2010 15:16:47 -0600	[thread overview]
Message-ID: <20101105211646.19958.43832.stgit@s20.home> (raw)
In-Reply-To: <20101105211426.19958.86894.stgit@s20.home>

This lets a save state handler NAK a migration or cancel if
it runs into problems.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---

 block-migration.c |    4 +++-
 hw/hw.h           |    2 +-
 savevm.c          |   18 +++++++++++++++---
 3 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/block-migration.c b/block-migration.c
index 0bfdb73..5fb3b72 100644
--- a/block-migration.c
+++ b/block-migration.c
@@ -628,13 +628,15 @@ static int block_load(QEMUFile *f, void *opaque, int version_id)
     return 0;
 }
 
-static void block_set_params(int blk_enable, int shared_base, void *opaque)
+static int block_set_params(int blk_enable, int shared_base, void *opaque)
 {
     block_mig_state.blk_enable = blk_enable;
     block_mig_state.shared_base = shared_base;
 
     /* shared base means that blk_enable = 1 */
     block_mig_state.blk_enable |= shared_base;
+
+    return 0;
 }
 
 void blk_mig_init(void)
diff --git a/hw/hw.h b/hw/hw.h
index 3ef67c8..dac89c7 100644
--- a/hw/hw.h
+++ b/hw/hw.h
@@ -239,7 +239,7 @@ static inline void qemu_get_sbe64s(QEMUFile *f, int64_t *pv)
 int64_t qemu_ftell(QEMUFile *f);
 int64_t qemu_fseek(QEMUFile *f, int64_t pos, int whence);
 
-typedef void SaveSetParamsHandler(int blk_enable, int shared, void * opaque);
+typedef int SaveSetParamsHandler(int blk_enable, int shared, void * opaque);
 typedef int SaveStateHandler(QEMUFile *f, void *opaque);
 typedef int SaveLiveStateHandler(Monitor *mon, QEMUFile *f, int stage,
                                  void *opaque);
diff --git a/savevm.c b/savevm.c
index ade7eb5..521edc8 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1435,12 +1435,16 @@ int qemu_savevm_state_begin(Monitor *mon, QEMUFile *f, int blk_enable,
                             int shared)
 {
     SaveStateEntry *se;
+    int ret;
 
     QTAILQ_FOREACH(se, &savevm_handlers, entry) {
         if(se->set_params == NULL) {
             continue;
 	}
-	se->set_params(blk_enable, shared, se->opaque);
+	ret = se->set_params(blk_enable, shared, se->opaque);
+        if (ret < 0) {
+            return ret;
+        }
     }
     
     qemu_put_be32(f, QEMU_VM_FILE_MAGIC);
@@ -1464,7 +1468,10 @@ int qemu_savevm_state_begin(Monitor *mon, QEMUFile *f, int blk_enable,
         qemu_put_be32(f, se->instance_id);
         qemu_put_be32(f, se->version_id);
 
-        se->save_live_state(mon, f, QEMU_VM_SECTION_START, se->opaque);
+        ret = se->save_live_state(mon, f, QEMU_VM_SECTION_START, se->opaque);
+        if (ret < 0) {
+            return ret;
+        }
     }
 
     if (qemu_file_has_error(f)) {
@@ -1495,6 +1502,8 @@ int qemu_savevm_state_iterate(Monitor *mon, QEMUFile *f)
                and reduces the probability that a faster changing state is
                synchronized over and over again. */
             break;
+        } else if (ret < 0) {
+            return ret;
         }
     }
 
@@ -1524,7 +1533,10 @@ int qemu_savevm_state_complete(Monitor *mon, QEMUFile *f)
         qemu_put_byte(f, QEMU_VM_SECTION_END);
         qemu_put_be32(f, se->section_id);
 
-        se->save_live_state(mon, f, QEMU_VM_SECTION_END, se->opaque);
+        r = se->save_live_state(mon, f, QEMU_VM_SECTION_END, se->opaque);
+        if (r < 0) {
+            return r;
+        }
     }
 
     QTAILQ_FOREACH(se, &savevm_handlers, entry) {

  parent reply	other threads:[~2010-11-05 21:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-05 21:16 [Qemu-devel] [PATCH RESEND 0/6] Save state error handling (kill off no_migrate) Alex Williamson
2010-11-05 21:16 ` [Qemu-devel] [PATCH RESEND 1/6] savevm: Allow SaveStateHandler() to return error Alex Williamson
2010-11-05 21:16 ` [Qemu-devel] [PATCH RESEND 2/6] savevm: Allow vmsd->pre_save " Alex Williamson
2010-11-05 21:16 ` [Qemu-devel] [PATCH RESEND 3/6] pci: Allow pci_device_save() " Alex Williamson
2010-11-05 21:16 ` [Qemu-devel] [PATCH RESEND 4/6] virtio: Allow virtio_save() errors Alex Williamson
2010-11-05 21:16 ` Alex Williamson [this message]
2010-11-05 21:16 ` [Qemu-devel] [PATCH RESEND 6/6] savevm: Remove register_device_unmigratable() Alex Williamson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20101105211646.19958.43832.stgit@s20.home \
    --to=alex.williamson@redhat.com \
    --cc=cam@cs.ualberta.ca \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).