From d592fd72a6afc1b620ebf0e8820d8e09d2d907d5 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Mon, 24 Sep 2012 08:04:20 +0200 Subject: [PATCH] experimental patch to keep vm running during snapshot creation --- debian/patches/savevm-live.patch | 55 ++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 debian/patches/savevm-live.patch diff --git a/debian/patches/savevm-live.patch b/debian/patches/savevm-live.patch new file mode 100644 index 0000000..c949910 --- /dev/null +++ b/debian/patches/savevm-live.patch @@ -0,0 +1,55 @@ +Index: new/savevm-async.c +=================================================================== +--- new.orig/savevm-async.c 2012-09-24 07:59:38.000000000 +0200 ++++ new/savevm-async.c 2012-09-24 08:03:38.000000000 +0200 +@@ -151,6 +151,8 @@ + + static void block_state_put_ready(void *opaque) + { ++ uint64_t remaining; ++ int64_t maxlen; + int ret; + + if (snap_state.state != SAVE_STATE_ACTIVE) { +@@ -158,16 +160,25 @@ + return; + } + +- if (!runstate_check(RUN_STATE_SAVE_VM)) { +- save_snapshot_error("put_ready returning because of wrong run state"); +- return; ++ ret = qemu_savevm_state_iterate(snap_state.file); ++ remaining = ram_bytes_remaining(); ++ ++ // stop if we get to the end of available space, ++ // or if remaining is just a few MB ++ maxlen = bdrv_getlength(snap_state.bs) - 30*1024*1024; ++ if ((remaining < 100000) || ((snap_state.bs_pos + remaining) >= maxlen)) { ++ if (runstate_is_running()) { ++ vm_stop(RUN_STATE_SAVE_VM); ++ } + } + +- ret = qemu_savevm_state_iterate(snap_state.file); + if (ret < 0) { + save_snapshot_error("qemu_savevm_state_iterate error %d", ret); + return; + } else if (ret == 1) { ++ if (runstate_is_running()) { ++ vm_stop(RUN_STATE_SAVE_VM); ++ } + DPRINTF("savevm inerate finished\n"); + if ((ret = qemu_savevm_state_complete(snap_state.file)) < 0) { + save_snapshot_error("qemu_savevm_state_complete error %d", ret); +@@ -211,10 +222,8 @@ + snap_state.error = NULL; + } + +- /* stop the VM */ +- vm_stop(RUN_STATE_SAVE_VM); +- + if (!has_statefile) { ++ vm_stop(RUN_STATE_SAVE_VM); + snap_state.state = SAVE_STATE_COMPLETED; + return; + } -- 2.39.2