VBoxHeadless.cpp revision 82f1138515c9fc1b9a5c4fe0610486932448fcb3
5383c976362d5b18656cf7b9248b2063a764a203vboxsync * VBoxHeadless - The VirtualBox Headless frontend for running VMs on servers.
5383c976362d5b18656cf7b9248b2063a764a203vboxsync * Copyright (C) 2006-2012 Oracle Corporation
5383c976362d5b18656cf7b9248b2063a764a203vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
5383c976362d5b18656cf7b9248b2063a764a203vboxsync * available from http://www.virtualbox.org. This file is free software;
5383c976362d5b18656cf7b9248b2063a764a203vboxsync * you can redistribute it and/or modify it under the terms of the GNU
5383c976362d5b18656cf7b9248b2063a764a203vboxsync * General Public License (GPL) as published by the Free Software
5383c976362d5b18656cf7b9248b2063a764a203vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
5383c976362d5b18656cf7b9248b2063a764a203vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
5383c976362d5b18656cf7b9248b2063a764a203vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
5383c976362d5b18656cf7b9248b2063a764a203vboxsyncusing namespace com;
5383c976362d5b18656cf7b9248b2063a764a203vboxsync//#define VBOX_WITH_SAVESTATE_ON_SIGNAL
#include "Framebuffer.h"
#include "NullFramebuffer.h"
static volatile bool g_fTerminateFE = false;
virtual ~VirtualBoxClientEventListener()
return S_OK;
void uninit()
switch (aType)
if (!fAvailable)
g_fTerminateFE = true;
AssertFailed();
return S_OK;
class VirtualBoxEventListener
mfNoLoggedInUsers = true;
virtual ~VirtualBoxEventListener()
return S_OK;
void uninit()
switch (aType)
if (gConsole)
bool fDropConnection = false;
mfNoLoggedInUsers = true;
fDropConnection = true;
mfNoLoggedInUsers = false;
fDropConnection = true;
if (fDropConnection)
AssertFailed();
return S_OK;
bool mfNoLoggedInUsers;
class ConsoleEventListener
m_fIgnorePowerOffEvents(false)
virtual ~ConsoleEventListener()
return S_OK;
void uninit()
switch (aType)
if (mouse)
* PoweredDown/Saved/Aborted. */
g_fTerminateFE = true;
if (gConsole)
if (info)
else if (port == 0)
AssertFailed();
return S_OK;
long mLastVRDEPort;
bool m_fIgnorePowerOffEvents;
lrc = ~0;
if (!lrc)
static void show_usage()
#ifdef VBOX_WITH_VIDEO_REC
#ifdef VBOX_WITH_VIDEO_REC
const char *pszEnvTemp;
errno = 0;
if (errno != 0)
errno = 0;
if (errno != 0)
errno = 0;
if (errno != 0)
if (!fStdIn)
if (!fStdIn)
return rcExit;
int rc;
return rcExit;
#ifdef RT_OS_WINDOWS
unsigned cVRDEProperties = 0;
unsigned fRawR0 = ~0U;
unsigned fRawR3 = ~0U;
unsigned fPATM = ~0U;
unsigned fCSAM = ~0U;
#ifdef VBOX_WITH_VIDEO_REC
unsigned fVIDEOREC = 0;
#ifdef VBOX_WITH_VIDEO_REC
enum eHeadlessOptions
#ifdef VBOX_WITH_VIDEO_REC
int ch;
switch(ch)
RTPrintf("Warning: '-p' or '-vrdpport' are deprecated. Use '-e \"TCP/Ports=%s\"'\n", ValueUnion.psz);
RTPrintf("Warning: '-a' or '-vrdpaddress' are deprecated. Use '-e \"TCP/Address=%s\"'\n", ValueUnion.psz);
case OPT_RAW_R0:
fRawR0 = true;
case OPT_NO_RAW_R0:
fRawR0 = false;
case OPT_RAW_R3:
fRawR3 = true;
case OPT_NO_RAW_R3:
fRawR3 = false;
case OPT_PATM:
fPATM = true;
case OPT_NO_PATM:
fPATM = false;
case OPT_CSAM:
fCSAM = true;
case OPT_NO_CSAM:
fCSAM = false;
case OPT_SETTINGSPW:
case OPT_SETTINGSPW_FILE:
#ifdef VBOX_WITH_VIDEO_REC
fVIDEOREC = true;
#ifdef VBOX_WITH_VIDEO_REC
show_usage();
case OPT_COMMENT:
show_usage();
return ch;
#ifdef VBOX_WITH_VIDEO_REC
if (!pcszNameOrUUID)
show_usage();
#ifdef VBOX_WITH_XPCOM
RTPrintf("Failed to initialize COM because the global settings directory '%s' is not accessible!", szHome);
bool fSessionOpened = false;
if (pcszSettingsPw)
else if (pcszSettingsPwFile)
fSessionOpened = true;
#ifdef VBOX_WITH_VIDEO_REC
if (fVIDEOREC)
rrc = SUPR3HardenedLdrLoadAppPriv("VBoxVideoRecFB", &hLdrVideoRecFB, RTLDRLOAD_FLAGS_LOCAL, &ErrInfo.Core);
reinterpret_cast<void **>(&pfnRegisterVideoRecFB));
LogError("Failed to load the video capture extension\n", rrc); /** @todo stupid function, no formatting options. */
unsigned uScreenId;
# ifdef VBOX_WITH_VIDEO_REC
if (!pVRDPFramebuffer)
if (machineDebugger)
if (fRawR0 != ~0U)
if (!machineDebugger)
if (fRawR3 != ~0U)
if (!machineDebugger)
if (fPATM != ~0U)
if (!machineDebugger)
if (fCSAM != ~0U)
if (!machineDebugger)
fVRDEEnable = false;
if (!fVRDEEnabled)
fVRDEEnable = false;
if (fVRDEEnable)
if (cVRDEProperties > 0)
for (unsigned i = 0; i < cVRDEProperties; i++)
if (pszProperty)
if (pDelimiter)
if (!fVRDEEnabled)
if (fVRDEEnabled)
if (!g_fTerminateFE)
CHECK_ERROR(machine, COMSETTER(GuestPropertyNotificationPatterns)(Bstr("/VirtualBox/GuestInfo/OS/*Logged*").raw()));
while ( !g_fTerminateFE
#ifdef VBOX_WITH_VIDEO_REC
if (pFramebuffer)
if ( gConsole
if (vboxListener)
if (consoleListener)
if (vboxClientListener)
/* No more access to the 'console' object, which will be uninitialized by the next session->Close call. */
if (fSessionOpened)
#ifndef VBOX_WITH_HARDENING
switch (rc)
#ifdef VBOX_WITH_XPCOM