@@ -1145,14 +1145,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) {
@@ -1163,9 +1162,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)) {
@@ -1191,7 +1187,7 @@ void do_loadvm(Monitor *mon, const char *name)
}
/* fatal on snapshot block device */
if (bs == bs1)
- goto the_end;
+ return;
}
}
}
@@ -1199,20 +1195,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();
}
@@ -52,6 +52,7 @@ void qemu_system_reset(void);
void do_savevm(Monitor *mon, const char *name);
void do_loadvm(Monitor *mon, const char *name);
+void load_vmstate(Monitor *mon, const char *name);
void do_delvm(Monitor *mon, const char *name);
void do_info_snapshots(Monitor *mon);
@@ -6037,7 +6037,7 @@ int main(int argc, char **argv, char **envp)
}
if (loadvm)
- do_loadvm(cur_mon, loadvm);
+ load_vmstate(cur_mon, loadvm);
if (incoming) {
qemu_start_incoming_migration(incoming);
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> --- savevm.c | 22 +++++++++++++--------- sysemu.h | 1 + vl.c | 2 +- 3 files changed, 15 insertions(+), 10 deletions(-)