summaryrefslogtreecommitdiff
path: root/src/VBox/Main/src-server
diff options
context:
space:
mode:
authorFelix Geyer <fgeyer@debian.org>2013-03-02 22:29:33 +0100
committerFelix Geyer <fgeyer@debian.org>2013-03-02 22:29:33 +0100
commitfb32dd2be67519662e93ffbbe520c79d95b1fbfb (patch)
treee445911bff35c842af26b5e5c0ee31573be49008 /src/VBox/Main/src-server
parent490244144bf10ecd165f2f81f2c88b7781c91d85 (diff)
downloadvirtualbox-upstream/4.2.8-dfsg.tar.gz
Imported Upstream version 4.2.8-dfsgupstream/4.2.8-dfsg
Diffstat (limited to 'src/VBox/Main/src-server')
-rw-r--r--src/VBox/Main/src-server/ApplianceImplExport.cpp2
-rw-r--r--src/VBox/Main/src-server/AudioAdapterImpl.cpp2
-rw-r--r--src/VBox/Main/src-server/BIOSSettingsImpl.cpp2
-rw-r--r--src/VBox/Main/src-server/DHCPServerImpl.cpp2
-rw-r--r--src/VBox/Main/src-server/DHCPServerRunner.cpp2
-rw-r--r--src/VBox/Main/src-server/HostPower.cpp2
-rw-r--r--src/VBox/Main/src-server/MachineImpl.cpp274
-rw-r--r--src/VBox/Main/src-server/MediumImpl.cpp145
-rw-r--r--src/VBox/Main/src-server/ParallelPortImpl.cpp2
-rw-r--r--src/VBox/Main/src-server/Performance.cpp48
-rw-r--r--src/VBox/Main/src-server/PerformanceImpl.cpp2
-rw-r--r--src/VBox/Main/src-server/ProgressProxyImpl.cpp2
-rw-r--r--src/VBox/Main/src-server/SerialPortImpl.cpp2
-rw-r--r--src/VBox/Main/src-server/SnapshotImpl.cpp30
-rw-r--r--src/VBox/Main/src-server/StorageControllerImpl.cpp2
-rw-r--r--src/VBox/Main/src-server/USBDeviceFilterImpl.cpp2
-rw-r--r--src/VBox/Main/src-server/VFSExplorerImpl.cpp2
-rw-r--r--src/VBox/Main/src-server/VRDEServerImpl.cpp100
-rw-r--r--src/VBox/Main/src-server/VirtualBoxImpl.cpp50
-rw-r--r--src/VBox/Main/src-server/darwin/HostPowerDarwin.cpp2
-rw-r--r--src/VBox/Main/src-server/darwin/NetIf-darwin.cpp2
-rw-r--r--src/VBox/Main/src-server/darwin/PerformanceDarwin.cpp19
-rw-r--r--src/VBox/Main/src-server/darwin/iokit.cpp2
-rw-r--r--src/VBox/Main/src-server/darwin/iokit.h2
-rw-r--r--src/VBox/Main/src-server/freebsd/HostHardwareFreeBSD.cpp2
-rw-r--r--src/VBox/Main/src-server/freebsd/NetIf-freebsd.cpp2
-rw-r--r--src/VBox/Main/src-server/freebsd/PerformanceFreeBSD.cpp2
-rw-r--r--src/VBox/Main/src-server/generic/AutostartDb-generic.cpp2
-rw-r--r--src/VBox/Main/src-server/generic/NetIf-generic.cpp2
-rw-r--r--src/VBox/Main/src-server/linux/HostHardwareLinux.cpp2
-rw-r--r--src/VBox/Main/src-server/linux/NetIf-linux.cpp2
-rw-r--r--src/VBox/Main/src-server/linux/PerformanceLinux.cpp2
-rw-r--r--src/VBox/Main/src-server/linux/USBGetDevices.cpp2
-rw-r--r--src/VBox/Main/src-server/linux/vbox-libhal.cpp2
-rw-r--r--src/VBox/Main/src-server/os2/NetIf-os2.cpp2
-rw-r--r--src/VBox/Main/src-server/os2/PerformanceOs2.cpp2
-rw-r--r--src/VBox/Main/src-server/solaris/DynLoadLibSolaris.cpp2
-rw-r--r--src/VBox/Main/src-server/solaris/DynLoadLibSolaris.h2
-rw-r--r--src/VBox/Main/src-server/solaris/NetIf-solaris.cpp16
-rw-r--r--src/VBox/Main/src-server/solaris/PerformanceSolaris.cpp23
-rw-r--r--src/VBox/Main/src-server/win/HostPowerWin.cpp2
-rw-r--r--src/VBox/Main/src-server/win/NetIf-win.cpp2
-rw-r--r--src/VBox/Main/src-server/win/PerformanceWin.cpp2
-rw-r--r--src/VBox/Main/src-server/win/svchlp.cpp2
-rw-r--r--src/VBox/Main/src-server/win/svchlp.h2
-rw-r--r--src/VBox/Main/src-server/xpcom/server.h2
46 files changed, 550 insertions, 229 deletions
diff --git a/src/VBox/Main/src-server/ApplianceImplExport.cpp b/src/VBox/Main/src-server/ApplianceImplExport.cpp
index cc47b4d1c..9b2d12196 100644
--- a/src/VBox/Main/src-server/ApplianceImplExport.cpp
+++ b/src/VBox/Main/src-server/ApplianceImplExport.cpp
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (C) 2008-2011 Oracle Corporation
+ * Copyright (C) 2008-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/src/VBox/Main/src-server/AudioAdapterImpl.cpp b/src/VBox/Main/src-server/AudioAdapterImpl.cpp
index 9b6dbf178..089359b21 100644
--- a/src/VBox/Main/src-server/AudioAdapterImpl.cpp
+++ b/src/VBox/Main/src-server/AudioAdapterImpl.cpp
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2011 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/src/VBox/Main/src-server/BIOSSettingsImpl.cpp b/src/VBox/Main/src-server/BIOSSettingsImpl.cpp
index bc40820ba..e21ea5892 100644
--- a/src/VBox/Main/src-server/BIOSSettingsImpl.cpp
+++ b/src/VBox/Main/src-server/BIOSSettingsImpl.cpp
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2011 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/src/VBox/Main/src-server/DHCPServerImpl.cpp b/src/VBox/Main/src-server/DHCPServerImpl.cpp
index 45f21370b..b2a921d8f 100644
--- a/src/VBox/Main/src-server/DHCPServerImpl.cpp
+++ b/src/VBox/Main/src-server/DHCPServerImpl.cpp
@@ -6,7 +6,7 @@
*/
/*
- * Copyright (C) 2006-2010 Oracle Corporation
+ * Copyright (C) 2006-2011 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/src/VBox/Main/src-server/DHCPServerRunner.cpp b/src/VBox/Main/src-server/DHCPServerRunner.cpp
index aab7c8a9f..4c0862be5 100644
--- a/src/VBox/Main/src-server/DHCPServerRunner.cpp
+++ b/src/VBox/Main/src-server/DHCPServerRunner.cpp
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2009 Oracle Corporation
+ * Copyright (C) 2009-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/src/VBox/Main/src-server/HostPower.cpp b/src/VBox/Main/src-server/HostPower.cpp
index 830729a00..8972599b5 100644
--- a/src/VBox/Main/src-server/HostPower.cpp
+++ b/src/VBox/Main/src-server/HostPower.cpp
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2011 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/src/VBox/Main/src-server/MachineImpl.cpp b/src/VBox/Main/src-server/MachineImpl.cpp
index 100f696e6..2086e3e29 100644
--- a/src/VBox/Main/src-server/MachineImpl.cpp
+++ b/src/VBox/Main/src-server/MachineImpl.cpp
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2004-2012 Oracle Corporation
+ * Copyright (C) 2004-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;
@@ -208,6 +208,7 @@ Machine::HWData::HWData()
mKeyboardHIDType = KeyboardHIDType_PS2Keyboard;
mPointingHIDType = PointingHIDType_PS2Mouse;
mChipsetType = ChipsetType_PIIX3;
+ mEmulatedUSBWebcamEnabled = FALSE;
mEmulatedUSBCardReaderEnabled = FALSE;
for (size_t i = 0; i < RT_ELEMENTS(mCPUAttached); i++)
@@ -1622,14 +1623,42 @@ STDMETHODIMP Machine::COMSETTER(EmulatedUSBCardReaderEnabled)(BOOL enabled)
STDMETHODIMP Machine::COMGETTER(EmulatedUSBWebcameraEnabled)(BOOL *enabled)
{
+#ifdef VBOX_WITH_USB_VIDEO
+ CheckComArgOutPointerValid(enabled);
+
+ AutoCaller autoCaller(this);
+ if (FAILED(autoCaller.rc())) return autoCaller.rc();
+
+ AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
+
+ *enabled = mHWData->mEmulatedUSBWebcamEnabled;
+
+ return S_OK;
+#else
NOREF(enabled);
return E_NOTIMPL;
+#endif
}
STDMETHODIMP Machine::COMSETTER(EmulatedUSBWebcameraEnabled)(BOOL enabled)
{
+#ifdef VBOX_WITH_USB_VIDEO
+ AutoCaller autoCaller(this);
+ if (FAILED(autoCaller.rc())) return autoCaller.rc();
+ AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
+
+ HRESULT rc = checkStateDependency(MutableStateDep);
+ if (FAILED(rc)) return rc;
+
+ setModified(IsModified_MachineData);
+ mHWData.backup();
+ mHWData->mEmulatedUSBWebcamEnabled = enabled;
+
+ return S_OK;
+#else
NOREF(enabled);
return E_NOTIMPL;
+#endif
}
STDMETHODIMP Machine::COMGETTER(HPETEnabled)(BOOL *enabled)
@@ -5441,21 +5470,18 @@ HRESULT Machine::getGuestPropertyFromService(IN_BSTR aName,
AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
Utf8Str strName(aName);
- HWData::GuestPropertyList::const_iterator it;
+ HWData::GuestPropertyMap::const_iterator it =
+ mHWData->mGuestProperties.find(strName);
- for (it = mHWData->mGuestProperties.begin();
- it != mHWData->mGuestProperties.end(); ++it)
+ if (it != mHWData->mGuestProperties.end())
{
- if (it->strName == strName)
- {
- char szFlags[MAX_FLAGS_LEN + 1];
- it->strValue.cloneTo(aValue);
- *aTimestamp = it->mTimestamp;
- writeFlags(it->mFlags, szFlags);
- Bstr(szFlags).cloneTo(aFlags);
- break;
- }
+ char szFlags[MAX_FLAGS_LEN + 1];
+ it->second.strValue.cloneTo(aValue);
+ *aTimestamp = it->second.mTimestamp;
+ writeFlags(it->second.mFlags, szFlags);
+ Bstr(szFlags).cloneTo(aFlags);
}
+
return S_OK;
}
@@ -5538,7 +5564,6 @@ HRESULT Machine::setGuestPropertyToService(IN_BSTR aName, IN_BSTR aValue,
HRESULT rc = S_OK;
HWData::GuestProperty property;
property.mFlags = NILFLAG;
- bool found = false;
rc = checkStateDependency(MutableStateDep);
if (FAILED(rc)) return rc;
@@ -5548,64 +5573,62 @@ HRESULT Machine::setGuestPropertyToService(IN_BSTR aName, IN_BSTR aValue,
Utf8Str utf8Name(aName);
Utf8Str utf8Flags(aFlags);
uint32_t fFlags = NILFLAG;
- if ( (aFlags != NULL)
- && RT_FAILURE(validateFlags(utf8Flags.c_str(), &fFlags))
+ if ( (aFlags != NULL)
+ && RT_FAILURE(validateFlags(utf8Flags.c_str(), &fFlags))
)
return setError(E_INVALIDARG,
- tr("Invalid flag values: '%ls'"),
+ tr("Invalid guest property flag values: '%ls'"),
aFlags);
- /** @todo r=bird: see efficiency rant in PushGuestProperty. (Yeah, I
- * know, this is simple and do an OK job atm.) */
- HWData::GuestPropertyList::iterator it;
- for (it = mHWData->mGuestProperties.begin();
- it != mHWData->mGuestProperties.end(); ++it)
- if (it->strName == utf8Name)
+ HWData::GuestPropertyMap::iterator it =
+ mHWData->mGuestProperties.find(utf8Name);
+
+ if (it == mHWData->mGuestProperties.end())
+ {
+ setModified(IsModified_MachineData);
+ mHWData.backupEx();
+
+ RTTIMESPEC time;
+ HWData::GuestProperty prop;
+ prop.strValue = aValue;
+ prop.mTimestamp = RTTimeSpecGetNano(RTTimeNow(&time));
+ prop.mFlags = fFlags;
+
+ mHWData->mGuestProperties[Utf8Str(aName)] = prop;
+ }
+ else
+ {
+ if (it->second.mFlags & (RDONLYHOST))
{
- property = *it;
- if (it->mFlags & (RDONLYHOST))
- rc = setError(E_ACCESSDENIED,
- tr("The property '%ls' cannot be changed by the host"),
- aName);
+ rc = setError(E_ACCESSDENIED,
+ tr("The property '%ls' cannot be changed by the host"),
+ aName);
+ }
+ else
+ {
+ setModified(IsModified_MachineData);
+ mHWData.backupEx();
+
+ /* The backupEx() operation invalidates our iterator,
+ * so get a new one. */
+ it = mHWData->mGuestProperties.find(utf8Name);
+ Assert(it != mHWData->mGuestProperties.end());
+
+ if (RT_VALID_PTR(aValue) && *(aValue) != '\0')
+ {
+ RTTIMESPEC time;
+ it->second.strValue = aValue;
+ it->second.mTimestamp = RTTimeSpecGetNano(RTTimeNow(&time));
+ if (aFlags != NULL)
+ it->second.mFlags = fFlags;
+ }
else
{
- setModified(IsModified_MachineData);
- mHWData.backup(); // @todo r=dj backup in a loop?!?
-
- /* The backup() operation invalidates our iterator, so
- * get a new one. */
- for (it = mHWData->mGuestProperties.begin();
- it->strName != utf8Name;
- ++it)
- ;
mHWData->mGuestProperties.erase(it);
}
- found = true;
- break;
}
- if (found && SUCCEEDED(rc))
- {
- if (aValue)
- {
- RTTIMESPEC time;
- property.strValue = aValue;
- property.mTimestamp = RTTimeSpecGetNano(RTTimeNow(&time));
- if (aFlags != NULL)
- property.mFlags = fFlags;
- mHWData->mGuestProperties.push_back(property);
- }
- }
- else if (SUCCEEDED(rc) && aValue)
- {
- RTTIMESPEC time;
- setModified(IsModified_MachineData);
- mHWData.backup();
- property.strName = aName;
- property.strValue = aValue;
- property.mTimestamp = RTTimeSpecGetNano(RTTimeNow(&time));
- property.mFlags = fFlags;
- mHWData->mGuestProperties.push_back(property);
}
+
if ( SUCCEEDED(rc)
&& ( mHWData->mGuestPropertyNotificationPatterns.isEmpty()
|| RTStrSimplePatternMultiMatch(mHWData->mGuestPropertyNotificationPatterns.c_str(),
@@ -5616,8 +5639,8 @@ HRESULT Machine::setGuestPropertyToService(IN_BSTR aName, IN_BSTR aValue,
)
)
{
- /** @todo r=bird: Why aren't we leaving the lock here? The
- * same code in PushGuestProperty does... */
+ alock.release();
+
mParent->onGuestPropertyChange(mData->mUuid, aName,
aValue ? aValue : Bstr("").raw(),
aFlags ? aFlags : Bstr("").raw());
@@ -5713,42 +5736,50 @@ HRESULT Machine::enumerateGuestPropertiesInService
AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
Utf8Str strPatterns(aPatterns);
+ HWData::GuestPropertyMap propMap;
+
/*
* Look for matching patterns and build up a list.
*/
- HWData::GuestPropertyList propList;
- for (HWData::GuestPropertyList::iterator it = mHWData->mGuestProperties.begin();
- it != mHWData->mGuestProperties.end();
- ++it)
+ HWData::GuestPropertyMap::const_iterator it = mHWData->mGuestProperties.begin();
+ while (it != mHWData->mGuestProperties.end())
+ {
if ( strPatterns.isEmpty()
|| RTStrSimplePatternMultiMatch(strPatterns.c_str(),
RTSTR_MAX,
- it->strName.c_str(),
+ it->first.c_str(),
RTSTR_MAX,
NULL)
)
- propList.push_back(*it);
+ {
+ propMap.insert(*it);
+ }
+
+ it++;
+ }
+
+ alock.release();
/*
* And build up the arrays for returning the property information.
*/
- size_t cEntries = propList.size();
+ size_t cEntries = propMap.size();
SafeArray<BSTR> names(cEntries);
SafeArray<BSTR> values(cEntries);
SafeArray<LONG64> timestamps(cEntries);
SafeArray<BSTR> flags(cEntries);
size_t iProp = 0;
- for (HWData::GuestPropertyList::iterator it = propList.begin();
- it != propList.end();
- ++it)
+
+ it = propMap.begin();
+ while (it != propMap.end())
{
char szFlags[MAX_FLAGS_LEN + 1];
- it->strName.cloneTo(&names[iProp]);
- it->strValue.cloneTo(&values[iProp]);
- timestamps[iProp] = it->mTimestamp;
- writeFlags(it->mFlags, szFlags);
- Bstr(szFlags).cloneTo(&flags[iProp]);
- ++iProp;
+ it->first.cloneTo(&names[iProp]);
+ it->second.strValue.cloneTo(&values[iProp]);
+ timestamps[iProp] = it->second.mTimestamp;
+ writeFlags(it->second.mFlags, szFlags);
+ Bstr(szFlags).cloneTo(&flags[iProp++]);
+ it++;
}
names.detachTo(ComSafeArrayOutArg(aNames));
values.detachTo(ComSafeArrayOutArg(aValues));
@@ -8530,6 +8561,7 @@ HRESULT Machine::loadHardware(const settings::Hardware &data, const settings::De
mHWData->mPointingHIDType = data.pointingHIDType;
mHWData->mKeyboardHIDType = data.keyboardHIDType;
mHWData->mChipsetType = data.chipsetType;
+ mHWData->mEmulatedUSBWebcamEnabled = data.fEmulatedUSBWebcam;
mHWData->mEmulatedUSBCardReaderEnabled = data.fEmulatedUSBCardReader;
mHWData->mHPETEnabled = data.fHPETEnabled;
@@ -8671,8 +8703,8 @@ HRESULT Machine::loadHardware(const settings::Hardware &data, const settings::De
const settings::GuestProperty &prop = *it;
uint32_t fFlags = guestProp::NILFLAG;
guestProp::validateFlags(prop.strFlags.c_str(), &fFlags);
- HWData::GuestProperty property = { prop.strName, prop.strValue, (LONG64) prop.timestamp, fFlags };
- mHWData->mGuestProperties.push_back(property);
+ HWData::GuestProperty property = { prop.strValue, (LONG64) prop.timestamp, fFlags };
+ mHWData->mGuestProperties[prop.strName] = property;
}
mHWData->mGuestPropertyNotificationPatterns = data.strNotificationPatterns;
@@ -9715,6 +9747,7 @@ HRESULT Machine::saveHardware(settings::Hardware &data, settings::Debugging *pDb
// chipset
data.chipsetType = mHWData->mChipsetType;
+ data.fEmulatedUSBWebcam = !!mHWData->mEmulatedUSBWebcamEnabled;
data.fEmulatedUSBCardReader = !!mHWData->mEmulatedUSBCardReaderEnabled;
// HPET
@@ -9854,11 +9887,11 @@ HRESULT Machine::saveHardware(settings::Hardware &data, settings::Debugging *pDb
// guest properties
data.llGuestProperties.clear();
#ifdef VBOX_WITH_GUEST_PROPS
- for (HWData::GuestPropertyList::const_iterator it = mHWData->mGuestProperties.begin();
+ for (HWData::GuestPropertyMap::const_iterator it = mHWData->mGuestProperties.begin();
it != mHWData->mGuestProperties.end();
++it)
{
- HWData::GuestProperty property = *it;
+ HWData::GuestProperty property = it->second;
/* Remove transient guest properties at shutdown unless we
* are saving state */
@@ -9869,7 +9902,7 @@ HRESULT Machine::saveHardware(settings::Hardware &data, settings::Debugging *pDb
|| property.mFlags & guestProp::TRANSRESET))
continue;
settings::GuestProperty prop;
- prop.strName = property.strName;
+ prop.strName = it->first;
prop.strValue = property.strValue;
prop.timestamp = property.mTimestamp;
char szFlags[guestProp::MAX_FLAGS_LEN + 1];
@@ -10372,6 +10405,30 @@ HRESULT Machine::deleteImplicitDiffs(bool aOnline)
/* We absolutely must have backed up state. */
AssertReturn(mMediaData.isBackedUp(), E_FAIL);
+ /* Check if there are any implicitly created diff images. */
+ bool fImplicitDiffs = false;
+ for (MediaData::AttachmentList::const_iterator it = mMediaData->mAttachments.begin();
+ it != mMediaData->mAttachments.end();
+ ++it)
+ {
+ const ComObjPtr<MediumAttachment> &pAtt = *it;
+ if (pAtt->isImplicit())
+ {
+ fImplicitDiffs = true;
+ break;
+ }
+ }
+ /* If there is nothing to do, leave early. This saves lots of image locking
+ * effort. It also avoids a MachineStateChanged event without real reason.
+ * This is important e.g. when loading a VM config, because there should be
+ * no events. Otherwise API clients can become thoroughly confused for
+ * inaccessible VMs (the code for loading VM configs uses this method for
+ * cleanup if the config makes no sense), as they take such events as an
+ * indication that the VM is alive, and they would force the VM config to
+ * be reread, leading to an endless loop. */
+ if (!fImplicitDiffs)
+ return S_OK;
+
HRESULT rc = S_OK;
MachineState_T oldState = mData->mMachineState;
@@ -12742,18 +12799,18 @@ STDMETHODIMP SessionMachine::PullGuestProperties(ComSafeArrayOut(BSTR, aNames),
com::SafeArray<LONG64> timestamps(cEntries);
com::SafeArray<BSTR> flags(cEntries);
unsigned i = 0;
- for (HWData::GuestPropertyList::iterator it = mHWData->mGuestProperties.begin();
+ for (HWData::GuestPropertyMap::iterator it = mHWData->mGuestProperties.begin();
it != mHWData->mGuestProperties.end();
++it)
{
char szFlags[MAX_FLAGS_LEN + 1];
- it->strName.cloneTo(&names[i]);
- it->strValue.cloneTo(&values[i]);
- timestamps[i] = it->mTimestamp;
+ it->first.cloneTo(&names[i]);
+ it->second.strValue.cloneTo(&values[i]);
+ timestamps[i] = it->second.mTimestamp;
/* If it is NULL, keep it NULL. */
- if (it->mFlags)
+ if (it->second.mFlags)
{
- writeFlags(it->mFlags, szFlags);
+ writeFlags(it->second.mFlags, szFlags);
Bstr(szFlags).cloneTo(&flags[i]);
}
else
@@ -12830,29 +12887,18 @@ STDMETHODIMP SessionMachine::PushGuestProperty(IN_BSTR aName,
setModified(IsModified_MachineData);
mHWData.backup();
- /** @todo r=bird: The careful memory handling doesn't work out here because
- * the catch block won't undo any damage we've done. So, if push_back throws
- * bad_alloc then you've lost the value.
- *
- * Another thing. Doing a linear search here isn't extremely efficient, esp.
- * since values that changes actually bubbles to the end of the list. Using
- * something that has an efficient lookup and can tolerate a bit of updates
- * would be nice. RTStrSpace is one suggestion (it's not perfect). Some
- * combination of RTStrCache (for sharing names and getting uniqueness into
- * the bargain) and hash/tree is another. */
- for (HWData::GuestPropertyList::iterator iter = mHWData->mGuestProperties.begin();
- iter != mHWData->mGuestProperties.end();
- ++iter)
- if (utf8Name == iter->strName)
+ HWData::GuestPropertyMap::iterator it = mHWData->mGuestProperties.find(utf8Name);
+ if (it != mHWData->mGuestProperties.end())
+ {
+ if (RT_VALID_PTR(aValue) && *(aValue) != '\0')
{
- mHWData->mGuestProperties.erase(iter);
- mData->mGuestPropertiesModified = TRUE;
- break;
+ it->second.strValue = aValue;
+ it->second.mFlags = fFlags;
+ it->second.mTimestamp = aTimestamp;
}
- if (aValue != NULL)
- {
- HWData::GuestProperty property = { aName, aValue, aTimestamp, fFlags };
- mHWData->mGuestProperties.push_back(property);
+ else
+ mHWData->mGuestProperties.erase(it);
+
mData->mGuestPropertiesModified = TRUE;
}
@@ -13918,13 +13964,13 @@ HRESULT SessionMachine::setMachineState(MachineState_T aMachineState)
/* Make sure any transient guest properties get removed from the
* property store on shutdown. */
- HWData::GuestPropertyList::iterator it;
+ HWData::GuestPropertyMap::const_iterator it;
BOOL fNeedsSaving = mData->mGuestPropertiesModified;
if (!fNeedsSaving)
for (it = mHWData->mGuestProperties.begin();
it != mHWData->mGuestProperties.end(); ++it)
- if ( (it->mFlags & guestProp::TRANSIENT)
- || (it->mFlags & guestProp::TRANSRESET))
+ if ( (it->second.mFlags & guestProp::TRANSIENT)
+ || (it->second.mFlags & guestProp::TRANSRESET))
{
fNeedsSaving = true;
break;
diff --git a/src/VBox/Main/src-server/MediumImpl.cpp b/src/VBox/Main/src-server/MediumImpl.cpp
index e942227e7..85c36fefd 100644
--- a/src/VBox/Main/src-server/MediumImpl.cpp
+++ b/src/VBox/Main/src-server/MediumImpl.cpp
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2008-2012 Oracle Corporation
+ * Copyright (C) 2008-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;
@@ -973,8 +973,29 @@ HRESULT Medium::init(VirtualBox *aVirtualBox,
AutoWriteLock treeLock(m->pVirtualBox->getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS);
ComObjPtr<Medium> pMedium;
+
+ /*
+ * Check whether the UUID is taken already and create a new one
+ * if required.
+ * Try this only a limited amount of times in case the PRNG is broken
+ * in some way to prevent an endless loop.
+ */
+ for (unsigned i = 0; i < 5; i++)
+ {
+ bool fInUse;
+
+ fInUse = m->pVirtualBox->isMediaUuidInUse(m->id, DeviceType_HardDisk);
+ if (fInUse)
+ {
+ // create new UUID
+ unconst(m->id).create();
+ }
+ else
+ break;
+ }
+
rc = m->pVirtualBox->registerMedium(this, &pMedium, DeviceType_HardDisk);
- Assert(this == pMedium);
+ Assert(this == pMedium || FAILED(rc));
}
/* Confirm a successful initialization when it's the case */
@@ -4452,6 +4473,112 @@ HRESULT Medium::unmarkLockedForDeletion()
}
/**
+ * Queries the preferred merge direction from this to the other medium, i.e.
+ * the one which requires the least amount of I/O and therefore time and
+ * disk consumption.
+ *
+ * @returns Status code.
+ * @retval E_FAIL in case determining the merge direction fails for some reason,
+ * for example if getting the size of the media fails. There is no
+ * error set though and the caller is free to continue to find out
+ * what was going wrong later. Leaves fMergeForward unset.
+ * @retval VBOX_E_INVALID_OBJECT_STATE if both media are not related to each other
+ * An error is set.
+ * @param pOther The other medium to merge with.
+ * @param fMergeForward Resulting preferred merge direction (out).
+ */
+HRESULT Medium::queryPreferredMergeDirection(const ComObjPtr<Medium> &pOther,
+ bool &fMergeForward)
+{
+ AssertReturn(pOther != NULL, E_FAIL);
+ AssertReturn(pOther != this, E_FAIL);
+
+ AutoCaller autoCaller(this);
+ AssertComRCReturnRC(autoCaller.rc());
+
+ AutoCaller otherCaller(pOther);
+ AssertComRCReturnRC(otherCaller.rc());
+
+ HRESULT rc = S_OK;
+ bool fThisParent = false; /**<< Flag whether this medium is the parent of pOther. */
+
+ try
+ {
+ // locking: we need the tree lock first because we access parent pointers
+ AutoWriteLock treeLock(m->pVirtualBox->getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS);
+
+ /* more sanity checking and figuring out the current merge direction */
+ ComObjPtr<Medium> pMedium = getParent();
+ while (!pMedium.isNull() && pMedium != pOther)
+ pMedium = pMedium->getParent();
+ if (pMedium == pOther)
+ fThisParent = false;
+ else
+ {
+ pMedium = pOther->getParent();
+ while (!pMedium.isNull() && pMedium != this)
+ pMedium = pMedium->getParent();
+ if (pMedium == this)
+ fThisParent = true;
+ else
+ {
+ Utf8Str tgtLoc;
+ {
+ AutoReadLock alock(pOther COMMA_LOCKVAL_SRC_POS);
+ tgtLoc = pOther->getLocationFull();
+ }
+
+ AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
+ throw setError(VBOX_E_INVALID_OBJECT_STATE,
+ tr("Media '%s' and '%s' are unrelated"),
+ m->strLocationFull.c_str(), tgtLoc.c_str());
+ }
+ }
+
+ /*
+ * Figure out the preferred merge direction. The current way is to
+ * get the current sizes of file based images and select the merge
+ * direction depending on the size.
+ *
+ * Can't use the VD API to get current size here as the media might
+ * be write locked by a running VM. Resort to RTFileQuerySize().
+ */
+ int vrc = VINF_SUCCESS;
+ uint64_t cbMediumThis = 0;
+ uint64_t cbMediumOther = 0;
+
+ if (isMediumFormatFile() && pOther->isMediumFormatFile())
+ {
+ vrc = RTFileQuerySize(this->getLocationFull().c_str(), &cbMediumThis);
+ if (RT_SUCCESS(vrc))
+ {
+ vrc = RTFileQuerySize(pOther->getLocationFull().c_str(),
+ &cbMediumOther);
+ }
+
+ if (RT_FAILURE(vrc))
+ rc = E_FAIL;
+ else
+ {
+ /*
+ * Check which merge direction might be more optimal.
+ * This method is not bullet proof of course as there might
+ * be overlapping blocks in the images so the file size is
+ * not the best indicator but it is good enough for our purpose
+ * and everything else is too complicated, especially when the
+ * media are used by a running VM.
+ */
+ bool fMergeIntoThis = cbMediumThis > cbMediumOther;
+ fMergeForward = fMergeIntoThis ^ fThisParent;
+ }
+ }
+ }
+ catch (HRESULT aRC) { rc = aRC; }
+
+ return rc;
+}
+
+/**
* Prepares this (source) medium, target medium and all intermediate media
* for the merge operation.
*
@@ -5534,7 +5661,12 @@ HRESULT Medium::queryInfo(bool fSetImageId, bool fSetParentId)
alock.acquire();
vrc = VDSetUuid(hdd, 0, m->uuidImage.raw());
alock.release();
- ComAssertRCThrow(vrc, E_FAIL);
+ if (RT_FAILURE(vrc))
+ {
+ lastAccessError = Utf8StrFmt(tr("Could not update the UUID of medium '%s'%s"),
+ location.c_str(), vdError(vrc).c_str());
+ throw S_OK;
+ }
mediumId = m->uuidImage;
}
if (fSetParentId)
@@ -5542,7 +5674,12 @@ HRESULT Medium::queryInfo(bool fSetImageId, bool fSetParentId)
alock.acquire();
vrc = VDSetParentUuid(hdd, 0, m->uuidParentImage.raw());
alock.release();
- ComAssertRCThrow(vrc, E_FAIL);
+ if (RT_FAILURE(vrc))
+ {
+ lastAccessError = Utf8StrFmt(tr("Could not update the parent UUID of medium '%s'%s"),
+ location.c_str(), vdError(vrc).c_str());
+ throw S_OK;
+ }
}
/* zap the information, these are no long-term members */
alock.acquire();
diff --git a/src/VBox/Main/src-server/ParallelPortImpl.cpp b/src/VBox/Main/src-server/ParallelPortImpl.cpp
index 56743a089..e9ce1d0d7 100644
--- a/src/VBox/Main/src-server/ParallelPortImpl.cpp
+++ b/src/VBox/Main/src-server/ParallelPortImpl.cpp
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2006-2010 Oracle Corporation
+ * Copyright (C) 2006-2011 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/src/VBox/Main/src-server/Performance.cpp b/src/VBox/Main/src-server/Performance.cpp
index 1ee789be6..b544f086f 100644
--- a/src/VBox/Main/src-server/Performance.cpp
+++ b/src/VBox/Main/src-server/Performance.cpp
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2008 Oracle Corporation
+ * Copyright (C) 2008-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;
@@ -28,6 +28,8 @@
#include "AutoCaller.h"
#endif
#include "Performance.h"
+#include "HostNetworkInterfaceImpl.h"
+#include "netif.h"
#include <VBox/com/array.h>
#include <VBox/com/ptr.h>
@@ -637,6 +639,12 @@ void HostCpuLoad::collect()
}
}
+void HostCpuLoadRaw::init(ULONG period, ULONG length)
+{
+ HostCpuLoad::init(period, length);
+ mHAL->getRawHostCpuLoad(&mUserPrev, &mKernelPrev, &mIdlePrev);
+}
+
void HostCpuLoadRaw::preCollect(CollectorHints& hints, uint64_t /* iTick */)
{
hints.collectHostCpuLoad();
@@ -677,12 +685,49 @@ void HostCpuLoadRaw::collect()
}
}
+#ifndef VBOX_COLLECTOR_TEST_CASE
+static bool getLinkSpeed(const char *szShortName, uint32_t *pSpeed)
+{
+ /*
+ * Note that we do not need the full name in the info, so we do not
+ * allocate the space for it and we rely on the fact that
+ * NetIfGetConfigByName() never fills it.
+ */
+ NETIFINFO Info;
+ memset(&Info, 0, sizeof(Info));
+ strcpy(Info.szShortName, szShortName);
+ int rc = NetIfGetConfigByName(&Info);
+ if (RT_FAILURE(rc))
+ return false;
+ *pSpeed = Info.enmStatus == NETIF_S_UP ? Info.uSpeedMbits : 0;
+ return true;
+}
+
+void HostNetworkSpeed::init(ULONG period, ULONG length)
+{
+ mPeriod = period;
+ mLength = length;
+ mLinkSpeed->init(length);
+ /*
+ * Retrieve the link speed now as it may be wrong if the metric was
+ * registered at boot (see @bugref{6613}).
+ */
+ getLinkSpeed(mShortName.c_str(), &mSpeed);
+}
+
void HostNetworkLoadRaw::init(ULONG period, ULONG length)
{
mPeriod = period;
mLength = length;
mRx->init(mLength);
mTx->init(mLength);
+ /*
+ * Retrieve the link speed now as it may be wrong if the metric was
+ * registered at boot (see @bugref{6613}).
+ */
+ uint32_t uSpeedMbit = 65535;
+ if (getLinkSpeed(mShortName.c_str(), &uSpeedMbit))
+ mSpeed = (uint64_t)uSpeedMbit * (1000000/8); /* Convert to bytes/sec */
/*int rc =*/ mHAL->getRawHostNetworkLoad(mShortName.c_str(), &mRxPrev, &mTxPrev);
//AssertRC(rc);
}
@@ -729,6 +774,7 @@ void HostNetworkLoadRaw::collect()
LogFlowThisFunc(("Failed to collect data: %Rrc (%d)."
" Will update the list of interfaces...\n", mRc,mRc));
}
+#endif /* !VBOX_COLLECTOR_TEST_CASE */
void HostDiskLoadRaw::init(ULONG period, ULONG length)
{
diff --git a/src/VBox/Main/src-server/PerformanceImpl.cpp b/src/VBox/Main/src-server/PerformanceImpl.cpp
index b233f0a7a..87ad1c4ca 100644
--- a/src/VBox/Main/src-server/PerformanceImpl.cpp
+++ b/src/VBox/Main/src-server/PerformanceImpl.cpp
@@ -6,7 +6,7 @@
*/
/*
- * Copyright (C) 2008-2010 Oracle Corporation
+ * Copyright (C) 2008-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/src/VBox/Main/src-server/ProgressProxyImpl.cpp b/src/VBox/Main/src-server/ProgressProxyImpl.cpp
index a6628760a..60750d6f8 100644
--- a/src/VBox/Main/src-server/ProgressProxyImpl.cpp
+++ b/src/VBox/Main/src-server/ProgressProxyImpl.cpp
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2010 Oracle Corporation
+ * Copyright (C) 2010-2011 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/src/VBox/Main/src-server/SerialPortImpl.cpp b/src/VBox/Main/src-server/SerialPortImpl.cpp
index 81234c490..5bbf4ba36 100644
--- a/src/VBox/Main/src-server/SerialPortImpl.cpp
+++ b/src/VBox/Main/src-server/SerialPortImpl.cpp
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2011 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/src/VBox/Main/src-server/SnapshotImpl.cpp b/src/VBox/Main/src-server/SnapshotImpl.cpp
index d8aa7a795..c45f7eb68 100644
--- a/src/VBox/Main/src-server/SnapshotImpl.cpp
+++ b/src/VBox/Main/src-server/SnapshotImpl.cpp
@@ -5,7 +5,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;
@@ -2449,7 +2449,6 @@ void SessionMachine::deleteSnapshotHandler(DeleteSnapshotTask &aTask)
// then do a backward merge, i.e. merge its only child onto the
// base disk. Here we need then to update the attachment that
// refers to the child and have it point to the parent instead
- Assert(pHD->getParent().isNull());
Assert(pHD->getChildren().size() == 1);
ComObjPtr<Medium> pReplaceHD = pHD->getChildren().front();
@@ -2887,9 +2886,30 @@ HRESULT SessionMachine::prepareDeleteSnapshotMedium(const ComObjPtr<Medium> &aHD
}
else
{
- /* forward merge */
- aSource = aHD;
- aTarget = pChild;
+ /* Determine best merge direction. */
+ bool fMergeForward = true;
+
+ childLock.release();
+ alock.release();
+ HRESULT rc = aHD->queryPreferredMergeDirection(pChild, fMergeForward);
+ alock.acquire();
+ childLock.acquire();
+
+ if (FAILED(rc) && rc != E_FAIL)
+ return rc;
+
+ if (fMergeForward)
+ {
+ aSource = aHD;
+ aTarget = pChild;
+ LogFlowFunc(("Forward merging selected\n"));
+ }
+ else
+ {
+ aSource = pChild;
+ aTarget = aHD;
+ LogFlowFunc(("Backward merging selected\n"));
+ }
}
HRESULT rc;
diff --git a/src/VBox/Main/src-server/StorageControllerImpl.cpp b/src/VBox/Main/src-server/StorageControllerImpl.cpp
index 100c5b227..b56869330 100644
--- a/src/VBox/Main/src-server/StorageControllerImpl.cpp
+++ b/src/VBox/Main/src-server/StorageControllerImpl.cpp
@@ -6,7 +6,7 @@
*/
/*
- * Copyright (C) 2008-2010 Oracle Corporation
+ * Copyright (C) 2008-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/src/VBox/Main/src-server/USBDeviceFilterImpl.cpp b/src/VBox/Main/src-server/USBDeviceFilterImpl.cpp
index 0c8046e96..b56f53e53 100644
--- a/src/VBox/Main/src-server/USBDeviceFilterImpl.cpp
+++ b/src/VBox/Main/src-server/USBDeviceFilterImpl.cpp
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2011 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/src/VBox/Main/src-server/VFSExplorerImpl.cpp b/src/VBox/Main/src-server/VFSExplorerImpl.cpp
index e94b7225d..892e00bb5 100644
--- a/src/VBox/Main/src-server/VFSExplorerImpl.cpp
+++ b/src/VBox/Main/src-server/VFSExplorerImpl.cpp
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (C) 2009 Oracle Corporation
+ * Copyright (C) 2009-2011 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/src/VBox/Main/src-server/VRDEServerImpl.cpp b/src/VBox/Main/src-server/VRDEServerImpl.cpp
index 5862545a4..0653b2c19 100644
--- a/src/VBox/Main/src-server/VRDEServerImpl.cpp
+++ b/src/VBox/Main/src-server/VRDEServerImpl.cpp
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2006-2010 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;
@@ -72,7 +72,7 @@ void VRDEServer::FinalRelease()
*
* @param aParent Handle of the parent object.
*/
-HRESULT VRDEServer::init (Machine *aParent)
+HRESULT VRDEServer::init(Machine *aParent)
{
LogFlowThisFunc(("aParent=%p\n", aParent));
@@ -111,7 +111,7 @@ HRESULT VRDEServer::init (Machine *aParent)
*
* @note Locks @a aThat object for reading.
*/
-HRESULT VRDEServer::init (Machine *aParent, VRDEServer *aThat)
+HRESULT VRDEServer::init(Machine *aParent, VRDEServer *aThat)
{
LogFlowThisFunc(("aParent=%p, aThat=%p\n", aParent, aThat));
@@ -124,11 +124,11 @@ HRESULT VRDEServer::init (Machine *aParent, VRDEServer *aThat)
unconst(mParent) = aParent;
unconst(mPeer) = aThat;
- AutoCaller thatCaller (aThat);
+ AutoCaller thatCaller(aThat);
AssertComRCReturnRC(thatCaller.rc());
AutoReadLock thatLock(aThat COMMA_LOCKVAL_SRC_POS);
- mData.share (aThat->mData);
+ mData.share(aThat->mData);
/* Confirm a successful initialization */
autoInitSpan.setSucceeded();
@@ -143,7 +143,7 @@ HRESULT VRDEServer::init (Machine *aParent, VRDEServer *aThat)
*
* @note Locks @a aThat object for reading.
*/
-HRESULT VRDEServer::initCopy (Machine *aParent, VRDEServer *aThat)
+HRESULT VRDEServer::initCopy(Machine *aParent, VRDEServer *aThat)
{
LogFlowThisFunc(("aParent=%p, aThat=%p\n", aParent, aThat));
@@ -156,11 +156,11 @@ HRESULT VRDEServer::initCopy (Machine *aParent, VRDEServer *aThat)
unconst(mParent) = aParent;
/* mPeer is left null */
- AutoCaller thatCaller (aThat);
+ AutoCaller thatCaller(aThat);
AssertComRCReturnRC(thatCaller.rc());
AutoReadLock thatLock(aThat COMMA_LOCKVAL_SRC_POS);
- mData.attachCopy (aThat->mData);
+ mData.attachCopy(aThat->mData);
/* Confirm a successful initialization */
autoInitSpan.setSucceeded();
@@ -245,7 +245,7 @@ HRESULT VRDEServer::saveSettings(settings::VRDESettings &data)
// IVRDEServer properties
/////////////////////////////////////////////////////////////////////////////
-STDMETHODIMP VRDEServer::COMGETTER(Enabled) (BOOL *aEnabled)
+STDMETHODIMP VRDEServer::COMGETTER(Enabled)(BOOL *aEnabled)
{
CheckComArgOutPointerValid(aEnabled);
@@ -257,13 +257,13 @@ STDMETHODIMP VRDEServer::COMGETTER(Enabled) (BOOL *aEnabled)
return S_OK;
}
-STDMETHODIMP VRDEServer::COMSETTER(Enabled) (BOOL aEnabled)
+STDMETHODIMP VRDEServer::COMSETTER(Enabled)(BOOL aEnabled)
{
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
/* the machine can also be in saved state for this property to change */
- AutoMutableOrSavedStateDependency adep (mParent);
+ AutoMutableOrSavedStateDependency adep(mParent);
if (FAILED(adep.rc())) return adep.rc();
AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
@@ -373,15 +373,15 @@ static int vrdpServerVerifyPortsString(Bstr ports)
return VINF_SUCCESS;
}
-STDMETHODIMP VRDEServer::SetVRDEProperty (IN_BSTR aKey, IN_BSTR aValue)
+STDMETHODIMP VRDEServer::SetVRDEProperty(IN_BSTR aKey, IN_BSTR aValue)
{
LogFlowThisFunc(("\n"));
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
- /* The machine needs to be mutable. */
- AutoMutableStateDependency adep(mParent);
+ /* the machine can also be in saved state for this property to change */
+ AutoMutableOrSavedStateDependency adep(mParent);
if (FAILED(adep.rc())) return adep.rc();
Bstr key = aKey;
@@ -460,7 +460,7 @@ STDMETHODIMP VRDEServer::SetVRDEProperty (IN_BSTR aKey, IN_BSTR aValue)
return S_OK;
}
-STDMETHODIMP VRDEServer::GetVRDEProperty (IN_BSTR aKey, BSTR *aValue)
+STDMETHODIMP VRDEServer::GetVRDEProperty(IN_BSTR aKey, BSTR *aValue)
{
CheckComArgOutPointerValid(aValue);
@@ -627,7 +627,7 @@ STDMETHODIMP VRDEServer::COMGETTER(VRDEProperties)(ComSafeArrayOut(BSTR, aProper
return S_OK;
}
-STDMETHODIMP VRDEServer::COMGETTER(AuthType) (AuthType_T *aType)
+STDMETHODIMP VRDEServer::COMGETTER(AuthType)(AuthType_T *aType)
{
CheckComArgOutPointerValid(aType);
@@ -641,13 +641,13 @@ STDMETHODIMP VRDEServer::COMGETTER(AuthType) (AuthType_T *aType)
return S_OK;
}
-STDMETHODIMP VRDEServer::COMSETTER(AuthType) (AuthType_T aType)
+STDMETHODIMP VRDEServer::COMSETTER(AuthType)(AuthType_T aType)
{
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
- /* the machine needs to be mutable */
- AutoMutableStateDependency adep(mParent);
+ /* the machine can also be in saved state for this property to change */
+ AutoMutableOrSavedStateDependency adep(mParent);
if (FAILED(adep.rc())) return adep.rc();
AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
@@ -670,7 +670,7 @@ STDMETHODIMP VRDEServer::COMSETTER(AuthType) (AuthType_T aType)
return S_OK;
}
-STDMETHODIMP VRDEServer::COMGETTER(AuthTimeout) (ULONG *aTimeout)
+STDMETHODIMP VRDEServer::COMGETTER(AuthTimeout)(ULONG *aTimeout)
{
CheckComArgOutPointerValid(aTimeout);
@@ -684,13 +684,13 @@ STDMETHODIMP VRDEServer::COMGETTER(AuthTimeout) (ULONG *aTimeout)
return S_OK;
}
-STDMETHODIMP VRDEServer::COMSETTER(AuthTimeout) (ULONG aTimeout)
+STDMETHODIMP VRDEServer::COMSETTER(AuthTimeout)(ULONG aTimeout)
{
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
- /* the machine needs to be mutable */
- AutoMutableStateDependency adep(mParent);
+ /* the machine can also be in saved state for this property to change */
+ AutoMutableOrSavedStateDependency adep(mParent);
if (FAILED(adep.rc())) return adep.rc();
AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
@@ -717,7 +717,7 @@ STDMETHODIMP VRDEServer::COMSETTER(AuthTimeout) (ULONG aTimeout)
return S_OK;
}
-STDMETHODIMP VRDEServer::COMGETTER(AuthLibrary) (BSTR *aLibrary)
+STDMETHODIMP VRDEServer::COMGETTER(AuthLibrary)(BSTR *aLibrary)
{
CheckComArgOutPointerValid(aLibrary);
@@ -748,13 +748,13 @@ STDMETHODIMP VRDEServer::COMGETTER(AuthLibrary) (BSTR *aLibrary)
return S_OK;
}
-STDMETHODIMP VRDEServer::COMSETTER(AuthLibrary) (IN_BSTR aLibrary)
+STDMETHODIMP VRDEServer::COMSETTER(AuthLibrary)(IN_BSTR aLibrary)
{
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
- /* the machine needs to be mutable */
- AutoMutableStateDependency adep(mParent);
+ /* the machine can also be in saved state for this property to change */
+ AutoMutableOrSavedStateDependency adep(mParent);
if (FAILED(adep.rc())) return adep.rc();
Bstr bstrLibrary(aLibrary);
@@ -779,8 +779,7 @@ STDMETHODIMP VRDEServer::COMSETTER(AuthLibrary) (IN_BSTR aLibrary)
return S_OK;
}
-STDMETHODIMP VRDEServer::COMGETTER(AllowMultiConnection) (
- BOOL *aAllowMultiConnection)
+STDMETHODIMP VRDEServer::COMGETTER(AllowMultiConnection)(BOOL *aAllowMultiConnection)
{
CheckComArgOutPointerValid(aAllowMultiConnection);
@@ -794,14 +793,13 @@ STDMETHODIMP VRDEServer::COMGETTER(AllowMultiConnection) (
return S_OK;
}
-STDMETHODIMP VRDEServer::COMSETTER(AllowMultiConnection) (
- BOOL aAllowMultiConnection)
+STDMETHODIMP VRDEServer::COMSETTER(AllowMultiConnection)(BOOL aAllowMultiConnection)
{
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
- /* the machine needs to be mutable */
- AutoMutableStateDependency adep(mParent);
+ /* the machine can also be in saved state for this property to change */
+ AutoMutableOrSavedStateDependency adep(mParent);
if (FAILED(adep.rc())) return adep.rc();
AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
@@ -824,8 +822,7 @@ STDMETHODIMP VRDEServer::COMSETTER(AllowMultiConnection) (
return S_OK;
}
-STDMETHODIMP VRDEServer::COMGETTER(ReuseSingleConnection) (
- BOOL *aReuseSingleConnection)
+STDMETHODIMP VRDEServer::COMGETTER(ReuseSingleConnection)(BOOL *aReuseSingleConnection)
{
CheckComArgOutPointerValid(aReuseSingleConnection);
@@ -839,14 +836,13 @@ STDMETHODIMP VRDEServer::COMGETTER(ReuseSingleConnection) (
return S_OK;
}
-STDMETHODIMP VRDEServer::COMSETTER(ReuseSingleConnection) (
- BOOL aReuseSingleConnection)
+STDMETHODIMP VRDEServer::COMSETTER(ReuseSingleConnection)(BOOL aReuseSingleConnection)
{
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
- /* the machine needs to be mutable */
- AutoMutableStateDependency adep(mParent);
+ /* the machine can also be in saved state for this property to change */
+ AutoMutableOrSavedStateDependency adep(mParent);
if (FAILED(adep.rc())) return adep.rc();
AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
@@ -869,7 +865,7 @@ STDMETHODIMP VRDEServer::COMSETTER(ReuseSingleConnection) (
return S_OK;
}
-STDMETHODIMP VRDEServer::COMGETTER(VRDEExtPack) (BSTR *aExtPack)
+STDMETHODIMP VRDEServer::COMGETTER(VRDEExtPack)(BSTR *aExtPack)
{
CheckComArgOutPointerValid(aExtPack);
@@ -919,8 +915,8 @@ STDMETHODIMP VRDEServer::COMSETTER(VRDEExtPack)(IN_BSTR aExtPack)
HRESULT hrc = autoCaller.rc();
if (SUCCEEDED(hrc))
{
- /* the machine needs to be mutable */
- AutoMutableStateDependency adep(mParent);
+ /* the machine can also be in saved state for this property to change */
+ AutoMutableOrSavedStateDependency adep(mParent);
hrc = adep.rc();
if (SUCCEEDED(hrc))
{
@@ -994,11 +990,11 @@ void VRDEServer::commit()
{
/* sanity */
AutoCaller autoCaller(this);
- AssertComRCReturnVoid (autoCaller.rc());
+ AssertComRCReturnVoid(autoCaller.rc());
/* sanity too */
- AutoCaller peerCaller (mPeer);
- AssertComRCReturnVoid (peerCaller.rc());
+ AutoCaller peerCaller(mPeer);
+ AssertComRCReturnVoid(peerCaller.rc());
/* lock both for writing since we modify both (mPeer is "master" so locked
* first) */
@@ -1010,7 +1006,7 @@ void VRDEServer::commit()
if (mPeer)
{
/* attach new data to the peer and reshare it */
- mPeer->mData.attach (mData);
+ mPeer->mData.attach(mData);
}
}
}
@@ -1019,17 +1015,17 @@ void VRDEServer::commit()
* @note Locks this object for writing, together with the peer object
* represented by @a aThat (locked for reading).
*/
-void VRDEServer::copyFrom (VRDEServer *aThat)
+void VRDEServer::copyFrom(VRDEServer *aThat)
{
- AssertReturnVoid (aThat != NULL);
+ AssertReturnVoid(aThat != NULL);
/* sanity */
AutoCaller autoCaller(this);
- AssertComRCReturnVoid (autoCaller.rc());
+ AssertComRCReturnVoid(autoCaller.rc());
/* sanity too */
- AutoCaller thatCaller (aThat);
- AssertComRCReturnVoid (thatCaller.rc());
+ AutoCaller thatCaller(aThat);
+ AssertComRCReturnVoid(thatCaller.rc());
/* peer is not modified, lock it for reading (aThat is "master" so locked
* first) */
@@ -1037,6 +1033,6 @@ void VRDEServer::copyFrom (VRDEServer *aThat)
AutoWriteLock wl(this COMMA_LOCKVAL_SRC_POS);
/* this will back up current data */
- mData.assignCopy (aThat->mData);
+ mData.assignCopy(aThat->mData);
}
/* vi: set tabstop=4 shiftwidth=4 expandtab: */
diff --git a/src/VBox/Main/src-server/VirtualBoxImpl.cpp b/src/VBox/Main/src-server/VirtualBoxImpl.cpp
index d90b0b0b2..9789a2bd0 100644
--- a/src/VBox/Main/src-server/VirtualBoxImpl.cpp
+++ b/src/VBox/Main/src-server/VirtualBoxImpl.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;
@@ -1514,13 +1514,13 @@ void sanitiseMachineFilename(Utf8Str &strName)
* *nix, or be otherwise difficult for shells to handle (I would have
* preferred to remove the space and brackets too). We also remove all
* characters which need UTF-16 surrogate pairs for Windows's benefit. */
-#ifdef RT_STRICT
RTUNICP aCpSet[] =
{ ' ', ' ', '(', ')', '-', '.', '0', '9', 'A', 'Z', 'a', 'z', '_', '_',
0xa0, 0xd7af, '\0' };
-#endif
char *pszName = strName.mutableRaw();
- Assert(RTStrPurgeComplementSet(pszName, aCpSet, '_') >= 0);
+ int cReplacements = RTStrPurgeComplementSet(pszName, aCpSet, '_');
+ Assert(cReplacements >= 0);
+ NOREF(cReplacements);
/* No leading dot or dash. */
if (pszName[0] == '.' || pszName[0] == '-')
pszName[0] = '_';
@@ -3877,6 +3877,48 @@ HRESULT VirtualBox::checkMediaForConflicts(const Guid &aId,
}
/**
+ * Checks whether the given UUID is already in use by one medium for the
+ * given device type.
+ *
+ * @returns true if the UUID is already in use
+ * fale otherwise
+ * @param aId The UUID to check.
+ * @param deviceType The device type the UUID is going to be checked for
+ * conflicts.
+ */
+bool VirtualBox::isMediaUuidInUse(const Guid &aId, DeviceType_T deviceType)
+{
+ AssertReturn(!aId.isEmpty(), E_FAIL);
+
+ AutoReadLock alock(getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS);
+
+ HRESULT rc = S_OK;
+ bool fInUse = false;
+
+ ComObjPtr<Medium> pMediumFound;
+
+ switch (deviceType)
+ {
+ case DeviceType_HardDisk:
+ rc = findHardDiskById(aId, false /* aSetError */, &pMediumFound);
+ break;
+ case DeviceType_DVD:
+ rc = findDVDOrFloppyImage(DeviceType_DVD, &aId, Utf8Str::Empty, false /* aSetError */, &pMediumFound);
+ break;
+ case DeviceType_Floppy:
+ rc = findDVDOrFloppyImage(DeviceType_Floppy, &aId, Utf8Str::Empty, false /* aSetError */, &pMediumFound);
+ break;
+ default:
+ AssertMsgFailed(("Invalid device type %d\n", deviceType));
+ }
+
+ if (SUCCEEDED(rc) && pMediumFound)
+ fInUse = true;
+
+ return fInUse;
+}
+
+/**
* Called from Machine::prepareSaveSettings() when it has detected
* that a machine has been renamed. Such renames will require
* updating the global media registry during the
diff --git a/src/VBox/Main/src-server/darwin/HostPowerDarwin.cpp b/src/VBox/Main/src-server/darwin/HostPowerDarwin.cpp
index a83297e40..f9e9cdc5d 100644
--- a/src/VBox/Main/src-server/darwin/HostPowerDarwin.cpp
+++ b/src/VBox/Main/src-server/darwin/HostPowerDarwin.cpp
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2008 Oracle Corporation
+ * Copyright (C) 2008-2010 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/src/VBox/Main/src-server/darwin/NetIf-darwin.cpp b/src/VBox/Main/src-server/darwin/NetIf-darwin.cpp
index 99cf52e2f..1e40064d5 100644
--- a/src/VBox/Main/src-server/darwin/NetIf-darwin.cpp
+++ b/src/VBox/Main/src-server/darwin/NetIf-darwin.cpp
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2008 Oracle Corporation
+ * Copyright (C) 2008-2011 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/src/VBox/Main/src-server/darwin/PerformanceDarwin.cpp b/src/VBox/Main/src-server/darwin/PerformanceDarwin.cpp
index f02581bb0..86f1cc678 100644
--- a/src/VBox/Main/src-server/darwin/PerformanceDarwin.cpp
+++ b/src/VBox/Main/src-server/darwin/PerformanceDarwin.cpp
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2008 Oracle Corporation
+ * Copyright (C) 2008-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;
@@ -24,6 +24,7 @@
#include <sys/errno.h>
#include <iprt/err.h>
#include <iprt/log.h>
+#include <iprt/mp.h>
#include <iprt/param.h>
#include "Performance.h"
@@ -64,6 +65,7 @@ public:
virtual int getProcessMemoryUsage(RTPROCESS process, ULONG *used);
private:
ULONG totalRAM;
+ uint32_t nCpus;
};
CollectorHAL *createHAL()
@@ -86,6 +88,13 @@ CollectorDarwin::CollectorDarwin()
hostMemory = 0;
}
totalRAM = (ULONG)(hostMemory / 1024);
+ nCpus = RTMpGetOnlineCount();
+ Assert(nCpus);
+ if (nCpus == 0)
+ {
+ /* It is rather unsual to have no CPUs, but the show must go on. */
+ nCpus = 1;
+ }
}
int CollectorDarwin::getRawHostCpuLoad(uint64_t *user, uint64_t *kernel, uint64_t *idle)
@@ -156,8 +165,12 @@ int CollectorDarwin::getRawProcessCpuLoad(RTPROCESS process, uint64_t *user, uin
int rc = getProcessInfo(process, &tinfo);
if (RT_SUCCESS(rc))
{
- *user = tinfo.pti_total_user;
- *kernel = tinfo.pti_total_system;
+ /*
+ * Adjust user and kernel values so 100% is when ALL cores are fully
+ * utilized (see @bugref{6345}).
+ */
+ *user = tinfo.pti_total_user / nCpus;
+ *kernel = tinfo.pti_total_system / nCpus;
*total = mach_absolute_time();
}
return rc;
diff --git a/src/VBox/Main/src-server/darwin/iokit.cpp b/src/VBox/Main/src-server/darwin/iokit.cpp
index 0045e7c0b..cbf32fc62 100644
--- a/src/VBox/Main/src-server/darwin/iokit.cpp
+++ b/src/VBox/Main/src-server/darwin/iokit.cpp
@@ -8,7 +8,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/src/VBox/Main/src-server/darwin/iokit.h b/src/VBox/Main/src-server/darwin/iokit.h
index 8cb80a52f..ff81b3c78 100644
--- a/src/VBox/Main/src-server/darwin/iokit.h
+++ b/src/VBox/Main/src-server/darwin/iokit.h
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2010 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/src/VBox/Main/src-server/freebsd/HostHardwareFreeBSD.cpp b/src/VBox/Main/src-server/freebsd/HostHardwareFreeBSD.cpp
index b654f5a63..f2e93bebf 100644
--- a/src/VBox/Main/src-server/freebsd/HostHardwareFreeBSD.cpp
+++ b/src/VBox/Main/src-server/freebsd/HostHardwareFreeBSD.cpp
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2008 Oracle Corporation
+ * Copyright (C) 2008-2011 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/src/VBox/Main/src-server/freebsd/NetIf-freebsd.cpp b/src/VBox/Main/src-server/freebsd/NetIf-freebsd.cpp
index 7066dab96..91895460b 100644
--- a/src/VBox/Main/src-server/freebsd/NetIf-freebsd.cpp
+++ b/src/VBox/Main/src-server/freebsd/NetIf-freebsd.cpp
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2008 Oracle Corporation
+ * Copyright (C) 2008-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/src/VBox/Main/src-server/freebsd/PerformanceFreeBSD.cpp b/src/VBox/Main/src-server/freebsd/PerformanceFreeBSD.cpp
index 0b8178423..77ec3169b 100644
--- a/src/VBox/Main/src-server/freebsd/PerformanceFreeBSD.cpp
+++ b/src/VBox/Main/src-server/freebsd/PerformanceFreeBSD.cpp
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2008-2009 Oracle Corporation
+ * Copyright (C) 2008-2010 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/src/VBox/Main/src-server/generic/AutostartDb-generic.cpp b/src/VBox/Main/src-server/generic/AutostartDb-generic.cpp
index 923e75fea..fe33bcf43 100644
--- a/src/VBox/Main/src-server/generic/AutostartDb-generic.cpp
+++ b/src/VBox/Main/src-server/generic/AutostartDb-generic.cpp
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2009-2010 Oracle Corporation
+ * Copyright (C) 2009-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/src/VBox/Main/src-server/generic/NetIf-generic.cpp b/src/VBox/Main/src-server/generic/NetIf-generic.cpp
index fdf72d6fc..9fc3b6b8d 100644
--- a/src/VBox/Main/src-server/generic/NetIf-generic.cpp
+++ b/src/VBox/Main/src-server/generic/NetIf-generic.cpp
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2009-2010 Oracle Corporation
+ * Copyright (C) 2009-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/src/VBox/Main/src-server/linux/HostHardwareLinux.cpp b/src/VBox/Main/src-server/linux/HostHardwareLinux.cpp
index 2dc722cce..c1d4995fa 100644
--- a/src/VBox/Main/src-server/linux/HostHardwareLinux.cpp
+++ b/src/VBox/Main/src-server/linux/HostHardwareLinux.cpp
@@ -6,7 +6,7 @@
*/
/*
- * Copyright (C) 2008-2010 Oracle Corporation
+ * Copyright (C) 2008-2011 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/src/VBox/Main/src-server/linux/NetIf-linux.cpp b/src/VBox/Main/src-server/linux/NetIf-linux.cpp
index e6dbc3f97..79f85d20d 100644
--- a/src/VBox/Main/src-server/linux/NetIf-linux.cpp
+++ b/src/VBox/Main/src-server/linux/NetIf-linux.cpp
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2008 Oracle Corporation
+ * Copyright (C) 2008-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/src/VBox/Main/src-server/linux/PerformanceLinux.cpp b/src/VBox/Main/src-server/linux/PerformanceLinux.cpp
index 63116c149..4eff670c3 100644
--- a/src/VBox/Main/src-server/linux/PerformanceLinux.cpp
+++ b/src/VBox/Main/src-server/linux/PerformanceLinux.cpp
@@ -6,7 +6,7 @@
*/
/*
- * Copyright (C) 2008-2011 Oracle Corporation
+ * Copyright (C) 2008-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/src/VBox/Main/src-server/linux/USBGetDevices.cpp b/src/VBox/Main/src-server/linux/USBGetDevices.cpp
index d824a0178..964d86cc8 100644
--- a/src/VBox/Main/src-server/linux/USBGetDevices.cpp
+++ b/src/VBox/Main/src-server/linux/USBGetDevices.cpp
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2006-2010 Oracle Corporation
+ * Copyright (C) 2006-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/src/VBox/Main/src-server/linux/vbox-libhal.cpp b/src/VBox/Main/src-server/linux/vbox-libhal.cpp
index 2e7c2716e..ade8f072b 100644
--- a/src/VBox/Main/src-server/linux/vbox-libhal.cpp
+++ b/src/VBox/Main/src-server/linux/vbox-libhal.cpp
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2010 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/src/VBox/Main/src-server/os2/NetIf-os2.cpp b/src/VBox/Main/src-server/os2/NetIf-os2.cpp
index d0c287b52..49fd9c1df 100644
--- a/src/VBox/Main/src-server/os2/NetIf-os2.cpp
+++ b/src/VBox/Main/src-server/os2/NetIf-os2.cpp
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2008 Oracle Corporation
+ * Copyright (C) 2008-2010 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/src/VBox/Main/src-server/os2/PerformanceOs2.cpp b/src/VBox/Main/src-server/os2/PerformanceOs2.cpp
index 19e804a93..27c812536 100644
--- a/src/VBox/Main/src-server/os2/PerformanceOs2.cpp
+++ b/src/VBox/Main/src-server/os2/PerformanceOs2.cpp
@@ -6,7 +6,7 @@
*/
/*
- * Copyright (C) 2008 Oracle Corporation
+ * Copyright (C) 2008-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/src/VBox/Main/src-server/solaris/DynLoadLibSolaris.cpp b/src/VBox/Main/src-server/solaris/DynLoadLibSolaris.cpp
index 4bd864f16..a38b7654d 100644
--- a/src/VBox/Main/src-server/solaris/DynLoadLibSolaris.cpp
+++ b/src/VBox/Main/src-server/solaris/DynLoadLibSolaris.cpp
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2008 Oracle Corporation
+ * Copyright (C) 2008-2010 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/src/VBox/Main/src-server/solaris/DynLoadLibSolaris.h b/src/VBox/Main/src-server/solaris/DynLoadLibSolaris.h
index 4fc35b8ac..e306dac0e 100644
--- a/src/VBox/Main/src-server/solaris/DynLoadLibSolaris.h
+++ b/src/VBox/Main/src-server/solaris/DynLoadLibSolaris.h
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2008 Oracle Corporation
+ * Copyright (C) 2008-2010 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/src/VBox/Main/src-server/solaris/NetIf-solaris.cpp b/src/VBox/Main/src-server/solaris/NetIf-solaris.cpp
index bc7008206..5b1574d7e 100644
--- a/src/VBox/Main/src-server/solaris/NetIf-solaris.cpp
+++ b/src/VBox/Main/src-server/solaris/NetIf-solaris.cpp
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2008-2011 Oracle Corporation
+ * Copyright (C) 2008-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -73,10 +73,10 @@ static uint32_t getInstance(const char *pszIfaceName, char *pszDevName)
return uInstance;
}
-static uint64_t kstatGet(const char *name)
+static uint32_t kstatGet(const char *name)
{
kstat_ctl_t *kc;
- uint64_t uSpeed = 0;
+ uint32_t uSpeed = 0;
if ((kc = kstat_open()) == 0)
{
@@ -103,15 +103,21 @@ static uint64_t kstatGet(const char *name)
if ((kn = (kstat_named_t *)kstat_data_lookup(ksAdapter, (char *)"ifspeed")) == 0)
LogRel(("kstat_data_lookup(ifspeed) -> %d, name=%s\n", errno, name));
else
- uSpeed = kn->value.ul;
+ uSpeed = kn->value.ul / 1000000; /* bits -> Mbits */
}
kstat_close(kc);
+ LogFlow(("kstatGet(%s) -> %u Mbit/s\n", name, uSpeed));
return uSpeed;
}
static void queryIfaceSpeed(PNETIFINFO pInfo)
{
- pInfo->uSpeedMbits = kstatGet(pInfo->szShortName) / 1000000; /* bits -> Mbits */
+ /* Don't query interface speed for inactive interfaces (see @bugref{6345}). */
+ if (pInfo->enmStatus == NETIF_S_UP)
+ pInfo->uSpeedMbits = kstatGet(pInfo->szShortName);
+ else
+ pInfo->uSpeedMbits = 0;
+ LogFlow(("queryIfaceSpeed(%s) -> %u\n", pInfo->szShortName, pInfo->uSpeedMbits));
}
static void vboxSolarisAddHostIface(char *pszIface, int Instance, void *pvHostNetworkInterfaceList)
diff --git a/src/VBox/Main/src-server/solaris/PerformanceSolaris.cpp b/src/VBox/Main/src-server/solaris/PerformanceSolaris.cpp
index 6b66393cc..82defd768 100644
--- a/src/VBox/Main/src-server/solaris/PerformanceSolaris.cpp
+++ b/src/VBox/Main/src-server/solaris/PerformanceSolaris.cpp
@@ -6,7 +6,7 @@
*/
/*
- * Copyright (C) 2008 Oracle Corporation
+ * Copyright (C) 2008-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;
@@ -99,6 +99,7 @@ private:
PFNZPOOLVDEVNAME mZpoolVdevName;
FsMap mFsMap;
+ uint32_t mCpus;
};
CollectorHAL *createHAL()
@@ -113,7 +114,8 @@ CollectorSolaris::CollectorSolaris()
: mKC(0),
mSysPages(0),
mZFSCache(0),
- mZfsLib(0)
+ mZfsLib(0),
+ mCpus(0)
{
if ((mKC = kstat_open()) == 0)
{
@@ -154,6 +156,7 @@ CollectorSolaris::CollectorSolaris()
}
updateFilesystemMap();
+ /* Notice that mCpus member will be initialized by HostCpuLoadRaw::init() */
}
CollectorSolaris::~CollectorSolaris()
@@ -195,6 +198,8 @@ int CollectorSolaris::getRawHostCpuLoad(uint64_t *user, uint64_t *kernel, uint64
Log(("no cpu stats found!\n"));
return VERR_INTERNAL_ERROR;
}
+ else
+ mCpus = cpus;
if (user) *user = tmpUser;
if (kernel) *kernel = tmpKernel;
@@ -220,8 +225,18 @@ int CollectorSolaris::getRawProcessCpuLoad(RTPROCESS process, uint64_t *user, ui
{
//Assert((pid_t)process == pstatus.pr_pid);
//Log(("user=%u kernel=%u total=%u\n", prusage.pr_utime.tv_sec, prusage.pr_stime.tv_sec, prusage.pr_tstamp.tv_sec));
- *user = (uint64_t)prusage.pr_utime.tv_sec * 1000000000 + prusage.pr_utime.tv_nsec;
- *kernel = (uint64_t)prusage.pr_stime.tv_sec * 1000000000 + prusage.pr_stime.tv_nsec;
+ /*
+ * The CPU time spent must be adjusted by the number of cores for compatibility with
+ * other platforms (see @bugref{6345}).
+ */
+ Assert(mCpus);
+ if (mCpus)
+ {
+ *user = ((uint64_t)prusage.pr_utime.tv_sec * 1000000000 + prusage.pr_utime.tv_nsec) / mCpus;
+ *kernel = ((uint64_t)prusage.pr_stime.tv_sec * 1000000000 + prusage.pr_stime.tv_nsec) / mCpus;
+ }
+ else
+ *user = *kernel = 0;
*total = (uint64_t)prusage.pr_tstamp.tv_sec * 1000000000 + prusage.pr_tstamp.tv_nsec;
//Log(("user=%llu kernel=%llu total=%llu\n", *user, *kernel, *total));
}
diff --git a/src/VBox/Main/src-server/win/HostPowerWin.cpp b/src/VBox/Main/src-server/win/HostPowerWin.cpp
index ae806fd75..da314d848 100644
--- a/src/VBox/Main/src-server/win/HostPowerWin.cpp
+++ b/src/VBox/Main/src-server/win/HostPowerWin.cpp
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2010 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/src/VBox/Main/src-server/win/NetIf-win.cpp b/src/VBox/Main/src-server/win/NetIf-win.cpp
index cce820da1..87fb021ff 100644
--- a/src/VBox/Main/src-server/win/NetIf-win.cpp
+++ b/src/VBox/Main/src-server/win/NetIf-win.cpp
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2008-2010 Oracle Corporation
+ * Copyright (C) 2008-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/src/VBox/Main/src-server/win/PerformanceWin.cpp b/src/VBox/Main/src-server/win/PerformanceWin.cpp
index 2fc96b5d8..a50b2a57c 100644
--- a/src/VBox/Main/src-server/win/PerformanceWin.cpp
+++ b/src/VBox/Main/src-server/win/PerformanceWin.cpp
@@ -6,7 +6,7 @@
*/
/*
- * Copyright (C) 2008 Oracle Corporation
+ * Copyright (C) 2008-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/src/VBox/Main/src-server/win/svchlp.cpp b/src/VBox/Main/src-server/win/svchlp.cpp
index 2191f3faa..a3c07ff6d 100644
--- a/src/VBox/Main/src-server/win/svchlp.cpp
+++ b/src/VBox/Main/src-server/win/svchlp.cpp
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2010 Oracle Corporation
+ * Copyright (C) 2006-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/src/VBox/Main/src-server/win/svchlp.h b/src/VBox/Main/src-server/win/svchlp.h
index 0e8b8b800..a5df8dba7 100644
--- a/src/VBox/Main/src-server/win/svchlp.h
+++ b/src/VBox/Main/src-server/win/svchlp.h
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2010 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/src/VBox/Main/src-server/xpcom/server.h b/src/VBox/Main/src-server/xpcom/server.h
index f14977af9..4fbaa2316 100644
--- a/src/VBox/Main/src-server/xpcom/server.h
+++ b/src/VBox/Main/src-server/xpcom/server.h
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2010 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;