summaryrefslogtreecommitdiff
path: root/src/VBox/Main/VirtualBoxImpl.cpp
diff options
context:
space:
mode:
authorFelix Geyer <debfx-pkg@fobos.de>2010-06-25 23:32:17 +0200
committerFelix Geyer <debfx-pkg@fobos.de>2010-06-25 23:32:17 +0200
commit3cc524b669caddac0b3c8c8fd0b57eaff7f490eb (patch)
tree8f1ab6c92e9e9b5c24ffa2982cc11579a10a1764 /src/VBox/Main/VirtualBoxImpl.cpp
parent4fc7368fb7c2191d0415356bc517ad2be123cd3c (diff)
downloadvirtualbox-3cc524b669caddac0b3c8c8fd0b57eaff7f490eb.tar.gz
Imported Upstream version 3.2.6-dfsgupstream/3.2.6-dfsg
Diffstat (limited to 'src/VBox/Main/VirtualBoxImpl.cpp')
-rw-r--r--src/VBox/Main/VirtualBoxImpl.cpp30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/VBox/Main/VirtualBoxImpl.cpp b/src/VBox/Main/VirtualBoxImpl.cpp
index 557b467b7..a57c9d915 100644
--- a/src/VBox/Main/VirtualBoxImpl.cpp
+++ b/src/VBox/Main/VirtualBoxImpl.cpp
@@ -3414,9 +3414,13 @@ void VirtualBox::rememberMachineNameChangeForMedia(const Utf8Str &strOldConfigDi
}
/**
- * Helper function to write out the configuration tree.
+ * Helper function which actually writes out VirtualBox.xml, the main configuration file.
+ * Gets called from the public VirtualBox::SaveSettings() as well as from various other
+ * places internally when settings need saving.
*
- * @note Caller must have locked the VirtualBox object for writing!
+ * @note Caller must have locked the VirtualBox object for writing and must not hold any
+ * other locks since this locks all kinds of member objects and trees temporarily,
+ * which could cause conflicts.
*/
HRESULT VirtualBox::saveSettings()
{
@@ -3487,8 +3491,8 @@ HRESULT VirtualBox::saveSettings()
// hard disks
settings::MediaList hardDisksTemp;
for (MediaList::const_iterator it = m->ollHardDisks.begin();
- it != m->ollHardDisks.end();
- ++it)
+ it != m->ollHardDisks.end();
+ ++it)
{
settings::Medium med;
rc = (*it)->saveSettings(med); // this recurses into its children
@@ -3499,8 +3503,8 @@ HRESULT VirtualBox::saveSettings()
/* CD/DVD images */
settings::MediaList dvdsTemp;
for (MediaList::const_iterator it = m->ollDVDImages.begin();
- it != m->ollDVDImages.end();
- ++it)
+ it != m->ollDVDImages.end();
+ ++it)
{
settings::Medium med;
rc = (*it)->saveSettings(med);
@@ -3511,8 +3515,8 @@ HRESULT VirtualBox::saveSettings()
/* floppy images */
settings::MediaList floppiesTemp;
for (MediaList::const_iterator it = m->ollFloppyImages.begin();
- it != m->ollFloppyImages.end();
- ++it)
+ it != m->ollFloppyImages.end();
+ ++it)
{
settings::Medium med;
rc = (*it)->saveSettings(med);
@@ -4697,9 +4701,7 @@ HRESULT VirtualBox::registerDHCPServer(DHCPServer *aDHCPServer,
ComPtr<IDHCPServer> existing;
rc = FindDHCPServerByNetworkName(name, existing.asOutParam());
if (SUCCEEDED(rc))
- {
return E_INVALIDARG;
- }
rc = S_OK;
@@ -4707,7 +4709,10 @@ HRESULT VirtualBox::registerDHCPServer(DHCPServer *aDHCPServer,
if (aSaveRegistry)
{
+ AutoWriteLock vboxLock(this COMMA_LOCKVAL_SRC_POS);
rc = saveSettings();
+ vboxLock.release();
+
if (FAILED(rc))
unregisterDHCPServer(aDHCPServer, false /* aSaveRegistry */);
}
@@ -4738,8 +4743,6 @@ HRESULT VirtualBox::unregisterDHCPServer(DHCPServer *aDHCPServer,
AutoCaller autoCaller(this);
AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
- AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
-
AutoCaller dhcpServerCaller(aDHCPServer);
AssertComRCReturn(dhcpServerCaller.rc(), dhcpServerCaller.rc());
@@ -4749,7 +4752,10 @@ HRESULT VirtualBox::unregisterDHCPServer(DHCPServer *aDHCPServer,
if (aSaveRegistry)
{
+ AutoWriteLock vboxLock(this COMMA_LOCKVAL_SRC_POS);
rc = saveSettings();
+ vboxLock.release();
+
if (FAILED(rc))
registerDHCPServer(aDHCPServer, false /* aSaveRegistry */);
}