third_party/virtualbox/src/VBox/Main/src-server/MachineImpl.cpp
/**
 * Copies all the hardware data from the given machine.
 *
 * Currently, only called when the VM is being restored from a snapshot. In
 * particular, this implies that the VM is not running during this method's
 * call.
 *
 * @note This method must be called from under this object's lock.
 *
 * @note This method doesn't call #i_commit(), so all data remains backed up and
 *       unsaved.
 */
Copies all the hardware data from the given machine.
Currently, only called when the VM is being restored from a snapshot. In
particular, this implies that the VM is not running during this method's
call.

@note This method must be called from under this object's lock.

@note This method doesn't call #i_commit(), so all data remains backed up and
unsaved.
Copies all the hardware data from the given machine . Currently only called when the VM is being restored from a snapshot . In particular this implies that the VM is not running during this method ' s call . @note This method must be called from under this object ' s lock . @note This method doesn ' t call #i_commit () so all data remains backed up and unsaved .
void Machine::i_copyFrom(Machine *aThat)
{
    AssertReturnVoid(!i_isSnapshotMachine());
    AssertReturnVoid(aThat->i_isSnapshotMachine());
    AssertReturnVoid(!Global::IsOnline(mData->mMachineState));
    mHWData.assignCopy(aThat->mHWData);
    for (HWData::SharedFolderList::iterator
         it = mHWData->mSharedFolders.begin();
         it != mHWData->mSharedFolders.end();
         ++it)
    {
        ComObjPtr<SharedFolder> folder;
        folder.createObject();
        HRESULT rc = folder->initCopy(i_getMachine(), *it);
        AssertComRC(rc);
        *it = folder;
    }
    mBIOSSettings->i_copyFrom(aThat->mBIOSSettings);
    mVRDEServer->i_copyFrom(aThat->mVRDEServer);
    mAudioAdapter->i_copyFrom(aThat->mAudioAdapter);
    mUSBDeviceFilters->i_copyFrom(aThat->mUSBDeviceFilters);
    mBandwidthControl->i_copyFrom(aThat->mBandwidthControl);
    mStorageControllers.backup();
    mStorageControllers->clear();
    for (StorageControllerList::const_iterator
         it = aThat->mStorageControllers->begin();
         it != aThat->mStorageControllers->end();
         ++it)
    {
        ComObjPtr<StorageController> ctrl;
        ctrl.createObject();
        ctrl->initCopy(this, *it);
        mStorageControllers->push_back(ctrl);
    }
    mUSBControllers.backup();
    mUSBControllers->clear();
    for (USBControllerList::const_iterator
         it = aThat->mUSBControllers->begin();
         it != aThat->mUSBControllers->end();
         ++it)
    {
        ComObjPtr<USBController> ctrl;
        ctrl.createObject();
        ctrl->initCopy(this, *it);
        mUSBControllers->push_back(ctrl);
    }
    mNetworkAdapters.resize(aThat->mNetworkAdapters.size());
    for (ULONG slot = 0; slot < mNetworkAdapters.size(); ++slot)
    {
        if (mNetworkAdapters[slot].isNotNull())
            mNetworkAdapters[slot]->i_copyFrom(aThat->mNetworkAdapters[slot]);
        else
        {
            unconst(mNetworkAdapters[slot]).createObject();
            mNetworkAdapters[slot]->initCopy(this, aThat->mNetworkAdapters[slot]);
        }
    }
    for (ULONG slot = 0; slot < RT_ELEMENTS(mSerialPorts); ++slot)
        mSerialPorts[slot]->i_copyFrom(aThat->mSerialPorts[slot]);
    for (ULONG slot = 0; slot < RT_ELEMENTS(mParallelPorts); ++slot)
        mParallelPorts[slot]->i_copyFrom(aThat->mParallelPorts[slot]);
}
void Machine :: i_copyFrom ( Machine * aThat ) { AssertReturnVoid ( ! i_isSnapshotMachine ( ) ) ; AssertReturnVoid ( aThat -> i_isSnapshotMachine ( ) ) ; AssertReturnVoid ( ! Global :: IsOnline ( mData -> mMachineState ) ) ; mHWData . assignCopy ( aThat -> mHWData ) ; for ( HWData :: SharedFolderList :: iterator it = mHWData -> mSharedFolders . begin ( ) ; it != mHWData -> mSharedFolders . end ( ) ; ++ it ) { ComObjPtr < SharedFolder > folder ; folder . createObject ( ) ; HRESULT rc = folder -> initCopy ( i_getMachine ( ) , * it ) ; AssertComRC ( rc ) ; * it = folder ; } mBIOSSettings -> i_copyFrom ( aThat -> mBIOSSettings ) ; mVRDEServer -> i_copyFrom ( aThat -> mVRDEServer ) ; mAudioAdapter -> i_copyFrom ( aThat -> mAudioAdapter ) ; mUSBDeviceFilters -> i_copyFrom ( aThat -> mUSBDeviceFilters ) ; mBandwidthControl -> i_copyFrom ( aThat -> mBandwidthControl ) ; mStorageControllers . backup ( ) ; mStorageControllers -> clear ( ) ; for ( StorageControllerList :: const_iterator it = aThat -> mStorageControllers -> begin ( ) ; it != aThat -> mStorageControllers -> end ( ) ; ++ it ) { ComObjPtr < StorageController > ctrl ; ctrl . createObject ( ) ; ctrl -> initCopy ( this , * it ) ; mStorageControllers -> push_back ( ctrl ) ; } mUSBControllers . backup ( ) ; mUSBControllers -> clear ( ) ; for ( USBControllerList :: const_iterator it = aThat -> mUSBControllers -> begin ( ) ; it != aThat -> mUSBControllers -> end ( ) ; ++ it ) { ComObjPtr < USBController > ctrl ; ctrl . createObject ( ) ; ctrl -> initCopy ( this , * it ) ; mUSBControllers -> push_back ( ctrl ) ; } mNetworkAdapters . resize ( aThat -> mNetworkAdapters . size ( ) ) ; for ( ULONG slot = 0 ; slot < mNetworkAdapters . size ( ) ; ++ slot ) { if ( mNetworkAdapters [ slot ] . isNotNull ( ) ) mNetworkAdapters [ slot ] -> i_copyFrom ( aThat -> mNetworkAdapters [ slot ] ) ; else { unconst ( mNetworkAdapters [ slot ] ) . createObject ( ) ; mNetworkAdapters [ slot ] -> initCopy ( this , aThat -> mNetworkAdapters [ slot ] ) ; } } for ( ULONG slot = 0 ; slot < RT_ELEMENTS ( mSerialPorts ) ; ++ slot ) mSerialPorts [ slot ] -> i_copyFrom ( aThat -> mSerialPorts [ slot ] ) ; for ( ULONG slot = 0 ; slot < RT_ELEMENTS ( mParallelPorts ) ; ++ slot ) mParallelPorts [ slot ] -> i_copyFrom ( aThat -> mParallelPorts [ slot ] ) ; }
Copies all the hardware data from the given machine.
Copies all the hardware data from the given machine .
// create copies of all shared folders (mHWData after attaching a copy // contains just references to original objects) /* create private copies of all controllers */ /* create private copies of all USB controllers */