Index: /trunk/src/VBox/VMM/SSM.cpp
===================================================================
--- /trunk/src/VBox/VMM/SSM.cpp	(revision 23904)
+++ /trunk/src/VBox/VMM/SSM.cpp	(revision 23905)
@@ -4751,7 +4751,5 @@
     pSSM->rc = VINF_SUCCESS;
     pSSM->enmOp = SSMSTATE_LIVE_EXEC;
-    for (PSSMUNIT pUnit = pVM->ssm.s.pHead;
-         /** @todo VMR3GetState(pVM) == VMSTATE_LIVE_SAVING &&*/ pUnit;
-         pUnit = pUnit->pNext)
+    for (PSSMUNIT pUnit = pVM->ssm.s.pHead; pUnit; pUnit = pUnit->pNext)
     {
         /*
@@ -4867,33 +4865,13 @@
 
 
-
-/**
- * Continue a live state saving operation on the worker thread.
- *
- * @returns VBox status.
- *
- * @param   pSSM            The SSM handle returned by SSMR3LiveSave.
- *
- * @thread  Non-EMT thread. Will involve the EMT at the end of the operation.
- */
-VMMR3_INT_DECL(int) SSMR3LiveDoStep1(PSSMHANDLE pSSM)
-{
-    LogFlow(("SSMR3LiveDoStep1: pSSM=%p\n", pSSM));
-
-    /*
-     * Validate input.
-     */
-    AssertPtrReturn(pSSM, VERR_INVALID_POINTER);
-    PVM pVM = pSSM->pVM;
-    VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
-    VM_ASSERT_OTHER_THREAD(pVM);
-    AssertMsgReturn(   pSSM->enmAfter == SSMAFTER_DESTROY
-                    || pSSM->enmAfter == SSMAFTER_CONTINUE
-                    || pSSM->enmAfter == SSMAFTER_TELEPORT,
-                    ("%d\n", pSSM->enmAfter),
-                    VERR_INVALID_PARAMETER);
-    AssertMsgReturn(pSSM->enmOp == SSMSTATE_LIVE_STEP1, ("%d\n", pSSM->enmOp), VERR_INVALID_STATE);
-    AssertRCReturn(pSSM->rc, pSSM->rc);
-
+/**
+ * Implements the live exec+vote loop.
+ *
+ * @returns VBox status code (no need to check pSSM->rc).
+ * @param   pVM                 The VM handle.
+ * @param   pSSM                The saved state handle.
+ */
+static int ssmR3DoLiveExecVoteLoop(PVM pVM, PSSMHANDLE pSSM)
+{
     /*
      * Calc the max saved state size before we should give up because of insane
@@ -4963,28 +4941,4 @@
             }
         }
-#if 0 /** @todo check this out... */
-        /*
-         * 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
     }
 
@@ -5058,4 +5012,42 @@
 
 /**
+ * Continue a live state saving operation on the worker thread.
+ *
+ * @returns VBox status.
+ *
+ * @param   pSSM            The SSM handle returned by SSMR3LiveSave.
+ *
+ * @thread  Non-EMT thread. Will involve the EMT at the end of the operation.
+ */
+VMMR3_INT_DECL(int) SSMR3LiveDoStep1(PSSMHANDLE pSSM)
+{
+    LogFlow(("SSMR3LiveDoStep1: pSSM=%p\n", pSSM));
+
+    /*
+     * Validate input.
+     */
+    AssertPtrReturn(pSSM, VERR_INVALID_POINTER);
+    PVM pVM = pSSM->pVM;
+    VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
+    VM_ASSERT_OTHER_THREAD(pVM);
+    AssertMsgReturn(   pSSM->enmAfter == SSMAFTER_DESTROY
+                    || pSSM->enmAfter == SSMAFTER_CONTINUE
+                    || pSSM->enmAfter == SSMAFTER_TELEPORT,
+                    ("%d\n", pSSM->enmAfter),
+                    VERR_INVALID_PARAMETER);
+    AssertMsgReturn(pSSM->enmOp == SSMSTATE_LIVE_STEP1, ("%d\n", pSSM->enmOp), VERR_INVALID_STATE);
+    AssertRCReturn(pSSM->rc, pSSM->rc);
+
+    /*
+     * Do the prep run, then the exec+vote cycle.
+     */
+    int rc = ssmR3DoLivePrepRun(pVM, pSSM);
+    if (RT_SUCCESS(rc))
+        rc = ssmR3DoLiveExecVoteLoop(pVM, pSSM);
+    return rc;
+}
+
+
+/**
  * Start saving the live state.
  *
@@ -5130,19 +5122,12 @@
     if (RT_SUCCESS(rc))
     {
-/** @todo If it turns out we don't need to do ssmR3DoLivePrepRun on EMT0,
- *        simply move the code to SSMR3LiveDoStep1.
- *  Update: This is certinaly the case, move it. */
-        rc = ssmR3DoLivePrepRun(pVM, pSSM);
-        if (RT_SUCCESS(rc))
-        {
-            /*
-             * Return and let the requstor thread do the pfnLiveExec/Vote part
-             * via SSMR3SaveFinishLive
-             */
-            pSSM->enmOp = SSMSTATE_LIVE_STEP1;
-            ssmR3SetCancellable(pVM, pSSM, true);
-            *ppSSM = pSSM;
-            return VINF_SUCCESS;
-        }
+        /*
+         * Return and let the requstor thread do the pfnLiveExec/Vote part
+         * via SSMR3SaveFinishLive
+         */
+        pSSM->enmOp = SSMSTATE_LIVE_STEP1;
+        ssmR3SetCancellable(pVM, pSSM, true);
+        *ppSSM = pSSM;
+        return VINF_SUCCESS;
     }
     /* bail out. */
@@ -5154,10 +5139,4 @@
 }
 
-
-VMMR3DECL(int) SSMR3LiveToRemote(PVM pVM, PFNVMPROGRESS pfnProgress, void *pvUser /*,
-                                 invent stream interface and stuff */)
-{
-    return VERR_NOT_IMPLEMENTED;
-}
 
 
