Index: /trunk/src/VBox/Main/ConsoleImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/ConsoleImpl.cpp	(revision 299)
+++ /trunk/src/VBox/Main/ConsoleImpl.cpp	(revision 300)
@@ -3020,4 +3020,8 @@
             {
                 rc = E_FAIL;
+            }
+            else
+            {
+                mConsoleVRDPServer->SetCallback ();
             }
         }
@@ -6168,24 +6172,10 @@
         }
 
-        /*
-         * Create the VM
-         */
-        PVM pVM;
-        /*
-         *  leave the lock since EMT will call Console. It's safe because
-         *  mMachineState is either Starting or Restoring state here.
-         */
-        alock.leave();
-
-        vrc = VMR3Create (task->mSetVMErrorCallback, task.get(),
-                          task->mConfigConstructor, task.get(),
-                          &pVM);
-
-        alock.enter();
-
 #ifdef VBOX_VRDP
         if (VBOX_SUCCESS (vrc))
         {
-            /* Start the VRDP server after the VM is created. */
+            /* Create the VRDP server. In case of headless operation, this will
+             * also create the framebuffer, required at VM creation.
+             */
             ConsoleVRDPServer *server = console->consoleVRDPServer();
             Assert (server);
@@ -6216,5 +6206,30 @@
                          vrc, errMsg.raw()));
                 hrc = setError (E_FAIL, errMsg);
+                break;
             }
+        }
+#endif /* VBOX_VRDP */
+
+        /*
+         * Create the VM
+         */
+        PVM pVM;
+        /*
+         *  leave the lock since EMT will call Console. It's safe because
+         *  mMachineState is either Starting or Restoring state here.
+         */
+        alock.leave();
+
+        vrc = VMR3Create (task->mSetVMErrorCallback, task.get(),
+                          task->mConfigConstructor, task.get(),
+                          &pVM);
+
+        alock.enter();
+
+#ifdef VBOX_VRDP
+        {
+            /* Enable client connections to the server. */
+            ConsoleVRDPServer *server = console->consoleVRDPServer();
+            server->SetCallback ();
         }
 #endif /* VBOX_VRDP */
Index: /trunk/src/VBox/Main/ConsoleVRDPServer.cpp
===================================================================
--- /trunk/src/VBox/Main/ConsoleVRDPServer.cpp	(revision 299)
+++ /trunk/src/VBox/Main/ConsoleVRDPServer.cpp	(revision 300)
@@ -127,6 +127,4 @@
                 framebuffer? VRDP_EXTERNAL_FRAMEBUFFER: VRDP_INTERNAL_FRAMEBUFFER);
 
-            mpfnVRDPSetCallback (mhServer, mConsole->getVrdpServerCallback (), mConsole);
-
             LogFlow(("Framebuffer %p set for the VRDP server\n", framebuffer));
             
@@ -144,4 +142,13 @@
 #endif
     return rc;
+}
+
+void ConsoleVRDPServer::SetCallback (void)
+{
+    /* This is called after VM is created and allows the server to accept client connection. */
+    if (mhServer && mpfnVRDPSetCallback)
+    {
+        mpfnVRDPSetCallback (mhServer, mConsole->getVrdpServerCallback (), mConsole);
+    }
 }
 
Index: /trunk/src/VBox/Main/include/ConsoleVRDPServer.h
===================================================================
--- /trunk/src/VBox/Main/include/ConsoleVRDPServer.h	(revision 299)
+++ /trunk/src/VBox/Main/include/ConsoleVRDPServer.h	(revision 300)
@@ -38,4 +38,5 @@
 
     int Launch (void);
+    void SetCallback (void);
     void Stop (void);
 
