VirtualBox

Changeset 17970 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Mar 16, 2009 7:08:16 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
44552
Message:

API/HardDisk, Storage/VBoxHDD, Frontend/VBoxManage: eliminated base image type, which led to much unnecessary code duplication. Was triggered by VBoxManage finally being able to create all image variants the backends can support.

Location:
trunk/src/VBox/Main
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/ApplianceImpl.cpp

    r17965 r17970  
    22172217
    22182218                            /* Create a dynamic growing disk image with the given capacity */
    2219                             rc = dstHdVBox->CreateDynamicStorage(di.iCapacity / _1M, HardDiskVariant_Standard, progress.asOutParam());
     2219                            rc = dstHdVBox->CreateBaseStorage(di.iCapacity / _1M, HardDiskVariant_Standard, progress.asOutParam());
    22202220                            if (FAILED(rc)) throw rc;
    22212221
  • trunk/src/VBox/Main/HardDiskImpl.cpp

    r17911 r17970  
    5858struct HardDisk::Task : public com::SupportErrorInfoBase
    5959{
    60     enum Operation { CreateDynamic, CreateFixed, CreateDiff,
     60    enum Operation { CreateBase, CreateDiff,
    6161                     Merge, Clone, Delete, Reset };
    6262
     
    9898        Data() : size (0) {}
    9999
    100         /* CreateDynamic, CreateStatic */
     100        /* CreateBase */
    101101
    102102        uint64_t size;
    103103
    104         /* CreateDynamic, CreateStatic, CreateDiff, Clone */
     104        /* CreateBase, CreateDiff, Clone */
    105105
    106106        HardDiskVariant_T variant;
     
    11781178}
    11791179
    1180 STDMETHODIMP HardDisk::CreateDynamicStorage(ULONG64 aLogicalSize,
    1181                                             HardDiskVariant_T aVariant,
    1182                                             IProgress **aProgress)
     1180STDMETHODIMP HardDisk::CreateBaseStorage(ULONG64 aLogicalSize,
     1181                                         HardDiskVariant_T aVariant,
     1182                                         IProgress **aProgress)
    11831183{
    11841184    CheckComArgOutPointerValid (aProgress);
     
    11891189    AutoWriteLock alock (this);
    11901190
    1191     if (!(mm.formatObj->capabilities() &
    1192           HardDiskFormatCapabilities_CreateDynamic))
     1191    aVariant &= ~HardDiskVariant_Diff;
     1192    if (    !(aVariant & HardDiskVariant_Fixed)
     1193        &&  !(mm.formatObj->capabilities() & HardDiskFormatCapabilities_CreateDynamic))
    11931194        return setError (VBOX_E_NOT_SUPPORTED,
    11941195            tr ("Hard disk format '%ls' does not support dynamic storage "
     1196                "creation"), mm.format.raw());
     1197    if (    (aVariant & HardDiskVariant_Fixed)
     1198        &&  !(mm.formatObj->capabilities() & HardDiskFormatCapabilities_CreateDynamic))
     1199        return setError (VBOX_E_NOT_SUPPORTED,
     1200            tr ("Hard disk format '%ls' does not support fixed storage "
    11951201                "creation"), mm.format.raw());
    11961202
     
    12051211    ComObjPtr <Progress> progress;
    12061212    progress.createObject();
     1213    /// @todo include fixed/dynamic
    12071214    HRESULT rc = progress->init (mVirtualBox, static_cast<IHardDisk*>(this),
    1208         BstrFmt (tr ("Creating dynamic hard disk storage unit '%ls'"),
    1209                  m.locationFull.raw()),
     1215        (aVariant & HardDiskVariant_Fixed)
     1216          ? BstrFmt (tr ("Creating fixed hard disk storage unit '%ls'"), m.locationFull.raw())
     1217          : BstrFmt (tr ("Creating dynamic hard disk storage unit '%ls'"), m.locationFull.raw()),
    12101218        FALSE /* aCancelable */);
    12111219    CheckComRCReturnRC (rc);
     
    12141222     * asynchronously */
    12151223
    1216     std::auto_ptr <Task> task (new Task (this, progress, Task::CreateDynamic));
    1217     AssertComRCReturnRC (task->autoCaller.rc());
    1218 
    1219     task->d.size = aLogicalSize;
    1220     task->d.variant = aVariant;
    1221 
    1222     rc = task->startThread();
    1223     CheckComRCReturnRC (rc);
    1224 
    1225     /* go to Creating state on success */
    1226     m.state = MediaState_Creating;
    1227 
    1228     /* task is now owned by taskThread() so release it */
    1229     task.release();
    1230 
    1231     /* return progress to the caller */
    1232     progress.queryInterfaceTo (aProgress);
    1233 
    1234     return S_OK;
    1235 }
    1236 
    1237 STDMETHODIMP HardDisk::CreateFixedStorage(ULONG64 aLogicalSize,
    1238                                           HardDiskVariant_T aVariant,
    1239                                           IProgress **aProgress)
    1240 {
    1241     CheckComArgOutPointerValid (aProgress);
    1242 
    1243     AutoCaller autoCaller (this);
    1244     CheckComRCReturnRC (autoCaller.rc());
    1245 
    1246     AutoWriteLock alock (this);
    1247 
    1248     if (!(mm.formatObj->capabilities() &
    1249           HardDiskFormatCapabilities_CreateFixed))
    1250         return setError (VBOX_E_NOT_SUPPORTED,
    1251             tr ("Hard disk format '%ls' does not support fixed storage "
    1252                 "creation"), mm.format.raw());
    1253 
    1254     switch (m.state)
    1255     {
    1256         case MediaState_NotCreated:
    1257             break;
    1258         default:
    1259             return setStateError();
    1260     }
    1261 
    1262     ComObjPtr <Progress> progress;
    1263     progress.createObject();
    1264     HRESULT rc = progress->init (mVirtualBox, static_cast<IHardDisk*>(this),
    1265         BstrFmt (tr ("Creating fixed hard disk storage unit '%ls'"),
    1266                  m.locationFull.raw()),
    1267         FALSE /* aCancelable */);
    1268     CheckComRCReturnRC (rc);
    1269 
    1270     /* setup task object and thread to carry out the operation
    1271      * asynchronously */
    1272 
    1273     std::auto_ptr <Task> task (new Task (this, progress, Task::CreateFixed));
     1224    std::auto_ptr <Task> task (new Task (this, progress, Task::CreateBase));
    12741225    AssertComRCReturnRC (task->autoCaller.rc());
    12751226
     
    29872938
    29882939            /* check the type */
    2989             VDIMAGETYPE type;
    2990             vrc = VDGetImageType (hdd, 0, &type);
     2940            unsigned uImageFlags;
     2941            vrc = VDGetImageFlags (hdd, 0, &uImageFlags);
    29912942            ComAssertRCThrow (vrc, E_FAIL);
    29922943
    2993             if (type == VD_IMAGE_TYPE_DIFF)
     2944            if (uImageFlags & VD_IMAGE_FLAGS_DIFF)
    29942945            {
    29952946                RTUUID parentId;
     
    33973348        ////////////////////////////////////////////////////////////////////////
    33983349
    3399         case Task::CreateDynamic:
    3400         case Task::CreateFixed:
     3350        case Task::CreateBase:
    34013351        {
    34023352            /* The lock is also used as a signal from the task initiator (which
     
    34443394
    34453395                    vrc = VDCreateBase (hdd, format, location,
    3446                                         task->operation == Task::CreateDynamic ?
    3447                                             VD_IMAGE_TYPE_NORMAL :
    3448                                             VD_IMAGE_TYPE_FIXED,
    34493396                                        task->d.size * _1M,
    34503397                                        task->d.variant,
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r17965 r17970  
    18041804        allocate a format-specific storage unit at the specified location:
    18051805        <ul>
    1806           <li><link to="IHardDisk::createDynamicStorage"/></li>
    1807           <li><link to="IHardDisk::createFixedStorage"/></li>
     1806          <li><link to="IHardDisk::createBaseStorage"/></li>
    18081807          <li><link to="IHardDisk::createDiffStorage"/></li>
    18091808        </ul>
     
    85588557  <enum
    85598558    name="HardDiskVariant"
    8560     uuid="3bc36e8c-bf7a-4dba-b6cb-df87cdc9cc19"
     8559    uuid="99334b63-7ed0-4f61-8a7e-7ec3e20dd912"
    85618560   >
    85628561    <desc>
     
    85798578        VMDK streamOptimized image. Special import/export format which is
    85808579        read-only/append-only.
     8580      </desc>
     8581    </const>
     8582    <const name="Fixed" value="0x1000">
     8583      <desc>
     8584        Fixed image. Only allowed for base images.
     8585      </desc>
     8586    </const>
     8587    <const name="Diff" value="0x2000">
     8588      <desc>
     8589        Fixed image. Only allowed for base images.
    85818590      </desc>
    85828591    </const>
     
    86188627  <interface
    86198628    name="IHardDisk" extends="IMedium"
    8620     uuid="a4d391a5-e2b1-474d-824e-2ff668a92d58"
     8629    uuid="3498d065-dee6-48bf-bcc5-47018fee4f42"
    86218630    wsmap="managed"
    86228631  >
     
    91579166    <!-- storage methods -->
    91589167
    9159     <method name="createDynamicStorage">
    9160       <desc>
    9161         Starts creating a dynamically expanding hard disk storage unit in the
    9162         background. The previous storage unit created for this object, if
    9163         any, must first be deleted using <link to="#deleteStorage"/>, otherwise
    9164         the operation will fail.
     9168    <method name="createBaseStorage">
     9169      <desc>
     9170        Starts creating a hard disk storage unit (fixed/dynamic, according
     9171        to the variant flags) in in the background. The previous storage unit
     9172        created for this object, if any, must first be deleted using
     9173        <link to="#deleteStorage"/>, otherwise the operation will fail.
    91659174
    91669175        Before the operation starts, the hard disk is placed in
     
    91759184
    91769185        <result name="VBOX_E_NOT_SUPPORTED">
    9177           Dynamic storage creation operation is not supported. See <link
     9186          The variant of storage creation operation is not supported. See <link
    91789187          to="IHardDiskFormat::capabilities"/>.
    91799188        </result>
     
    91819190      <param name="logicalSize" type="unsigned long long" dir="in">
    91829191        <desc>Maximum logical size of the hard disk in megabytes.</desc>
    9183       </param>
    9184       <param name="variant" type="HardDiskVariant" dir="in">
    9185         <desc>Exact image variant which should be created.</desc>
    9186       </param>
    9187       <param name="progress" type="IProgress" dir="return">
    9188         <desc>Progress object to track the operation completion.</desc>
    9189       </param>
    9190     </method>
    9191 
    9192     <method name="createFixedStorage">
    9193       <desc>
    9194         Starts creating a fixed-size hard disk storage unit in the background.
    9195         The previous storage unit created for this object, if
    9196         any, must be first deleted using <link to="#deleteStorage"/>, otherwise
    9197         the operation will fail.
    9198 
    9199         Before the operation starts, the hard disk is placed to
    9200         <link to="MediaState_Creating"/> state. If the create operation
    9201         fails, the media will placed back to <link to="MediaState_NotCreated"/>
    9202         state.
    9203 
    9204         After the returned progress object reports that the operation is
    9205         successfully complete, the media state will be set to <link
    9206         to="MediaState_Created"/>, the hard disk will be remembered by this
    9207         VirtualBox installation and may be attached to virtual machines.
    9208 
    9209         <result name="VBOX_E_NOT_SUPPORTED">
    9210           Fixed storage creation operation is not supported. See
    9211           <link to="IHardDiskFormat::capabilities"/>.
    9212         </result>
    9213       </desc>
    9214       <param name="logicalSize" type="unsigned long long" dir="in">
    9215         <desc>Logical size of the hard disk in megabytes.</desc>
    92169192      </param>
    92179193      <param name="variant" type="HardDiskVariant" dir="in">
  • trunk/src/VBox/Main/include/HardDiskImpl.h

    r17825 r17970  
    108108    STDMETHOD(SetProperties) (ComSafeArrayIn (IN_BSTR, aNames),
    109109                              ComSafeArrayIn (IN_BSTR, aValues));
    110     STDMETHOD(CreateDynamicStorage) (ULONG64 aLogicalSize,
    111                                      HardDiskVariant_T aVariant,
    112                                      IProgress **aProgress);
    113     STDMETHOD(CreateFixedStorage) (ULONG64 aLogicalSize,
    114                                    HardDiskVariant_T aVariant,
    115                                    IProgress **aProgress);
     110    STDMETHOD(CreateBaseStorage) (ULONG64 aLogicalSize,
     111                                  HardDiskVariant_T aVariant,
     112                                  IProgress **aProgress);
    116113    STDMETHOD(DeleteStorage) (IProgress **aProgress);
    117114    STDMETHOD(CreateDiffStorage) (IHardDisk *aTarget,
  • trunk/src/VBox/Main/testcase/tstVBoxAPILinux.cpp

    r17825 r17970  
    314314         */
    315315        nsCOMPtr <IProgress> progress;
    316         rc = hardDisk->CreateDynamicStorage(100,                                // size in megabytes
    317                                             HardDiskVariant_Standard,
    318                                             getter_AddRefs(progress));          // optional progress object
     316        rc = hardDisk->CreateBaseStorage(100,                                // size in megabytes
     317                                         HardDiskVariant_Standard,
     318                                         getter_AddRefs(progress));          // optional progress object
    319319        if (NS_FAILED(rc))
    320320        {
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