Index: /trunk/include/VBox/err.h
===================================================================
--- /trunk/include/VBox/err.h	(revision 22806)
+++ /trunk/include/VBox/err.h	(revision 22807)
@@ -578,4 +578,13 @@
 /** Giving up a live snapshot attempt because we're low on disk space.  */
 #define VERR_SSM_LOW_ON_DISK_SPACE              (-1855)
+/** The machine was powered off while saving. */
+#define VERR_SSM_LIVE_POWERED_OFF               (-1856)
+/** The live snapshot/migration operation was cancelled. */
+#define VERR_SSM_LIVE_CANCELLED                 (-1857)
+/** The live snapshot/migration operation was aborted because of a guru
+ *  meditation. */
+#define VERR_SSM_LIVE_GURU_MEDITATION           (-1858)
+/** The VM was paused while saving, don't resume execution. */
+#define VINF_SSM_LIVE_PAUSED                    1859
 /** @} */
 
Index: /trunk/include/VBox/err.mac
===================================================================
--- /trunk/include/VBox/err.mac	(revision 22806)
+++ /trunk/include/VBox/err.mac	(revision 22807)
@@ -192,4 +192,13 @@
 %define VERR_SSM_GCPHYS_OVERFLOW    (-1849)
 %define VERR_SSM_GCPTR_OVERFLOW    (-1850)
+%define VINF_SSM_VOTE_FOR_ANOTHER_PASS    1851
+%define VERR_SSM_VOTE_FOR_GIVING_UP    (-1852)
+%define VERR_SSM_TOO_MANY_PASSES    (-1853)
+%define VERR_SSM_STATE_GREW_TOO_BIG    (-1854)
+%define VERR_SSM_LOW_ON_DISK_SPACE    (-1855)
+%define VERR_SSM_LIVE_POWERED_OFF    (-1856)
+%define VERR_SSM_LIVE_CANCELLED    (-1857)
+%define VERR_SSM_LIVE_GURU_MEDITATION    (-1858)
+%define VINF_SSM_LIVE_PAUSED    1859
 %define VERR_VM_ATRESET_NOT_FOUND    (-1900)
 %define VERR_VM_REQUEST_INVALID_TYPE    (-1901)
@@ -419,4 +428,5 @@
 %define VERR_SUPDRV_INTERFACE_NOT_SUPPORTED    (-3701)
 %define VERR_SUPDRV_SERVICE_NOT_FOUND    (-3702)
+%define VERR_SUPDRV_KERNEL_TOO_OLD_FOR_VTX    (-3703)
 %define VERR_GMM_SEED_ME    (-3800)
 %define VERR_GMM_OUT_OF_MEMORY    (-3801)
Index: /trunk/src/VBox/VMM/SSM.cpp
===================================================================
--- /trunk/src/VBox/VMM/SSM.cpp	(revision 22806)
+++ /trunk/src/VBox/VMM/SSM.cpp	(revision 22807)
@@ -49,8 +49,9 @@
  * Compared to normal saved stated and snapshots, the difference is in that the
  * VM is running while we do most of the saving.  Prior to LS, there was only
- * round of callback during saving, after LS there are 1 or more while the VM is
- * still running and a final one after it has been paused.  The runtime stages
- * is executed on a dedicated thread running at at the same priority as the EMTs
- * so that the saving doesn't starve or lose in scheduling questions.  The final
+ * one round of callbacks during saving and the VM was paused during it.  With
+ * LS there are 1 or more passes while the VM is still running and a final one
+ * after it has been paused.  The runtime passes are executed on a dedicated
+ * thread running at at the same priority as the EMTs so that the saving doesn't
+ * starve or lose in scheduling questions (note: not implemented yet). The final
  * pass is done on EMT(0).
  *
@@ -59,9 +60,18 @@
  *   - Takes too long (LM) / Too much output (LS).
  *
- * FIGURE THIS: It is currently unclear who will resume the VM after it has been
- * paused.  The most efficient way to do this is by doing it before returning
- * from the VMR3Save call and use a callback for reconfiguring the disk images.
- * (It is more efficient because of fewer thread switches.) The more convenient
- * way is to have main do it after calling VMR3Save.
+ *
+ * The live saving sequence is something like this:
+ *
+ *      -# SSMR3LiveToFile is called on EMT0.  It returns a saved state
+ *         handle.
+ *      -# SSMR3LiveDoStep1 is called on a non-EMT.  This will save the major
+ *         parts of the state while the VM may still be running.
+ *      -# The VM is suspended.
+ *      -# SSMR3LiveDoStep2 is called on EMT0 to save the remainder of the state
+ *         in the normal way.
+ *      -# The client does any necessary reconfiguration of harddisks and
+ *         similar.
+ *      -# SSMR3LiveDone is called on EMT0 to close the handle.
+ *      -# The VM is resumed or powered off and destroyed.
  *
  *
@@ -4039,5 +4049,7 @@
     pSSM->rc = VINF_SUCCESS;
     pSSM->enmOp = SSMSTATE_LIVE_EXEC;
-    for (PSSMUNIT pUnit = pVM->ssm.s.pHead; pUnit; pUnit = pUnit->pNext)
+    for (PSSMUNIT pUnit = pVM->ssm.s.pHead;
+         /** @todo VMR3GetState(pVM) == VMSTATE_LIVE_SAVING &&*/ pUnit;
+         pUnit = pUnit->pNext)
     {
         /*
@@ -4232,4 +4244,28 @@
             }
         }
+#if 0
+        /*
+         * Check the VM state to see if it has changed.
+         */
+        VMSTATE enmState = VMR3GetState(pVM);
+        if (enmState != VMSTATE_LIVE_SAVING)
+        {
+            switch (enmState)
+            {
+                case VMSTATE_LIVE_CANCELLED:
+                    LogRel(("SSM: Cancelled\n"));
+                    return pSSM->rc = VERR_SSM_LIVE_CANCELLED;
+                case VMSTATE_LIVE_POWERED_OFF:
+                    LogRel(("SSM: Powered off, no state to save, aborting.\n"));
+                    return pSSM->rc = VERR_SSM_LIVE_POWERED_OFF;
+                case VMSTATE_GURU_MEDITATION:
+                    LogRel(("SSM: Guru meditation, aborting.\n"));
+                    return pSSM->rc = VERR_SSM_LIVE_GURU_MEDITATION;
+                default:
+                    LogRel(("SSM: Invalid VM state transition: %d->%d\n", VMSTATE_LIVE_SAVING, enmState));
+                    return pSSM->rc = VERR_INTERNAL_ERROR_3;
+            }
+        }
+#endif
     }
 
@@ -4305,18 +4341,5 @@
  * Start saving the live state to a file.
  *
- * The live saving sequence is something like this:
- *
- *      -# SSMR3LiveToFile is called on EMT0.  It returns a saved state
- *         handle.
- *      -# SSMR3LiveDoStep1 is called on a non-EMT.  This will save the major
- *         parts of the state while the VM may still be running.
- *      -# The VM is suspended.
- *      -# SSMR3LiveDoStep2 is called on EMT0 to save the remainder of the state
- *         in the normal way.
- *      -# The client does any necessary reconfiguration of harddisks and
- *         similar.
- *      -# SSMR3LiveDone is called on EMT0 to close the handle.
- *      -# The VM is resumed or powered off and destroyed.
- *
+ * Call SSMR3LiveDoStep1, SSMR3LiveDoStep2 and finally SSMR3LiveDone on success.
  * SSMR3LiveDone should be called even if SSMR3LiveDoStep1 or SSMR3LiveDoStep2
  * fails.
