aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorSteven Hand <steven@xensource.com>2007-05-14 15:19:46 +0100
committerSteven Hand <steven@xensource.com>2007-05-14 15:19:46 +0100
commit415b7c6f46c5b0f4b2a58bbc4a000379c5503abb (patch)
tree09d45c99f123487ea7b2e125d45398ded7cd7d6e /tools
parentf0c155875d0b59e356288ee4bf2ceeeadcb99461 (diff)
downloadxen-415b7c6f46c5b0f4b2a58bbc4a000379c5503abb.tar.gz
xen-415b7c6f46c5b0f4b2a58bbc4a000379c5503abb.tar.bz2
xen-415b7c6f46c5b0f4b2a58bbc4a000379c5503abb.zip
Fix HVM save/restore after upgrade to 0.90.
Signed-off-by: Steven Hand <steven@xensource.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/ioemu/vl.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/tools/ioemu/vl.c b/tools/ioemu/vl.c
index 75d49f5c00..32d5163b4e 100644
--- a/tools/ioemu/vl.c
+++ b/tools/ioemu/vl.c
@@ -4891,6 +4891,77 @@ static int bdrv_snapshot_find(BlockDriverState *bs, QEMUSnapshotInfo *sn_info,
return ret;
}
+#ifdef CONFIG_DM
+/* We use simpler state save/load functions for Xen */
+void do_savevm(const char *name)
+{
+ QEMUFile *f;
+ int saved_vm_running, ret;
+
+ f = qemu_fopen(name, "wb");
+
+ /* ??? Should this occur after vm_stop? */
+ qemu_aio_flush();
+
+ saved_vm_running = vm_running;
+ vm_stop(0);
+
+ if (!f) {
+ fprintf(logfile, "Failed to open savevm file '%s'\n", name);
+ goto the_end;
+ }
+
+ ret = qemu_savevm_state(f);
+ qemu_fclose(f);
+
+ if (ret < 0)
+ fprintf(logfile, "Error %d while writing VM to savevm file '%s'\n",
+ ret, name);
+
+ the_end:
+ if (saved_vm_running)
+ vm_start();
+
+ return;
+}
+void do_loadvm(const char *name)
+{
+ QEMUFile *f;
+ int saved_vm_running, ret;
+
+ /* Flush all IO requests so they don't interfere with the new state. */
+ qemu_aio_flush();
+
+ saved_vm_running = vm_running;
+ vm_stop(0);
+
+ /* restore the VM state */
+ f = qemu_fopen(name, "rb");
+ if (!f) {
+ fprintf(logfile, "Could not open VM state file\n");
+ goto the_end;
+ }
+
+ ret = qemu_loadvm_state(f);
+ qemu_fclose(f);
+ if (ret < 0) {
+ fprintf(logfile, "Error %d while loading savevm file '%s'\n",
+ ret, name);
+ goto the_end;
+ }
+
+#if 0
+ /* del tmp file */
+ if (unlink(name) == -1)
+ fprintf(stderr, "delete tmp qemu state file failed.\n");
+#endif
+
+
+ the_end:
+ if (saved_vm_running)
+ vm_start();
+}
+#else
void do_savevm(const char *name)
{
BlockDriverState *bs, *bs1;
@@ -5064,6 +5135,7 @@ void do_loadvm(const char *name)
if (saved_vm_running)
vm_start();
}
+#endif
void do_delvm(const char *name)
{