1 Index: 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
7 static void block_state_put_ready(void *opaque)
13 if (snap_state.state != SAVE_STATE_ACTIVE) {
18 - if (!runstate_check(RUN_STATE_SAVE_VM)) {
19 - save_snapshot_error("put_ready returning because of wrong run state");
21 + ret = qemu_savevm_state_iterate(snap_state.file);
22 + remaining = ram_bytes_remaining();
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);
33 - ret = qemu_savevm_state_iterate(snap_state.file);
35 save_snapshot_error("qemu_savevm_state_iterate error %d", ret);
37 } else if (ret == 1) {
38 + if (runstate_is_running()) {
39 + vm_stop(RUN_STATE_SAVE_VM);
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);
45 snap_state.error = NULL;
49 - vm_stop(RUN_STATE_SAVE_VM);
52 + vm_stop(RUN_STATE_SAVE_VM);
53 snap_state.state = SAVE_STATE_COMPLETED;