VirtualBox

Ignore:
Timestamp:
Apr 8, 2010 6:07:13 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
59826
Message:

Main: more Machine::init() work to get OVF vbox:Machine import running; works now for machines without media attachments

File:
1 edited

Legend:

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

    r28098 r28110  
    3434#include "GuestOSTypeImpl.h"
    3535#include "ProgressImpl.h"
     36#include "MachineImpl.h"
    3637
    3738#include "AutoCaller.h"
     
    11211122
    11221123            if (vsdescThis->m->pConfig)
    1123                 importVBoxMachine(*vsdescThis->m->pConfig, pNewMachine, stack);
     1124                importVBoxMachine(vsdescThis, pNewMachine, stack);
    11241125            else
    11251126                importMachineGeneric(vsysThis, vsdescThis, pNewMachine, stack);
    11261127        }
    1127         catch(HRESULT aRC)
     1128        catch (HRESULT aRC)
    11281129        {
    11291130            rc = aRC;
     
    13671368        size_t a = 0;
    13681369        for (nwIt = vsdeNW.begin();
    1369                 (nwIt != vsdeNW.end() && a < SchemaDefs::NetworkAdapterCount);
    1370                 ++nwIt, ++a)
     1370             (nwIt != vsdeNW.end() && a < SchemaDefs::NetworkAdapterCount);
     1371             ++nwIt, ++a)
    13711372        {
    13721373            const VirtualSystemDescriptionEntry* pvsys = *nwIt;
     
    15291530    if (FAILED(rc)) throw rc;
    15301531
     1532    // store new machine for roll-back in case of errors
    15311533    Bstr bstrNewMachineId;
    15321534    rc = pNewMachine->COMGETTER(Id)(bstrNewMachineId.asOutParam());
    15331535    if (FAILED(rc)) throw rc;
    1534 
    1535     // store new machine for roll-back in case of errors
    15361536    stack.llMachinesRegistered.push_back(bstrNewMachineId);
    15371537
     
    18621862 * @param stack
    18631863 */
    1864 void Appliance::importVBoxMachine(const settings::MachineConfigFile &config,
    1865                                   ComPtr<IMachine> &pNewMachine,
     1864void Appliance::importVBoxMachine(ComObjPtr<VirtualSystemDescription> &vsdescThis,
     1865                                  ComPtr<IMachine> &pReturnNewMachine,
    18661866                                  ImportStack &stack)
    18671867{
     1868    Assert(vsdescThis->m->pConfig);
     1869    const settings::MachineConfigFile &config = *vsdescThis->m->pConfig;
     1870
     1871    // use the name that we computed in the OVF fields to avoid duplicates
     1872    std::list<VirtualSystemDescriptionEntry*> vsdeName = vsdescThis->findByType(VirtualSystemDescriptionType_Name);
     1873    if (vsdeName.size() < 1)
     1874        throw setError(VBOX_E_FILE_ERROR,
     1875                        tr("Missing VM name"));
     1876    const Utf8Str &strNameVBox = vsdeName.front()->strVbox;
     1877
     1878    ComObjPtr<Machine> pNewMachine;
     1879    HRESULT rc = pNewMachine.createObject();
     1880    if (FAILED(rc)) throw rc;
     1881    rc = pNewMachine->init(mVirtualBox, strNameVBox, config);
     1882    if (FAILED(rc)) throw rc;
     1883
     1884    IMachine *p;
     1885    rc = pNewMachine.queryInterfaceTo(&p);
     1886    if (FAILED(rc)) throw rc;
     1887
     1888    pReturnNewMachine = p;
     1889
     1890    rc = mVirtualBox->RegisterMachine(pNewMachine);
     1891    if (FAILED(rc)) throw rc;
     1892
     1893    // store new machine for roll-back in case of errors
     1894    Bstr bstrNewMachineId;
     1895    rc = pNewMachine->COMGETTER(Id)(bstrNewMachineId.asOutParam());
     1896    if (FAILED(rc)) throw rc;
     1897    stack.llMachinesRegistered.push_back(bstrNewMachineId);
    18681898}
    18691899
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