Index: /trunk/src/VBox/Main/src-server/MachineImplCloneVM.cpp
===================================================================
--- /trunk/src/VBox/Main/src-server/MachineImplCloneVM.cpp	(revision 37602)
+++ /trunk/src/VBox/Main/src-server/MachineImplCloneVM.cpp	(revision 37603)
@@ -580,5 +580,8 @@
                     if (FAILED(rc)) throw rc;
 
-                    Bstr bstrSrcFormat = "VDI";
+                    /* Default format? */
+                    Utf8Str strDefaultFormat;
+                    p->mParent->getDefaultHardDiskFormat(strDefaultFormat);
+                    Bstr bstrSrcFormat(strDefaultFormat);
                     ULONG srcVar = MediumVariant_Standard;
                     /* Is the source file based? */
@@ -614,6 +617,6 @@
                                        Utf8Str(bstrSrcFormat),
                                        strFile,
-                                       Guid(),  /* empty media registry */
-                                       NULL     /* llRegistriesThatNeedSaving */);
+                                       Guid::Empty,  /* empty media registry */
+                                       NULL          /* llRegistriesThatNeedSaving */);
                     if (FAILED(rc)) throw rc;
 
@@ -643,5 +646,6 @@
                         throw p->setError(iRc, Utf8Str(info.getText()).c_str());
                     }
-
+                    /* Remember created medias. */
+                    newMedias.append(pTarget);
                     /* Get the medium type from the source and set it to the
                      * new medium. */
@@ -652,7 +656,7 @@
                     if (FAILED(rc)) throw rc;
                     map.insert(TStrMediumPair(Utf8Str(bstrSrcId), pTarget));
-
-                    /* Remember created medias. */
-                    newMedias.append(pTarget);
+                    /* Global register the new harddisk */
+                    rc = p->mParent->registerHardDisk(pTarget, NULL /* pllRegistriesThatNeedSaving */);
+                    if (FAILED(rc)) return rc;
                     /* This medium becomes the parent of the next medium in the
                      * chain. */
@@ -672,6 +676,6 @@
                                 pNewParent->getPreferredDiffFormat(),
                                 Utf8StrFmt("%s%c", strTrgSnapshotFolder.c_str(), RTPATH_DELIMITER),
-                                Guid(), /* empty media registry */
-                                NULL);  /* pllRegistriesThatNeedSaving */
+                                Guid::Empty, /* empty media registry */
+                                NULL);       /* pllRegistriesThatNeedSaving */
                 if (FAILED(rc)) throw rc;
                 MediumLockList *pMediumLockList(new MediumLockList());
@@ -690,6 +694,12 @@
                 delete pMediumLockList;
                 if (FAILED(rc)) throw rc;
+                /* Remember created medias. */
+                newMedias.append(diff);
+                /* Global register the new harddisk */
+                rc = p->mParent->registerHardDisk(diff, NULL /* pllRegistriesThatNeedSaving */);
+                if (FAILED(rc)) return rc;
+                /* This medium becomes the parent of the next medium in the
+                 * chain. */
                 pNewParent = diff;
-                newMedias.append(diff);
             }
             Bstr bstrSrcId;
@@ -703,7 +713,7 @@
             d->updateStorageLists(trgMCF.storageMachine.llStorageControllers, bstrSrcId, bstrTrgId);
             d->updateSnapshotStorageLists(trgMCF.llFirstSnapshot, bstrSrcId, bstrTrgId);
-            /* Make sure all disks know of the new machine uuid. We do this
-             * last to be able to change the medium type above. */
-            rc = pNewParent->addRegistry(d->pTrgMachine->mData->mUuid, true /* fRecursive */);
+            /* Make sure all parent disks know of the new machine uuid. We do
+             * this last to be able to change the medium type above. */
+            rc = pNewParent->addRegistry(d->pTrgMachine->mData->mUuid, false /* fRecursive */);
             if (FAILED(rc)) throw rc;
         }
