]> git.proxmox.com Git - pve-qemu-kvm.git/blame - debian/patches/savevm-live.patch
experimental patch to keep vm running during snapshot creation
[pve-qemu-kvm.git] / debian / patches / savevm-live.patch
CommitLineData
d592fd72
DM
1Index: new/savevm-async.c
2===================================================================
3--- new.orig/savevm-async.c 2012-09-24 07:59:38.000000000 +0200
4+++ new/savevm-async.c 2012-09-24 08:03:38.000000000 +0200
5@@ -151,6 +151,8 @@
6
7 static void block_state_put_ready(void *opaque)
8 {
9+ uint64_t remaining;
10+ int64_t maxlen;
11 int ret;
12
13 if (snap_state.state != SAVE_STATE_ACTIVE) {
14@@ -158,16 +160,25 @@
15 return;
16 }
17
18- if (!runstate_check(RUN_STATE_SAVE_VM)) {
19- save_snapshot_error("put_ready returning because of wrong run state");
20- return;
21+ ret = qemu_savevm_state_iterate(snap_state.file);
22+ remaining = ram_bytes_remaining();
23+
24+ // stop if we get to the end of available space,
25+ // or if remaining is just a few MB
26+ maxlen = bdrv_getlength(snap_state.bs) - 30*1024*1024;
27+ if ((remaining < 100000) || ((snap_state.bs_pos + remaining) >= maxlen)) {
28+ if (runstate_is_running()) {
29+ vm_stop(RUN_STATE_SAVE_VM);
30+ }
31 }
32
33- ret = qemu_savevm_state_iterate(snap_state.file);
34 if (ret < 0) {
35 save_snapshot_error("qemu_savevm_state_iterate error %d", ret);
36 return;
37 } else if (ret == 1) {
38+ if (runstate_is_running()) {
39+ vm_stop(RUN_STATE_SAVE_VM);
40+ }
41 DPRINTF("savevm inerate finished\n");
42 if ((ret = qemu_savevm_state_complete(snap_state.file)) < 0) {
43 save_snapshot_error("qemu_savevm_state_complete error %d", ret);
44@@ -211,10 +222,8 @@
45 snap_state.error = NULL;
46 }
47
48- /* stop the VM */
49- vm_stop(RUN_STATE_SAVE_VM);
50-
51 if (!has_statefile) {
52+ vm_stop(RUN_STATE_SAVE_VM);
53 snap_state.state = SAVE_STATE_COMPLETED;
54 return;
55 }