VirtualBox

Changeset 17287 in vbox


Ignore:
Timestamp:
Mar 3, 2009 2:45:17 PM (16 years ago)
Author:
vboxsync
Message:

OVF: more export implementation.

Location:
trunk/src/VBox
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageImport.cpp

    r17098 r17287  
    581581            break;
    582582
    583         CHECK_ERROR_BREAK(pAppliance, Write(Bstr(strOutputFile)));
     583        ComPtr<IProgress> progress;
     584        CHECK_ERROR_BREAK(pAppliance, Write(Bstr(strOutputFile), progress.asOutParam()));
     585
     586        showProgress(progress);
     587
     588        if (SUCCEEDED(rc))
     589            progress->COMGETTER(ResultCode)(&rc);
     590
     591        if (FAILED(rc))
     592        {
     593            com::ProgressErrorInfo info(progress);
     594            com::GluePrintErrorInfo(info);
     595            com::GluePrintErrorContext("Write", __FILE__, __LINE__);
     596        }
     597        else
     598            RTPrintf("Successfully exported %d machine(s).\n", llMachines.size());
    584599
    585600    } while (0);
  • trunk/src/VBox/Main/ApplianceImpl.cpp

    r17162 r17287  
    199199};
    200200
    201 struct Appliance::Task
    202 {
    203     Task(Appliance *aThat, Progress *aProgress)
     201struct Appliance::TaskImportMachines
     202{
     203    TaskImportMachines(Appliance *aThat, Progress *aProgress)
    204204        : that(aThat)
    205205        , progress(aProgress)
    206206        , rc(S_OK)
    207207    {}
    208     ~Task() {}
     208    ~TaskImportMachines() {}
    209209
    210210    HRESULT startThread();
     
    263263////////////////////////////////////////////////////////////////////////////////
    264264
    265 HRESULT Appliance::Task::startThread()
    266 {
    267     int vrc = RTThreadCreate(NULL, Appliance::taskThread, this,
     265HRESULT Appliance::TaskImportMachines::startThread()
     266{
     267    int vrc = RTThreadCreate(NULL, Appliance::taskThreadImportMachines, this,
    268268                             0, RTTHREADTYPE_MAIN_HEAVY_WORKER, 0,
    269269                             "Appliance::Task");
     
    16531653
    16541654        /* Initialize our worker task */
    1655         std::auto_ptr<Task> task(new Task(this, progress));
     1655        std::auto_ptr<TaskImportMachines> task(new TaskImportMachines(this, progress));
    16561656        //AssertComRCThrowRC (task->autoCaller.rc());
    16571657
     
    16731673}
    16741674
    1675 STDMETHODIMP Appliance::Write(IN_BSTR path)
     1675STDMETHODIMP Appliance::Write(IN_BSTR path, IProgress **aProgress)
    16761676{
    16771677    HRESULT rc = S_OK;
     
    17401740 */
    17411741/* static */
    1742 DECLCALLBACK(int) Appliance::taskThread(RTTHREAD aThread, void *pvUser)
    1743 {
    1744     std::auto_ptr<Task> task(static_cast<Task *>(pvUser));
     1742DECLCALLBACK(int) Appliance::taskThreadImportMachines(RTTHREAD aThread, void *pvUser)
     1743{
     1744    std::auto_ptr<TaskImportMachines> task(static_cast<TaskImportMachines*>(pvUser));
    17451745    AssertReturn(task.get(), VERR_GENERAL_FAILURE);
    17461746
     
    26962696        fDVDEnabled = 1;
    26972697
    2698         // hardDiskAttachments
    2699 //         mHDData->mAttachments @todo
    2700 
    27012698        // this is more tricky so use the COM method
    27022699        rc = COMGETTER(USBController)(pUsbController.asOutParam());
     
    27402737                           strMemory);
    27412738
     2739        uint32_t uControllerId = 1;
     2740        Utf8Str strIdeControllerID;
     2741        Utf8Str strSataControllerID;
     2742
    27422743//     <const name="HardDiskControllerIDE" value="6" />
     2744        ComPtr<IBIOSSettings> pBiosSettings;
     2745        pBiosSettings = mBIOSSettings;
     2746        Utf8Str strConfig;
     2747        IDEControllerType_T ctlr;
     2748        rc = pBiosSettings->COMGETTER(IDEControllerType)(&ctlr);
     2749        if (FAILED(rc)) throw rc;
     2750        switch(ctlr)
     2751        {
     2752            case IDEControllerType_PIIX3: strConfig = "PIIX3"; break;
     2753            case IDEControllerType_PIIX4: strConfig = "PIIX4"; break;
     2754            case IDEControllerType_ICH6: strConfig = "ICH6"; break;
     2755        }
     2756
     2757        if (strConfig.length())
     2758        {
     2759            strIdeControllerID = Utf8StrFmt("%RI32", uControllerId++);
     2760            pNewDesc->addEntry(VirtualSystemDescriptionType_HardDiskControllerIDE, strIdeControllerID, strConfig, "");
     2761        }
     2762
     2763#ifdef VBOX_WITH_AHCI
    27432764//     <const name="HardDiskControllerSATA" value="7" />
     2765        ComPtr<ISATAController> pSataController;
     2766        pSataController = mSATAController;
     2767        BOOL fSataEnabled;
     2768        rc = pSataController->COMGETTER(Enabled)(&fSataEnabled);
     2769        if (FAILED(rc)) throw rc;
     2770        if (fSataEnabled)
     2771        {
     2772            strSataControllerID = Utf8StrFmt("%RI32", uControllerId++);
     2773            pNewDesc->addEntry(VirtualSystemDescriptionType_HardDiskControllerSATA, strSataControllerID, strConfig, "");
     2774        }
     2775#endif // VBOX_WITH_AHCI
     2776
    27442777//     <const name="HardDiskControllerSCSI" value="8" />
     2778        // @todo
     2779
    27452780//     <const name="HardDiskImage" value="9" />
     2781        // hardDiskAttachments
     2782//         mHDData->mAttachments @todo
     2783        HDData::AttachmentList::iterator itA;
     2784        for (itA = mHDData->mAttachments.begin();
     2785             itA != mHDData->mAttachments.end();
     2786             ++itA)
     2787        {
     2788            ComObjPtr<HardDiskAttachment> pHDA = *itA;
     2789
     2790            // get the attachment's data
     2791            ComPtr<IHardDisk> pHardDisk;
     2792            StorageBus_T storageBus;
     2793            LONG lChannel;
     2794            LONG lDevice;
     2795
     2796            rc = pHDA->COMGETTER(HardDisk)(pHardDisk.asOutParam());
     2797            if (FAILED(rc)) throw rc;
     2798
     2799            rc = pHDA->COMGETTER(Bus)(&storageBus);
     2800            if (FAILED(rc)) throw rc;
     2801
     2802            rc = pHDA->COMGETTER(Channel)(&lChannel);
     2803            if (FAILED(rc)) throw rc;
     2804
     2805            rc = pHDA->COMGETTER(Device)(&lDevice);
     2806            if (FAILED(rc)) throw rc;
     2807
     2808            pNewDesc->addEntry(VirtualSystemDescriptionType_HardDiskImage,
     2809                               "", // hd.strDiskId,
     2810                               "", // di.strHref,
     2811                               "",
     2812                               ""); // strExtraConfig
     2813        }
    27462814
    27472815        /* Floppy Drive */
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r17275 r17287  
    29272927    <attribute name="path" type="wstring" readonly="yes">
    29282928      <desc>Path to the main file of the OVF appliance, which is either the <tt>.ovf</tt> or
    2929           the <tt>.ova</tt> file passed to <link to="IAppliance::read" />.</desc>
     2929          the <tt>.ova</tt> file passed to <link to="#read" /> (for import) or
     2930          <link to="#write" /> (for export).
     2931          This attribute is empty until one of these methods has been called.
     2932      </desc>
    29302933    </attribute>
    29312934
     
    29712974    <attribute name="virtualSystemDescriptions" type="IVirtualSystemDescription" readonly="yes" safearray="yes">
    29722975      <desc> Array of virtual system descriptions. One such description is created
    2973       for each virtual system found in the OVF. The array is empty until after <link to="#interpret" />
    2974       has been called.
     2976      for each virtual system found in the OVF.
     2977      This array is empty until either <link to="#interpret" /> (for import) or <link to="IMachine::export" />
     2978      (for export) has been called.
    29752979      </desc>
    29762980    </attribute>
     
    30153019        see <link to="IAppliance" /> for an overview.
    30163020
    3017         Since importing the appliance may imply copying disk images, which can take a long
    3018         time, this method operates asynchronously and returns an IProgress object to allow
    3019         the caller to monitor the progress.
     3021        Since importing the appliance will most probably involve copying and converting
     3022        disk images, which can take a long time, this method operates asynchronously and
     3023        returns an IProgress object to allow the caller to monitor the progress.
    30203024      </desc>
    30213025
     
    30313035          Calling this method is the final step of exporting an appliance from VirtualBox;
    30323036          see <link to="IAppliance" /> for an overview.
     3037
     3038          Since importing the appliance will most probably involve copying and converting
     3039          disk images, which can take a long time, this method operates asynchronously and
     3040          returns an IProgress object to allow the caller to monitor the progress.
    30333041      </desc>
    30343042      <param name="path" type="wstring" dir="in">
     
    30373045          on whether the appliance is distributed as a set of files or as a single file, respectively).
    30383046        </desc>
     3047      </param>
     3048      <param name="aProgress" type="IProgress" dir="return">
     3049          <desc></desc>
    30393050      </param>
    30403051    </method>
     
    31353146      </li>
    31363147      <li>
    3137         "Harddisk": a virtual hard disk, most probably as a reference to an image file. There can be an
     3148        "HardDiskImage": a virtual hard disk, most probably as a reference to an image file. There can be an
    31383149        arbitrary number of these items, one for each virtual disk image that accompanies the OVF. The
    31393150        array item in aOrigValues[] will contain the file specification from the OVF file, whereas the
  • trunk/src/VBox/Main/include/ApplianceImpl.h

    r17099 r17287  
    7777    STDMETHOD(Interpret)(void);
    7878    STDMETHOD(ImportMachines)(IProgress **aProgress);
    79     STDMETHOD(Write)(IN_BSTR path);
     79    STDMETHOD(Write)(IN_BSTR path, IProgress **aProgress);
    8080    /* public methods only for internal purposes */
    8181
     
    8585    const ComObjPtr <VirtualBox, ComWeakRef> mVirtualBox;
    8686
    87     struct Task; /* Worker thread for import */
     87    struct TaskImportMachines; /* Worker thread for import */
     88    struct TaskExportOVF; /* Worker thread for import */
    8889
    8990    struct Data;            // obscure, defined in AppliannceImpl.cpp
     
    9899    HRESULT searchUniqueDiskImageFilePath(Utf8Str& aName) const;
    99100
    100     static DECLCALLBACK(int) taskThread(RTTHREAD thread, void *pvUser);
     101    static DECLCALLBACK(int) taskThreadImportMachines(RTTHREAD thread, void *pvUser);
     102    static DECLCALLBACK(int) taskThreadExportOVF(RTTHREAD thread, void *pvUser);
    101103
    102104    friend class Machine;
  • trunk/src/VBox/Main/include/MachineImpl.h

    r17180 r17287  
    281281     *  taking or discarding snapshots, etc.
    282282     *
    283      *  The data variable is |mHWData|.
     283     *  The data variable is |mHDData|.
    284284     */
    285285    struct HDData
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