Index: /trunk/src/VBox/Main/ConsoleImpl-LiveMigration.cpp
===================================================================
--- /trunk/src/VBox/Main/ConsoleImpl-LiveMigration.cpp	(revision 23599)
+++ /trunk/src/VBox/Main/ConsoleImpl-LiveMigration.cpp	(revision 23599)
@@ -0,0 +1,41 @@
+/* $Id$ */
+/** @file
+ * VBox Console COM Class implementation, The Live Migration Part.
+ */
+
+/*
+ * Copyright (C) 2009 Sun Microsystems, Inc.
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
+ * Clara, CA 95054 USA or visit http://www.sun.com if you need
+ * additional information or have any questions.
+ */
+
+/*******************************************************************************
+*   Header Files                                                               *
+*******************************************************************************/
+#include "ConsoleImpl.h"
+#include "Logging.h"
+
+#include <VBox/vmapi.h>
+#include <VBox/ssm.h>
+#include <VBox/err.h>
+#include <VBox/version.h>
+#include <VBox/com/string.h>
+
+
+STDMETHODIMP
+Console::Migrate(IN_BSTR aHostname, ULONG aPort, IN_BSTR aPassword, IProgress **aProgress)
+{
+    return E_FAIL;
+}
+
+
Index: /trunk/src/VBox/Main/MachineImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/MachineImpl.cpp	(revision 23598)
+++ /trunk/src/VBox/Main/MachineImpl.cpp	(revision 23599)
@@ -155,4 +155,6 @@
 
     mNameSync = TRUE;
+    mLiveMigrationTarget = FALSE;
+    mLiveMigrationPort = 0;
 
     /* mName, mOSTypeId, mSnapshotFolder, mSnapshotFolderFull are initialized in
@@ -1817,5 +1819,5 @@
     mHWData->mGuestPropertyNotificationPatterns.cloneTo(aPatterns);
 
-    return RT_LIKELY (aPatterns != NULL) ? S_OK : E_OUTOFMEMORY;
+    return RT_LIKELY (aPatterns != NULL) ? S_OK : E_OUTOFMEMORY; /** @todo r=bird: this is wrong... :-) */
 }
 
@@ -1854,4 +1856,112 @@
     return S_OK;
 }
+
+STDMETHODIMP
+Machine::COMGETTER(LiveMigrationTarget)(BOOL *aEnabled)
+{
+    CheckComArgOutPointerValid(aEnabled);
+
+    AutoCaller autoCaller(this);
+    CheckComRCReturnRC(autoCaller.rc());
+
+    AutoReadLock alock(this);
+
+    *aEnabled = mUserData->mLiveMigrationTarget;
+
+    return S_OK;
+}
+
+STDMETHODIMP
+Machine::COMSETTER(LiveMigrationTarget)(BOOL aEnabled)
+{
+    AutoCaller autoCaller(this);
+    CheckComRCReturnRC(autoCaller.rc());
+
+    AutoWriteLock alock(this);
+
+    /* Only allow it to be set to true when PoweredOff.
+       (Clearing it is always permitted.) */
+    if (    aEnabled
+        &&  mData->mRegistered
+        &&  (   mType != IsSessionMachine
+             || mData->mMachineState > MachineState_PoweredOff)
+       )
+        return setError(VBOX_E_INVALID_VM_STATE,
+                        tr("The machine is not powered off (state is %d)"),
+                        mData->mMachineState);
+
+    mUserData.backup();
+    mUserData->mLiveMigrationTarget = aEnabled;
+
+    return S_OK;
+}
+
+STDMETHODIMP
+Machine::COMGETTER(LiveMigrationPort)(ULONG *aPort)
+{
+    CheckComArgOutPointerValid(aPort);
+
+    AutoCaller autoCaller(this);
+    CheckComRCReturnRC(autoCaller.rc());
+
+    AutoReadLock alock(this);
+
+    *aPort = mUserData->mLiveMigrationPort;
+
+    return S_OK;
+}
+
+STDMETHODIMP
+Machine::COMSETTER(LiveMigrationPort)(ULONG aPort)
+{
+    if (aPort >= _64K)
+        return setError(E_INVALIDARG, tr("Invalid port number %d"), aPort);
+
+    AutoCaller autoCaller(this);
+    CheckComRCReturnRC(autoCaller.rc());
+
+    AutoWriteLock alock(this);
+
+    HRESULT rc = checkStateDependency(MutableStateDep);
+    CheckComRCReturnRC(rc);
+
+    mUserData.backup();
+    mUserData->mLiveMigrationPort = aPort;
+
+    return S_OK;
+}
+
+STDMETHODIMP
+Machine::COMGETTER(LiveMigrationPassword)(BSTR *aPassword)
+{
+    CheckComArgOutPointerValid(aPassword);
+
+    AutoCaller autoCaller(this);
+    CheckComRCReturnRC(autoCaller.rc());
+
+    AutoReadLock alock(this);
+
+    mUserData->mLiveMigrationPassword.cloneTo(aPassword);
+
+    return S_OK;
+}
+
+STDMETHODIMP
+Machine::COMSETTER(LiveMigrationPassword)(IN_BSTR aPassword)
+{
+    AutoCaller autoCaller(this);
+    CheckComRCReturnRC(autoCaller.rc());
+
+    AutoWriteLock alock(this);
+
+    HRESULT rc = checkStateDependency(MutableStateDep);
+    CheckComRCReturnRC(rc);
+
+    mUserData.backup();
+    mUserData->mLiveMigrationPassword = aPassword;
+
+    return S_OK;
+}
+
 
 // IMachine methods
@@ -4922,4 +5032,5 @@
         mData->mLastStateChange = mData->m_pMachineConfigFile->timeLastStateChange;
 
+/** @todo LiveMigration: Load LiveMigration properties here. */
         /*
          *  note: all mUserData members must be assigned prior this point because
@@ -5911,4 +6022,5 @@
         mData->m_pMachineConfigFile->timeLastStateChange = mData->mLastStateChange;
         mData->m_pMachineConfigFile->fAborted = (mData->mMachineState == MachineState_Aborted);
+/** @todo LiveMigration: Save LiveMigration properties here. */
 
         rc = saveHardware(mData->m_pMachineConfigFile->hardwareMachine);
Index: /trunk/src/VBox/Main/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Main/Makefile.kmk	(revision 23598)
+++ /trunk/src/VBox/Main/Makefile.kmk	(revision 23599)
@@ -598,4 +598,5 @@
 	ConsoleImpl.cpp \
 	ConsoleImpl2.cpp \
+	ConsoleImpl-LiveMigration.cpp \
 	ConsoleVRDPServer.cpp \
 	GuestImpl.cpp \
Index: /trunk/src/VBox/Main/idl/VirtualBox.xidl
===================================================================
--- /trunk/src/VBox/Main/idl/VirtualBox.xidl	(revision 23598)
+++ /trunk/src/VBox/Main/idl/VirtualBox.xidl	(revision 23599)
@@ -4002,5 +4002,5 @@
   <interface
      name="IMachine" extends="$unknown"
-     uuid="445ecfcc-8ebd-a2a5-459c-4d21ae0b206b"
+     uuid="160b0ccc-c3d6-4c1b-bbe9-39b1a732f833"
      wsmap="managed"
      >
@@ -4491,4 +4491,32 @@
     </attribute>
 
+    <attribute name="liveMigrationTarget" type="boolean">
+      <desc>
+        When set to @a true, the virtual machine becomes a live migration
+        target.  This can only set to @a true when the VM is in the @a
+        PoweredOff state.
+
+        This property is automatically set to @a false when the VM is powered
+        on.
+      </desc>
+    </attribute>
+
+    <attribute name="liveMigrationPort" type="unsigned long">
+      <desc>
+        The TCP port used for live migration.  This can only be set when the
+        VM is in the @a PoweredOff state.
+
+        0 means the port is automatically selected and the source machine will
+        have to be told where to connected after the destination has been
+        started.
+      </desc>
+    </attribute>
+
+    <attribute name="liveMigrationPassword" type="wstring">
+      <desc>
+        The password the live migration target will check for.
+      </desc>
+    </attribute>
+
     <method name="setBootOrder">
       <desc>
@@ -5913,5 +5941,5 @@
   <interface
      name="IConsole" extends="$unknown"
-     uuid="0a51994b-cbc6-4686-94eb-d4e4023280e2"
+     uuid="c47486e1-3d99-4212-b1c5-86451978999d"
      wsmap="managed"
      >
@@ -6646,4 +6674,28 @@
         </result>
       </desc>
+      <param name="progress" type="IProgress" dir="return">
+        <desc>Progress object to track the operation completion.</desc>
+      </param>
+    </method>
+
+    <method name="migrate">
+      <desc>
+        Migrate the VM to a different host machine.
+
+        TODO explain the details.
+
+        <result name="VBOX_E_INVALID_VM_STATE">
+          Virtual machine not running or paused.
+        </result>
+      </desc>
+      <param name="hostname" type="wstring" dir="in">
+        <desc>The name or IP of the host to migrate to.</desc>
+      </param>
+      <param name="port" type="unsigned long" dir="in">
+        <desc>The TCP port to connect to (1..65535).</desc>
+      </param>
+      <param name="password" type="wstring" dir="in">
+        <desc>The password.</desc>
+      </param>
       <param name="progress" type="IProgress" dir="return">
         <desc>Progress object to track the operation completion.</desc>
Index: /trunk/src/VBox/Main/include/ConsoleImpl.h
===================================================================
--- /trunk/src/VBox/Main/include/ConsoleImpl.h	(revision 23598)
+++ /trunk/src/VBox/Main/include/ConsoleImpl.h	(revision 23599)
@@ -147,4 +147,5 @@
     STDMETHOD(DiscardCurrentState) (IProgress **aProgress);
     STDMETHOD(DiscardCurrentSnapshotAndState) (IProgress **aProgress);
+    STDMETHOD(Migrate)(IN_BSTR aHostname, ULONG aPort, IN_BSTR aPassword, IProgress **aProgress);
     STDMETHOD(RegisterCallback) (IConsoleCallback *aCallback);
     STDMETHOD(UnregisterCallback)(IConsoleCallback *aCallback);
Index: /trunk/src/VBox/Main/include/MachineImpl.h
===================================================================
--- /trunk/src/VBox/Main/include/MachineImpl.h	(revision 23598)
+++ /trunk/src/VBox/Main/include/MachineImpl.h	(revision 23599)
@@ -233,5 +233,8 @@
                     mDescription == that.mDescription &&
                     mOSTypeId == that.mOSTypeId &&
-                    mSnapshotFolderFull == that.mSnapshotFolderFull);
+                    mSnapshotFolderFull == that.mSnapshotFolderFull &&
+                    mLiveMigrationTarget == that.mLiveMigrationTarget &&
+                    mLiveMigrationPort == that.mLiveMigrationPort &&
+                    mLiveMigrationPassword == that.mLiveMigrationPassword);
         }
 
@@ -242,4 +245,7 @@
         Bstr    mSnapshotFolder;
         Bstr    mSnapshotFolderFull;
+        BOOL    mLiveMigrationTarget;
+        ULONG   mLiveMigrationPort;
+        Bstr    mLiveMigrationPassword;
     };
 
@@ -560,4 +566,10 @@
     STDMETHOD(COMSETTER(GuestPropertyNotificationPatterns))(IN_BSTR aPattern);
     STDMETHOD(COMGETTER(StorageControllers))(ComSafeArrayOut(IStorageController *, aStorageControllers));
+    STDMETHOD(COMGETTER(LiveMigrationTarget))(BOOL *aEnabled);
+    STDMETHOD(COMSETTER(LiveMigrationTarget))(BOOL aEnabled);
+    STDMETHOD(COMGETTER(LiveMigrationPort))(ULONG *aPort);
+    STDMETHOD(COMSETTER(LiveMigrationPort))(ULONG aPort);
+    STDMETHOD(COMGETTER(LiveMigrationPassword))(BSTR *aPassword);
+    STDMETHOD(COMSETTER(LiveMigrationPassword))(IN_BSTR aPassword);
 
     // IMachine methods
