VirtualBox

Changeset 27886 in vbox


Ignore:
Timestamp:
Mar 31, 2010 12:18:38 PM (15 years ago)
Author:
vboxsync
Message:

Main/OVF: document import code

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

Legend:

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

    r27882 r27886  
    931931}
    932932
    933 int Appliance::TaskExportOVF::startThread()
    934 {
    935     int vrc = RTThreadCreate(NULL, Appliance::taskThreadWriteOVF, this,
    936                              0, RTTHREADTYPE_MAIN_HEAVY_WORKER, 0,
    937                              "Appliance::Task");
    938 
    939     ComAssertMsgRCRet(vrc,
    940                       ("Could not create taskThreadWriteOVF (%Rrc)\n", vrc), E_FAIL);
    941 
    942     return S_OK;
    943 }
    944 
    945933////////////////////////////////////////////////////////////////////////////////
    946934//
  • trunk/src/VBox/Main/ApplianceImplExport.cpp

    r27837 r27886  
    602602/**
    603603 * Implementation for writing out the OVF to disk. This starts a new thread which will call
    604  * Appliance::taskThreadWriteOVF(). This is in a separate private method because it is used
    605  * from two locations:
     604 * Appliance::taskThreadWriteOVF().
     605 *
     606 * This is in a separate private method because it is used from two locations:
    606607 *
    607608 * 1) from the public Appliance::Write().
     
    650651
    651652    return rc;
     653}
     654
     655/**
     656 *
     657 * @return
     658 */
     659int Appliance::TaskExportOVF::startThread()
     660{
     661    int vrc = RTThreadCreate(NULL, Appliance::taskThreadWriteOVF, this,
     662                             0, RTTHREADTYPE_MAIN_HEAVY_WORKER, 0,
     663                             "Appliance::Task");
     664
     665    ComAssertMsgRCRet(vrc,
     666                      ("Could not create taskThreadWriteOVF (%Rrc)\n", vrc), E_FAIL);
     667
     668    return S_OK;
    652669}
    653670
  • trunk/src/VBox/Main/ApplianceImplImport.cpp

    r27882 r27886  
    562562
    563563/**
     564 * Implementation for reading an OVF. This starts a new thread which will call
     565 * Appliance::taskThreadImportOVF() which will then call readFS() or readS3().
     566 *
     567 * This is in a separate private method because it is used from two locations:
     568 *
     569 * 1) from the public Appliance::Read().
     570 * 2) from Appliance::readS3(), which got called from a previous instance of Appliance::taskThreadImportOVF().
    564571 *
    565572 * @param aLocInfo
     
    615622/**
    616623 *
     624 * @return
     625 */
     626int Appliance::TaskImportOVF::startThread()
     627{
     628    int vrc = RTThreadCreate(NULL, Appliance::taskThreadImportOVF, this,
     629                             0, RTTHREADTYPE_MAIN_HEAVY_WORKER, 0,
     630                             "Appliance::Task");
     631
     632    ComAssertMsgRCRet(vrc,
     633                      ("Could not create taskThreadImportOVF (%Rrc)\n", vrc), E_FAIL);
     634
     635    return S_OK;
     636}
     637
     638/**
     639 * Thread function for the thread started in Appliance::readImpl() and Appliance::importImpl().
     640 * This will in turn call Appliance::readFS() or Appliance::readS3() or Appliance::importFS()
     641 * or Appliance::importS3().
     642 *
     643 * @param aThread
     644 * @param pvUser
     645 */
     646/* static */
     647DECLCALLBACK(int) Appliance::taskThreadImportOVF(RTTHREAD /* aThread */, void *pvUser)
     648{
     649    std::auto_ptr<TaskImportOVF> task(static_cast<TaskImportOVF*>(pvUser));
     650    AssertReturn(task.get(), VERR_GENERAL_FAILURE);
     651
     652    Appliance *pAppliance = task->pAppliance;
     653
     654    LogFlowFuncEnter();
     655    LogFlowFunc(("Appliance %p\n", pAppliance));
     656
     657    HRESULT taskrc = S_OK;
     658
     659    switch (task->taskType)
     660    {
     661        case TaskImportOVF::Read:
     662        {
     663            if (task->locInfo.storageType == VFSType_File)
     664                taskrc = pAppliance->readFS(task.get());
     665            else if (task->locInfo.storageType == VFSType_S3)
     666                taskrc = pAppliance->readS3(task.get());
     667            break;
     668        }
     669        case TaskImportOVF::Import:
     670        {
     671            if (task->locInfo.storageType == VFSType_File)
     672                taskrc = pAppliance->importFS(task.get());
     673            else if (task->locInfo.storageType == VFSType_S3)
     674                taskrc = pAppliance->importS3(task.get());
     675            break;
     676        }
     677    }
     678
     679    task->rc = taskrc;
     680
     681    LogFlowFuncLeave();
     682
     683    return VINF_SUCCESS;
     684}
     685
     686/**
     687 * Actual worker code for reading an OVF from disk. This is called from Appliance::taskThreadImportOVF()
     688 * and therefore runs on the OVF read worker thread. This runs in two contexts:
     689 *
     690 * 1) in a first worker thread; in that case, Appliance::Read() called Appliance::readImpl();
     691 *
     692 * 2) in a second worker thread; in that case, Appliance::Read() called Appliance::readImpl(), which
     693 *    called Appliance::readS3(), which called Appliance::readImpl(), which then called this.
     694 *
    617695 * @param pTask
    618696 * @return
     
    666744
    667745/**
     746 * Worker code for writing out OVF to the cloud. This is called from Appliance::taskThreadImportOVF()
     747 * in S3 mode and therefore runs on the OVF read worker thread. This then starts a second worker
     748 * thread to create temporary files (see Appliance::readFS()).
    668749 *
    669750 * @param pTask
     
    863944
    864945/**
    865  * Implementation of the import code. This gets called from the public Appliance::ImportMachines()
    866  * method as well as Appliance::importS3().
     946 * Implementation for importing OVF data into VirtualBox. This starts a new thread which will call
     947 * Appliance::taskThreadImportOVF().
     948 *
     949 * This is in a separate private method because it is used from two locations:
     950 *
     951 * 1) from the public Appliance::ImportMachines().
     952 * 2) from Appliance::importS3(), which got called from a previous instance of Appliance::taskThreadImportOVF().
     953 *
    867954 * @param aLocInfo
    868955 * @param aProgress
     
    902989
    903990/**
    904  * Worker thread implementation for Read() (ovf reader).
    905  * @param aThread
    906  * @param pvUser
    907  */
    908 /* static */
    909 DECLCALLBACK(int) Appliance::taskThreadImportOVF(RTTHREAD /* aThread */, void *pvUser)
    910 {
    911     std::auto_ptr<TaskImportOVF> task(static_cast<TaskImportOVF*>(pvUser));
    912     AssertReturn(task.get(), VERR_GENERAL_FAILURE);
    913 
    914     Appliance *pAppliance = task->pAppliance;
    915 
    916     LogFlowFuncEnter();
    917     LogFlowFunc(("Appliance %p\n", pAppliance));
    918 
    919     switch (task->taskType)
    920     {
    921         case TaskImportOVF::Read:
    922         {
    923             if (task->locInfo.storageType == VFSType_File)
    924                 pAppliance->readFS(task.get());
    925             else if (task->locInfo.storageType == VFSType_S3)
    926                 pAppliance->readS3(task.get());
    927             break;
    928         }
    929         case TaskImportOVF::Import:
    930         {
    931             if (task->locInfo.storageType == VFSType_File)
    932                 pAppliance->importFS(task.get());
    933             else if (task->locInfo.storageType == VFSType_S3)
    934                 pAppliance->importS3(task.get());
    935             break;
    936         }
    937     }
    938 
    939     LogFlowFuncLeave();
    940 
    941     return VINF_SUCCESS;
    942 }
    943 
    944 /**
     991 * Actual worker code for importing OVF data into VirtualBox. This is called from Appliance::taskThreadImportOVF()
     992 * and therefore runs on the OVF import worker thread. This runs in two contexts:
    945993 *
    946  * @return
    947  */
    948 int Appliance::TaskImportOVF::startThread()
    949 {
    950     int vrc = RTThreadCreate(NULL, Appliance::taskThreadImportOVF, this,
    951                              0, RTTHREADTYPE_MAIN_HEAVY_WORKER, 0,
    952                              "Appliance::Task");
    953 
    954     ComAssertMsgRCRet(vrc,
    955                       ("Could not create taskThreadImportOVF (%Rrc)\n", vrc), E_FAIL);
    956 
    957     return S_OK;
    958 }
    959 
    960 /**
     994 * 1) in a first worker thread; in that case, Appliance::ImportMachines() called Appliance::importImpl();
     995 *
     996 * 2) in a second worker thread; in that case, Appliance::ImportMachines() called Appliance::importImpl(), which
     997 *    called Appliance::importS3(), which called Appliance::importImpl(), which then called this.
    961998 *
    962999 * @param pTask
     
    18001837
    18011838/**
    1802  *
     1839 * Gets called from taskThreadImportOVF().
    18031840 * @param pTask
    18041841 * @return
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