Changeset 56563 in vbox
- Timestamp:
- Jun 19, 2015 2:39:16 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/MachineImplCloneVM.cpp
r54948 r56563 103 103 HRESULT createMachineList(const ComPtr<ISnapshot> &pSnapshot, RTCList< ComObjPtr<Machine> > &machineList) const; 104 104 inline void updateProgressStats(MEDIUMTASKCHAIN &mtc, bool fAttachLinked, ULONG &uCount, ULONG &uTotalWeight) const; 105 inline HRESULT addSaveState(const ComObjPtr<Machine> &machine, ULONG &uCount, ULONG &uTotalWeight);105 inline HRESULT addSaveState(const ComObjPtr<Machine> &machine, bool fAttachCurrent, ULONG &uCount, ULONG &uTotalWeight); 106 106 inline HRESULT queryBaseName(const ComPtr<IMedium> &pMedium, Utf8Str &strBaseName) const; 107 107 HRESULT queryMediasForMachineState(const RTCList<ComObjPtr<Machine> > &machineList, … … 200 200 } 201 201 202 HRESULT MachineCloneVMPrivate::addSaveState(const ComObjPtr<Machine> &machine, ULONG &uCount, ULONG &uTotalWeight)202 HRESULT MachineCloneVMPrivate::addSaveState(const ComObjPtr<Machine> &machine, bool fAttachCurrent, ULONG &uCount, ULONG &uTotalWeight) 203 203 { 204 204 Bstr bstrSrcSaveStatePath; … … 208 208 { 209 209 SAVESTATETASK sst; 210 sst.snapshotUuid = machine->i_getSnapshotId(); 210 if (fAttachCurrent) 211 { 212 /* Make this saved state part of "current state" of the target 213 * machine, whether it is part of a snapshot or not. */ 214 sst.snapshotUuid.clear(); 215 } 216 else 217 sst.snapshotUuid = machine->i_getSnapshotId(); 211 218 sst.strSaveStateFile = bstrSrcSaveStatePath; 212 219 uint64_t cbSize; … … 241 248 { 242 249 /* This mode is pretty straightforward. We didn't need to know about any 243 * parent/children relationship and therefor simply adding all directly250 * parent/children relationship and therefore simply adding all directly 244 251 * attached images of the source VM as cloning targets. The IMedium code 245 252 * take than care to merge any (possibly) existing parents into the new … … 309 316 } 310 317 /* Add the save state files of this machine if there is one. */ 311 rc = addSaveState(machine, uCount, uTotalWeight);318 rc = addSaveState(machine, true /*fAttachCurrent*/, uCount, uTotalWeight); 312 319 if (FAILED(rc)) return rc; 313 320 } … … 346 353 * 347 354 * Note: This still leads to media chains which can have the same medium 348 * included. This case is handled in "run" and therefor not critical, but355 * included. This case is handled in "run" and therefore not critical, but 349 356 * it leads to wrong progress infos which isn't nice. */ 350 357 358 Assert(!fAttachLinked); 351 359 HRESULT rc = S_OK; 352 360 std::map<ComPtr<IMedium>, uint32_t> mediaHist; /* Our usage histogram for the medias */ … … 412 420 } 413 421 /* Add the save state files of this machine if there is one. */ 414 rc = addSaveState(machine, uCount, uTotalWeight);422 rc = addSaveState(machine, false /*fAttachCurrent*/, uCount, uTotalWeight); 415 423 if (FAILED(rc)) return rc; 424 /* If this is the newly created current state, make sure that the 425 * saved state is also attached to it. */ 426 if (fCreateDiffs) 427 { 428 rc = addSaveState(machine, true /*fAttachCurrent*/, uCount, uTotalWeight); 429 if (FAILED(rc)) return rc; 430 } 416 431 } 417 432 /* Build up the index list of the image chain. Unfortunately we can't do … … 485 500 * adding all directly and indirectly attached disk images to the worker 486 501 * list. */ 502 Assert(!fAttachLinked); 487 503 HRESULT rc = S_OK; 488 504 for (size_t i = 0; i < machineList.size(); ++i) … … 549 565 } 550 566 /* Add the save state files of this machine if there is one. */ 551 rc = addSaveState(machine, uCount, uTotalWeight);567 rc = addSaveState(machine, false /*fAttachCurrent*/, uCount, uTotalWeight); 552 568 if (FAILED(rc)) return rc; 569 /* If this is the newly created current state, make sure that the 570 * saved state is also attached to it. */ 571 if (fCreateDiffs) 572 { 573 rc = addSaveState(machine, true /*fAttachCurrent*/, uCount, uTotalWeight); 574 if (FAILED(rc)) return rc; 575 } 553 576 } 554 577 /* Build up the index list of the image chain. Unfortunately we can't do … … 982 1005 p->tr("Could not find data to snapshots '%s'"), d->snapshotId.toString().c_str()); 983 1006 984 985 986 1007 if (d->mode == CloneMode_MachineState) 987 1008 { … … 1008 1029 /* Current state is under root snapshot. */ 1009 1030 trgMCF.uuidCurrentSnapshot = sn.uuid; 1010 /* There will be created a new differencing image based on this1011 * snapshot. So reset the modified state. */1012 trgMCF.fCurrentStateModified = false;1013 1031 } 1014 1032 /* The snapshot will be the root one. */ … … 1396 1414 rc = d->pTrgMachine->i_loadMachineDataFromSettings(trgMCF, &d->pTrgMachine->mData->mUuid); 1397 1415 if (FAILED(rc)) throw rc; 1416 1417 /* Fix up the "current state modified" flag to what it should be, 1418 * as the value guessed in i_loadMachineDataFromSettings can be 1419 * quite far off the logical value for the cloned VM. */ 1420 if (d->mode == CloneMode_MachineState) 1421 d->pTrgMachine->mData->mCurrentStateModified = FALSE; 1422 else if ( d->mode == CloneMode_MachineAndChildStates 1423 && sn.uuid.isValid() 1424 && !sn.uuid.isZero()) 1425 { 1426 if (!d->pOldMachineState.isNull()) 1427 { 1428 /* There will be created a new differencing image based on 1429 * this snapshot. So reset the modified state. */ 1430 d->pTrgMachine->mData->mCurrentStateModified = FALSE; 1431 } 1432 else 1433 d->pTrgMachine->mData->mCurrentStateModified = p->mData->mCurrentStateModified; 1434 } 1435 else if (d->mode == CloneMode_AllStates) 1436 d->pTrgMachine->mData->mCurrentStateModified = p->mData->mCurrentStateModified; 1437 1438 /* If the target machine has saved state we MUST adjust the machine 1439 * state, otherwise saving settings will drop the information. */ 1440 if (trgMCF.strStateFile.isNotEmpty()) 1441 d->pTrgMachine->i_setMachineState(MachineState_Saved); 1442 1398 1443 /* save all VM data */ 1399 1444 bool fNeedsGlobalSaveSettings = false;
Note:
See TracChangeset
for help on using the changeset viewer.