]> git.proxmox.com Git - pve-qemu-kvm.git/commitdiff
activate savevm-live.patch patch
authorDietmar Maurer <dietmar@proxmox.com>
Mon, 24 Sep 2012 08:38:52 +0000 (10:38 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 24 Sep 2012 08:38:52 +0000 (10:38 +0200)
white space cleanups

debian/patches/series
new/savevm-async.c

index b5208b007b18bd4433e81398a4e2d205055d9faf..8470f587189e7447506882c7fdddac31a436dd9a 100644 (file)
@@ -12,3 +12,4 @@ sheepdog-fix-savevm-loadvm.patch
 fix-qemu-img-snapshot-removal.patch
 move-bdrv-snapshot-find.patch
 internal-snapshot-async.patch
+savevm-live.patch
index 6e81fd794a27c5e2e9016bf80ce4e18c276516c4..7081019d591a6af64b673366e6f1f92a1994aa14 100644 (file)
@@ -151,6 +151,8 @@ static ssize_t block_state_put_buffer(void *opaque, const void *buf,
 
 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 @@ static void block_state_put_ready(void *opaque)
         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 @@ void qmp_savevm_start(bool has_statefile, const char *statefile, Error **errp)
         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;
     }