Index: /trunk/src/VBox/Main/src-server/MachineImplCloneVM.cpp
===================================================================
--- /trunk/src/VBox/Main/src-server/MachineImplCloneVM.cpp	(revision 37521)
+++ /trunk/src/VBox/Main/src-server/MachineImplCloneVM.cpp	(revision 37522)
@@ -399,7 +399,4 @@
     /*
      * Todo:
-     * - Regardless where the old media comes from (e.g. snapshots folder) it
-     *   goes to the new main VM folder. Maybe we like to be a little bit
-     *   smarter here.
      * - Snapshot diffs (can) have the uuid as name. After cloning this isn't
      *   right anymore. Is it worth to change to the new uuid? Or should the
@@ -470,5 +467,5 @@
         if (FAILED(rc)) throw rc;
         /* The absolute name of the snapshot folder. */
-        strTrgSnapshotFolder = Utf8StrFmt("%s%c%s%c", strTrgMachineFolder.c_str(), RTPATH_DELIMITER, trgMCF.machineUserData.strSnapshotFolder.c_str(), RTPATH_DELIMITER);
+        strTrgSnapshotFolder = Utf8StrFmt("%s%c%s", strTrgMachineFolder.c_str(), RTPATH_DELIMITER, trgMCF.machineUserData.strSnapshotFolder.c_str());
 
         /* We need to create a map with the already created medias. This is
@@ -529,5 +526,17 @@
                     if (FAILED(rc)) throw rc;
 
+                    /* Check if this medium comes from the snapshot folder, if
+                     * so, put it there in the cloned machine as well.
+                     * Otherwise it goes to the machine folder. */
                     Utf8Str strFile = Utf8StrFmt("%s%c%lS", strTrgMachineFolder.c_str(), RTPATH_DELIMITER, bstrSrcName.raw());
+                    Bstr bstrSrcPath;
+                    rc = pMedium->COMGETTER(Location)(bstrSrcPath.asOutParam());
+                    if (FAILED(rc)) throw rc;
+                    if (   !bstrSrcPath.isEmpty()
+                        &&  RTPathStartsWith(Utf8Str(bstrSrcPath).c_str(), Utf8Str(bstrSrcSnapshotFolder).c_str()))
+                        strFile = Utf8StrFmt("%s%c%lS", strTrgSnapshotFolder.c_str(), RTPATH_DELIMITER, bstrSrcName.raw());
+                    else
+                        strFile = Utf8StrFmt("%s%c%lS", strTrgMachineFolder.c_str(), RTPATH_DELIMITER, bstrSrcName.raw());
+
                     rc = pTarget->init(p->mParent,
                                        Utf8Str(bstrSrcFormat),
@@ -584,5 +593,5 @@
                 rc = diff->init(p->mParent,
                                 pNewParent->getPreferredDiffFormat(),
-                                strTrgSnapshotFolder,
+                                Utf8StrFmt("%s%c", strTrgSnapshotFolder.c_str(), RTPATH_DELIMITER),
                                 d->pTrgMachine->mData->mUuid,
                                 NULL); // pllRegistriesThatNeedSaving
@@ -621,5 +630,5 @@
         {
             SAVESTATETASK sst = d->llSaveStateFiles.at(i);
-            const Utf8Str &strTrgSaveState = Utf8StrFmt("%s%s", strTrgSnapshotFolder.c_str(), RTPathFilename(sst.strSaveStateFile.c_str()));
+            const Utf8Str &strTrgSaveState = Utf8StrFmt("%s%c%s", strTrgSnapshotFolder.c_str(), RTPATH_DELIMITER, RTPathFilename(sst.strSaveStateFile.c_str()));
 
             /* Move to next sub-operation. */
