VirtualBox

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


Ignore:
Timestamp:
Jul 6, 2012 12:54:35 PM (12 years ago)
Author:
vboxsync
Message:

Main/ApplianceImport: Don't use the SHA VFS layer if there is no manifest to check against

File:
1 edited

Legend:

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

    r41783 r42038  
    12331233    HRESULT rc = S_OK;
    12341234
    1235     PVDINTERFACEIO pShaIo = 0;
    1236     PVDINTERFACEIO pFileIo = 0;
    1237     void *pvMfBuf = 0;
     1235    PVDINTERFACEIO pShaIo = NULL;
     1236    PVDINTERFACEIO pFileIo = NULL;
     1237    void *pvMfBuf = NULL;
    12381238    writeLock.release();
    12391239    try
    12401240    {
    12411241        /* Create the necessary file access interfaces. */
    1242         pShaIo = ShaCreateInterface();
    1243         if (!pShaIo)
    1244             throw setError(E_OUTOFMEMORY);
    12451242        pFileIo = FileCreateInterface();
    12461243        if (!pFileIo)
    12471244            throw setError(E_OUTOFMEMORY);
    12481245
    1249         SHASTORAGE storage;
    1250         RT_ZERO(storage);
    1251         storage.fCreateDigest = true;
    1252         int vrc = VDInterfaceAdd(&pFileIo->Core, "Appliance::IOFile",
    1253                                  VDINTERFACETYPE_IO, 0, sizeof(VDINTERFACEIO),
    1254                                  &storage.pVDImageIfaces);
    1255         if (RT_FAILURE(vrc))
    1256             throw setError(VBOX_E_IPRT_ERROR, "Creation of the VD interface failed (%Rrc)", vrc);
    1257 
    1258         size_t cbMfSize = 0;
    12591246        Utf8Str strMfFile = Utf8Str(pTask->locInfo.strPath).stripExt().append(".mf");
    12601247        /* Create the import stack for the rollback on errors. */
    12611248        ImportStack stack(pTask->locInfo, m->pReader->m_mapDisks, pTask->pProgress);
    1262         /* Do we need the digest information? */
    1263         storage.fCreateDigest = RTFileExists(strMfFile.c_str());
    1264         /* Now import the appliance. */
    1265         importMachines(stack, pShaIo, &storage);
    1266         /* Read & verify the manifest file, if there is one. */
    1267         if (storage.fCreateDigest)
    1268         {
     1249
     1250        if (RTFileExists(strMfFile.c_str()))
     1251        {
     1252            SHASTORAGE storage;
     1253            RT_ZERO(storage);
     1254
     1255            pShaIo = ShaCreateInterface();
     1256            if (!pShaIo)
     1257                throw setError(E_OUTOFMEMORY);
     1258
     1259            storage.fCreateDigest = true;
     1260            int vrc = VDInterfaceAdd(&pFileIo->Core, "Appliance::IOFile",
     1261                                     VDINTERFACETYPE_IO, 0, sizeof(VDINTERFACEIO),
     1262                                     &storage.pVDImageIfaces);
     1263            if (RT_FAILURE(vrc))
     1264                throw setError(VBOX_E_IPRT_ERROR, "Creation of the VD interface failed (%Rrc)", vrc);
     1265
     1266            size_t cbMfSize = 0;
     1267            storage.fCreateDigest = true;
     1268            /* Now import the appliance. */
     1269            importMachines(stack, pShaIo, &storage);
     1270            /* Read & verify the manifest file. */
    12691271            /* Add the ovf file to the digest list. */
    12701272            stack.llSrcDisksDigest.push_front(STRPAIR(pTask->locInfo.strPath, m->strOVFSHADigest));
     
    12741276            if (FAILED(rc)) throw rc;
    12751277        }
     1278        else
     1279            importMachines(stack, pFileIo, NULL);
    12761280    }
    12771281    catch (HRESULT rc2)
     
    19121916    /* Add the newly create disk path + a corresponding digest the our list for
    19131917     * later manifest verification. */
    1914     stack.llSrcDisksDigest.push_back(STRPAIR(strSrcFilePath, pStorage->strDigest));
     1918    stack.llSrcDisksDigest.push_back(STRPAIR(strSrcFilePath, pStorage ? pStorage->strDigest : ""));
    19151919}
    19161920
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