VirtualBox

Changeset 37900 in vbox


Ignore:
Timestamp:
Jul 12, 2011 1:31:46 PM (13 years ago)
Author:
vboxsync
Message:

Main-CloneVM;FE/CLI;Doc: update differencing disk names with there new uuid; rename all other disks to the new name + disk#; optional allow keeping old disk names

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/manual/en_US/user_VBoxManage.xml

    r37872 r37900  
    11181118       </listitem>
    11191119       <listitem>
    1120            <para><computeroutput>--options keepallmacs|keepnatmacs</computeroutput>:
    1121            With this option you define how the MAC addresses of every virtual
     1120           <para><computeroutput>--options keepallmacs|keepnatmacs|keepdisknames</computeroutput>:
     1121           Allows additional fine tuning of the clone operation. The first two
     1122           options allow to define how the MAC addresses of every virtual
    11221123           network card should be handled. They can either be reinitialized
    11231124           (the default), leaved unchanged
    11241125           (<computeroutput>keepallmacs</computeroutput>) or leaved unchanged
    1125            when the network type is NAT (<computeroutput>keepnatmacs</computeroutput>).
    1126            </para>
     1126           when the network type is NAT
     1127           (<computeroutput>keepnatmacs</computeroutput>). If you add
     1128           <computeroutput>keepdisknames</computeroutput> all new disk images
     1129           are called like the original once, otherwise they are
     1130           renamed.</para>
    11271131       </listitem>
    11281132       <listitem>
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp

    r37862 r37900  
    336336                     "                            [--snapshot <uuid>|<name>]\n"
    337337                     "                            [--mode machine|machineandchilds|all]\n"
    338                      "                            [--options keepallmacs|keepnatmacs]\n"
     338                     "                            [--options keepallmacs|keepnatmacs|keepdisknames]\n"
    339339                     "                            [--name <name>]\n"
    340340                     "                            [--basefolder <basefolder>]\n"
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp

    r37896 r37900  
    309309            else if (!RTStrNICmp(psz, "KeepNATMACs", len))
    310310                options->push_back(CloneOptions_KeepNATMACs);
     311            else if (!RTStrNICmp(psz, "KeepDiskNames", len))
     312                options->push_back(CloneOptions_KeepDiskNames);
    311313//            else if (!RTStrNICmp(psz, "Link", len))
    312 //                *options.push_back(CloneOptions_Link)
     314//                options->push_back(CloneOptions_Link)
    313315            else
    314316                rc = VERR_PARSE_ERROR;
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r37863 r37900  
    36003600  <enum
    36013601    name="CloneOptions" extends="$unknown"
    3602     uuid="1be61ee1-c0ea-4942-b733-7496f27d4f28"
     3602    uuid="22243f8e-96ab-497c-8cf0-f40a566c630b"
    36033603    >
    36043604
     
    36153615    <const name="KeepNATMACs"        value="3">
    36163616      <desc>Don't generate new MAC addresses of the attached network adapters when they are using NAT.</desc>
     3617    </const>
     3618    <const name="KeepDiskNames"      value="4">
     3619      <desc>Don't change the disk names.</desc>
    36173620    </const>
    36183621
  • trunk/src/VBox/Main/include/MediumImpl.h

    r37831 r37900  
    205205
    206206    bool isReadOnly();
     207    void updateId(const Guid &id);
    207208
    208209    HRESULT saveSettings(settings::Medium &data,
  • trunk/src/VBox/Main/src-server/MachineImplCloneVM.cpp

    r37612 r37900  
    464464    /*
    465465     * Todo:
    466      * - Snapshot diffs (can) have the uuid as name. After cloning this isn't
    467      *   right anymore. Is it worth to change to the new uuid? Or should the
    468      *   cloned disks called exactly as the original one or should all new disks
    469      *   get a new name with the new VM name in it.
    470466     * - What about log files?
    471467     */
     
    541537        strTrgSnapshotFolder = Utf8StrFmt("%s%c%s", strTrgMachineFolder.c_str(), RTPATH_DELIMITER, trgMCF.machineUserData.strSnapshotFolder.c_str());
    542538
     539        /* Should we rename the disk names. */
     540        bool fKeepDiskNames = d->options.contains(CloneOptions_KeepDiskNames);
     541
    543542        /* We need to create a map with the already created medias. This is
    544543         * necessary, cause different snapshots could have the same
     
    548547        typedef std::pair<Utf8Str, ComObjPtr<Medium> > TStrMediumPair;
    549548        TStrMediumMap map;
     549        size_t cDisks = 0;
    550550        for (size_t i = 0; i < d->llMedias.size(); ++i)
    551551        {
     
    596596                    }
    597597
     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
    598621                    /* Check if this medium comes from the snapshot folder, if
    599622                     * so, put it there in the cloned machine as well.
    600623                     * Otherwise it goes to the machine folder. */
    601                     Utf8Str strFile = Utf8StrFmt("%s%c%lS", strTrgMachineFolder.c_str(), RTPATH_DELIMITER, bstrSrcName.raw());
    602624                    Bstr bstrSrcPath;
     625                    Utf8Str strFile = Utf8StrFmt("%s%c%s", strTrgMachineFolder.c_str(), RTPATH_DELIMITER, strNewName.c_str());
    603626                    rc = pMedium->COMGETTER(Location)(bstrSrcPath.asOutParam());
    604627                    if (FAILED(rc)) throw rc;
    605628                    if (   !bstrSrcPath.isEmpty()
    606629                        &&  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());
    608631                    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());
    610633
    611634                    /* Start creating the clone. */
     
    620643                                       NULL          /* llRegistriesThatNeedSaving */);
    621644                    if (FAILED(rc)) throw rc;
     645
     646                    /* Update the new uuid. */
     647                    pTarget->updateId(newId);
    622648
    623649                    srcLock.release();
  • trunk/src/VBox/Main/src-server/MediumImpl.cpp

    r37831 r37900  
    36403640
    36413641    AssertFailedReturn(false);
     3642}
     3643
     3644/**
     3645 * Internal method to return the medium's size. Must have caller + locking!
     3646 * @return
     3647 */
     3648void Medium::updateId(const Guid &id)
     3649{
     3650    unconst(m->id) = id;
    36423651}
    36433652
Note: See TracChangeset for help on using the changeset viewer.

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