VirtualBox

Ignore:
Timestamp:
Oct 12, 2010 1:39:13 PM (14 years ago)
Author:
vboxsync
Message:

Main: fix broken per-machine media registry for OVF-import-from-vbox:Machine case (trunk regression)

File:
1 edited

Legend:

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

    r33051 r33067  
    406406                unconst(mData->mUuid) = mData->pMachineConfigFile->uuid;
    407407
    408                 rc = loadMachineDataFromSettings(*mData->pMachineConfigFile);
     408                rc = loadMachineDataFromSettings(*mData->pMachineConfigFile,
     409                                                 NULL /* puuidRegistry */);
    409410                if (FAILED(rc)) throw rc;
    410411
     
    496497        unconst(mData->mUuid).create();
    497498
    498         rc = loadMachineDataFromSettings(config);
     499        rc = loadMachineDataFromSettings(config,
     500                                         &mData->mUuid); // puuidRegistry: initialize media with this registry ID
    499501
    500502        // override VM name as well, it may be different
     
    655657                               mParent->settingsFilePath().c_str());
    656658
    657             rc = loadMachineDataFromSettings(*mData->pMachineConfigFile);
     659            rc = loadMachineDataFromSettings(*mData->pMachineConfigFile,
     660                                             NULL /* const Guid *puuidRegistry */);
    658661            if (FAILED(rc)) throw rc;
    659662        }
     
    68136816 * depending on the caller's use case, so the caller needs to set that herself.
    68146817 *
    6815  * @param config
    6816  * @param fAllowStorage
     6818 * This gets called in several contexts during machine initialization:
     6819 *
     6820 * -- When machine XML exists on disk already and needs to be loaded into memory,
     6821 *    for example, from registeredInit() to load all registered machines on
     6822 *    VirtualBox startup. In this case, puuidRegistry is NULL because the media
     6823 *    attached to the machine should be part of some media registry already.
     6824 *
     6825 * -- During OVF import, when a machine config has been constructed from an
     6826 *    OVF file. In this case, puuidRegistry is set to the machine UUID to
     6827 *    ensure that the media listed as attachments in the config (which have
     6828 *    been imported from the OVF) receive the correct registry ID.
     6829 *
     6830 * @param config Machine settings from XML.
     6831 * @param puuidRegistry If != NULL, Medium::setRegistryIdIfFirst() gets called with this registry ID for each attached medium in the config.
     6832 * @return
    68176833 */
    6818 HRESULT Machine::loadMachineDataFromSettings(const settings::MachineConfigFile &config)
     6834HRESULT Machine::loadMachineDataFromSettings(const settings::MachineConfigFile &config,
     6835                                             const Guid *puuidRegistry)
    68196836{
    68206837    // copy name, description, OS type, teleporter, UTC etc.
     
    68866903
    68876904    // load storage controllers
    6888     rc = loadStorageControllers(config.storageMachine);
     6905    rc = loadStorageControllers(config.storageMachine,
     6906                                puuidRegistry,
     6907                                NULL /* puuidSnapshot */);
    68896908    if (FAILED(rc)) return rc;
    68906909
    68916910    /*
    6892         *  NOTE: the assignment below must be the last thing to do,
    6893         *  otherwise it will be not possible to change the settings
    6894         *  somewehere in the code above because all setters will be
    6895         *  blocked by checkStateDependency(MutableStateDep).
    6896         */
     6911     *  NOTE: the assignment below must be the last thing to do,
     6912     *  otherwise it will be not possible to change the settings
     6913     *  somewehere in the code above because all setters will be
     6914     *  blocked by checkStateDependency(MutableStateDep).
     6915     */
    68976916
    68986917    /* set the machine state to Aborted or Saved when appropriate */
     
    72057224}
    72067225
    7207   /**
    7208    *  @param aNode    <StorageControllers> node.
    7209    */
     7226/**
     7227 *  Called from loadMachineDataFromSettings() for the storage controller data, including media.
     7228 *
     7229 * @param data
     7230 * @param puuidRegistry media registry ID to set media to or NULL; see Machine::loadMachineDataFromSettings()
     7231 * @param puuidSnapshot
     7232 * @return
     7233 */
    72107234HRESULT Machine::loadStorageControllers(const settings::Storage &data,
    7211                                         const Guid *aSnapshotId /* = NULL */)
     7235                                        const Guid *puuidRegistry,
     7236                                        const Guid *puuidSnapshot)
    72127237{
    72137238    AssertReturn(!isSessionMachine(), E_FAIL);
     
    72617286        rc = loadStorageDevices(pCtl,
    72627287                                ctlData,
    7263                                 aSnapshotId);
     7288                                puuidRegistry,
     7289                                puuidSnapshot);
    72647290        if (FAILED(rc)) return rc;
    72657291    }
     
    72697295
    72707296/**
    7271  * @param aNode        <HardDiskAttachments> node.
    7272  * @param fAllowStorage if false, we produce an error if the config requests media attachments
    7273  *                      (used with importing unregistered machines which cannot have media attachments)
     7297 * Called from loadStorageControllers for a controller's devices.
     7298 *
     7299 * @param aStorageController
     7300 * @param data
     7301 * @param puuidRegistry media registry ID to set media to or NULL; see Machine::loadMachineDataFromSettings()
    72747302 * @param aSnapshotId  pointer to the snapshot ID if this is a snapshot machine
    7275  *
    7276  * @note Lock mParent  for reading and hard disks for writing before calling.
     7303 * @return
    72777304 */
    72787305HRESULT Machine::loadStorageDevices(StorageController *aStorageController,
    72797306                                    const settings::StorageController &data,
    7280                                     const Guid *aSnapshotId /*= NULL*/)
     7307                                    const Guid *puuidRegistry,
     7308                                    const Guid *puuidSnapshot)
    72817309{
    72827310    HRESULT rc = S_OK;
     
    73407368                        return setError(E_FAIL,
    73417369                                        tr("A differencing image of snapshot {%RTuuid} could not be found. %ls"),
    7342                                         aSnapshotId->raw(),
     7370                                        puuidSnapshot->raw(),
    73437371                                        info.getText().raw());
    73447372                    }
     
    73577385                                        medium->getLocationFull().c_str(),
    73587386                                        dev.uuid.raw(),
    7359                                         aSnapshotId->raw(),
     7387                                        puuidSnapshot->raw(),
    73607388                                        mUserData->s.strName.c_str(),
    73617389                                        mData->m_strConfigFileFull.c_str());
     
    74217449        {
    74227450            if (isSnapshotMachine())
    7423                 rc = medium->addBackReference(mData->mUuid, *aSnapshotId);
     7451                rc = medium->addBackReference(mData->mUuid, *puuidSnapshot);
    74247452            else
    74257453                rc = medium->addBackReference(mData->mUuid);
     7454
     7455            if (puuidRegistry)
     7456                // caller wants registry ID to be set on all attached media (OVF import case)
     7457                medium->setRegistryIdIfFirst(*puuidRegistry);
    74267458        }
    74277459
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