Index: /trunk/src/VBox/Frontends/VBoxManage/VBoxManageControlVM.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VBoxManage/VBoxManageControlVM.cpp	(revision 41924)
+++ /trunk/src/VBox/Frontends/VBoxManage/VBoxManageControlVM.cpp	(revision 41925)
@@ -162,4 +162,32 @@
 
             CHECK_ERROR_BREAK(sessionMachine, COMSETTER(CPUExecutionCap)(n));
+        }
+        else if (!strcmp(a->argv[1], "clipboard"))
+        {
+            if (a->argc <= 1 + 1)
+            {
+                errorArgument("Missing argument to '%s'. Expected clipboard mode.", a->argv[1]);
+                rc = E_FAIL;
+                break;
+            }
+
+            ClipboardMode_T mode;
+            if (!strcmp(a->argv[2], "disabled"))
+                mode = ClipboardMode_Disabled;
+            else if (!strcmp(a->argv[2], "hosttoguest"))
+                mode = ClipboardMode_HostToGuest;
+            else if (!strcmp(a->argv[2], "guesttohost"))
+                mode = ClipboardMode_GuestToHost;
+            else if (!strcmp(a->argv[2], "bidirectional"))
+                mode = ClipboardMode_Bidirectional;
+            else
+            {
+                errorArgument("Invalid '%s' argument '%s'.", a->argv[1], a->argv[2]);
+                rc = E_FAIL;
+            }
+            if (SUCCEEDED(rc))
+            {
+                CHECK_ERROR_BREAK(sessionMachine, COMSETTER(ClipboardMode)(mode));
+            }
         }
         else if (!strcmp(a->argv[1], "poweroff"))
Index: /trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp	(revision 41924)
+++ /trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp	(revision 41925)
@@ -420,12 +420,11 @@
                      "                            gueststatisticsinterval <seconds>]\n"
                      "                            usbattach <uuid>|<address> |\n"
-                     "                            usbdetach <uuid>|<address> |\n");
-        RTStrmPrintf(pStrm,
-                     "                            vrde on|off |\n");
-        RTStrmPrintf(pStrm,
+                     "                            usbdetach <uuid>|<address> |\n"
+                     "                            clipboard disabled|hosttoguest|guesttohost|\n"
+                     "                                         bidirectional]\n"
+                     "                            vrde on|off |\n"
                      "                            vrdeport <port> |\n"
                      "                            vrdeproperty <name=[value]> |\n"
-                     "                            vrdevideochannelquality <percent>\n");
-        RTStrmPrintf(pStrm,
+                     "                            vrdevideochannelquality <percent>\n"
                      "                            setvideomodehint <xres> <yres> <bpp> [display] |\n"
                      "                            screenshotpng <file> [display] |\n"
Index: /trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp	(revision 41924)
+++ /trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp	(revision 41925)
@@ -1954,24 +1954,21 @@
             case MODIFYVM_CLIPBOARD:
             {
+                ClipboardMode_T mode;
                 if (!strcmp(ValueUnion.psz, "disabled"))
-                {
-                    CHECK_ERROR(machine, COMSETTER(ClipboardMode)(ClipboardMode_Disabled));
-                }
+                    mode = ClipboardMode_Disabled;
                 else if (!strcmp(ValueUnion.psz, "hosttoguest"))
-                {
-                    CHECK_ERROR(machine, COMSETTER(ClipboardMode)(ClipboardMode_HostToGuest));
-                }
+                    mode = ClipboardMode_HostToGuest;
                 else if (!strcmp(ValueUnion.psz, "guesttohost"))
-                {
-                    CHECK_ERROR(machine, COMSETTER(ClipboardMode)(ClipboardMode_GuestToHost));
-                }
+                    mode = ClipboardMode_GuestToHost;
                 else if (!strcmp(ValueUnion.psz, "bidirectional"))
-                {
-                    CHECK_ERROR(machine, COMSETTER(ClipboardMode)(ClipboardMode_Bidirectional));
-                }
+                    mode = ClipboardMode_Bidirectional;
                 else
                 {
                     errorArgument("Invalid --clipboard argument '%s'", ValueUnion.psz);
                     rc = E_FAIL;
+                }
+                if (SUCCEEDED(rc))
+                {
+                    CHECK_ERROR(machine, COMSETTER(ClipboardMode)(mode));
                 }
                 break;
Index: /trunk/src/VBox/Main/idl/VirtualBox.xidl
===================================================================
--- /trunk/src/VBox/Main/idl/VirtualBox.xidl	(revision 41924)
+++ /trunk/src/VBox/Main/idl/VirtualBox.xidl	(revision 41925)
@@ -14722,5 +14722,5 @@
   <interface
     name="IInternalSessionControl" extends="$unknown"
-    uuid="c2b4cd5f-d3ce-4dd6-b915-123272163ef5"
+    uuid="9ddb5449-f463-47cb-a717-d6f22da3b3a2"
     internal="yes"
     wsmap="suppress"
@@ -14913,4 +14913,13 @@
       <param name="remove" type="boolean" dir="in">
         <desc>TRUE if the device is removed, FALSE if it was added.</desc>
+      </param>
+    </method>
+    
+    <method name="onClipboardModeChange">
+      <desc>
+        Notification when the shared clipboard mode changes.
+      </desc>
+      <param name="clipboardMode" type="ClipboardMode" dir="in">
+        <desc>The new shared clipboard mode.</desc>
       </param>
     </method>
@@ -16665,5 +16674,5 @@
   <enum
     name="VBoxEventType"
-    uuid="cce48db6-8561-479d-8d46-1358bab45d4e"
+    uuid="100cf5c8-7dd4-4600-8d75-636d211479c9"
     >
 
@@ -16923,7 +16932,12 @@
       </desc>
     </const>
+    <const name="OnClipboardModeChanged" value="72">
+      <desc>
+        See <link to="IClipboardModeChangedEvent">IClipboardModeChangedEvent</link>.
+      </desc>
+    </const>
 
     <!-- Last event marker -->
-    <const name="Last" value="72">
+    <const name="Last" value="73">
       <desc>
         Must be last event, used for iterations and structures relying on numerical event values.
@@ -17666,4 +17680,19 @@
       <desc>
         Medium attachment that is subject to change.
+      </desc>
+    </attribute>
+  </interface>
+
+  <interface
+    name="IClipboardModeChangedEvent" extends="IEvent"
+    uuid="cac21692-7997-4595-a731-3a509db604e5"
+    wsmap="managed" autogen="VBoxEvent" id="OnClipboardModeChanged"
+    >
+    <desc>
+      Notification when the shared clipboard mode changes.
+    </desc>
+    <attribute name="clipboardMode" type="ClipboardMode" readonly="yes">
+      <desc>
+        The new clipboard mode.
       </desc>
     </attribute>
Index: /trunk/src/VBox/Main/include/ConsoleImpl.h
===================================================================
--- /trunk/src/VBox/Main/include/ConsoleImpl.h	(revision 41924)
+++ /trunk/src/VBox/Main/include/ConsoleImpl.h	(revision 41925)
@@ -197,4 +197,5 @@
     HRESULT onCPUChange(ULONG aCPU, BOOL aRemove);
     HRESULT onCPUExecutionCapChange(ULONG aExecutionCap);
+    HRESULT onClipboardModeChange(ClipboardMode_T aClipboardMode);
     HRESULT onVRDEServerChange(BOOL aRestart);
     HRESULT onUSBControllerChange();
@@ -600,4 +601,6 @@
                                                      INetworkAdapter *aNetworkAdapter);
 
+    void changeClipboardMode(ClipboardMode_T aClipboardMode);
+
 #ifdef VBOX_WITH_USB
     HRESULT attachUSBDevice(IUSBDevice *aHostDevice, ULONG aMaskedIfs);
Index: /trunk/src/VBox/Main/include/MachineImpl.h
===================================================================
--- /trunk/src/VBox/Main/include/MachineImpl.h	(revision 41924)
+++ /trunk/src/VBox/Main/include/MachineImpl.h	(revision 41925)
@@ -687,4 +687,5 @@
     virtual HRESULT onMediumChange(IMediumAttachment * /* mediumAttachment */, BOOL /* force */) { return S_OK; }
     virtual HRESULT onSharedFolderChange() { return S_OK; }
+    virtual HRESULT onClipboardModeChange(ClipboardMode_T /* aClipboardMode */) { return S_OK; }
     virtual HRESULT onBandwidthGroupChange(IBandwidthGroup * /* aBandwidthGroup */) { return S_OK; }
     virtual HRESULT onStorageDeviceChange(IMediumAttachment * /* mediumAttachment */, BOOL /* remove */) { return S_OK; }
@@ -1072,4 +1073,5 @@
                               IVirtualBoxErrorInfo *aError);
     HRESULT onSharedFolderChange();
+    HRESULT onClipboardModeChange(ClipboardMode_T aClipboardMode);
     HRESULT onBandwidthGroupChange(IBandwidthGroup *aBandwidthGroup);
     HRESULT onStorageDeviceChange(IMediumAttachment *aMediumAttachment, BOOL aRemove);
Index: /trunk/src/VBox/Main/include/SessionImpl.h
===================================================================
--- /trunk/src/VBox/Main/include/SessionImpl.h	(revision 41924)
+++ /trunk/src/VBox/Main/include/SessionImpl.h	(revision 41925)
@@ -95,4 +95,5 @@
     STDMETHOD(OnUSBControllerChange)();
     STDMETHOD(OnSharedFolderChange)(BOOL aGlobal);
+    STDMETHOD(OnClipboardModeChange)(ClipboardMode_T aClipboardMode);
     STDMETHOD(OnUSBDeviceAttach)(IUSBDevice *aDevice, IVirtualBoxErrorInfo *aError, ULONG aMaskedIfs);
     STDMETHOD(OnUSBDeviceDetach)(IN_BSTR aId, IVirtualBoxErrorInfo *aError);
Index: /trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/ConsoleImpl.cpp	(revision 41924)
+++ /trunk/src/VBox/Main/src-client/ConsoleImpl.cpp	(revision 41925)
@@ -4847,4 +4847,44 @@
         alock.release();
         fireCPUExecutionCapChangedEvent(mEventSource, aExecutionCap);
+    }
+
+    LogFlowThisFunc(("Leaving rc=%#x\n", rc));
+    return rc;
+}
+
+/**
+ * Called by IInternalSessionControl::OnClipboardModeChange().
+ *
+ * @note Locks this object for writing.
+ */
+HRESULT Console::onClipboardModeChange(ClipboardMode_T aClipboardMode)
+{
+    LogFlowThisFunc(("\n"));
+
+    AutoCaller autoCaller(this);
+    AssertComRCReturnRC(autoCaller.rc());
+
+    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
+
+    HRESULT rc = S_OK;
+
+    /* don't trigger the Clipboard mode change if the VM isn't running */
+    SafeVMPtrQuiet ptrVM(this);
+    if (ptrVM.isOk())
+    {
+        if (   mMachineState == MachineState_Running
+            || mMachineState == MachineState_Teleporting
+            || mMachineState == MachineState_LiveSnapshotting)
+            changeClipboardMode(aClipboardMode);
+        else
+            rc = setInvalidMachineStateError();
+        ptrVM.release();
+    }
+
+    /* notify console callbacks on success */
+    if (SUCCEEDED(rc))
+    {
+        alock.release();
+        fireClipboardModeChangedEvent(mEventSource, aClipboardMode);
     }
 
@@ -7627,4 +7667,41 @@
             break;
     }
+}
+
+/**
+ * Changes the clipboard mode.
+ *
+ * @param aClipboardMode  new clipboard mode.
+ */
+void Console::changeClipboardMode(ClipboardMode_T aClipboardMode)
+{
+    VMMDev *pVMMDev = m_pVMMDev;
+    Assert(pVMMDev);
+
+    VBOXHGCMSVCPARM parm;
+    parm.type = VBOX_HGCM_SVC_PARM_32BIT;
+
+    switch (aClipboardMode)
+    {
+        default:
+        case ClipboardMode_Disabled:
+            LogRel(("VBoxSharedClipboard mode: Off\n"));
+            parm.u.uint32 = VBOX_SHARED_CLIPBOARD_MODE_OFF;
+            break;
+        case ClipboardMode_GuestToHost:
+            LogRel(("VBoxSharedClipboard mode: Guest to Host\n"));
+            parm.u.uint32 = VBOX_SHARED_CLIPBOARD_MODE_GUEST_TO_HOST;
+            break;
+        case ClipboardMode_HostToGuest:
+            LogRel(("VBoxSharedClipboard mode: Host to Guest\n"));
+            parm.u.uint32 = VBOX_SHARED_CLIPBOARD_MODE_HOST_TO_GUEST;
+            break;
+        case ClipboardMode_Bidirectional:
+            LogRel(("VBoxSharedClipboard mode: Bidirectional\n"));
+            parm.u.uint32 = VBOX_SHARED_CLIPBOARD_MODE_BIDIRECTIONAL;
+            break;
+    }
+
+    pVMMDev->hgcmHostCall("VBoxSharedClipboard", VBOX_SHARED_CLIPBOARD_HOST_FN_SET_MODE, 1, &parm);
 }
 
Index: /trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp	(revision 41924)
+++ /trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp	(revision 41925)
@@ -2438,5 +2438,5 @@
             hrc = pMachine->COMGETTER(ClipboardMode)(&mode);                                H();
 
-            if (mode != ClipboardMode_Disabled)
+            if (/* mode != ClipboardMode_Disabled */ true)
             {
                 /* Load the service */
@@ -2451,42 +2451,10 @@
                 else
                 {
+                    changeClipboardMode(mode);
+
                     /* Setup the service. */
                     VBOXHGCMSVCPARM parm;
-
                     parm.type = VBOX_HGCM_SVC_PARM_32BIT;
-
-                    switch (mode)
-                    {
-                        default:
-                        case ClipboardMode_Disabled:
-                        {
-                            LogRel(("VBoxSharedClipboard mode: Off\n"));
-                            parm.u.uint32 = VBOX_SHARED_CLIPBOARD_MODE_OFF;
-                            break;
-                        }
-                        case ClipboardMode_GuestToHost:
-                        {
-                            LogRel(("VBoxSharedClipboard mode: Guest to Host\n"));
-                            parm.u.uint32 = VBOX_SHARED_CLIPBOARD_MODE_GUEST_TO_HOST;
-                            break;
-                        }
-                        case ClipboardMode_HostToGuest:
-                        {
-                            LogRel(("VBoxSharedClipboard mode: Host to Guest\n"));
-                            parm.u.uint32 = VBOX_SHARED_CLIPBOARD_MODE_HOST_TO_GUEST;
-                            break;
-                        }
-                        case ClipboardMode_Bidirectional:
-                        {
-                            LogRel(("VBoxSharedClipboard mode: Bidirectional\n"));
-                            parm.u.uint32 = VBOX_SHARED_CLIPBOARD_MODE_BIDIRECTIONAL;
-                            break;
-                        }
-                    }
-
-                    pVMMDev->hgcmHostCall("VBoxSharedClipboard", VBOX_SHARED_CLIPBOARD_HOST_FN_SET_MODE, 1, &parm);
-
                     parm.setUInt32(!useHostClipboard());
-
                     pVMMDev->hgcmHostCall("VBoxSharedClipboard", VBOX_SHARED_CLIPBOARD_HOST_FN_SET_HEADLESS, 1, &parm);
 
Index: /trunk/src/VBox/Main/src-client/SessionImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/SessionImpl.cpp	(revision 41924)
+++ /trunk/src/VBox/Main/src-client/SessionImpl.cpp	(revision 41925)
@@ -657,4 +657,18 @@
 
     return mConsole->onSharedFolderChange(aGlobal);
+}
+
+STDMETHODIMP Session::OnClipboardModeChange(ClipboardMode_T aClipboardMode)
+{
+    LogFlowThisFunc(("\n"));
+
+    AutoCaller autoCaller(this);
+    AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
+
+    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
+    AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE);
+    AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE);
+
+    return mConsole->onClipboardModeChange(aClipboardMode);
 }
 
Index: /trunk/src/VBox/Main/src-server/MachineImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-server/MachineImpl.cpp	(revision 41924)
+++ /trunk/src/VBox/Main/src-server/MachineImpl.cpp	(revision 41925)
@@ -2562,10 +2562,10 @@
     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
 
-    HRESULT rc = checkStateDependency(MutableStateDep);
-    if (FAILED(rc)) return rc;
-
     setModified(IsModified_MachineData);
     mHWData.backup();
     mHWData->mClipboardMode = aClipboardMode;
+
+    alock.release();
+    onClipboardModeChange(aClipboardMode);
 
     return S_OK;
@@ -8360,5 +8360,5 @@
             uint32_t fFlags = guestProp::NILFLAG;
             guestProp::validateFlags(prop.strFlags.c_str(), &fFlags);
-            HWData::GuestProperty property = { prop.strName, prop.strValue, prop.timestamp, fFlags };
+            HWData::GuestProperty property = { prop.strName, prop.strValue, (LONG64) prop.timestamp, fFlags };
             mHWData->mGuestProperties.push_back(property);
         }
@@ -12746,4 +12746,27 @@
 
 /**
+ * @note Locks this object for reading.
+ */
+HRESULT SessionMachine::onClipboardModeChange(ClipboardMode_T aClipboardMode)
+{
+    LogFlowThisFunc(("\n"));
+
+    AutoCaller autoCaller(this);
+    AssertComRCReturnRC(autoCaller.rc());
+
+    ComPtr<IInternalSessionControl> directControl;
+    {
+        AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
+        directControl = mData->mSession.mDirectControl;
+    }
+
+    /* ignore notifications sent after #OnSessionEnd() is called */
+    if (!directControl)
+        return S_OK;
+
+    return directControl->OnClipboardModeChange(aClipboardMode);
+}
+
+/**
  *  @note Locks this object for reading.
  */
