SystemPropertiesImpl.cpp revision 35779b5ff92d92bc215bf98458583ed33162762f
/* $Id$ */
/** @file
* VirtualBox COM class implementation
*/
/*
* Copyright (C) 2006-2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* 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.
*/
#include "SystemPropertiesImpl.h"
#include "VirtualBoxImpl.h"
#include "MachineImpl.h"
#ifdef VBOX_WITH_EXTPACK
# include "ExtPackManagerImpl.h"
#endif
#include "AutoCaller.h"
#include "Global.h"
#include "Logging.h"
#include "AutostartDb.h"
// generated header
#include "SchemaDefs.h"
#include <VBox/settings.h>
// defines
/////////////////////////////////////////////////////////////////////////////
// constructor / destructor
/////////////////////////////////////////////////////////////////////////////
m(new settings::SystemProperties)
{
}
{
delete m;
}
{
return BaseFinalConstruct();
}
void SystemProperties::FinalRelease()
{
uninit();
}
// public methods only for internal purposes
/////////////////////////////////////////////////////////////////////////////
/**
* Initializes the system information object.
*
* @returns COM result indicator
*/
{
/* Enclose the state transition NotReady->InInit->Ready */
AutoInitSpan autoInitSpan(this);
m->ulLogHistoryCount = 3;
/* On Windows and OS X, HW virtualization use isn't exclusive by
* default so that VT-x or AMD-V can be shared with other
* hypervisors without requiring user intervention.
* NB: See also SystemProperties constructor in settings.h
*/
#if defined(RT_OS_DARWIN) || defined(RT_OS_WINDOWS)
m->fExclusiveHwVirt = false;
#else
m->fExclusiveHwVirt = true;
#endif
/* Fetch info of all available hd backends. */
/// @todo NEWMEDIA VDBackendInfo needs to be improved to let us enumerate
/// any number of backends
unsigned cEntries;
if (RT_SUCCESS(vrc))
{
for (unsigned i = 0; i < cEntries; ++ i)
{
}
}
/* Confirm a successful initialization */
return rc;
}
/**
* Uninitializes the instance and sets the ready flag to FALSE.
* Called either from FinalRelease() or by the parent when it gets destroyed.
*/
void SystemProperties::uninit()
{
LogFlowThisFunc(("\n"));
/* Enclose the state transition Ready->InUninit->NotReady */
AutoUninitSpan autoUninitSpan(this);
if (autoUninitSpan.uninitDone())
return;
}
// ISystemProperties properties
/////////////////////////////////////////////////////////////////////////////
{
AutoCaller autoCaller(this);
/* no need to lock, this is const */
return S_OK;
}
{
AutoCaller autoCaller(this);
/* no need to lock, this is const */
return S_OK;
}
{
AutoCaller autoCaller(this);
/* no need to lock, this is const */
return S_OK;
}
{
AutoCaller autoCaller(this);
/* no need to lock, this is const */
return S_OK;
}
{
AutoCaller autoCaller(this);
/* no need to lock, this is const */
return S_OK;
}
{
AutoCaller autoCaller(this);
/* no need to lock, this is const */
return S_OK;
}
{
AutoCaller autoCaller(this);
/* no need to lock, this is const */
return S_OK;
}
{
AutoCaller autoCaller(this);
/*
* The BIOS supports currently 32 bit LBA numbers (implementing the full
* 48 bit range is in theory trivial, but the crappy compiler makes things
* more difficult). This translates to almost 2 TiBytes (to be on the safe
* side, the reported limit is 1 MiByte less than that, as the total number
* of sectors should fit in 32 bits, too), which should be enough for the
* moment. Since the MBR partition tables support only 32bit sector numbers
* and thus the BIOS can only boot from disks smaller than 2T this is a
* rather hard limit.
*
* LBA64 (almost, more like LBA55 in practice), so the theoretical maximum
* disk size is 128 PiByte/16 EiByte. The GUI works nicely with 6 orders
* of magnitude, but not with 11..13 orders of magnitude.
*/
/* no need to lock, this is const */
return S_OK;
}
{
AutoCaller autoCaller(this);
/* no need to lock, this is const */
return S_OK;
}
{
AutoCaller autoCaller(this);
/* no need to lock, this is const */
return S_OK;
}
{
AutoCaller autoCaller(this);
/* no need to lock, this is const */
return S_OK;
}
{
AutoCaller autoCaller(this);
*aExclusiveHwVirt = m->fExclusiveHwVirt;
return S_OK;
}
{
AutoCaller autoCaller(this);
m->fExclusiveHwVirt = !!aExclusiveHwVirt;
// VirtualBox::saveSettings() needs vbox write lock
return rc;
}
{
AutoCaller autoCaller(this);
/* no need for locking, no state */
if (uResult == 0)
return S_OK;
}
STDMETHODIMP SystemProperties::GetMaxNetworkAdaptersOfType(ChipsetType_T aChipset, NetworkAttachmentType_T aType, ULONG *count)
{
AutoCaller autoCaller(this);
/* no need for locking, no state */
if (uResult == 0)
switch (aType)
{
/* chipset default is OK */
break;
/* Maybe use current host interface count here? */
break;
break;
default:
}
return S_OK;
}
{
AutoCaller autoCaller(this);
/* no need to lock, this is const */
switch (aBus)
{
case StorageBus_SATA:
case StorageBus_SCSI:
case StorageBus_SAS:
case StorageBus_USB:
{
/* SATA and both SCSI controllers only support one device per port. */
*aMaxDevicesPerPort = 1;
break;
}
case StorageBus_IDE:
case StorageBus_Floppy:
{
/* The IDE and Floppy controllers support 2 devices. One as master
* and one as slave (or floppy drive 0 and 1). */
*aMaxDevicesPerPort = 2;
break;
}
default:
}
return S_OK;
}
{
AutoCaller autoCaller(this);
/* no need to lock, this is const */
switch (aBus)
{
case StorageBus_SATA:
{
*aMinPortCount = 1;
break;
}
case StorageBus_SCSI:
{
*aMinPortCount = 16;
break;
}
case StorageBus_IDE:
{
*aMinPortCount = 2;
break;
}
case StorageBus_Floppy:
{
*aMinPortCount = 1;
break;
}
case StorageBus_SAS:
case StorageBus_USB:
{
*aMinPortCount = 8;
break;
}
default:
}
return S_OK;
}
{
AutoCaller autoCaller(this);
/* no need to lock, this is const */
switch (aBus)
{
case StorageBus_SATA:
{
*aMaxPortCount = 30;
break;
}
case StorageBus_SCSI:
{
*aMaxPortCount = 16;
break;
}
case StorageBus_IDE:
{
*aMaxPortCount = 2;
break;
}
case StorageBus_Floppy:
{
*aMaxPortCount = 1;
break;
}
case StorageBus_SAS:
case StorageBus_USB:
{
*aMaxPortCount = 8;
break;
}
default:
}
return S_OK;
}
{
AutoCaller autoCaller(this);
/* no need to lock, this is const */
switch (aBus)
{
case StorageBus_SATA:
case StorageBus_SCSI:
case StorageBus_SAS:
break;
case StorageBus_USB:
case StorageBus_IDE:
case StorageBus_Floppy:
{
cCtrs = 1;
break;
}
default:
}
*aMaxInstances = cCtrs;
return S_OK;
}
{
AutoCaller autoCaller(this);
/* no need to lock, this is const */
switch (aBus)
{
case StorageBus_IDE:
case StorageBus_SATA:
case StorageBus_SCSI:
case StorageBus_SAS:
case StorageBus_USB:
{
saDeviceTypes[0] = DeviceType_DVD;
break;
}
case StorageBus_Floppy:
{
break;
}
default:
}
return S_OK;
}
STDMETHODIMP SystemProperties::GetDefaultIoCacheSettingForStorageController(StorageControllerType_T aControllerType, BOOL *aEnabled)
{
AutoCaller autoCaller(this);
/* no need to lock, this is const */
switch (aControllerType)
{
*aEnabled = false;
break;
*aEnabled = true;
break;
default:
}
return S_OK;
}
{
AutoCaller autoCaller(this);
/* no need to lock, this is const */
switch (aType)
{
case USBControllerType_OHCI:
case USBControllerType_EHCI:
{
cCtrs = 1;
break;
}
default:
}
*aMaxInstances = cCtrs;
return S_OK;
}
{
AutoCaller autoCaller(this);
return S_OK;
}
{
AutoCaller autoCaller(this);
{
// VirtualBox::saveSettings() needs vbox write lock
}
return rc;
}
{
AutoCaller autoCaller(this);
if (useLoggingLevel.isEmpty())
return S_OK;
}
{
AutoCaller autoCaller(this);
{
}
else
LogRel(("Cannot set passed logging level=%ls, or the default one - Error=%Rhrc \n", aLoggingLevel, rc));
return rc;
}
STDMETHODIMP SystemProperties::COMGETTER(MediumFormats)(ComSafeArrayOut(IMediumFormat *, aMediumFormats))
{
AutoCaller autoCaller(this);
return S_OK;
}
{
AutoCaller autoCaller(this);
return S_OK;
}
{
AutoCaller autoCaller(this);
{
// VirtualBox::saveSettings() needs vbox write lock
}
return rc;
}
{
}
{
}
{
}
STDMETHODIMP SystemProperties::COMSETTER(FreeDiskSpacePercentWarning)(ULONG /* aFreeSpacePercent */)
{
}
{
}
{
}
{
}
{
}
{
AutoCaller autoCaller(this);
return S_OK;
}
{
AutoCaller autoCaller(this);
{
// VirtualBox::saveSettings() needs vbox write lock
}
return rc;
}
{
AutoCaller autoCaller(this);
return S_OK;
}
{
AutoCaller autoCaller(this);
{
// VirtualBox::saveSettings() needs vbox write lock
}
return rc;
}
{
AutoCaller autoCaller(this);
{
if (strExtPack.isNotEmpty())
{
else
#ifdef VBOX_WITH_EXTPACK
#else
#endif
}
else
{
#ifdef VBOX_WITH_EXTPACK
#endif
if (strExtPack.isEmpty())
{
/*
* Klugde - check if VBoxVRDP.dll/.so/.dylib is installed.
* This is hardcoded uglyness, sorry.
*/
char szPath[RTPATH_MAX];
if (RT_SUCCESS(vrc))
if (RT_SUCCESS(vrc))
{
/* Illegal extpack name, so no conflict. */
}
}
}
}
return S_OK;
}
{
AutoCaller autoCaller(this);
{
if (strExtPack.isNotEmpty())
{
else
#ifdef VBOX_WITH_EXTPACK
#else
#endif
}
{
{
/* VirtualBox::saveSettings() needs the VirtualBox write lock. */
}
}
}
return hrc;
}
{
AutoCaller autoCaller(this);
*count = m->ulLogHistoryCount;
return S_OK;
}
{
AutoCaller autoCaller(this);
m->ulLogHistoryCount = count;
// VirtualBox::saveSettings() needs vbox write lock
return rc;
}
{
AutoCaller autoCaller(this);
return S_OK;
}
{
AutoCaller autoCaller(this);
return S_OK;
}
{
AutoCaller autoCaller(this);
{
// VirtualBox::saveSettings() needs vbox write lock
}
return rc;
}
{
AutoCaller autoCaller(this);
if (m->strDefaultAdditionsISO.isEmpty())
{
/* no guest additions, check if it showed up in the mean time */
{
(void)setDefaultAdditionsISO("");
}
}
return S_OK;
}
{
AutoCaller autoCaller(this);
/** @todo not yet implemented, settings handling is missing */
{
// VirtualBox::saveSettings() needs vbox write lock
}
return rc;
}
{
AutoCaller autoCaller(this);
return S_OK;
}
{
AutoCaller autoCaller(this);
return S_OK;
{
// VirtualBox::saveSettings() needs vbox write lock
}
return rc;
}
// public methods only for internal purposes
/////////////////////////////////////////////////////////////////////////////
{
AutoCaller autoCaller(this);
{
/* must ignore errors signalled here, because the guest additions
* file may not exist, and in this case keep the empty string */
}
return S_OK;
}
{
AutoCaller autoCaller(this);
data = *m;
return S_OK;
}
/**
* Returns a medium format object corresponding to the given format
* identifier or null if no such format.
*
* @param aFormat Format identifier.
*
* @return ComObjPtr<MediumFormat>
*/
{
AutoCaller autoCaller(this);
++ it)
{
/* MediumFormat is all const, no need to lock */
{
break;
}
}
return format;
}
/**
* Returns a medium format object corresponding to the given file extension or
* null if no such format.
*
* @param aExt File extension.
*
* @return ComObjPtr<MediumFormat>
*/
{
AutoCaller autoCaller(this);
bool fFound = false;
++it)
{
/* MediumFormat is all const, no need to lock */
++it1)
{
{
fFound = true;
break;
}
}
}
return format;
}
// private methods
/////////////////////////////////////////////////////////////////////////////
/**
* Returns the user's home directory. Wrapper around RTPathUserHome().
* @param strPath
* @return
*/
{
char szHome[RTPATH_MAX];
if (RT_FAILURE(vrc))
tr("Cannot determine user home directory (%Rrc)"),
vrc);
return S_OK;
}
/**
* Internal implementation to set the default machine folder. Gets called
* from the public attribute setter as well as loadSettings(). With 4.0,
* the "default default" machine folder has changed, and we now require
* a full path always.
* @param aPath
* @return
*/
{
// in VirtualBox.xml if user upgrades from before 4.0 and
// has not changed the default machine folder
)
{
// new default with VirtualBox 4.0: "$HOME/VirtualBox VMs"
}
return setError(E_INVALIDARG,
tr("Given default machine folder '%s' is not fully qualified"),
m->strDefaultMachineFolder = path;
return S_OK;
}
{
// If failed and not the default logging level - try to use the default logging level.
if (RT_FAILURE(rc))
{
// If failed write message to the release log.
// If attempted logging level not the default one then try the default one.
{
// If failed report this to the release log.
if (RT_FAILURE(rc))
}
// On any failure - set default level as the one to be stored.
}
}
{
else
m->strDefaultHardDiskFormat = "VDI";
return S_OK;
}
{
m->strVRDEAuthLibrary = aPath;
else
m->strVRDEAuthLibrary = "VBoxAuth";
return S_OK;
}
{
else
m->strWebServiceAuthLibrary = "VBoxAuth";
return S_OK;
}
{
return S_OK;
}
{
{
/* Update path in the autostart database. */
if (RT_SUCCESS(vrc))
else
tr("Cannot set the autostart database path (%Rrc)"),
vrc);
}
else
{
m->strAutostartDatabasePath = "";
else
tr("Deleting the autostart database path failed (%Rrc)"),
vrc);
}
return rc;
}
{
{
char strTemp[RTPATH_MAX];
Utf8Str strSrc3 = Utf8StrFmt("%s/VBoxGuestAdditions_%ls.iso", strTemp, VirtualBox::getVersionNormalized().raw());
/* Check the standard image locations */
else
tr("Cannot determine default Guest Additions ISO location. Most likely they are not available"));
}
return setError(E_INVALIDARG,
tr("Given default machine Guest Additions ISO file '%s' is not fully qualified"),
return setError(E_INVALIDARG,
tr("Given default machine Guest Additions ISO file '%s' does not exist"),
m->strDefaultAdditionsISO = path;
return S_OK;
}
{
return S_OK;
}