VirtualBox

Changeset 37905 in vbox for trunk/src/VBox/Main/src-server


Ignore:
Timestamp:
Jul 12, 2011 3:37:33 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
72808
Message:

Main-CloneVM: change the name of a cloned disk to the new VM name, if the old was the old VM name

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/MachineImplCloneVM.cpp

    r37900 r37905  
    528528        trgMCF.fCurrentStateModified = true;
    529529        /* Set the new name. */
     530        const Utf8Str strOldVMName = trgMCF.machineUserData.strName;
    530531        trgMCF.machineUserData.strName = d->pTrgMachine->mUserData->s.strName;
    531532        trgMCF.uuid = d->pTrgMachine->mData->mUuid;
     
    596597                    }
    597598
    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". */
    602599                    Guid newId;
    603600                    newId.create();
     
    605602                    if (!fKeepDiskNames)
    606603                    {
    607                         strNewName = Utf8StrFmt("%s-disk%d%s", trgMCF.machineUserData.strName.c_str(), ++cDisks, RTPathExt(Utf8Str(bstrSrcName).c_str()));
     604                        /* If the old disk name was in {uuid} format we also
     605                         * want the new name in this format, but with the
     606                         * updated id of course. If the old disk was called
     607                         * like the VM name, we change it to the new VM name.
     608                         * For all other disks we rename them with this
     609                         * template: "new name-disk1.vdi". */
    608610                        Utf8Str strSrcTest = Utf8Str(bstrSrcName).stripExt();
     611                        if (strSrcTest == strOldVMName)
     612                            strNewName = Utf8StrFmt("%s%s", trgMCF.machineUserData.strName.c_str(), RTPathExt(Utf8Str(bstrSrcName).c_str()));
     613                        else
    609614                        if (strSrcTest.startsWith("{") &&
    610615                            strSrcTest.endsWith("}"))
     
    612617                            strSrcTest = strSrcTest.substr(1, strSrcTest.length() - 2);
    613618                            if (isValidGuid(strSrcTest))
    614                             {
    615619                                strNewName = Utf8StrFmt("%s%s", newId.toStringCurly().c_str(), RTPathExt(strNewName.c_str()));
    616                                 --cDisks;
    617                             }
    618620                        }
     621                        else
     622                            strNewName = Utf8StrFmt("%s-disk%d%s", trgMCF.machineUserData.strName.c_str(), ++cDisks, RTPathExt(Utf8Str(bstrSrcName).c_str()));
    619623                    }
    620624
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette