VirtualBox

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


Ignore:
Timestamp:
Apr 9, 2010 3:58:10 PM (15 years ago)
Author:
vboxsync
Message:

Main/OVF: use readable disk names instead of UUIDs on export, better progress message

File:
1 edited

Legend:

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

    r28149 r28150  
    318318                strLocation = bstrLocation;
    319319
    320                 Bstr bstrName;
    321                 rc = pMedium->COMGETTER(Name)(bstrName.asOutParam());
    322                 if (FAILED(rc)) throw rc;
    323 
    324                 strTargetVmdkName = bstrName;
    325                 strTargetVmdkName.stripExt();
    326                 strTargetVmdkName.append(".vmdk");
    327 
    328                 // we need the size of the image so we can give it to addEntry();
    329                 // later, on export, the progress weight will be based on this.
    330                 // pMedium can be a differencing image though; in that case, we
    331                 // need to use the size of the base instead.
     320                // find the source's base medium for two things:
     321                // 1) we'll use its name to determine the name of the target disk, which is readable,
     322                //    as opposed to the UUID filename of a differencing image, if pMedium is one
     323                // 2) we need the size of the base image so we can give it to addEntry(), and later
     324                //    on export, the progress will be based on that (and not the diff image)
    332325                ComPtr<IMedium> pBaseMedium;
    333326                rc = pMedium->COMGETTER(Base)(pBaseMedium.asOutParam());
    334327                        // returns pMedium if there are no diff images
    335328                if (FAILED(rc)) throw rc;
     329
     330                Bstr bstrBaseName;
     331                rc = pBaseMedium->COMGETTER(Name)(bstrBaseName.asOutParam());
     332                if (FAILED(rc)) throw rc;
     333
     334                strTargetVmdkName = bstrBaseName;
     335                strTargetVmdkName.stripExt();
     336                strTargetVmdkName.append(".vmdk");
    336337
    337338                // force reading state, or else size will be returned as 0
     
    14071408                               strSrcFilePath.c_str());
    14081409
     1410            // clone the disk:
     1411            ComPtr<IMedium> pSourceDisk;
     1412            ComPtr<IMedium> pTargetDisk;
     1413            ComPtr<IProgress> pProgress2;
     1414
     1415            Log(("Finding source disk \"%ls\"\n", bstrSrcFilePath.raw()));
     1416            rc = mVirtualBox->FindHardDisk(bstrSrcFilePath, pSourceDisk.asOutParam());
     1417            if (FAILED(rc)) throw rc;
     1418
     1419            Bstr uuidSource;
     1420            rc = pSourceDisk->COMGETTER(Id)(uuidSource.asOutParam());
     1421            if (FAILED(rc)) throw rc;
     1422            Guid guidSource(uuidSource);
     1423
    14091424            // output filename
    14101425            const Utf8Str &strTargetFileNameOnly = pDiskEntry->strOvf;
     
    14151430            strTargetFilePath.append(strTargetFileNameOnly);
    14161431
    1417             // clone the disk:
    1418             ComPtr<IMedium> pSourceDisk;
    1419             ComPtr<IMedium> pTargetDisk;
    1420             ComPtr<IProgress> pProgress2;
    1421 
    1422             Log(("Finding source disk \"%ls\"\n", bstrSrcFilePath.raw()));
    1423             rc = mVirtualBox->FindHardDisk(bstrSrcFilePath, pSourceDisk.asOutParam());
    1424             if (FAILED(rc)) throw rc;
    1425 
    1426             Bstr uuidSource;
    1427             rc = pSourceDisk->COMGETTER(Id)(uuidSource.asOutParam());
    1428             if (FAILED(rc)) throw rc;
    1429             Guid guidSource(uuidSource);
    1430 
    14311432            // We are always exporting to VMDK stream optimized for now
    14321433            Bstr bstrSrcFormat = L"VMDK";
     
    14471448                // advance to the next operation
    14481449                if (!pProgress.isNull())
    1449                     pProgress->SetNextOperation(BstrFmt(tr("Exporting virtual disk image '%s'"), strSrcFilePath.c_str()),
     1450                    pProgress->SetNextOperation(BstrFmt(tr("Exporting to disk image '%s'"), strTargetFilePath.c_str()),
    14501451                                                pDiskEntry->ulSizeMB);     // operation's weight, as set up with the IProgress originally);
    14511452
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