aboutsummaryrefslogtreecommitdiff
path: root/savevm.c
diff options
context:
space:
mode:
authorJuan Quintela <quintela@redhat.com>2009-08-20 19:42:20 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-08-27 20:30:20 -0500
commit7b63034926351c58643a7e365581f719c70d6e8c (patch)
tree82ea946d1d606bee3bc5dd16afe449314649a193 /savevm.c
parentf0d99ad7116e9f6f62db6f7c7fa7b1fca8289b3c (diff)
downloadqemu-7b63034926351c58643a7e365581f719c70d6e8c.zip
qemu-7b63034926351c58643a7e365581f719c70d6e8c.tar.gz
qemu-7b63034926351c58643a7e365581f719c70d6e8c.tar.bz2
split do_loadvm() into do_loadvm() and load_vmstate()
do_loadvm() is now called from the monitor. load_vmstate() is called by do_loadvm() and when -loadvm command line is used. Command line don't have to play games with vmstop()/vmstart() Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'savevm.c')
-rw-r--r--savevm.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/savevm.c b/savevm.c
index 4575653..95947a9 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1174,14 +1174,13 @@ void do_savevm(Monitor *mon, const char *name)
vm_start();
}
-void do_loadvm(Monitor *mon, const char *name)
+void load_vmstate(Monitor *mon, const char *name)
{
DriveInfo *dinfo;
BlockDriverState *bs, *bs1;
QEMUSnapshotInfo sn;
QEMUFile *f;
int ret;
- int saved_vm_running;
bs = get_bs_snapshots();
if (!bs) {
@@ -1192,9 +1191,6 @@ void do_loadvm(Monitor *mon, const char *name)
/* Flush all IO requests so they don't interfere with the new state. */
qemu_aio_flush();
- saved_vm_running = vm_running;
- vm_stop(0);
-
TAILQ_FOREACH(dinfo, &drives, next) {
bs1 = dinfo->bdrv;
if (bdrv_has_snapshot(bs1)) {
@@ -1220,7 +1216,7 @@ void do_loadvm(Monitor *mon, const char *name)
}
/* fatal on snapshot block device */
if (bs == bs1)
- goto the_end;
+ return;
}
}
}
@@ -1228,20 +1224,28 @@ void do_loadvm(Monitor *mon, const char *name)
/* Don't even try to load empty VM states */
ret = bdrv_snapshot_find(bs, &sn, name);
if ((ret >= 0) && (sn.vm_state_size == 0))
- goto the_end;
+ return;
/* restore the VM state */
f = qemu_fopen_bdrv(bs, 0);
if (!f) {
monitor_printf(mon, "Could not open VM state file\n");
- goto the_end;
+ return;
}
ret = qemu_loadvm_state(f);
qemu_fclose(f);
if (ret < 0) {
monitor_printf(mon, "Error %d while loading VM state\n", ret);
}
- the_end:
+}
+
+void do_loadvm(Monitor *mon, const char *name)
+{
+ int saved_vm_running = vm_running;
+
+ vm_stop(0);
+
+ load_vmstate(mon, name);
if (saved_vm_running)
vm_start();
}