Changeset 37900 in vbox for trunk/src/VBox/Main/src-server
- Timestamp:
- Jul 12, 2011 1:31:46 PM (14 years ago)
- Location:
- trunk/src/VBox/Main/src-server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/MachineImplCloneVM.cpp
r37612 r37900 464 464 /* 465 465 * Todo: 466 * - Snapshot diffs (can) have the uuid as name. After cloning this isn't467 * right anymore. Is it worth to change to the new uuid? Or should the468 * cloned disks called exactly as the original one or should all new disks469 * get a new name with the new VM name in it.470 466 * - What about log files? 471 467 */ … … 541 537 strTrgSnapshotFolder = Utf8StrFmt("%s%c%s", strTrgMachineFolder.c_str(), RTPATH_DELIMITER, trgMCF.machineUserData.strSnapshotFolder.c_str()); 542 538 539 /* Should we rename the disk names. */ 540 bool fKeepDiskNames = d->options.contains(CloneOptions_KeepDiskNames); 541 543 542 /* We need to create a map with the already created medias. This is 544 543 * necessary, cause different snapshots could have the same … … 548 547 typedef std::pair<Utf8Str, ComObjPtr<Medium> > TStrMediumPair; 549 548 TStrMediumMap map; 549 size_t cDisks = 0; 550 550 for (size_t i = 0; i < d->llMedias.size(); ++i) 551 551 { … … 596 596 } 597 597 598 /* If the old disk name was in {uuid} format we also want 599 * the new name in this format, but with the updated id of 600 * course. For all other disks we rename them with this 601 * template: "new name-disk1.vdi". */ 602 Guid newId; 603 newId.create(); 604 Utf8Str strNewName(bstrSrcName); 605 if (!fKeepDiskNames) 606 { 607 strNewName = Utf8StrFmt("%s-disk%d%s", trgMCF.machineUserData.strName.c_str(), ++cDisks, RTPathExt(Utf8Str(bstrSrcName).c_str())); 608 Utf8Str strSrcTest = Utf8Str(bstrSrcName).stripExt(); 609 if (strSrcTest.startsWith("{") && 610 strSrcTest.endsWith("}")) 611 { 612 strSrcTest = strSrcTest.substr(1, strSrcTest.length() - 2); 613 if (isValidGuid(strSrcTest)) 614 { 615 strNewName = Utf8StrFmt("%s%s", newId.toStringCurly().c_str(), RTPathExt(strNewName.c_str())); 616 --cDisks; 617 } 618 } 619 } 620 598 621 /* Check if this medium comes from the snapshot folder, if 599 622 * so, put it there in the cloned machine as well. 600 623 * Otherwise it goes to the machine folder. */ 601 Utf8Str strFile = Utf8StrFmt("%s%c%lS", strTrgMachineFolder.c_str(), RTPATH_DELIMITER, bstrSrcName.raw());602 624 Bstr bstrSrcPath; 625 Utf8Str strFile = Utf8StrFmt("%s%c%s", strTrgMachineFolder.c_str(), RTPATH_DELIMITER, strNewName.c_str()); 603 626 rc = pMedium->COMGETTER(Location)(bstrSrcPath.asOutParam()); 604 627 if (FAILED(rc)) throw rc; 605 628 if ( !bstrSrcPath.isEmpty() 606 629 && RTPathStartsWith(Utf8Str(bstrSrcPath).c_str(), Utf8Str(bstrSrcSnapshotFolder).c_str())) 607 strFile = Utf8StrFmt("%s%c% lS", strTrgSnapshotFolder.c_str(), RTPATH_DELIMITER, bstrSrcName.raw());630 strFile = Utf8StrFmt("%s%c%s", strTrgSnapshotFolder.c_str(), RTPATH_DELIMITER, strNewName.c_str()); 608 631 else 609 strFile = Utf8StrFmt("%s%c% lS", strTrgMachineFolder.c_str(), RTPATH_DELIMITER, bstrSrcName.raw());632 strFile = Utf8StrFmt("%s%c%s", strTrgMachineFolder.c_str(), RTPATH_DELIMITER, strNewName.c_str()); 610 633 611 634 /* Start creating the clone. */ … … 620 643 NULL /* llRegistriesThatNeedSaving */); 621 644 if (FAILED(rc)) throw rc; 645 646 /* Update the new uuid. */ 647 pTarget->updateId(newId); 622 648 623 649 srcLock.release(); -
trunk/src/VBox/Main/src-server/MediumImpl.cpp
r37831 r37900 3640 3640 3641 3641 AssertFailedReturn(false); 3642 } 3643 3644 /** 3645 * Internal method to return the medium's size. Must have caller + locking! 3646 * @return 3647 */ 3648 void Medium::updateId(const Guid &id) 3649 { 3650 unconst(m->id) = id; 3642 3651 } 3643 3652
Note:
See TracChangeset
for help on using the changeset viewer.