VirtualBox

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


Ignore:
Timestamp:
Jun 2, 2017 3:24:58 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
115944
Message:

Main/Appliance++: Removed non-VBOX_WITH_NEW_TAR_CREATOR code.

Location:
trunk/src/VBox/Main
Files:
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/Makefile.kmk

    r67211 r67249  
    374374        $(if $(VBOX_WITH_NEW_USB_CODE_ON_DARWIN),VBOX_WITH_NEW_USB_CODE_ON_DARWIN,)
    375375endif
    376 if !defined(VBOX_WITHOUT_NEW_TAR_CREATOR)
    377  VBoxSVC_DEFS += VBOX_WITH_NEW_TAR_CREATOR
    378 endif
    379376VBoxSVC_DEFS.win += VBOX_COM_OUTOFPROC_MODULE
    380377VBoxSVC_DEFS.win += _WIN32_WINNT=0x0510
     
    447444        src-server/ApplianceImplExport.cpp \
    448445        src-server/ApplianceImplImport.cpp \
    449         src-server/ApplianceImplIO.cpp \
    450446        src-server/AudioAdapterImpl.cpp \
    451447        src-server/BandwidthControlImpl.cpp \
  • trunk/src/VBox/Main/include/ApplianceImpl.h

    r67208 r67249  
    220220    HRESULT i_writeFSOVA(TaskOVF *pTask, AutoWriteLockBase& writeLock);
    221221    HRESULT i_writeFSOPC(TaskOVF *pTask, AutoWriteLockBase& writeLock);
    222 #ifdef VBOX_WITH_NEW_TAR_CREATOR
    223222    HRESULT i_writeFSImpl(TaskOVF *pTask, AutoWriteLockBase &writeLock, RTVFSFSSTREAM hVfsFssDst);
    224223    HRESULT i_writeBufferToFile(RTVFSFSSTREAM hVfsFssDst, const char *pszFilename, const void *pvContent, size_t cbContent);
    225 #else
    226     HRESULT i_writeFSImpl(TaskOVF *pTask, AutoWriteLockBase &writeLock, PVDINTERFACEIO pCallbacks, PSHASTORAGE pStorage);
    227 #endif
    228224
    229225    struct XMLStack;
  • trunk/src/VBox/Main/include/ApplianceImplPrivate.h

    r67199 r67249  
    7171      , hOurManifest(NIL_RTMANIFEST)
    7272      , fManifest(true)
    73 #ifndef VBOX_WITH_NEW_TAR_CREATOR
    74       , fSha256(false)
    75 #endif
    7673      , fDeterminedDigestTypes(false)
    7774      , hTheirManifest(NIL_RTMANIFEST)
     
    162159     * @{ */
    163160    bool                fManifest;      // Create a manifest file on export
    164 #ifndef VBOX_WITH_NEW_TAR_CREATOR
    165     bool                fSha256;        // true = SHA256 (OVF 2.0), false = SHA1 (OVF 1.0)
    166 #endif
    167161    /** @} */
    168162
     
    429423
    430424
    431 #ifndef VBOX_WITH_NEW_TAR_CREATOR
    432 typedef struct SHASTORAGE
    433 {
    434     PVDINTERFACE pVDImageIfaces;
    435     bool         fCreateDigest;
    436     bool         fSha256;        /* false = SHA1 (OVF 1.x), true = SHA256 (OVF 2.0) */
    437     Utf8Str      strDigest;
    438 } SHASTORAGE, *PSHASTORAGE;
    439 
    440 PVDINTERFACEIO ShaCreateInterface();
    441 PVDINTERFACEIO FileCreateInterface();
    442 PVDINTERFACEIO tarWriterCreateInterface(void);
    443 #endif
    444 
    445 int writeBufferToFile(const char *pcszFilename, void *pvBuf, size_t cbSize, PVDINTERFACEIO pIfIo, void *pvUser);
    446 
    447425#endif // !____H_APPLIANCEIMPLPRIVATE
    448426
  • trunk/src/VBox/Main/include/MediumImpl.h

    r67244 r67249  
    210210                         MediumVariant_T aVariant,
    211211                         SecretKeyStore *pKeyStore,
    212 #ifdef VBOX_WITH_NEW_TAR_CREATOR
    213212                         RTVFSIOSTREAM hVfsIosDst,
    214 #else
    215                          PVDINTERFACEIO aVDImageIOIf, void *aVDImageIOUser,
    216 #endif
    217213                         const ComObjPtr<Progress> &aProgress);
    218214    HRESULT i_importFile(const char *aFilename,
     
    382378    class DeleteTask;
    383379    class MergeTask;
    384 #ifndef VBOX_WITH_NEW_TAR_CREATOR
    385     class ExportTask;
    386 #endif
    387380    class ImportTask;
    388381    class EncryptTask;
     
    397390    friend class DeleteTask;
    398391    friend class MergeTask;
    399 #ifndef VBOX_WITH_NEW_TAR_CREATOR
    400     friend class ExportTask;
    401 #endif
    402392    friend class ImportTask;
    403393    friend class EncryptTask;
     
    412402    HRESULT i_taskCompactHandler(Medium::CompactTask &task);
    413403    HRESULT i_taskResizeHandler(Medium::ResizeTask &task);
    414 #ifndef VBOX_WITH_NEW_TAR_CREATOR
    415     HRESULT i_taskExportHandler(Medium::ExportTask &task);
    416 #endif
    417404    HRESULT i_taskImportHandler(Medium::ImportTask &task);
    418405    HRESULT i_taskEncryptHandler(Medium::EncryptTask &task);
     
    426413};
    427414
    428 #endif /* ____H_MEDIUMIMPL */
    429 
     415#endif /* !____H_MEDIUMIMPL */
     416
  • trunk/src/VBox/Main/src-server/ApplianceImplExport.cpp

    r67244 r67249  
    2222#include <iprt/manifest.h>
    2323#include <iprt/stream.h>
    24 #ifndef VBOX_WITH_NEW_TAR_CREATOR
    25 # include <iprt/tar.h>
    26 #else
    27 # include <iprt/zip.h>
    28 #endif
     24#include <iprt/zip.h>
    2925
    3026#include <VBox/version.h>
     
    705701    if (m->fManifest)
    706702        m->fDigestTypes = ovfF >= ovf::OVFVersion_2_0 ? RTMANIFEST_ATTR_SHA256 : RTMANIFEST_ATTR_SHA1;
    707 #ifndef VBOX_WITH_NEW_TAR_CREATOR
    708     m->fSha256 = ovfF >= ovf::OVFVersion_2_0;
    709 #endif
    710703    Assert(m->hOurManifest == NIL_RTMANIFEST);
    711704
     
    19881981
    19891982    if (pTask->enFormat == ovf::OVFVersion_unknown)
    1990 #ifdef VBOX_WITH_NEW_TAR_CREATOR
    19911983        rc = i_writeFSOPC(pTask, multiLock);
    1992 #else
    1993         rc = E_NOTIMPL;
    1994 #endif
    19951984    else if (pTask->locInfo.strPath.endsWith(".ovf", Utf8Str::CaseInsensitive))
    19961985        rc = i_writeFSOVF(pTask, multiLock);
     
    20101999    LogFlowFuncEnter();
    20112000
    2012 #ifdef VBOX_WITH_NEW_TAR_CREATOR
    20132001    /*
    20142002     * Create write-to-dir file system stream for the target directory.
     
    20462034    LogFlowFuncLeave();
    20472035    return hrc;
    2048 
    2049 #else /* VBOX_WITH_NEW_TAR_CREATOR */
    2050     HRESULT rc = S_OK;
    2051 
    2052     PVDINTERFACEIO pShaIo = 0;
    2053     PVDINTERFACEIO pFileIo = 0;
    2054     do
    2055     {
    2056         pShaIo = ShaCreateInterface();
    2057         if (!pShaIo)
    2058         {
    2059             rc = E_OUTOFMEMORY;
    2060             break;
    2061         }
    2062         pFileIo = FileCreateInterface();
    2063         if (!pFileIo)
    2064         {
    2065             rc = E_OUTOFMEMORY;
    2066             break;
    2067         }
    2068 
    2069         SHASTORAGE storage;
    2070         RT_ZERO(storage);
    2071         storage.fCreateDigest = m->fManifest;
    2072         storage.fSha256 = m->fSha256;
    2073 
    2074 
    2075         Utf8Str name = i_applianceIOName(applianceIOFile);
    2076 
    2077         int vrc = VDInterfaceAdd(&pFileIo->Core, name.c_str(),
    2078                                  VDINTERFACETYPE_IO, 0, sizeof(VDINTERFACEIO),
    2079                                  &storage.pVDImageIfaces);
    2080         if (RT_FAILURE(vrc))
    2081         {
    2082             rc = E_FAIL;
    2083             break;
    2084         }
    2085         rc = i_writeFSImpl(pTask, writeLock, pShaIo, &storage);
    2086     } while (0);
    2087 
    2088     /* Cleanup */
    2089     if (pShaIo)
    2090         RTMemFree(pShaIo);
    2091     if (pFileIo)
    2092         RTMemFree(pFileIo);
    2093 
    2094     LogFlowFuncLeave();
    2095     return rc;
    2096 #endif
    20972036}
    20982037
     
    21012040    LogFlowFuncEnter();
    21022041
    2103 #ifdef VBOX_WITH_NEW_TAR_CREATOR
    21042042    /*
    21052043     * Open the output file and attach a TAR creator to it.
     
    21342072    LogFlowFuncLeave();
    21352073    return hrc;
    2136 
    2137 #else /* VBOX_WITH_NEW_TAR_CREATOR */
    2138 
    2139     RTTAR tar;
    2140     int vrc = RTTarOpen(&tar, pTask->locInfo.strPath.c_str(), RTFILE_O_CREATE | RTFILE_O_WRITE | RTFILE_O_DENY_ALL);
    2141     if (RT_FAILURE(vrc))
    2142         return setError(VBOX_E_FILE_ERROR,
    2143                         tr("Could not create OVA file '%s' (%Rrc)"),
    2144                         pTask->locInfo.strPath.c_str(), vrc);
    2145 
    2146     HRESULT rc = S_OK;
    2147 
    2148     PVDINTERFACEIO pShaIo = 0;
    2149     PVDINTERFACEIO pTarIo = 0;
    2150     do
    2151     {
    2152         pShaIo = ShaCreateInterface();
    2153         if (!pShaIo)
    2154         {
    2155             rc = E_OUTOFMEMORY;
    2156             break;
    2157         }
    2158         pTarIo = tarWriterCreateInterface();
    2159         if (!pTarIo)
    2160         {
    2161             rc = E_OUTOFMEMORY;
    2162             break;
    2163         }
    2164         SHASTORAGE storage;
    2165         RT_ZERO(storage);
    2166         storage.fCreateDigest = m->fManifest;
    2167         storage.fSha256 = m->fSha256;
    2168 
    2169         Utf8Str name = i_applianceIOName(applianceIOTar);
    2170 
    2171         vrc = VDInterfaceAdd(&pTarIo->Core, name.c_str(),
    2172                              VDINTERFACETYPE_IO, tar, sizeof(VDINTERFACEIO),
    2173                              &storage.pVDImageIfaces);
    2174 
    2175         if (RT_FAILURE(vrc))
    2176         {
    2177             rc = E_FAIL;
    2178             break;
    2179         }
    2180         rc = i_writeFSImpl(pTask, writeLock, pShaIo, &storage);
    2181     } while (0);
    2182 
    2183     RTTarClose(tar);
    2184 
    2185     /* Cleanup */
    2186     if (pShaIo)
    2187         RTMemFree(pShaIo);
    2188     if (pTarIo)
    2189         RTMemFree(pTarIo);
    2190 
    2191     /* Delete ova file on error */
    2192     if (FAILED(rc))
    2193         RTFileDelete(pTask->locInfo.strPath.c_str());
    2194 
    2195     LogFlowFuncLeave();
    2196     return rc;
    2197 #endif
    21982074}
    21992075
    2200 #ifdef VBOX_WITH_NEW_TAR_CREATOR
    22012076/**
    22022077 * Writes the Oracle Public Cloud appliance.
     
    23812256
    23822257}
    2383 #endif
    2384 
    2385 #ifdef VBOX_WITH_NEW_TAR_CREATOR
     2258
    23862259HRESULT Appliance::i_writeFSImpl(TaskOVF *pTask, AutoWriteLockBase &writeLock, RTVFSFSSTREAM hVfsFssDst)
    2387 #else
    2388 HRESULT Appliance::i_writeFSImpl(TaskOVF *pTask, AutoWriteLockBase& writeLock, PVDINTERFACEIO pIfIo, PSHASTORAGE pStorage)
    2389 #endif
    23902260{
    23912261    LogFlowFuncEnter();
     
    23932263    HRESULT rc = S_OK;
    23942264    int vrc;
    2395 #ifndef VBOX_WITH_NEW_TAR_CREATOR
    2396     list<STRPAIR> fileList;
    2397 #endif
    23982265    try
    23992266    {
     
    24062273            /* Construct the OVF name. */
    24072274            Utf8Str strOvfFile(pTask->locInfo.strPath);
    2408 #ifdef VBOX_WITH_NEW_TAR_CREATOR
    24092275            strOvfFile.stripPath().stripSuffix().append(".ovf");
    2410 #else
    2411             strOvfFile.stripSuffix().append(".ovf");
    2412 #endif
    24132276
    24142277            /* Render a valid ovf document into a memory buffer.  The unknown
     
    24182281                       pTask->enFormat != ovf::OVFVersion_unknown ? pTask->enFormat : ovf::OVFVersion_2_0);
    24192282
    2420             {
    2421                 void *pvBuf = NULL;
    2422                 size_t cbSize = 0;
    2423                 xml::XmlMemWriter writer;
    2424                 writer.write(doc, &pvBuf, &cbSize);
    2425                 if (RT_UNLIKELY(!pvBuf))
    2426                     throw setError(VBOX_E_FILE_ERROR, tr("Could not create OVF file '%s'"), strOvfFile.c_str());
    2427 
    2428                 /* Write the ovf file to "disk". */
    2429 #ifdef VBOX_WITH_NEW_TAR_CREATOR
    2430                 rc = i_writeBufferToFile(hVfsFssDst, strOvfFile.c_str(), pvBuf, cbSize);
    2431                 if (FAILED(rc))
    2432                     throw rc;
    2433 #else
    2434                 vrc = writeBufferToFile(strOvfFile.c_str(), pvBuf, cbSize, pIfIo, pStorage);
    2435                 if (RT_FAILURE(vrc))
    2436                     throw setErrorVrc(vrc, tr("Could not create OVF file '%s' (%Rrc)"), strOvfFile.c_str(), vrc);
    2437 #endif
    2438 
    2439 #ifndef VBOX_WITH_NEW_TAR_CREATOR
    2440                 fileList.push_back(STRPAIR(strOvfFile, pStorage->strDigest));
    2441 #endif
    2442             }
     2283            void *pvBuf = NULL;
     2284            size_t cbSize = 0;
     2285            xml::XmlMemWriter writer;
     2286            writer.write(doc, &pvBuf, &cbSize);
     2287            if (RT_UNLIKELY(!pvBuf))
     2288                throw setError(VBOX_E_FILE_ERROR, tr("Could not create OVF file '%s'"), strOvfFile.c_str());
     2289
     2290            /* Write the ovf file to "disk". */
     2291            rc = i_writeBufferToFile(hVfsFssDst, strOvfFile.c_str(), pvBuf, cbSize);
     2292            if (FAILED(rc))
     2293                throw rc;
    24432294        }
    24442295
     
    25142365            const Utf8Str &strTargetFileNameOnly = pDiskEntry->strOvf;
    25152366            // target path needs to be composed from where the output OVF is
    2516 #ifdef VBOX_WITH_NEW_TAR_CREATOR
    25172367            const Utf8Str &strTargetFilePath = strTargetFileNameOnly;
    2518 #else
    2519             Utf8Str strTargetFilePath(pTask->locInfo.strPath);
    2520             strTargetFilePath.stripFilename()
    2521                 .append("/")
    2522                 .append(strTargetFileNameOnly);
    2523 #endif
    25242368
    25252369            // The exporting requests a lock on the media tree. So leave our lock temporary.
     
    25392383                     * Export a disk image.
    25402384                     */
    2541 #ifdef VBOX_WITH_NEW_TAR_CREATOR
    25422385                    /* For compressed VMDK fun, we let i_exportFile produce the image bytes. */
    25432386                    RTVFSIOSTREAM hVfsIosDst;
     
    25582401                                                   pTask->pProgress);
    25592402                    RTVfsIoStrmRelease(hVfsIosDst);
    2560                     if (FAILED(rc)) throw rc;
    2561 #else
    2562                     /** @todo this progress object needs to be hooked up to pTask->pProgress... */
    2563                     ComObjPtr<Progress> pProgress2;
    2564                     pProgress2.createObject();
    2565                     rc = pProgress2->init(mVirtualBox, static_cast<IAppliance*>(this),
    2566                                           BstrFmt(tr("Creating medium '%s'"),
    2567                                           strTargetFilePath.c_str()).raw(), TRUE);
    2568                     if (FAILED(rc)) throw rc;
    2569 
    2570                     rc = pSourceDisk->i_exportFile(strTargetFilePath.c_str(),
    2571                                                    format,
    2572                                                    MediumVariant_VmdkStreamOptimized,
    2573                                                    m->m_pSecretKeyStore,
    2574                                                    pIfIo,
    2575                                                    pStorage,
    2576                                                    pProgress2);
    2577                     if (FAILED(rc)) throw rc;
    2578 
    2579                     ComPtr<IProgress> pProgress3(pProgress2);
    2580                     // now wait for the background disk operation to complete; this throws HRESULTs on error
    2581                     i_waitForAsyncProgress(pTask->pProgress, pProgress3);
    2582 #endif
    25832403                }
    25842404                else
     
    25882408                     */
    25892409                    Assert(pDiskEntry->type == VirtualSystemDescriptionType_CDROM);
    2590 
    2591 #ifdef VBOX_WITH_NEW_TAR_CREATOR
    25922410                    rc = pSourceDisk->i_addRawToFss(strTargetFilePath.c_str(), m->m_pSecretKeyStore, hVfsFssDst,
    25932411                                                    pTask->pProgress, false /*fSparse*/);
    2594                     if (FAILED(rc)) throw rc;
    2595 #else
    2596                     /* Read the ISO file and add one to OVA/OVF package */
    2597                     void *pvStorage;
    2598                     RTFILE pFile = NULL;
    2599                     void *pvUser = pStorage;
    2600 
    2601                     vrc = pIfIo->pfnOpen(pvUser, strTargetFilePath.c_str(),
    2602                                          RTFILE_O_OPEN_CREATE | RTFILE_O_WRITE | RTFILE_O_DENY_NONE,
    2603                                          0,
    2604                                          &pvStorage);
    2605                     if (RT_FAILURE(vrc))
    2606                         throw setError(VBOX_E_FILE_ERROR,
    2607                                        tr("Could not create or open file '%s' (%Rrc)"),
    2608                                        strTargetFilePath.c_str(), vrc);
    2609 
    2610                     vrc = RTFileOpen(&pFile,
    2611                                      strSrcFilePath.c_str(),
    2612                                      RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_NONE);
    2613 
    2614                     if (RT_FAILURE(vrc) || pFile == NULL)
    2615                     {
    2616                         pIfIo->pfnClose(pvUser, pvStorage);
    2617                         throw setError(VBOX_E_FILE_ERROR,
    2618                                        tr("Could not create or open file '%s' (%Rrc)"),
    2619                                        strSrcFilePath.c_str(), vrc);
    2620                     }
    2621 
    2622                     uint64_t cbFile = 0;
    2623                     vrc = RTFileGetSize(pFile, &cbFile);
    2624                     if (RT_SUCCESS(vrc))
    2625                     {
    2626                         size_t const cbTmpSize = _1M;
    2627                         void *pvTmpBuf = RTMemAlloc(cbTmpSize);
    2628                         if (pvTmpBuf)
    2629                         {
    2630                             /* The copy loop. */
    2631                             uint64_t offDstFile = 0;
    2632                             for (;;)
    2633                             {
    2634                                 size_t cbChunk = 0;
    2635                                 vrc = RTFileRead(pFile, pvTmpBuf, cbTmpSize, &cbChunk);
    2636                                 if (RT_FAILURE(vrc) || cbChunk == 0)
    2637                                     break;
    2638 
    2639                                 size_t cbWritten = 0;
    2640                                 vrc = pIfIo->pfnWriteSync(pvUser,
    2641                                                           pvStorage,
    2642                                                           offDstFile,
    2643                                                           pvTmpBuf,
    2644                                                           cbChunk,
    2645                                                           &cbWritten);
    2646                                 if (RT_FAILURE(vrc))
    2647                                     break;
    2648                                 Assert(cbWritten == cbChunk);
    2649 
    2650                                 offDstFile += cbWritten;
    2651                             }
    2652 
    2653                             RTMemFree(pvTmpBuf);
    2654                         }
    2655                         else
    2656                             vrc = VERR_NO_MEMORY;
    2657                     }
    2658 
    2659                     pIfIo->pfnClose(pvUser, pvStorage);
    2660                     RTFileClose(pFile);
    2661 
    2662                     if (RT_FAILURE(vrc))
    2663                     {
    2664                         if (vrc == VERR_EOF)
    2665                             vrc = VINF_SUCCESS;
    2666                         else
    2667                             throw setError(VBOX_E_FILE_ERROR,
    2668                                            tr("Error during copy CD/DVD image '%s' (%Rrc)"),
    2669                                            strSrcFilePath.c_str(), vrc);
    2670                     }
    2671 #endif
    26722412                }
     2413                if (FAILED(rc)) throw rc;
    26732414            }
    26742415            catch (HRESULT rc3)
     
    26812422            // in the meantime)
    26822423            writeLock.acquire();
    2683 #ifndef VBOX_WITH_NEW_TAR_CREATOR
    2684             fileList.push_back(STRPAIR(strTargetFilePath, pStorage->strDigest));
    2685 #endif
    26862424        }
    26872425
     
    26942432                                               m->ulWeightForManifestOperation);     // operation's weight, as set up
    26952433                                                                                     // with the IProgress originally);
    2696 #ifdef VBOX_WITH_NEW_TAR_CREATOR
    26972434            /* Create a memory I/O stream and write the manifest to it. */
    26982435            RTVFSIOSTREAM hVfsIosManifest;
     
    27242461            if (FAILED(rc))
    27252462                throw rc;
    2726 #else
    2727             PRTMANIFESTTEST paManifestFiles = (PRTMANIFESTTEST)RTMemAlloc(sizeof(RTMANIFESTTEST) * fileList.size());
    2728             size_t i = 0;
    2729             for (list<STRPAIR>::const_iterator
    2730                  it = fileList.begin();
    2731                  it != fileList.end();
    2732                  ++it, ++i)
    2733             {
    2734                 paManifestFiles[i].pszTestFile   = (*it).first.c_str();
    2735                 paManifestFiles[i].pszTestDigest = (*it).second.c_str();
    2736             }
    2737             void *pvBuf;
    2738             size_t cbSize;
    2739             vrc = RTManifestWriteFilesBuf(&pvBuf, &cbSize, m->fSha256 ? RTDIGESTTYPE_SHA256 : RTDIGESTTYPE_SHA1,
    2740                                           paManifestFiles, fileList.size());
    2741             RTMemFree(paManifestFiles);
    2742             if (RT_FAILURE(vrc))
    2743                 throw setError(VBOX_E_FILE_ERROR,
    2744                                tr("Could not create manifest file '%s' (%Rrc)"),
    2745                                strMfFileName.c_str(), vrc);
    2746             /* Disable digest creation for the manifest file. */
    2747             pStorage->fCreateDigest = false;
    2748             /* Write the manifest file to disk. */
    2749             vrc = writeBufferToFile(strMfFilePath.c_str(), pvBuf, cbSize, pIfIo, pStorage);
    2750             RTMemFree(pvBuf);
    2751             if (RT_FAILURE(vrc))
    2752                 throw setError(VBOX_E_FILE_ERROR,
    2753                                tr("Could not create manifest file '%s' (%Rrc)"),
    2754                                strMfFilePath.c_str(), vrc);
    2755 #endif
    27562463        }
    27572464    }
     
    27662473    }
    27672474
    2768 #ifndef VBOX_WITH_NEW_TAR_CREATOR /* done in caller now */
    2769     /* Cleanup on error */
    2770     if (FAILED(rc))
    2771     {
    2772         for (list<STRPAIR>::const_iterator
    2773              it = fileList.begin();
    2774              it != fileList.end();
    2775              ++it)
    2776              pIfIo->pfnDelete(pStorage, (*it).first.c_str());
    2777     }
    2778 #endif
    2779 
    27802475    LogFlowFunc(("rc=%Rhrc\n", rc));
    27812476    LogFlowFuncLeave();
     
    27852480
    27862481
    2787 #ifdef VBOX_WITH_NEW_TAR_CREATOR
    27882482/**
    27892483 * Writes a memory buffer to a file in the output file system stream.
     
    28272521    return hrc;
    28282522}
    2829 #endif
    2830 
     2523
  • trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp

    r67184 r67249  
    15071507    m->fDeterminedDigestTypes = true;
    15081508
    1509 #ifndef VBOX_WITH_NEW_TAR_CREATOR
    1510     m->fSha256 = RT_BOOL(m->fDigestTypes & RTMANIFEST_ATTR_SHA256); /** @todo retire this member */
    1511 #endif
    15121509    return S_OK;
    15131510}
  • trunk/src/VBox/Main/src-server/MediumImpl.cpp

    r67244 r67249  
    651651};
    652652
    653 #ifndef VBOX_WITH_NEW_TAR_CREATOR
    654 class Medium::ExportTask : public Medium::Task
    655 {
    656 public:
    657     ExportTask(Medium *aMedium,
    658                Progress *aProgress,
    659                const char *aFilename,
    660                MediumFormat *aFormat,
    661                MediumVariant_T aVariant,
    662                SecretKeyStore *pSecretKeyStore,
    663                VDINTERFACEIO *aVDImageIOIf,
    664                void *aVDImageIOUser,
    665                MediumLockList *aSourceMediumLockList,
    666                bool fKeepSourceMediumLockList = false)
    667         : Medium::Task(aMedium, aProgress),
    668           mpSourceMediumLockList(aSourceMediumLockList),
    669           mFilename(aFilename),
    670           mFormat(aFormat),
    671           mVariant(aVariant),
    672           m_pSecretKeyStore(pSecretKeyStore),
    673           mfKeepSourceMediumLockList(fKeepSourceMediumLockList)
    674     {
    675         AssertReturnVoidStmt(aSourceMediumLockList != NULL, mRC = E_FAIL);
    676 
    677         mVDImageIfaces = aMedium->m->vdImageIfaces;
    678 
    679         if (aVDImageIOIf)
    680         {
    681             int vrc = VDInterfaceAdd(&aVDImageIOIf->Core, "Medium::vdInterfaceIO",
    682                                      VDINTERFACETYPE_IO, aVDImageIOUser,
    683                                      sizeof(VDINTERFACEIO), &mVDImageIfaces);
    684             AssertRCReturnVoidStmt(vrc, mRC = E_FAIL);
    685         }
    686         m_strTaskName = "createExport";
    687     }
    688 
    689     ~ExportTask()
    690     {
    691         if (!mfKeepSourceMediumLockList && mpSourceMediumLockList)
    692             delete mpSourceMediumLockList;
    693     }
    694 
    695     MediumLockList *mpSourceMediumLockList;
    696     Utf8Str mFilename;
    697     ComObjPtr<MediumFormat> mFormat;
    698     MediumVariant_T mVariant;
    699     PVDINTERFACE mVDImageIfaces;
    700     SecretKeyStore *m_pSecretKeyStore;
    701 
    702 private:
    703     HRESULT executeTask();
    704     bool mfKeepSourceMediumLockList;
    705 };
    706 #endif /* !VBOX_WITH_NEW_TAR_CREATOR */
    707 
    708653class Medium::ImportTask : public Medium::Task
    709654{
     
    956901    return mMedium->i_taskMergeHandler(*this);
    957902}
    958 
    959 #ifndef VBOX_WITH_NEW_TAR_CREATOR
    960 /**
    961  * Implementation code for the "export" task.
    962  */
    963 HRESULT Medium::ExportTask::executeTask()
    964 {
    965     return mMedium->i_taskExportHandler(*this);
    966 }
    967 #endif
    968903
    969904/**
     
    61416076 * @param pKeyStore         The optional key store for decrypting the data for
    61426077 *                          encrypted media during the export.
    6143  * @param aVDImageIOIf      Pointer to the callback table for a VDINTERFACEIO
    6144  *                          interface. May be NULL.
    6145  * @param aVDImageIOUser    Opaque data for the callbacks.
     6078 * @param hVfsIosDst        The destination I/O stream object.
    61466079 * @param aProgress         Progress object to use.
    61476080 * @return
     
    61536086                             MediumVariant_T aVariant,
    61546087                             SecretKeyStore *pKeyStore,
    6155 #ifdef VBOX_WITH_NEW_TAR_CREATOR
    61566088                             RTVFSIOSTREAM hVfsIosDst,
    6157 #else
    6158                              PVDINTERFACEIO aVDImageIOIf, void *aVDImageIOUser,
    6159 #endif
    61606089                             const ComObjPtr<Progress> &aProgress)
    61616090{
     
    61636092    AssertReturn(aFormat.isNotNull(), E_INVALIDARG);
    61646093    AssertReturn(aProgress.isNotNull(), E_INVALIDARG);
    6165 
    6166 #ifdef VBOX_WITH_NEW_TAR_CREATOR
    61676094
    61686095    AutoCaller autoCaller(this);
     
    62566183    }
    62576184    return hrc;
    6258 #else
    6259 
    6260     AutoCaller autoCaller(this);
    6261     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    6262 
    6263     HRESULT rc = S_OK;
    6264     Medium::Task *pTask = NULL;
    6265 
    6266     try
    6267     {
    6268         // This needs no extra locks besides what is done in the called methods.
    6269 
    6270         /* Build the source lock list. */
    6271         MediumLockList *pSourceMediumLockList(new MediumLockList());
    6272         rc = i_createMediumLockList(true /* fFailIfInaccessible */,
    6273                                     NULL /* pToLockWrite */,
    6274                                     false /* fMediumLockWriteAll */,
    6275                                     NULL,
    6276                                     *pSourceMediumLockList);
    6277         if (FAILED(rc))
    6278         {
    6279             delete pSourceMediumLockList;
    6280             throw rc;
    6281         }
    6282 
    6283         rc = pSourceMediumLockList->Lock();
    6284         if (FAILED(rc))
    6285         {
    6286             delete pSourceMediumLockList;
    6287             throw setError(rc,
    6288                            tr("Failed to lock source media '%s'"),
    6289                            i_getLocationFull().c_str());
    6290         }
    6291 
    6292         /* setup task object to carry out the operation asynchronously */
    6293         pTask = new Medium::ExportTask(this, aProgress, aFilename, aFormat, aVariant,
    6294                                        pKeyStore, aVDImageIOIf, aVDImageIOUser, pSourceMediumLockList);
    6295         rc = pTask->rc();
    6296         AssertComRC(rc);
    6297         if (FAILED(rc))
    6298             throw rc;
    6299     }
    6300     catch (HRESULT aRC) { rc = aRC; }
    6301 
    6302     if (SUCCEEDED(rc))
    6303         rc = pTask->createThread();
    6304     else if (pTask != NULL)
    6305         delete pTask;
    6306 
    6307     return rc;
    6308 #endif
    63096185}
    63106186
     
    97679643}
    97689644
    9769 #ifndef VBOX_WITH_NEW_TAR_CREATOR
    9770 /**
    9771  * Implementation code for the "export" task.
    9772  *
    9773  * This only gets started from Medium::exportFile() and always runs
    9774  * asynchronously. It doesn't touch anything configuration related, so
    9775  * we never save the VirtualBox.xml file here.
    9776  *
    9777  * @param task
    9778  * @return
    9779  */
    9780 HRESULT Medium::i_taskExportHandler(Medium::ExportTask &task)
    9781 {
    9782     HRESULT rc = S_OK;
    9783 
    9784     try
    9785     {
    9786         /* Lock all in {parent,child} order. The lock is also used as a
    9787          * signal from the task initiator (which releases it only after
    9788          * RTThreadCreate()) that we can start the job. */
    9789         ComObjPtr<Medium> pBase = i_getBase();
    9790         AutoWriteLock thisLock(this COMMA_LOCKVAL_SRC_POS);
    9791 
    9792         PVDISK hdd;
    9793         int vrc = VDCreate(m->vdDiskIfaces, i_convertDeviceType(), &hdd);
    9794         ComAssertRCThrow(vrc, E_FAIL);
    9795 
    9796         try
    9797         {
    9798             settings::StringsMap::iterator itKeyStore = pBase->m->mapProperties.find("CRYPT/KeyStore");
    9799             if (itKeyStore != pBase->m->mapProperties.end())
    9800             {
    9801                 settings::StringsMap::iterator itKeyId = pBase->m->mapProperties.find("CRYPT/KeyId");
    9802 
    9803 #ifdef VBOX_WITH_EXTPACK
    9804                 ExtPackManager *pExtPackManager = m->pVirtualBox->i_getExtPackManager();
    9805                 if (pExtPackManager->i_isExtPackUsable(ORACLE_PUEL_EXTPACK_NAME))
    9806                 {
    9807                     /* Load the plugin */
    9808                     Utf8Str strPlugin;
    9809                     rc = pExtPackManager->i_getLibraryPathForExtPack(g_szVDPlugin, ORACLE_PUEL_EXTPACK_NAME, &strPlugin);
    9810                     if (SUCCEEDED(rc))
    9811                     {
    9812                         vrc = VDPluginLoadFromFilename(strPlugin.c_str());
    9813                         if (RT_FAILURE(vrc))
    9814                             throw setError(VBOX_E_NOT_SUPPORTED,
    9815                                            tr("Retrieving encryption settings of the image failed because the encryption plugin could not be loaded (%s)"),
    9816                                            i_vdError(vrc).c_str());
    9817                     }
    9818                     else
    9819                         throw setError(VBOX_E_NOT_SUPPORTED,
    9820                                        tr("Encryption is not supported because the extension pack '%s' is missing the encryption plugin (old extension pack installed?)"),
    9821                                        ORACLE_PUEL_EXTPACK_NAME);
    9822                 }
    9823                 else
    9824                     throw setError(VBOX_E_NOT_SUPPORTED,
    9825                                    tr("Encryption is not supported because the extension pack '%s' is missing"),
    9826                                    ORACLE_PUEL_EXTPACK_NAME);
    9827 #else
    9828                 throw setError(VBOX_E_NOT_SUPPORTED,
    9829                                tr("Encryption is not supported because extension pack support is not built in"));
    9830 #endif
    9831 
    9832                 if (itKeyId == pBase->m->mapProperties.end())
    9833                     throw setError(VBOX_E_INVALID_OBJECT_STATE,
    9834                                    tr("Image '%s' is configured for encryption but doesn't has a key identifier set"),
    9835                                    pBase->m->strLocationFull.c_str());
    9836 
    9837                 /* Find the proper secret key in the key store. */
    9838                 if (!task.m_pSecretKeyStore)
    9839                     throw setError(VBOX_E_INVALID_OBJECT_STATE,
    9840                                    tr("Image '%s' is configured for encryption but there is no key store to retrieve the password from"),
    9841                                    pBase->m->strLocationFull.c_str());
    9842 
    9843                 SecretKey *pKey = NULL;
    9844                 vrc = task.m_pSecretKeyStore->retainSecretKey(itKeyId->second, &pKey);
    9845                 if (RT_FAILURE(vrc))
    9846                     throw setError(VBOX_E_INVALID_OBJECT_STATE,
    9847                                    tr("Failed to retrieve the secret key with ID \"%s\" from the store (%Rrc)"),
    9848                                    itKeyId->second.c_str(), vrc);
    9849 
    9850 /** @todo r=bird: Someone explain why this continue to work when
    9851  *        CryptoSettingsRead goes out of the scope? */
    9852                 Medium::CryptoFilterSettings CryptoSettingsRead;
    9853                 i_taskEncryptSettingsSetup(&CryptoSettingsRead, NULL, itKeyStore->second.c_str(), (const char *)pKey->getKeyBuffer(),
    9854                                            false /* fCreateKeyStore */);
    9855                 vrc = VDFilterAdd(hdd, "CRYPT", VD_FILTER_FLAGS_READ, CryptoSettingsRead.vdFilterIfaces);
    9856                 if (vrc == VERR_VD_PASSWORD_INCORRECT)
    9857                 {
    9858                     task.m_pSecretKeyStore->releaseSecretKey(itKeyId->second);
    9859                     throw setError(VBOX_E_PASSWORD_INCORRECT,
    9860                                    tr("The password to decrypt the image is incorrect"));
    9861                 }
    9862                 else if (RT_FAILURE(vrc))
    9863                 {
    9864                     task.m_pSecretKeyStore->releaseSecretKey(itKeyId->second);
    9865                     throw setError(VBOX_E_INVALID_OBJECT_STATE,
    9866                                    tr("Failed to load the decryption filter: %s"),
    9867                                    i_vdError(vrc).c_str());
    9868                 }
    9869 
    9870                 task.m_pSecretKeyStore->releaseSecretKey(itKeyId->second);
    9871             }
    9872 
    9873             /* Open all media in the source chain. */
    9874             MediumLockList::Base::const_iterator sourceListBegin =
    9875                 task.mpSourceMediumLockList->GetBegin();
    9876             MediumLockList::Base::const_iterator sourceListEnd =
    9877                 task.mpSourceMediumLockList->GetEnd();
    9878             for (MediumLockList::Base::const_iterator it = sourceListBegin;
    9879                  it != sourceListEnd;
    9880                  ++it)
    9881             {
    9882                 const MediumLock &mediumLock = *it;
    9883                 const ComObjPtr<Medium> &pMedium = mediumLock.GetMedium();
    9884                 AutoReadLock alock(pMedium COMMA_LOCKVAL_SRC_POS);
    9885 
    9886                 /* sanity check */
    9887                 Assert(pMedium->m->state == MediumState_LockedRead);
    9888 
    9889                 /* Open all media in read-only mode. */
    9890                 vrc = VDOpen(hdd,
    9891                              pMedium->m->strFormat.c_str(),
    9892                              pMedium->m->strLocationFull.c_str(),
    9893                              VD_OPEN_FLAGS_READONLY | m->uOpenFlagsDef,
    9894                              pMedium->m->vdImageIfaces);
    9895                 if (RT_FAILURE(vrc))
    9896                     throw setError(VBOX_E_FILE_ERROR,
    9897                                    tr("Could not open the medium storage unit '%s'%s"),
    9898                                    pMedium->m->strLocationFull.c_str(),
    9899                                    i_vdError(vrc).c_str());
    9900             }
    9901 
    9902             Utf8Str targetFormat(task.mFormat->i_getId());
    9903             Utf8Str targetLocation(task.mFilename);
    9904             uint64_t capabilities = task.mFormat->i_getCapabilities();
    9905 
    9906             Assert(m->state == MediumState_LockedRead);
    9907 
    9908             /* unlock before the potentially lengthy operation */
    9909             thisLock.release();
    9910 
    9911             /* ensure the target directory exists */
    9912             if (capabilities & MediumFormatCapabilities_File)
    9913             {
    9914                 rc = VirtualBox::i_ensureFilePathExists(targetLocation,
    9915                                                         !(task.mVariant & MediumVariant_NoCreateDir) /* fCreate */);
    9916                 if (FAILED(rc))
    9917                     throw rc;
    9918             }
    9919 
    9920             PVDISK targetHdd;
    9921             vrc = VDCreate(m->vdDiskIfaces, i_convertDeviceType(), &targetHdd);
    9922             ComAssertRCThrow(vrc, E_FAIL);
    9923 
    9924             try
    9925             {
    9926                 vrc = VDCopy(hdd,
    9927                              VD_LAST_IMAGE,
    9928                              targetHdd,
    9929                              targetFormat.c_str(),
    9930                              targetLocation.c_str(),
    9931                              false /* fMoveByRename */,
    9932                              0 /* cbSize */,
    9933                              task.mVariant & ~MediumVariant_NoCreateDir,
    9934                              NULL /* pDstUuid */,
    9935                              VD_OPEN_FLAGS_NORMAL | VD_OPEN_FLAGS_SEQUENTIAL,
    9936                              NULL /* pVDIfsOperation */,
    9937                              task.mVDImageIfaces,
    9938                              task.mVDOperationIfaces);
    9939                 if (RT_FAILURE(vrc))
    9940                     throw setError(VBOX_E_FILE_ERROR,
    9941                                    tr("Could not create the exported medium '%s'%s"),
    9942                                    targetLocation.c_str(), i_vdError(vrc).c_str());
    9943             }
    9944             catch (HRESULT aRC) { rc = aRC; }
    9945 
    9946             VDDestroy(targetHdd);
    9947         }
    9948         catch (HRESULT aRC) { rc = aRC; }
    9949 
    9950         VDDestroy(hdd);
    9951     }
    9952     catch (HRESULT aRC) { rc = aRC; }
    9953 
    9954     /* Everything is explicitly unlocked when the task exits,
    9955      * as the task destruction also destroys the source chain. */
    9956 
    9957     /* Make sure the source chain is released early, otherwise it can
    9958      * lead to deadlocks with concurrent IAppliance activities. */
    9959     task.mpSourceMediumLockList->Clear();
    9960 
    9961     return rc;
    9962 }
    9963 #endif /* !VBOX_WITH_NEW_TAR_CREATOR */
    9964 
    99659645/**
    99669646 * Implementation code for the "import" task.
Note: See TracChangeset for help on using the changeset viewer.

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