Index: /trunk/src/VBox/Main/src-server/MachineImplCloneVM.cpp
===================================================================
--- /trunk/src/VBox/Main/src-server/MachineImplCloneVM.cpp	(revision 37520)
+++ /trunk/src/VBox/Main/src-server/MachineImplCloneVM.cpp	(revision 37521)
@@ -406,7 +406,9 @@
      *   cloned disks called exactly as the original one or should all new disks
      *   get a new name with the new VM name in it.
+     * - What about log files?
      */
 
     /* Where should all the media go? */
+    Utf8Str strTrgSnapshotFolder;
     Utf8Str strTrgMachineFolder = d->pTrgMachine->getSettingsFileFull();
     strTrgMachineFolder.stripFilename();
@@ -468,5 +470,5 @@
         if (FAILED(rc)) throw rc;
         /* The absolute name of the snapshot folder. */
-        Utf8Str strTrgSnapshotFolder = Utf8StrFmt("%s%c%s%c", strTrgMachineFolder.c_str(), RTPATH_DELIMITER, trgMCF.machineUserData.strSnapshotFolder.c_str(), RTPATH_DELIMITER);
+        strTrgSnapshotFolder = Utf8StrFmt("%s%c%s%c", strTrgMachineFolder.c_str(), RTPATH_DELIMITER, trgMCF.machineUserData.strSnapshotFolder.c_str(), RTPATH_DELIMITER);
 
         /* We need to create a map with the already created medias. This is
@@ -602,4 +604,5 @@
                 if (FAILED(rc)) throw rc;
                 pNewParent = diff;
+                newMedias.append(diff);
             }
             Bstr bstrSrcId;
@@ -743,15 +746,14 @@
         for (size_t i = newMedias.size(); i > 0; --i)
         {
+            bool fFile = false;
+            Utf8Str strLoc;
             ComObjPtr<Medium> &pMedium = newMedias.at(i - 1);
-            AutoCaller mac(pMedium);
-            if (FAILED(mac.rc())) { continue; rc = mac.rc(); }
-            AutoReadLock mlock(pMedium COMMA_LOCKVAL_SRC_POS);
-            bool fFile = pMedium->isMediumFormatFile();
-            Utf8Str strLoc = pMedium->getLocationFull();
-            mlock.release();
-            /* Close the medium. If this succeed, delete it finally from the
-             * disk. */
-            rc = pMedium->close(NULL, mac);
-            if (FAILED(rc)) continue;
+            {
+                AutoCaller mac(pMedium);
+                if (FAILED(mac.rc())) { continue; rc = mac.rc(); }
+                AutoReadLock mlock(pMedium COMMA_LOCKVAL_SRC_POS);
+                fFile = pMedium->isMediumFormatFile();
+                strLoc = pMedium->getLocationFull();
+            }
             if (fFile)
             {
@@ -761,4 +763,7 @@
             }
         }
+        /* Delete the snapshot folder when not empty. */
+        if (!strTrgSnapshotFolder.isEmpty())
+            RTDirRemove(strTrgSnapshotFolder.c_str());
         /* Delete the machine folder when not empty. */
         RTDirRemove(strTrgMachineFolder.c_str());
