summaryrefslogtreecommitdiff
path: root/src/VBox/Main/src-server/SystemPropertiesImpl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/VBox/Main/src-server/SystemPropertiesImpl.cpp')
-rw-r--r--src/VBox/Main/src-server/SystemPropertiesImpl.cpp203
1 files changed, 191 insertions, 12 deletions
diff --git a/src/VBox/Main/src-server/SystemPropertiesImpl.cpp b/src/VBox/Main/src-server/SystemPropertiesImpl.cpp
index 380f7574..3e0ff614 100644
--- a/src/VBox/Main/src-server/SystemPropertiesImpl.cpp
+++ b/src/VBox/Main/src-server/SystemPropertiesImpl.cpp
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2006-2012 Oracle Corporation
+ * 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;
@@ -90,6 +90,7 @@ HRESULT SystemProperties::init(VirtualBox *aParent)
unconst(mParent) = aParent;
setDefaultMachineFolder(Utf8Str::Empty);
+ setLoggingLevel(Utf8Str::Empty);
setDefaultHardDiskFormat(Utf8Str::Empty);
setVRDEAuthLibrary(Utf8Str::Empty);
@@ -97,6 +98,18 @@ HRESULT SystemProperties::init(VirtualBox *aParent)
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
+
HRESULT rc = S_OK;
/* Fetch info of all available hd backends. */
@@ -313,6 +326,36 @@ STDMETHODIMP SystemProperties::COMGETTER(MaxBootPosition)(ULONG *aMaxBootPositio
}
+STDMETHODIMP SystemProperties::COMGETTER(ExclusiveHwVirt)(BOOL *aExclusiveHwVirt)
+{
+ CheckComArgOutPointerValid(aExclusiveHwVirt);
+
+ AutoCaller autoCaller(this);
+ if (FAILED(autoCaller.rc())) return autoCaller.rc();
+
+ AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
+
+ *aExclusiveHwVirt = m->fExclusiveHwVirt;
+
+ return S_OK;
+}
+
+STDMETHODIMP SystemProperties::COMSETTER(ExclusiveHwVirt)(BOOL aExclusiveHwVirt)
+{
+ AutoCaller autoCaller(this);
+ if (FAILED(autoCaller.rc())) return autoCaller.rc();
+
+ AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
+ m->fExclusiveHwVirt = !!aExclusiveHwVirt;
+ alock.release();
+
+ // VirtualBox::saveSettings() needs vbox write lock
+ AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
+ HRESULT rc = mParent->saveSettings();
+
+ return rc;
+}
+
STDMETHODIMP SystemProperties::GetMaxNetworkAdapters(ChipsetType_T aChipset, ULONG *count)
{
CheckComArgOutPointerValid(count);
@@ -346,6 +389,7 @@ STDMETHODIMP SystemProperties::GetMaxNetworkAdaptersOfType(ChipsetType_T aChipse
{
case NetworkAttachmentType_NAT:
case NetworkAttachmentType_Internal:
+ case NetworkAttachmentType_NATNetwork:
/* chipset default is OK */
break;
case NetworkAttachmentType_Bridged:
@@ -531,6 +575,8 @@ STDMETHODIMP SystemProperties::GetDeviceTypesForStorageBus(StorageBus_T aBus,
{
case StorageBus_IDE:
case StorageBus_SATA:
+ case StorageBus_SCSI:
+ case StorageBus_SAS:
{
com::SafeArray<DeviceType_T> saDeviceTypes(2);
saDeviceTypes[0] = DeviceType_DVD;
@@ -538,14 +584,6 @@ STDMETHODIMP SystemProperties::GetDeviceTypesForStorageBus(StorageBus_T aBus,
saDeviceTypes.detachTo(ComSafeArrayOutArg(aDeviceTypes));
break;
}
- case StorageBus_SCSI:
- case StorageBus_SAS:
- {
- com::SafeArray<DeviceType_T> saDeviceTypes(1);
- saDeviceTypes[0] = DeviceType_HardDisk;
- saDeviceTypes.detachTo(ComSafeArrayOutArg(aDeviceTypes));
- break;
- }
case StorageBus_Floppy:
{
com::SafeArray<DeviceType_T> saDeviceTypes(1);
@@ -588,6 +626,36 @@ STDMETHODIMP SystemProperties::GetDefaultIoCacheSettingForStorageController(Stor
return S_OK;
}
+STDMETHODIMP SystemProperties::GetMaxInstancesOfUSBControllerType(ChipsetType_T aChipset,
+ USBControllerType_T aType,
+ ULONG *aMaxInstances)
+{
+ NOREF(aChipset);
+ CheckComArgOutPointerValid(aMaxInstances);
+
+ AutoCaller autoCaller(this);
+ if (FAILED(autoCaller.rc())) return autoCaller.rc();
+
+ ULONG cCtrs = 0;
+
+ /* no need to lock, this is const */
+ switch (aType)
+ {
+ case USBControllerType_OHCI:
+ case USBControllerType_EHCI:
+ {
+ cCtrs = 1;
+ break;
+ }
+ default:
+ AssertMsgFailed(("Invalid bus type %d\n", aType));
+ }
+
+ *aMaxInstances = cCtrs;
+
+ return S_OK;
+}
+
STDMETHODIMP SystemProperties::COMGETTER(DefaultMachineFolder)(BSTR *aDefaultMachineFolder)
{
CheckComArgOutPointerValid(aDefaultMachineFolder);
@@ -621,6 +689,44 @@ STDMETHODIMP SystemProperties::COMSETTER(DefaultMachineFolder)(IN_BSTR aDefaultM
return rc;
}
+STDMETHODIMP SystemProperties::COMGETTER(LoggingLevel)(BSTR *aLoggingLevel)
+{
+ CheckComArgOutPointerValid(aLoggingLevel);
+
+ AutoCaller autoCaller(this);
+ if (FAILED(autoCaller.rc())) return autoCaller.rc();
+
+ AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
+
+ Utf8Str useLoggingLevel(m->strLoggingLevel);
+ if (useLoggingLevel.isEmpty())
+ useLoggingLevel = VBOXSVC_LOG_DEFAULT;
+
+ useLoggingLevel.cloneTo(aLoggingLevel);
+ return S_OK;
+}
+
+
+STDMETHODIMP SystemProperties::COMSETTER(LoggingLevel)(IN_BSTR aLoggingLevel)
+{
+ AutoCaller autoCaller(this);
+ if (FAILED(autoCaller.rc())) return autoCaller.rc();
+
+ AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
+ HRESULT rc = setLoggingLevel(aLoggingLevel);
+ alock.release();
+
+ if (SUCCEEDED(rc))
+ {
+ AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
+ rc = mParent->saveSettings();
+ }
+ 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))
{
CheckComArgOutSafeArrayPointerValid(aMediumFormats);
@@ -997,6 +1103,40 @@ STDMETHODIMP SystemProperties::COMSETTER(DefaultAdditionsISO)(IN_BSTR aDefaultAd
return rc;
}
+STDMETHODIMP SystemProperties::COMGETTER(DefaultFrontend)(BSTR *aDefaultFrontend)
+{
+ CheckComArgOutPointerValid(aDefaultFrontend);
+
+ AutoCaller autoCaller(this);
+ if (FAILED(autoCaller.rc())) return autoCaller.rc();
+
+ AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
+ m->strDefaultFrontend.cloneTo(aDefaultFrontend);
+
+ return S_OK;
+}
+
+STDMETHODIMP SystemProperties::COMSETTER(DefaultFrontend)(IN_BSTR aDefaultFrontend)
+{
+ AutoCaller autoCaller(this);
+ if (FAILED(autoCaller.rc())) return autoCaller.rc();
+
+ AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
+ if (m->strDefaultFrontend == Utf8Str(aDefaultFrontend))
+ return S_OK;
+ HRESULT rc = setDefaultFrontend(aDefaultFrontend);
+ alock.release();
+
+ if (SUCCEEDED(rc))
+ {
+ // VirtualBox::saveSettings() needs vbox write lock
+ AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
+ rc = mParent->saveSettings();
+ }
+
+ return rc;
+}
+
// public methods only for internal purposes
/////////////////////////////////////////////////////////////////////////////
@@ -1012,6 +1152,9 @@ HRESULT SystemProperties::loadSettings(const settings::SystemProperties &data)
rc = setDefaultMachineFolder(data.strDefaultMachineFolder);
if (FAILED(rc)) return rc;
+ rc = setLoggingLevel(data.strLoggingLevel);
+ if (FAILED(rc)) return rc;
+
rc = setDefaultHardDiskFormat(data.strDefaultHardDiskFormat);
if (FAILED(rc)) return rc;
@@ -1025,6 +1168,7 @@ HRESULT SystemProperties::loadSettings(const settings::SystemProperties &data)
if (FAILED(rc)) return rc;
m->ulLogHistoryCount = data.ulLogHistoryCount;
+ m->fExclusiveHwVirt = data.fExclusiveHwVirt;
rc = setAutostartDatabasePath(data.strAutostartDatabasePath);
if (FAILED(rc)) return rc;
@@ -1036,6 +1180,9 @@ HRESULT SystemProperties::loadSettings(const settings::SystemProperties &data)
(void)setDefaultAdditionsISO(data.strDefaultAdditionsISO);
}
+ rc = setDefaultFrontend(data.strDefaultFrontend);
+ if (FAILED(rc)) return rc;
+
return S_OK;
}
@@ -1074,7 +1221,7 @@ ComObjPtr<MediumFormat> SystemProperties::mediumFormat(const Utf8Str &aFormat)
{
/* MediumFormat is all const, no need to lock */
- if ((*it)->getId().compare(aFormat, Utf8Str::CaseInsensitive) == 0)
+ if ((*it)->i_getId().compare(aFormat, Utf8Str::CaseInsensitive) == 0)
{
format = *it;
break;
@@ -1107,8 +1254,8 @@ ComObjPtr<MediumFormat> SystemProperties::mediumFormatFromExtension(const Utf8St
++it)
{
/* MediumFormat is all const, no need to lock */
- MediumFormat::StrList aFileList = (*it)->getFileExtensions();
- for (MediumFormat::StrList::const_iterator it1 = aFileList.begin();
+ MediumFormat::StrArray aFileList = (*it)->i_getFileExtensions();
+ for (MediumFormat::StrArray::const_iterator it1 = aFileList.begin();
it1 != aFileList.end();
++it1)
{
@@ -1177,6 +1324,31 @@ HRESULT SystemProperties::setDefaultMachineFolder(const Utf8Str &strPath)
return S_OK;
}
+HRESULT SystemProperties::setLoggingLevel(const Utf8Str &aLoggingLevel)
+{
+ Utf8Str useLoggingLevel(aLoggingLevel);
+ int rc = RTLogGroupSettings(RTLogRelDefaultInstance(), useLoggingLevel.c_str());
+ // 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.
+ LogRel(("Cannot set passed logging level=%s Error=%Rrc \n", useLoggingLevel.c_str(), rc));
+ // If attempted logging level not the default one then try the default one.
+ if (!useLoggingLevel.equals(VBOXSVC_LOG_DEFAULT))
+ {
+ rc = RTLogGroupSettings(RTLogRelDefaultInstance(), VBOXSVC_LOG_DEFAULT);
+ // If failed report this to the release log.
+ if (RT_FAILURE(rc))
+ LogRel(("Cannot set default logging level Error=%Rrc \n", rc));
+ }
+ // On any failure - set default level as the one to be stored.
+ useLoggingLevel = VBOXSVC_LOG_DEFAULT;
+ }
+ // Set to passed value or if default used/attempted (even if error condition) use empty string.
+ m->strLoggingLevel = (useLoggingLevel.equals(VBOXSVC_LOG_DEFAULT) ? "" : useLoggingLevel);
+ return RT_SUCCESS(rc) ? S_OK : E_FAIL;
+}
+
HRESULT SystemProperties::setDefaultHardDiskFormat(const Utf8Str &aFormat)
{
if (!aFormat.isEmpty())
@@ -1288,3 +1460,10 @@ HRESULT SystemProperties::setDefaultAdditionsISO(const Utf8Str &aPath)
return S_OK;
}
+
+HRESULT SystemProperties::setDefaultFrontend(const Utf8Str &aDefaultFrontend)
+{
+ m->strDefaultFrontend = aDefaultFrontend;
+
+ return S_OK;
+}