Index: trunk/src/VBox/Main/include/VirtualBoxImpl.h
===================================================================
--- trunk/src/VBox/Main/include/VirtualBoxImpl.h	(revision 37974)
+++ trunk/src/VBox/Main/include/VirtualBoxImpl.h	(revision 37985)
@@ -279,5 +279,5 @@
     HRESULT saveSettings();
 
-    void addGuidToListUniquely(GuidList &llRegistriesThatNeedSaving, const Guid &uuid);
+    static void addGuidToListUniquely(GuidList &llRegistriesThatNeedSaving, const Guid &uuid);
     HRESULT saveRegistries(const GuidList &llRegistriesThatNeedSaving);
 
Index: trunk/src/VBox/Main/src-server/MachineImpl.cpp
===================================================================
--- trunk/src/VBox/Main/src-server/MachineImpl.cpp	(revision 37974)
+++ trunk/src/VBox/Main/src-server/MachineImpl.cpp	(revision 37985)
@@ -6260,5 +6260,13 @@
         optList = com::SafeArray<CloneOptions_T>(ComSafeArrayInArg(options)).toList();
 
-    AssertReturn(!optList.contains(CloneOptions_Link) || (isSnapshotMachine() && mode == CloneMode_MachineState), E_INVALIDARG);
+    if (optList.contains(CloneOptions_Link))
+    {
+        if (!isSnapshotMachine())
+            return setError(E_INVALIDARG,
+                            tr("Linked clone can only be created from a snapshot\n"));
+        if (mode != CloneMode_MachineState)
+            return setError(E_INVALIDARG,
+                            tr("Linked clone can only be created for a single machine state\n"));
+    }
     AssertReturn(!(optList.contains(CloneOptions_KeepAllMACs) && optList.contains(CloneOptions_KeepNATMACs)), E_INVALIDARG);
 
@@ -9202,5 +9210,5 @@
     if (pMedium->addRegistry(uuid, false /* fRecurse */))
         // registry actually changed:
-        mParent->addGuidToListUniquely(llRegistriesThatNeedSaving, uuid);
+        VirtualBox::addGuidToListUniquely(llRegistriesThatNeedSaving, uuid);
 
     if (puuid)
Index: trunk/src/VBox/Main/src-server/MachineImplCloneVM.cpp
===================================================================
--- trunk/src/VBox/Main/src-server/MachineImplCloneVM.cpp	(revision 37974)
+++ trunk/src/VBox/Main/src-server/MachineImplCloneVM.cpp	(revision 37985)
@@ -596,4 +596,5 @@
         typedef std::pair<Utf8Str, ComObjPtr<Medium> > TStrMediumPair;
         TStrMediumMap map;
+        GuidList llRegistriesThatNeedSaving;
         size_t cDisks = 0;
         for (size_t i = 0; i < d->llMedias.size(); ++i)
@@ -812,5 +813,20 @@
             if (FAILED(mac.rc())) throw mac.rc();
             AutoWriteLock mlock(pMedium COMMA_LOCKVAL_SRC_POS);
-            pMedium->addRegistry(d->options.contains(CloneOptions_Link) ? d->pSrcMachine->mData->mUuid : d->pTrgMachine->mData->mUuid, false /* fRecurse */);
+            Guid uuid = d->pTrgMachine->mData->mUuid;
+            if (d->options.contains(CloneOptions_Link))
+            {
+                ComObjPtr<Medium> pParent = pMedium->getParent();
+                mlock.release();
+                if (!pParent.isNull())
+                {
+                    AutoCaller mac2(pParent);
+                    if (FAILED(mac2.rc())) throw mac2.rc();
+                    AutoReadLock mlock2(pParent COMMA_LOCKVAL_SRC_POS);
+                    if (pParent->getFirstRegistryMachineId(uuid))
+                        VirtualBox::addGuidToListUniquely(llRegistriesThatNeedSaving, uuid);
+                }
+                mlock.acquire();
+            }
+            pMedium->addRegistry(uuid, false /* fRecurse */);
         }
         /* Check if a snapshot folder is necessary and if so doesn't already
@@ -867,10 +883,8 @@
         if (FAILED(rc)) throw rc;
         trgLock.release();
-        if (d->options.contains(CloneOptions_Link))
+        if (!llRegistriesThatNeedSaving.empty())
         {
             srcLock.release();
-            GuidList llRegistrySrc;
-            llRegistrySrc.push_back(d->pSrcMachine->mData->mUuid);
-            rc = p->mParent->saveRegistries(llRegistrySrc);
+            rc = p->mParent->saveRegistries(llRegistriesThatNeedSaving);
             if (FAILED(rc)) throw rc;
         }
Index: trunk/src/VBox/Main/src-server/MediumImpl.cpp
===================================================================
--- trunk/src/VBox/Main/src-server/MediumImpl.cpp	(revision 37974)
+++ trunk/src/VBox/Main/src-server/MediumImpl.cpp	(revision 37985)
@@ -3278,5 +3278,5 @@
          ++it)
     {
-        m->pVirtualBox->addGuidToListUniquely(llRegistryIDs, *it);
+        VirtualBox::addGuidToListUniquely(llRegistryIDs, *it);
     }
 
Index: trunk/src/VBox/Main/src-server/SnapshotImpl.cpp
===================================================================
--- trunk/src/VBox/Main/src-server/SnapshotImpl.cpp	(revision 37974)
+++ trunk/src/VBox/Main/src-server/SnapshotImpl.cpp	(revision 37985)
@@ -1936,5 +1936,5 @@
         // unconditionally add the parent registry. We do similar in SessionMachine::EndTakingSnapshot
         // (mParent->saveSettings())
-        mParent->addGuidToListUniquely(llRegistriesThatNeedSaving, mParent->getGlobalRegistryId());
+        VirtualBox::addGuidToListUniquely(llRegistriesThatNeedSaving, mParent->getGlobalRegistryId());
 
         // let go of the locks while we're deleting image files below
@@ -2480,5 +2480,5 @@
 
                 // machine will need saving now
-                mParent->addGuidToListUniquely(llRegistriesThatNeedSaving, getId());
+                VirtualBox::addGuidToListUniquely(llRegistriesThatNeedSaving, getId());
             }
         }
@@ -2655,5 +2655,5 @@
 
             // One attachment is merged, must save the settings
-            mParent->addGuidToListUniquely(llRegistriesThatNeedSaving, getId());
+            VirtualBox::addGuidToListUniquely(llRegistriesThatNeedSaving, getId());
 
             // prevent calling cancelDeleteSnapshotMedium() for this attachment
@@ -2674,5 +2674,5 @@
             aTask.pSnapshot->uninit();
 
-            mParent->addGuidToListUniquely(llRegistriesThatNeedSaving, getId());
+            VirtualBox::addGuidToListUniquely(llRegistriesThatNeedSaving, getId());
         }
     }
Index: trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp
===================================================================
--- trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp	(revision 37974)
+++ trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp	(revision 37985)
@@ -3838,5 +3838,5 @@
                     pMedium->addRegistry(*puuidBetter, true /* fRecurse */);
                     // 3) and make sure the registry is saved below
-                    addGuidToListUniquely(llRegistriesThatNeedSaving, *puuidBetter);
+                    VirtualBox::addGuidToListUniquely(llRegistriesThatNeedSaving, *puuidBetter);
                 }
             }
@@ -3860,4 +3860,5 @@
  * @param uuid
  */
+/* static */
 void VirtualBox::addGuidToListUniquely(GuidList &llRegistriesThatNeedSaving,
                                        const Guid &uuid)
