aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Quintela <quintela@redhat.com>2011-09-22 11:02:14 +0200
committerJuan Quintela <quintela@redhat.com>2011-10-20 13:23:52 +0200
commit3934638539c763ad23026b70483e60be34078c57 (patch)
tree33dac9d54aa032ebb45313d55997d9f87823f88b
parentdcd1d224dfcad1154a516e683ab55ea848497f50 (diff)
migration: return real error code
make functions propagate errno, instead of just using -EIO. Add a comment about what are the return value of qemu_savevm_state_iterate(). Signed-off-by: Juan Quintela <quintela@redhat.com>
-rw-r--r--migration.c6
-rw-r--r--savevm.c39
2 files changed, 26 insertions, 19 deletions
diff --git a/migration.c b/migration.c
index d5876a9d93..c1d647c102 100644
--- a/migration.c
+++ b/migration.c
@@ -367,6 +367,7 @@ void migrate_fd_connect(FdMigrationState *s)
void migrate_fd_put_ready(void *opaque)
{
FdMigrationState *s = opaque;
+ int ret;
if (s->state != MIG_STATE_ACTIVE) {
DPRINTF("put_ready returning because of non-active state\n");
@@ -374,7 +375,10 @@ void migrate_fd_put_ready(void *opaque)
}
DPRINTF("iterate\n");
- if (qemu_savevm_state_iterate(s->mon, s->file) == 1) {
+ ret = qemu_savevm_state_iterate(s->mon, s->file);
+ if (ret < 0) {
+ migrate_fd_error(s);
+ } else if (ret == 1) {
int old_vm_running = runstate_is_running();
DPRINTF("done iterating\n");
diff --git a/savevm.c b/savevm.c
index 5bef618516..b2f22bdc82 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1504,6 +1504,7 @@ 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) {
@@ -1535,15 +1536,21 @@ int qemu_savevm_state_begin(Monitor *mon, QEMUFile *f, int blk_enable,
se->save_live_state(mon, f, QEMU_VM_SECTION_START, se->opaque);
}
-
- if (qemu_file_has_error(f)) {
+ ret = qemu_file_has_error(f);
+ if (ret != 0) {
qemu_savevm_state_cancel(mon, f);
- return -EIO;
}
- return 0;
+ return ret;
+
}
+/*
+ * this funtion has three return values:
+ * negative: there was one error, and we have -errno.
+ * 0 : We haven't finished, caller have to go again
+ * 1 : We have finished, we can go to complete phase
+ */
int qemu_savevm_state_iterate(Monitor *mon, QEMUFile *f)
{
SaveStateEntry *se;
@@ -1566,16 +1573,14 @@ int qemu_savevm_state_iterate(Monitor *mon, QEMUFile *f)
break;
}
}
-
- if (ret)
- return 1;
-
- if (qemu_file_has_error(f)) {
+ if (ret != 0) {
+ return ret;
+ }
+ ret = qemu_file_has_error(f);
+ if (ret != 0) {
qemu_savevm_state_cancel(mon, f);
- return -EIO;
}
-
- return 0;
+ return ret;
}
int qemu_savevm_state_complete(Monitor *mon, QEMUFile *f)
@@ -1618,10 +1623,7 @@ int qemu_savevm_state_complete(Monitor *mon, QEMUFile *f)
qemu_put_byte(f, QEMU_VM_EOF);
- if (qemu_file_has_error(f))
- return -EIO;
-
- return 0;
+ return qemu_file_has_error(f);
}
void qemu_savevm_state_cancel(Monitor *mon, QEMUFile *f)
@@ -1661,8 +1663,9 @@ static int qemu_savevm_state(Monitor *mon, QEMUFile *f)
ret = qemu_savevm_state_complete(mon, f);
out:
- if (qemu_file_has_error(f))
- ret = -EIO;
+ if (ret == 0) {
+ ret = qemu_file_has_error(f);
+ }
if (!ret && saved_vm_running)
vm_start();