VirtualBox

Changeset 97865 in vbox for trunk


Ignore:
Timestamp:
Dec 23, 2022 9:36:09 PM (2 years ago)
Author:
vboxsync
Message:

Main: undo. bugref:10090

Location:
trunk
Files:
1 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/manual/en_US/man_VBoxManage-clonemedium.xml

    r97864 r97865  
    6464      </group>
    6565      <arg>--existing</arg>
    66       <arg>--resize=<replaceable>size-in-MB</replaceable></arg>
    6766      <arg>--format=<group choice="plain">
    6867          <arg choice="plain">VDI</arg>
     
    135134      </varlistentry>
    136135      <varlistentry>
    137         <term><option>--resize=<replaceable>size-in-MB</replaceable></option></term>
    138           <listitem><para>
    139             Performs a resize of the target medium to the specified
    140             size before performing the clone operation.
    141           </para></listitem>
    142       </varlistentry>
    143       <varlistentry>
    144136        <term><option>--format</option></term>
    145137        <listitem><para>
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageDisk.cpp

    r97864 r97865  
    10051005    { "--variant",      'm', RTGETOPT_REQ_STRING },
    10061006    { "-variant",       'm', RTGETOPT_REQ_STRING },
    1007     { "--resize",       'r', RTGETOPT_REQ_UINT64 },
    10081007};
    10091008
     
    10231022    MediumVariant_T enmMediumVariant = MediumVariant_Standard;
    10241023    bool fExisting = false;
    1025     bool fNeedResize = false;
    1026     uint64_t cbResize = 0;
    10271024
    10281025    int c;
     
    10741071                if (RT_FAILURE(vrc))
    10751072                    return errorArgument(Disk::tr("Invalid medium variant '%s'"), ValueUnion.psz);
    1076                 break;
    1077 
    1078             case 'r':   // --resize
    1079                 fNeedResize = true;
    1080                 cbResize = ValueUnion.u64 * _1M;
    10811073                break;
    10821074
     
    11991191        }
    12001192
    1201         if (fNeedResize)
    1202         {
    1203             CHECK_ERROR_BREAK(pSrcMedium, ResizeAndCloneTo(pDstMedium, cbResize, ComSafeArrayAsInParam(l_variants), NULL, pProgress.asOutParam()));
    1204         }
    1205         else
    1206         {
    1207             CHECK_ERROR_BREAK(pSrcMedium, CloneTo(pDstMedium, ComSafeArrayAsInParam(l_variants), NULL, pProgress.asOutParam()));
    1208         }
    1209 
     1193        CHECK_ERROR_BREAK(pSrcMedium, CloneTo(pDstMedium, ComSafeArrayAsInParam(l_variants), NULL, pProgress.asOutParam()));
    12101194
    12111195        hrc = showProgress(pProgress);
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r97864 r97865  
    1812618126  <interface
    1812718127    name="IMedium" extends="$unknown"
    18128     uuid="dbe1d807-5fa1-482f-9121-37b8fd855348"
     18128    uuid="ad47ad09-787b-44ab-b343-a082a3f2dfb1"
    1812918129    wsmap="managed"
    1813018130    rest="managed"
     
    1921219212      <param name="target" type="IMedium" dir="in">
    1921319213        <desc>Target medium.</desc>
    19214       </param>
    19215       <param name="variant" type="MediumVariant" safearray="yes" dir="in">
    19216         <desc>Exact image variant which should be created (as a combination of
    19217           <link to="MediumVariant" /> flags).</desc>
    19218       </param>
    19219       <param name="parent" type="IMedium" dir="in">
    19220         <desc>Parent of the cloned medium.</desc>
    19221       </param>
    19222       <param name="progress" type="IProgress" dir="return">
    19223         <desc>Progress object to track the operation completion.</desc>
    19224       </param>
    19225     </method>
    19226 
    19227     <method name="resizeAndCloneTo">
    19228       <rest request="post" path="/mediums/{mediumid}/actions/"/>
    19229 
    19230       <desc>
    19231         This is a helper function that combines the functionality of
    19232         <link to="IMedium::cloneTo"/> and <link to="IMedium::resize"/>. The target medium will take the
    19233         contents of the calling medium.
    19234         <result name="E_NOTIMPL">
    19235           The specified cloning variant is not supported at the moment.
    19236         </result>
    19237       </desc>
    19238 
    19239       <param name="target" type="IMedium" dir="in">
    19240         <desc>Target medium.</desc>
    19241       </param>
    19242       <param name="logicalSize" type="long long" dir="in">
    19243         <desc>New nominal capacity of the medium in bytes.</desc>
    1924419214      </param>
    1924519215      <param name="variant" type="MediumVariant" safearray="yes" dir="in">
  • trunk/src/VBox/Main/include/MediumImpl.h

    r97864 r97865  
    317317                    const ComPtr<IMedium> &aParent,
    318318                    ComPtr<IProgress> &aProgress);
    319     HRESULT resizeAndCloneTo(const ComPtr<IMedium> &aTarget,
    320                              const LONG64 aLogicalSize,
    321                              const std::vector<MediumVariant_T> &aVariant,
    322                              const ComPtr<IMedium> &aParent,
    323                              ComPtr<IProgress> &aProgress);
    324319    HRESULT cloneToBase(const ComPtr<IMedium> &aTarget,
    325320                        const std::vector<MediumVariant_T> &aVariant,
  • trunk/src/VBox/Main/src-server/MediumImpl.cpp

    r97864 r97865  
    497497              bool fKeepSourceMediumLockList = false,
    498498              bool fKeepTargetMediumLockList = false,
    499               bool fNotifyAboutChanges = true,
    500               LONG64 aTargetLogicalSize = 0)
     499              bool fNotifyAboutChanges = true)
    501500        : Medium::Task(aMedium, aProgress, fNotifyAboutChanges),
    502501          mTarget(aTarget),
    503502          mParent(aParent),
    504           mTargetLogicalSize(aTargetLogicalSize),
    505503          mpSourceMediumLockList(aSourceMediumLockList),
    506504          mpTargetMediumLockList(aTargetMediumLockList),
     
    512510          mfKeepSourceMediumLockList(fKeepSourceMediumLockList),
    513511          mfKeepTargetMediumLockList(fKeepTargetMediumLockList)
    514 
    515512    {
    516513        AssertReturnVoidStmt(aTarget != NULL, mRC = E_FAIL);
     
    537534    const ComObjPtr<Medium> mTarget;
    538535    const ComObjPtr<Medium> mParent;
    539     LONG64 mTargetLogicalSize;
    540536    MediumLockList *mpSourceMediumLockList;
    541537    MediumLockList *mpTargetMediumLockList;
     
    30243020                        ComPtr<IProgress> &aProgress)
    30253021{
    3026     return resizeAndCloneTo(aTarget, 0, aVariant, aParent, aProgress);
    3027 }
    3028 
    3029 /**
    3030  * This is a helper function that combines the functionality of
    3031  * Medium::cloneTo() and Medium::resize(). The target medium will take the
    3032  * contents of the calling medium.
    3033  *
    3034  * @param aTarget           Medium to resize and clone to
    3035  * @param aLogicalSize      Desired size for targer medium
    3036  * @param aVariant
    3037  * @param aParent
    3038  * @param aProgress
    3039  * @return HRESULT
    3040  */
    3041 HRESULT Medium::resizeAndCloneTo(const ComPtr<IMedium> &aTarget,
    3042                                  const LONG64 aLogicalSize,
    3043                                  const std::vector<MediumVariant_T> &aVariant,
    3044                                  const ComPtr<IMedium> &aParent,
    3045                                  ComPtr<IProgress> &aProgress)
    3046 {
    3047     /* Check for valid args */
     3022    /** @todo r=klaus The code below needs to be double checked with regard
     3023     * to lock order violations, it probably causes lock order issues related
     3024     * to the AutoCaller usage. */
    30483025    ComAssertRet(aTarget != this, E_INVALIDARG);
    3049     CheckComArgExpr(aLogicalSize, aLogicalSize >= 0);
    3050 
    3051     /* Convert args to usable/needed types */
     3026
    30523027    IMedium *aT = aTarget;
    30533028    ComObjPtr<Medium> pTarget = static_cast<Medium*>(aT);
     
    30593034    }
    30603035
    3061     /* Set up variables. Fetch needed data in lockable blocks */
    30623036    HRESULT rc = S_OK;
    3063     ComObjPtr<Progress> pTmpProgress;
     3037    ComObjPtr<Progress> pProgress;
    30643038    Medium::Task *pTask = NULL;
    3065 
    3066     Utf8Str strSourceName;
    3067     {
    3068         AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    3069         strSourceName = i_getName();
    3070     }
    3071 
    3072     uint64_t uTargetExistingSize = 0;
    3073     Utf8Str strTargetName;
    3074     {
    3075         AutoReadLock alock(pTarget COMMA_LOCKVAL_SRC_POS);
    3076         uTargetExistingSize = pTarget->i_getLogicalSize();
    3077         strTargetName = pTarget->i_getName();
    3078     }
    3079 
    3080     /* Set up internal multi-subprocess progress object */
    3081     ComObjPtr<Progress> pProgress;
    3082     pProgress.createObject();
    3083     rc = pProgress->init(m->pVirtualBox,
    3084                 static_cast<IMedium*>(this),
    3085                 BstrFmt(tr("Resizing medium and cloning into it")).raw(),
    3086                 TRUE, /* aCancelable */
    3087                 2, /* Number of opearations */
    3088                 BstrFmt(tr("Resizing medium before clone")).raw()
    3089                 );
    3090 
    3091     if (FAILED(rc))
    3092         throw rc;
    3093 
    3094     /* If target does not exist, handle resize. */
    3095     if (pTarget->m->state != MediumState_NotCreated && aLogicalSize > 0)
    3096     {
    3097         if ((LONG64)uTargetExistingSize != aLogicalSize) {
    3098             if (!i_isMediumFormatFile())
    3099             {
    3100                 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    3101                 rc = setError(VBOX_E_NOT_SUPPORTED,
    3102                               tr("Sizes of '%s' and '%s' are different and \
    3103                                  medium format does not support resing"),
    3104                               strSourceName.c_str(), strTargetName.c_str());
    3105                 throw rc;
    3106             }
    3107 
    3108             /**
    3109              * Need to lock the target medium as i_resize does do so
    3110              * automatically.
    3111              */
    3112 
    3113             ComPtr<IToken> pToken;
    3114             rc = pTarget->LockWrite(pToken.asOutParam());
    3115 
    3116             if (FAILED(rc)) throw rc;
    3117 
    3118             /**
    3119              * Have to make own lock list, because "resize" method resizes only
    3120              * last image in the lock chain.
    3121              */
    3122 
    3123             MediumLockList* pMediumLockListForResize = new MediumLockList();
    3124             pMediumLockListForResize->Append(pTarget, pTarget->m->state == MediumState_LockedWrite);
    3125 
    3126             rc = pMediumLockListForResize->Lock(true /* fSkipOverLockedMedia */);
    3127 
    3128             if (FAILED(rc))
    3129             {
    3130                 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    3131                 rc = setError(rc,
    3132                                 tr("Failed to lock the medium '%s' to resize before merge"),
    3133                                 strTargetName.c_str());
    3134                 delete pMediumLockListForResize;
    3135                 throw rc;
    3136             }
    3137 
    3138 
    3139             rc = pTarget->i_resize((uint64_t)aLogicalSize, pMediumLockListForResize, &pProgress, true, false);
    3140 
    3141             if (FAILED(rc))
    3142             {
    3143                 /* No need to setError becasue i_resize and i_taskResizeHandler handle this automatically. */
    3144                 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    3145                 delete pMediumLockListForResize;
    3146                 throw rc;
    3147             }
    3148 
    3149             delete pMediumLockListForResize;
    3150 
    3151             pTarget->m->logicalSize = aLogicalSize;
    3152 
    3153             pToken->Abandon();
    3154             pToken.setNull();
    3155         }
    3156     }
    3157 
    3158     /* Report progress to supplied progress argument */
    3159     if (SUCCEEDED(rc))
    3160     {
    3161         pProgress.queryInterfaceTo(aProgress.asOutParam());
    3162     }
    31633039
    31643040    try
     
    32353111        }
    32363112
     3113        pProgress.createObject();
     3114        rc = pProgress->init(m->pVirtualBox,
     3115                             static_cast <IMedium *>(this),
     3116                             BstrFmt(tr("Creating clone medium '%s'"), pTarget->m->strLocationFull.c_str()).raw(),
     3117                             TRUE /* aCancelable */);
     3118        if (FAILED(rc))
     3119        {
     3120            delete pSourceMediumLockList;
     3121            delete pTargetMediumLockList;
     3122            throw rc;
     3123        }
     3124
    32373125        ULONG mediumVariantFlags = 0;
    32383126
     
    32513139        }
    32523140
    3253         if (pTarget->m->state != MediumState_NotCreated || aLogicalSize == 0)
    3254         {
    3255             /* setup task object to carry out the operation asynchronously */
    3256             pTask = new Medium::CloneTask(this, pProgress, pTarget,
    3257                                           (MediumVariant_T)mediumVariantFlags,
    3258                                           pParent, UINT32_MAX, UINT32_MAX,
    3259                                           pSourceMediumLockList, pTargetMediumLockList,
    3260                                           false, false, true, 0);
    3261         }
    3262         else
    3263         {
    3264             /* setup task object to carry out the operation asynchronously */
    3265             pTask = new Medium::CloneTask(this, pProgress, pTarget,
    3266                                           (MediumVariant_T)mediumVariantFlags,
    3267                                           pParent, UINT32_MAX, UINT32_MAX,
    3268                                           pSourceMediumLockList, pTargetMediumLockList,
    3269                                           false, false, true, aLogicalSize);
    3270         }
    3271 
     3141        /* setup task object to carry out the operation asynchronously */
     3142        pTask = new Medium::CloneTask(this, pProgress, pTarget,
     3143                                      (MediumVariant_T)mediumVariantFlags,
     3144                                      pParent, UINT32_MAX, UINT32_MAX,
     3145                                      pSourceMediumLockList, pTargetMediumLockList);
    32723146        rc = pTask->rc();
    32733147        AssertComRC(rc);
     
    32873161            pProgress.queryInterfaceTo(aProgress.asOutParam());
    32883162    }
    3289     else if (pTask != NULL) {
     3163    else if (pTask != NULL)
    32903164        delete pTask;
    3291         throw rc;
    3292     }
    32933165
    32943166    return rc;
     
    97759647                                 (fCreatingTarget) ? targetLocation.c_str() : (char *)NULL,
    97769648                                 false /* fMoveByRename */,
    9777                                  (uint64_t) task.mTargetLogicalSize /* cbSize */,
     9649                                 0 /* cbSize */,
    97789650                                 task.mVariant & ~(MediumVariant_NoCreateDir | MediumVariant_Formatted),
    97799651                                 targetId.raw(),
     
    97919663                                   (fCreatingTarget) ? targetLocation.c_str() : (char *)NULL,
    97929664                                   false /* fMoveByRename */,
    9793                                    (uint64_t) task.mTargetLogicalSize /* cbSize */,
     9665                                   0 /* cbSize */,
    97949666                                   task.midxSrcImageSame,
    97959667                                   task.midxDstImageSame,
  • trunk/src/VBox/ValidationKit/tests/api/tdApi1.py

    r97864 r97865  
    9595    from tdTreeDepth1    import SubTstDrvTreeDepth1;  # pylint: disable=relative-import
    9696    from tdMoveVm1       import SubTstDrvMoveVm1;     # pylint: disable=relative-import
    97     from tdCloneMedium1  import SubTstDrvCloneMedium1;# pylint: disable=relative-import
    9897    sys.exit(tdApi1([SubTstDrvPython1, SubTstDrvAppliance1, SubTstDrvMoveMedium1,
    99                      SubTstDrvTreeDepth1, SubTstDrvMoveVm1, SubTstDrvCloneMedium1]).main(sys.argv))
     98                     SubTstDrvTreeDepth1, SubTstDrvMoveVm1]).main(sys.argv))
     99
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