VirtualBox

Changeset 57996 in vbox for trunk/src/VBox/Main/src-server


Ignore:
Timestamp:
Oct 2, 2015 8:13:15 AM (9 years ago)
Author:
vboxsync
Message:

pr7179. First part. The tasks VMPowerDownTask, VMPowerUpTask, TaskOVF were changed

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

Legend:

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

    r57437 r57996  
    11851185
    11861186/**
    1187  * Starts the worker thread for the task.
    1188  *
    1189  * @return COM status code.
    1190  */
    1191 HRESULT Appliance::TaskOVF::startThread()
    1192 {
    1193     /* Pick a thread name suitable for logging (<= 8 chars). */
    1194     const char *pszTaskNm;
    1195     switch (taskType)
    1196     {
    1197         case TaskOVF::Read:     pszTaskNm = "ApplRead"; break;
    1198         case TaskOVF::Import:   pszTaskNm = "ApplImp"; break;
    1199         case TaskOVF::Write:    pszTaskNm = "ApplWrit"; break;
    1200         default:                pszTaskNm = "ApplTask"; break;
    1201     }
    1202 
    1203     int vrc = RTThreadCreate(NULL, Appliance::i_taskThreadImportOrExport, this,
    1204                              0, RTTHREADTYPE_MAIN_HEAVY_WORKER, 0, pszTaskNm);
    1205     if (RT_SUCCESS(vrc))
    1206         return S_OK;
    1207     return Appliance::i_setErrorStatic(E_FAIL, Utf8StrFmt("Could not create OVF task thread (%Rrc)\n", vrc));
    1208 }
    1209 
    1210 /**
    12111187 * Thread function for the thread started in Appliance::readImpl() and Appliance::importImpl()
    12121188 * and Appliance::writeImpl().
     
    12201196DECLCALLBACK(int) Appliance::i_taskThreadImportOrExport(RTTHREAD /* aThread */, void *pvUser)
    12211197{
    1222     std::auto_ptr<TaskOVF> task(static_cast<TaskOVF*>(pvUser));
    1223     AssertReturn(task.get(), VERR_GENERAL_FAILURE);
     1198    TaskOVF* task = static_cast<TaskOVF*>(pvUser);
     1199    AssertReturn(task, VERR_GENERAL_FAILURE);
    12241200
    12251201    Appliance *pAppliance = task->pAppliance;
     
    12341210        case TaskOVF::Read:
    12351211            if (task->locInfo.storageType == VFSType_File)
    1236                 taskrc = pAppliance->i_readFS(task.get());
     1212                taskrc = pAppliance->i_readFS(task);
    12371213            else if (task->locInfo.storageType == VFSType_S3)
    12381214#ifdef VBOX_WITH_S3
    1239                 taskrc = pAppliance->i_readS3(task.get());
     1215                taskrc = pAppliance->i_readS3(task);
    12401216#else
    12411217                taskrc = VERR_NOT_IMPLEMENTED;
     
    12451221        case TaskOVF::Import:
    12461222            if (task->locInfo.storageType == VFSType_File)
    1247                 taskrc = pAppliance->i_importFS(task.get());
     1223                taskrc = pAppliance->i_importFS(task);
    12481224            else if (task->locInfo.storageType == VFSType_S3)
    12491225#ifdef VBOX_WITH_S3
    1250                 taskrc = pAppliance->i_importS3(task.get());
     1226                taskrc = pAppliance->i_importS3(task);
    12511227#else
    12521228                taskrc = VERR_NOT_IMPLEMENTED;
     
    12561232        case TaskOVF::Write:
    12571233            if (task->locInfo.storageType == VFSType_File)
    1258                 taskrc = pAppliance->i_writeFS(task.get());
     1234                taskrc = pAppliance->i_writeFS(task);
    12591235            else if (task->locInfo.storageType == VFSType_S3)
    12601236#ifdef VBOX_WITH_S3
    1261                 taskrc = pAppliance->i_writeS3(task.get());
     1237                taskrc = pAppliance->i_writeS3(task);
    12621238#else
    12631239                taskrc = VERR_NOT_IMPLEMENTED;
  • trunk/src/VBox/Main/src-server/ApplianceImplExport.cpp

    r57277 r57996  
    2828#include "ApplianceImpl.h"
    2929#include "VirtualBoxImpl.h"
    30 
    3130#include "ProgressImpl.h"
    3231#include "MachineImpl.h"
     
    754753
    755754        /* Initialize our worker task */
    756         std::auto_ptr<TaskOVF> task(new TaskOVF(this, TaskOVF::Write, aLocInfo, aProgress));
     755        TaskOVF* task = NULL;
     756        try
     757        {
     758            task = new TaskOVF(this, TaskOVF::Write, aLocInfo, aProgress);
     759        }
     760        catch(...)
     761        {
     762            delete task;
     763            throw rc = setError(VBOX_E_OBJECT_NOT_FOUND,
     764                                tr("Could not create TaskOVF object for for writing out the OVF to disk"));
     765        }
     766
    757767        /* The OVF version to write */
    758768        task->enFormat = aFormat;
    759769
    760         rc = task->startThread();
     770        rc = task->createThread();
    761771        if (FAILED(rc)) throw rc;
    762772
    763         /* Don't destruct on success */
    764         task.release();
    765773    }
    766774    catch (HRESULT aRC)
     
    12511259    pelmSystem->createChild("vssd:VirtualSystemIdentifier")->addContent(strVMName);
    12521260    // <vssd:VirtualSystemType>vmx-4</vssd:VirtualSystemType>
    1253     const char *pcszHardware = "virtualbox-2.2";
     1261    const char *pcszHardware = "virtualbox";
    12541262    if (enFormat == ovf::OVFVersion_0_9)
    12551263        // pretend to be vmware compatible then
  • trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp

    r56599 r57996  
    874874
    875875    /* Initialize our worker task */
    876     std::auto_ptr<TaskOVF> task(new TaskOVF(this, TaskOVF::Read, aLocInfo, aProgress));
    877 
    878     rc = task->startThread();
     876    TaskOVF* task = NULL;
     877    try
     878    {
     879        task = new TaskOVF(this, TaskOVF::Read, aLocInfo, aProgress);
     880    }
     881    catch(...)
     882    {
     883        delete task;
     884        throw rc = setError(VBOX_E_OBJECT_NOT_FOUND,
     885                            tr("Could not create TaskOVF object for reading the OVF from disk"));
     886    }
     887
     888    rc = task->createThread();
    879889    if (FAILED(rc)) throw rc;
    880 
    881     /* Don't destruct on success */
    882     task.release();
    883890
    884891    return rc;
     
    13711378
    13721379    /* Initialize our worker task */
    1373     std::auto_ptr<TaskOVF> task(new TaskOVF(this, TaskOVF::Import, locInfo, progress));
    1374 
    1375     rc = task->startThread();
     1380    TaskOVF* task = NULL;
     1381    try
     1382    {
     1383        task = new TaskOVF(this, TaskOVF::Import, locInfo, progress);
     1384    }
     1385    catch(...)
     1386    {
     1387        delete task;
     1388        throw rc = setError(VBOX_E_OBJECT_NOT_FOUND,
     1389                            tr("Could not create TaskOVF object for importing OVF data into VirtualBox"));
     1390    }
     1391
     1392    rc = task->createThread();
    13761393    if (FAILED(rc)) throw rc;
    1377 
    1378     /* Don't destruct on success */
    1379     task.release();
    13801394
    13811395    return rc;
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