VirtualBox

Changeset 25786 in vbox


Ignore:
Timestamp:
Jan 12, 2010 6:01:05 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
56544
Message:

Main: fix broken rollback in OVF error handling code (any error in media import would result in incomprehensible error messages saying that a machine could not be registered because it still has hard disk attachments; apparently introduced in april 2009 by the UUID changes -- r46627)

File:
1 edited

Legend:

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

    r25310 r25786  
    6868struct Appliance::Data
    6969{
    70         Data()
    71           : pReader(NULL) {}
    72 
    73         ~Data()
    74         {
    75             if (pReader)
    76             {
    77                 delete pReader;
    78                 pReader = NULL;
    79             }
    80         }
     70    Data()
     71      : pReader(NULL) {}
     72
     73    ~Data()
     74    {
     75        if (pReader)
     76        {
     77            delete pReader;
     78            pReader = NULL;
     79        }
     80    }
    8181
    8282    LocationInfo locInfo; /* The location info for the currently processed OVF */
     
    757757struct MyHardDiskAttachment
    758758{
    759     Guid                uuid;
     759    Bstr                bstrUuid;
    760760    ComPtr<IMachine>    pMachine;
    761761    Bstr                controllerType;
     
    10981098    list<MyHardDiskAttachment> llHardDiskAttachments;
    10991099    list< ComPtr<IMedium> > llHardDisksCreated;
    1100     list<Guid> llMachinesRegistered;
     1100    list<Bstr> llMachinesRegistered;            // list of string UUIDs
    11011101
    11021102    ComPtr<ISession> session;
     
    11091109    // if pReader != NULL
    11101110
    1111     /* If an manifest file exists, verify the content. Therefor we need all
     1111    /* If an manifest file exists, verify the content. Therefore we need all
    11121112     * files which are referenced by the OVF & the OVF itself */
    11131113    Utf8Str strMfFile = manifestFileName(pTask->locInfo.strPath);
     
    15071507            if (FAILED(rc)) throw rc;
    15081508
    1509             Bstr newMachineId_;
    1510             rc = pNewMachine->COMGETTER(Id)(newMachineId_.asOutParam());
     1509            Bstr bstrNewMachineId;
     1510            rc = pNewMachine->COMGETTER(Id)(bstrNewMachineId.asOutParam());
    15111511            if (FAILED(rc)) throw rc;
    1512             Guid newMachineId(newMachineId_);
    15131512
    15141513            // store new machine for roll-back in case of errors
    1515             llMachinesRegistered.push_back(newMachineId);
     1514            llMachinesRegistered.push_back(bstrNewMachineId);
    15161515
    15171516            // Add floppies and CD-ROMs to the appropriate controllers.
     
    15321531                    /* In order to attach things we need to open a session
    15331532                     * for the new machine */
    1534                     rc = mVirtualBox->OpenSession(session, newMachineId_);
     1533                    rc = mVirtualBox->OpenSession(session, bstrNewMachineId);
    15351534                    if (FAILED(rc)) throw rc;
    15361535                    fSessionOpen = true;
     
    15531552                        // this is for rollback later
    15541553                        MyHardDiskAttachment mhda;
    1555                         mhda.uuid = newMachineId;
     1554                        mhda.bstrUuid = bstrNewMachineId;
    15561555                        mhda.pMachine = pNewMachine;
    15571556                        mhda.controllerType = bstrName;
     
    15991598                        // this is for rollback later
    16001599                        MyHardDiskAttachment mhda;
    1601                         mhda.uuid = newMachineId;
     1600                        mhda.bstrUuid = bstrNewMachineId;
    16021601                        mhda.pMachine = pNewMachine;
    16031602
     
    16501649                    /* In order to attach hard disks we need to open a session
    16511650                     * for the new machine */
    1652                     rc = mVirtualBox->OpenSession(session, newMachineId_);
     1651                    rc = mVirtualBox->OpenSession(session, bstrNewMachineId);
    16531652                    if (FAILED(rc)) throw rc;
    16541653                    fSessionOpen = true;
     
    17861785                        // this is for rollback later
    17871786                        MyHardDiskAttachment mhda;
    1788                         mhda.uuid = newMachineId;
     1787                        mhda.bstrUuid = bstrNewMachineId;
    17891788                        mhda.pMachine = pNewMachine;
    17901789
     
    18511850        {
    18521851            const MyHardDiskAttachment &mhda = *itM;
    1853             rc2 = mVirtualBox->OpenSession(session, Bstr(mhda.uuid));
     1852            rc2 = mVirtualBox->OpenSession(session, mhda.bstrUuid);
    18541853            if (SUCCEEDED(rc2))
    18551854            {
     
    18781877
    18791878        // finally, deregister and remove all machines
    1880         list<Guid>::iterator itID;
     1879        list<Bstr>::iterator itID;
    18811880        for (itID = llMachinesRegistered.begin();
    18821881             itID != llMachinesRegistered.end();
    18831882             ++itID)
    18841883        {
    1885             const Guid &guid = *itID;
     1884            const Bstr &bstrGuid = *itID;
    18861885            ComPtr<IMachine> failedMachine;
    1887             rc2 = mVirtualBox->UnregisterMachine(guid.toUtf16(), failedMachine.asOutParam());
     1886            rc2 = mVirtualBox->UnregisterMachine(bstrGuid, failedMachine.asOutParam());
    18881887            if (SUCCEEDED(rc2))
    18891888                rc2 = failedMachine->DeleteSettings();
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