Changeset 76215 in vbox for trunk/src/VBox/Main/src-server
- Timestamp:
- Dec 13, 2018 6:58:16 PM (6 years ago)
- Location:
- trunk/src/VBox/Main/src-server
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp
r74804 r76215 2641 2641 hVfsIosReadAhead, 2642 2642 nullParent, 2643 pProgressImportTmp); 2643 pProgressImportTmp, 2644 true /* aNotify */); 2644 2645 RTVfsIoStrmRelease(hVfsIosReadAhead); 2645 2646 hVfsIosSrc = NIL_RTVFSIOSTREAM; -
trunk/src/VBox/Main/src-server/MachineImpl.cpp
r75817 r76215 4037 4037 pMediumLockList, 4038 4038 NULL /* aProgress */, 4039 true /* aWait */); 4039 true /* aWait */, 4040 false /* aNotify */); 4040 4041 4041 4042 alock.acquire(); … … 4145 4146 mParent->i_saveModifiedRegistries(); 4146 4147 4148 if (aM) 4149 mParent->i_onMediumConfigChanged(aM); 4147 4150 return rc; 4148 4151 } … … 10819 10822 pMediumLockList, 10820 10823 NULL /* aProgress */, 10821 true /* aWait */); 10824 true /* aWait */, 10825 false /* aNotify */); 10822 10826 alock.acquire(); 10823 10827 if (FAILED(rc)) throw rc; … … 11055 11059 Assert(pMedium); 11056 11060 11057 rc = pMedium->i_deleteStorage(NULL /*aProgress*/, true /*aWait*/ );11061 rc = pMedium->i_deleteStorage(NULL /*aProgress*/, true /*aWait*/, false /*aNotify*/); 11058 11062 // continue on delete failure, just collect error messages 11059 11063 AssertMsg(SUCCEEDED(rc), ("rc=%Rhrc it=%s hd=%s\n", rc, pAtt->i_getLogName(), … … 11223 11227 11224 11228 HRESULT rc = oldmedium->i_deleteStorage(NULL /*aProgress*/, 11225 true /*aWait*/); 11229 true /*aWait*/, 11230 false /*aNotify*/); 11226 11231 11227 11232 writeLock.acquire(); … … 14023 14028 } 14024 14029 14030 mParent->i_onMediumChanged(aAttachment); 14031 14025 14032 /* ignore notifications sent after #OnSessionEnd() is called */ 14026 14033 if (!directControl) … … 14259 14266 directControl = mData->mSession.mDirectControl; 14260 14267 } 14268 14269 mParent->i_onStorageDeviceChanged(aAttachment, aRemove, aSilent); 14261 14270 14262 14271 /* ignore notifications sent after #OnSessionEnd() is called */ -
trunk/src/VBox/Main/src-server/MachineImplCloneVM.cpp
r74804 r76215 16 16 */ 17 17 18 #include <set> 19 #include <map> 18 20 #include "MachineImplCloneVM.h" 19 21 … … 730 732 pMediumLockList, 731 733 NULL /* aProgress */, 732 true /* aWait */); 734 true /* aWait */, 735 false /* aNotify */); 733 736 delete pMediumLockList; 734 737 if (FAILED(rc)) throw rc; … … 1016 1019 RTCList<ComObjPtr<Medium> > newMedia; /* All created images */ 1017 1020 RTCList<Utf8Str> newFiles; /* All extra created files (save states, ...) */ 1021 std::set<ComObjPtr<Medium> > pMediumsForNotify; 1022 std::map<Guid, DeviceType_T> uIdsForNotify; 1018 1023 try 1019 1024 { … … 1153 1158 /* diff image has to be used... */ 1154 1159 pNewParent = pDiff; 1160 pMediumsForNotify.insert(pDiff->i_getParent()); 1161 uIdsForNotify[pDiff->i_getId()] = pDiff->i_getDeviceType(); 1155 1162 } 1156 1163 else … … 1284 1291 progress2.asOutParam(), 1285 1292 uSrcParentIdx, 1286 uTrgParentIdx); 1293 uTrgParentIdx, 1294 false /* aNotify */); 1287 1295 srcLock.acquire(); 1288 1296 if (FAILED(rc)) throw rc; … … 1318 1326 * chain. */ 1319 1327 pNewParent = pTarget; 1328 uIdsForNotify[pTarget->i_getId()] = pTarget->i_getDeviceType(); 1320 1329 } 1321 1330 } … … 1356 1365 /* diff image has to be used... */ 1357 1366 pNewParent = pDiff; 1367 pMediumsForNotify.insert(pDiff->i_getParent()); 1368 uIdsForNotify[pDiff->i_getId()] = pDiff->i_getDeviceType(); 1358 1369 } 1359 1370 else … … 1534 1545 const ComObjPtr<Medium> &pMedium = newMedia.at(i - 1); 1535 1546 mrc = pMedium->i_deleteStorage(NULL /* aProgress */, 1536 true /* aWait */); 1547 true /* aWait */, 1548 false /* aNotify */); 1537 1549 pMedium->Close(); 1538 1550 } … … 1546 1558 p->mParent->i_saveModifiedRegistries(); 1547 1559 } 1560 else 1561 { 1562 for (std::map<Guid, DeviceType_T>::const_iterator it = uIdsForNotify.begin(); 1563 it != uIdsForNotify.end(); 1564 ++it) 1565 { 1566 p->mParent->i_onMediumRegistered(it->first, it->second, TRUE); 1567 } 1568 for (std::set<ComObjPtr<Medium> >::const_iterator it = pMediumsForNotify.begin(); 1569 it != pMediumsForNotify.end(); 1570 ++it) 1571 { 1572 if (it->isNotNull()) 1573 p->mParent->i_onMediumConfigChanged(*it); 1574 } 1575 } 1548 1576 1549 1577 return mrc; -
trunk/src/VBox/Main/src-server/MediumImpl.cpp
r76154 r76215 46 46 #include <algorithm> 47 47 #include <list> 48 #include <set> 49 #include <map> 48 50 49 51 … … 222 224 { 223 225 public: 224 Task(Medium *aMedium, Progress *aProgress )226 Task(Medium *aMedium, Progress *aProgress, bool fNotifyAboutChanges = true) 225 227 : ThreadTask("Medium::Task"), 226 228 mVDOperationIfaces(NULL), … … 228 230 mMediumCaller(aMedium), 229 231 mProgress(aProgress), 230 mVirtualBoxCaller(NULL) 232 mVirtualBoxCaller(NULL), 233 mNotifyAboutChanges(fNotifyAboutChanges) 231 234 { 232 235 AssertReturnVoidStmt(aMedium, mRC = E_FAIL); … … 271 274 HRESULT rc() const { return mRC; } 272 275 bool isOk() const { return SUCCEEDED(rc()); } 276 bool NotifyAboutChanges() const { return mNotifyAboutChanges; } 273 277 274 278 const ComPtr<Progress>& GetProgressObject() const {return mProgress;} … … 331 335 ComObjPtr<VirtualBox> mVirtualBox; 332 336 AutoCaller mVirtualBoxCaller; 337 bool mNotifyAboutChanges; 333 338 }; 334 339 … … 344 349 Progress *aProgress, 345 350 uint64_t aSize, 346 MediumVariant_T aVariant) 347 : Medium::Task(aMedium, aProgress), 351 MediumVariant_T aVariant, 352 bool fNotifyAboutChanges = true) 353 : Medium::Task(aMedium, aProgress, fNotifyAboutChanges), 348 354 mSize(aSize), 349 355 mVariant(aVariant) … … 367 373 MediumVariant_T aVariant, 368 374 MediumLockList *aMediumLockList, 369 bool fKeepMediumLockList = false) 370 : Medium::Task(aMedium, aProgress), 375 bool fKeepMediumLockList = false, 376 bool fNotifyAboutChanges = true) 377 : Medium::Task(aMedium, aProgress, fNotifyAboutChanges), 371 378 mpMediumLockList(aMediumLockList), 372 379 mTarget(aTarget), … … 412 419 MediumLockList *aTargetMediumLockList, 413 420 bool fKeepSourceMediumLockList = false, 414 bool fKeepTargetMediumLockList = false) 415 : Medium::Task(aMedium, aProgress), 421 bool fKeepTargetMediumLockList = false, 422 bool fNotifyAboutChanges = true) 423 : Medium::Task(aMedium, aProgress, fNotifyAboutChanges), 416 424 mTarget(aTarget), 417 425 mParent(aParent), … … 470 478 MediumVariant_T aVariant, 471 479 MediumLockList *aMediumLockList, 472 bool fKeepMediumLockList = false) 473 : Medium::Task(aMedium, aProgress), 480 bool fKeepMediumLockList = false, 481 bool fNotifyAboutChanges = true) 482 : Medium::Task(aMedium, aProgress, fNotifyAboutChanges), 474 483 mpMediumLockList(aMediumLockList), 475 484 mVariant(aVariant), … … 500 509 Progress *aProgress, 501 510 MediumLockList *aMediumLockList, 502 bool fKeepMediumLockList = false) 503 : Medium::Task(aMedium, aProgress), 511 bool fKeepMediumLockList = false, 512 bool fNotifyAboutChanges = true) 513 : Medium::Task(aMedium, aProgress, fNotifyAboutChanges), 504 514 mpMediumLockList(aMediumLockList), 505 515 mfKeepMediumLockList(fKeepMediumLockList) … … 529 539 Progress *aProgress, 530 540 MediumLockList *aMediumLockList, 531 bool fKeepMediumLockList = false) 532 : Medium::Task(aMedium, aProgress), 541 bool fKeepMediumLockList = false, 542 bool fNotifyAboutChanges = true) 543 : Medium::Task(aMedium, aProgress, fNotifyAboutChanges), 533 544 mSize(aSize), 534 545 mpMediumLockList(aMediumLockList), … … 559 570 Progress *aProgress, 560 571 MediumLockList *aMediumLockList, 561 bool fKeepMediumLockList = false) 562 : Medium::Task(aMedium, aProgress), 572 bool fKeepMediumLockList = false, 573 bool fNotifyAboutChanges = true) 574 : Medium::Task(aMedium, aProgress, fNotifyAboutChanges), 563 575 mpMediumLockList(aMediumLockList), 564 576 mfKeepMediumLockList(fKeepMediumLockList) … … 586 598 Progress *aProgress, 587 599 MediumLockList *aMediumLockList, 588 bool fKeepMediumLockList = false) 589 : Medium::Task(aMedium, aProgress), 600 bool fKeepMediumLockList = false, 601 bool fNotifyAboutChanges = true) 602 : Medium::Task(aMedium, aProgress, fNotifyAboutChanges), 590 603 mpMediumLockList(aMediumLockList), 591 604 mfKeepMediumLockList(fKeepMediumLockList) … … 617 630 Progress *aProgress, 618 631 MediumLockList *aMediumLockList, 619 bool fKeepMediumLockList = false) 620 : Medium::Task(aMedium, aProgress), 632 bool fKeepMediumLockList = false, 633 bool fNotifyAboutChanges = true) 634 : Medium::Task(aMedium, aProgress, fNotifyAboutChanges), 621 635 mTarget(aTarget), 622 636 mfMergeForward(fMergeForward), … … 666 680 Medium *aParent, 667 681 MediumLockList *aTargetMediumLockList, 668 bool fKeepTargetMediumLockList = false) 669 : Medium::Task(aMedium, aProgress), 682 bool fKeepTargetMediumLockList = false, 683 bool fNotifyAboutChanges = true) 684 : Medium::Task(aMedium, aProgress, fNotifyAboutChanges), 670 685 mFilename(aFilename), 671 686 mFormat(aFormat), … … 730 745 Progress *aProgress, 731 746 MediumLockList *aMediumLockList) 732 : Medium::Task(aMedium, aProgress ),747 : Medium::Task(aMedium, aProgress, false), 733 748 mstrNewPassword(strNewPassword), 734 749 mstrCurrentPassword(strCurrentPassword), … … 1644 1659 i_markRegistriesModified(); 1645 1660 m->pVirtualBox->i_saveModifiedRegistries(); 1661 m->pVirtualBox->i_onMediumConfigChanged(this); 1646 1662 } 1647 1663 catch (HRESULT aRC) { rc = aRC; } … … 1879 1895 i_markRegistriesModified(); 1880 1896 m->pVirtualBox->i_saveModifiedRegistries(); 1897 m->pVirtualBox->i_onMediumConfigChanged(this); 1881 1898 1882 1899 return S_OK; … … 1990 2007 i_markRegistriesModified(); 1991 2008 m->pVirtualBox->i_saveModifiedRegistries(); 2009 m->pVirtualBox->i_onMediumConfigChanged(this); 1992 2010 } 1993 2011 … … 2056 2074 } 2057 2075 2076 const Guid uPrevImage = m->uuidImage; 2058 2077 unconst(m->uuidImage) = imageId; 2078 ComObjPtr<Medium> pPrevParent = i_getParent(); 2059 2079 unconst(m->uuidParentImage) = parentId; 2060 2080 … … 2065 2085 !!aSetParentId /* fSetParentId */, 2066 2086 autoCaller); 2087 2088 AutoReadLock arlock(this COMMA_LOCKVAL_SRC_POS); 2089 const Guid uCurrImage = m->uuidImage; 2090 ComObjPtr<Medium> pCurrParent = i_getParent(); 2091 arlock.release(); 2092 2093 if (SUCCEEDED(rc)) 2094 { 2095 if (uCurrImage != uPrevImage) 2096 m->pVirtualBox->i_onMediumConfigChanged(this); 2097 if (pPrevParent != pCurrParent) 2098 { 2099 m->pVirtualBox->i_onMediumConfigChanged(pPrevParent); 2100 m->pVirtualBox->i_onMediumConfigChanged(pCurrParent); 2101 } 2102 } 2067 2103 2068 2104 return rc; … … 2358 2394 ComObjPtr<VirtualBox> pVirtualBox(m->pVirtualBox); 2359 2395 2396 Guid uId = i_getId(); 2397 DeviceType_T devType = i_getDeviceType(); 2398 bool wasCreated = m->state != MediumState_NotCreated; 2360 2399 MultiResult mrc = i_close(aAutoCaller); 2361 2400 2362 2401 pVirtualBox->i_saveModifiedRegistries(); 2402 2403 if (SUCCEEDED(mrc) && wasCreated) 2404 m->pVirtualBox->i_onMediumRegistered(uId, devType, FALSE); 2363 2405 2364 2406 return mrc; … … 2430 2472 i_markRegistriesModified(); 2431 2473 m->pVirtualBox->i_saveModifiedRegistries(); 2474 m->pVirtualBox->i_onMediumConfigChanged(this); 2432 2475 2433 2476 return S_OK; … … 2509 2552 i_markRegistriesModified(); 2510 2553 m->pVirtualBox->i_saveModifiedRegistries(); 2554 m->pVirtualBox->i_onMediumConfigChanged(this); 2511 2555 2512 2556 return S_OK; 2513 2557 } 2558 2514 2559 HRESULT Medium::createBaseStorage(LONG64 aLogicalSize, 2515 2560 const std::vector<MediumVariant_T> &aVariant, … … 2597 2642 2598 2643 MultiResult mrc = i_deleteStorage(&pProgress, 2599 false /* aWait */); 2644 false /* aWait */, 2645 true /* aNotify */); 2600 2646 /* Must save the registries in any case, since an entry was removed. */ 2601 2647 m->pVirtualBox->i_saveModifiedRegistries(); … … 2716 2762 2717 2763 rc = i_createDiffStorage(diff, (MediumVariant_T)mediumVariantFlags, pMediumLockList, 2718 &pProgress, false /* aWait */ );2764 &pProgress, false /* aWait */, true /* aNotify */); 2719 2765 if (FAILED(rc)) 2720 2766 delete pMediumLockList; … … 2748 2794 2749 2795 rc = i_mergeTo(pTarget, fMergeForward, pParentForTarget, pChildrenToReparent, 2750 pMediumLockList, &pProgress, false /* aWait */ );2796 pMediumLockList, &pProgress, false /* aWait */, true /* aNotify */); 2751 2797 if (FAILED(rc)) 2752 2798 i_cancelMergeTo(pChildrenToReparent, pMediumLockList); … … 3299 3345 MediumState_T mediumState; 3300 3346 refreshState(autoCaller, &mediumState); 3347 m->pVirtualBox->i_onMediumConfigChanged(this); 3301 3348 } 3302 3349 catch (HRESULT aRC) { rc = aRC; } … … 3426 3473 3427 3474 if (SUCCEEDED(rc)) 3428 rc = i_resize(aLogicalSize, pMediumLockList, &pProgress, false /* aWait */ );3475 rc = i_resize(aLogicalSize, pMediumLockList, &pProgress, false /* aWait */, true /* aNotify */); 3429 3476 3430 3477 if (SUCCEEDED(rc)) … … 4479 4526 unconst(m->strLocationFull) = newPath; 4480 4527 4528 m->pVirtualBox->i_onMediumConfigChanged(this); 4529 4481 4530 LogFlowThisFunc(("locationFull.after='%s'\n", m->strLocationFull.c_str())); 4482 4531 // we changed something … … 4625 4674 4626 4675 /** 4627 * Internal method to return the medium's size. Must have caller + locking!4676 * Internal method to update the medium's id. Must have caller + locking! 4628 4677 * @return 4629 4678 */ … … 4878 4927 MediumLockList *aMediumLockList, 4879 4928 ComObjPtr<Progress> *aProgress, 4880 bool aWait) 4929 bool aWait, 4930 bool aNotify) 4881 4931 { 4882 4932 AssertReturn(!aTarget.isNull(), E_FAIL); … … 4953 5003 pTask = new Medium::CreateDiffTask(this, pProgress, aTarget, aVariant, 4954 5004 aMediumLockList, 4955 aWait /* fKeepMediumLockList */); 5005 aWait /* fKeepMediumLockList */, 5006 aNotify); 4956 5007 rc = pTask->rc(); 4957 5008 AssertComRC(rc); … … 5138 5189 */ 5139 5190 HRESULT Medium::i_deleteStorage(ComObjPtr<Progress> *aProgress, 5140 bool aWait )5191 bool aWait, bool aNotify) 5141 5192 { 5142 5193 AssertReturn(aProgress != NULL || aWait == true, E_FAIL); … … 5309 5360 5310 5361 /* setup task object to carry out the operation sync/async */ 5311 pTask = new Medium::DeleteTask(this, pProgress, pMediumLockList );5362 pTask = new Medium::DeleteTask(this, pProgress, pMediumLockList, false, aNotify); 5312 5363 rc = pTask->rc(); 5313 5364 AssertComRC(rc); … … 5964 6015 MediumLockList *aMediumLockList, 5965 6016 ComObjPtr<Progress> *aProgress, 5966 bool aWait )6017 bool aWait, bool aNotify) 5967 6018 { 5968 6019 AssertReturn(pTarget != NULL, E_FAIL); … … 6019 6070 pParentForTarget, aChildrenToReparent, 6020 6071 pProgress, aMediumLockList, 6021 aWait /* fKeepMediumLockList */); 6072 aWait /* fKeepMediumLockList */, 6073 aNotify); 6022 6074 rc = pTask->rc(); 6023 6075 AssertComRC(rc); … … 6141 6193 MediumLockList *aMediumLockList, 6142 6194 ComObjPtr<Progress> *aProgress, 6143 bool aWait) 6195 bool aWait, 6196 bool aNotify) 6144 6197 { 6145 6198 AssertReturn(aMediumLockList != NULL, E_FAIL); … … 6180 6233 pProgress, 6181 6234 aMediumLockList, 6182 aWait /* fKeepMediumLockList */); 6235 aWait /* fKeepMediumLockList */, 6236 aNotify); 6183 6237 rc = pTask->rc(); 6184 6238 AssertComRC(rc); … … 6496 6550 RTVFSIOSTREAM aVfsIosSrc, 6497 6551 const ComObjPtr<Medium> &aParent, 6498 const ComObjPtr<Progress> &aProgress) 6552 const ComObjPtr<Progress> &aProgress, 6553 bool aNotify) 6499 6554 { 6500 6555 /** @todo r=klaus The code below needs to be double checked with regard … … 6557 6612 /* setup task object to carry out the operation asynchronously */ 6558 6613 pTask = new Medium::ImportTask(this, aProgress, aFilename, aFormat, aVariant, 6559 aVfsIosSrc, aParent, pTargetMediumLockList );6614 aVfsIosSrc, aParent, pTargetMediumLockList, false, aNotify); 6560 6615 rc = pTask->rc(); 6561 6616 AssertComRC(rc); … … 6595 6650 HRESULT Medium::i_cloneToEx(const ComObjPtr<Medium> &aTarget, MediumVariant_T aVariant, 6596 6651 const ComObjPtr<Medium> &aParent, IProgress **aProgress, 6597 uint32_t idxSrcImageSame, uint32_t idxDstImageSame )6652 uint32_t idxSrcImageSame, uint32_t idxDstImageSame, bool aNotify) 6598 6653 { 6599 6654 /** @todo r=klaus The code below needs to be double checked with regard … … 6700 6755 aParent, idxSrcImageSame, 6701 6756 idxDstImageSame, pSourceMediumLockList, 6702 pTargetMediumLockList );6757 pTargetMediumLockList, false, false, aNotify); 6703 6758 rc = pTask->rc(); 6704 6759 AssertComRC(rc); … … 7300 7355 pToken.setNull(); 7301 7356 7302 if (FAILED(rc)) return rc; 7357 if (FAILED(rc)) 7358 return rc; 7303 7359 7304 7360 /* If this is a base image which incorrectly has a parent UUID set, … … 7308 7364 * with a diff image before the base is registered this would destroy 7309 7365 * the diff. Not acceptable. */ 7310 if (fRepairImageZeroParentUuid) 7311 { 7312 rc = LockWrite(pToken.asOutParam()); 7313 if (FAILED(rc)) return rc; 7314 7315 alock.release(); 7316 7317 try 7318 { 7319 PVDISK hdd; 7320 vrc = VDCreate(m->vdDiskIfaces, i_convertDeviceType(), &hdd); 7321 ComAssertRCThrow(vrc, E_FAIL); 7366 do 7367 { 7368 if (fRepairImageZeroParentUuid) 7369 { 7370 rc = LockWrite(pToken.asOutParam()); 7371 if (FAILED(rc)) 7372 break; 7373 7374 alock.release(); 7322 7375 7323 7376 try 7324 7377 { 7325 vrc = VDOpen(hdd, 7326 format.c_str(), 7327 location.c_str(), 7328 (uOpenFlags & ~VD_OPEN_FLAGS_READONLY) | m->uOpenFlagsDef, 7329 m->vdImageIfaces); 7330 if (RT_FAILURE(vrc)) 7331 throw S_OK; 7332 7333 RTUUID zeroParentUuid; 7334 RTUuidClear(&zeroParentUuid); 7335 vrc = VDSetParentUuid(hdd, 0, &zeroParentUuid); 7378 PVDISK hdd; 7379 vrc = VDCreate(m->vdDiskIfaces, i_convertDeviceType(), &hdd); 7336 7380 ComAssertRCThrow(vrc, E_FAIL); 7381 7382 try 7383 { 7384 vrc = VDOpen(hdd, 7385 format.c_str(), 7386 location.c_str(), 7387 (uOpenFlags & ~VD_OPEN_FLAGS_READONLY) | m->uOpenFlagsDef, 7388 m->vdImageIfaces); 7389 if (RT_FAILURE(vrc)) 7390 throw S_OK; 7391 7392 RTUUID zeroParentUuid; 7393 RTUuidClear(&zeroParentUuid); 7394 vrc = VDSetParentUuid(hdd, 0, &zeroParentUuid); 7395 ComAssertRCThrow(vrc, E_FAIL); 7396 } 7397 catch (HRESULT aRC) 7398 { 7399 rc = aRC; 7400 } 7401 7402 VDDestroy(hdd); 7337 7403 } 7338 7404 catch (HRESULT aRC) … … 7341 7407 } 7342 7408 7343 VDDestroy(hdd); 7344 } 7345 catch (HRESULT aRC) 7346 { 7347 rc = aRC; 7348 } 7349 7350 pToken->Abandon(); 7351 pToken.setNull(); 7352 if (FAILED(rc)) return rc; 7353 } 7409 pToken->Abandon(); 7410 pToken.setNull(); 7411 if (FAILED(rc)) 7412 break; 7413 } 7414 } while(0); 7354 7415 7355 7416 return rc; … … 8493 8554 m->pVirtualBox->i_saveModifiedRegistries(); 8494 8555 } 8556 if (task.NotifyAboutChanges()) 8557 m->pVirtualBox->i_onMediumRegistered(m->id, m->devType, TRUE); 8495 8558 } 8496 8559 else … … 8728 8791 * unlock the medium. */ 8729 8792 8793 if (task.NotifyAboutChanges() && SUCCEEDED(mrc)) 8794 { 8795 m->pVirtualBox->i_onMediumRegistered(pTarget->i_getId(), pTarget->i_getDeviceType(), TRUE); 8796 m->pVirtualBox->i_onMediumConfigChanged(this); 8797 } 8798 8730 8799 return mrc; 8731 8800 } … … 8820 8889 8821 8890 ComObjPtr<Progress> pProgress(task.GetProgressObject()); 8822 rc = pTarget->i_resize(sourceSize, pMediumLockListForResize, &pProgress, true );8891 rc = pTarget->i_resize(sourceSize, pMediumLockListForResize, &pProgress, true, false); 8823 8892 if (FAILED(rc)) 8824 8893 { … … 8986 9055 HRESULT rc2; 8987 9056 9057 std::set<ComObjPtr<Medium> > pMediumsForNotify; 9058 std::map<Guid, DeviceType_T> uIdsForNotify; 9059 8988 9060 if (SUCCEEDED(mrc)) 8989 9061 { … … 9003 9075 * (chain->parent() is source's parent). Depth check above. */ 9004 9076 pTarget->i_deparent(); 9077 if (task.NotifyAboutChanges()) 9078 pMediumsForNotify.insert(task.mParentForTarget); 9005 9079 pTarget->i_setParent(task.mParentForTarget); 9006 9080 if (task.mParentForTarget) … … 9040 9114 // no depth check, reduces depth 9041 9115 pMedium->i_setParent(pTarget); 9116 9117 if (task.NotifyAboutChanges()) 9118 pMediumsForNotify.insert(pMedium); 9042 9119 } 9043 9120 } 9121 pMediumsForNotify.insert(pTarget); 9044 9122 } 9045 9123 … … 9066 9144 } 9067 9145 9146 uIdsForNotify[pMedium->i_getId()] = pMedium->i_getDeviceType(); 9068 9147 rc2 = pMedium->m->pVirtualBox->i_unregisterMedium(pMedium); 9069 9148 AssertComRC(rc2); … … 9126 9205 if (task.isAsync()) 9127 9206 i_cancelMergeTo(task.mpChildrenToReparent, task.mpMediumLockList); 9207 } 9208 else if (task.NotifyAboutChanges()) 9209 { 9210 for (std::set<ComObjPtr<Medium> >::const_iterator it = pMediumsForNotify.begin(); 9211 it != pMediumsForNotify.end(); 9212 ++it) 9213 { 9214 if (it->isNotNull()) 9215 m->pVirtualBox->i_onMediumConfigChanged(*it); 9216 } 9217 for (std::map<Guid, DeviceType_T>::const_iterator it = uIdsForNotify.begin(); 9218 it != uIdsForNotify.end(); 9219 ++it) 9220 { 9221 m->pVirtualBox->i_onMediumRegistered(it->first, it->second, FALSE); 9222 } 9128 9223 } 9129 9224 … … 9446 9541 m->pVirtualBox->i_saveModifiedRegistries(); 9447 9542 eik.fetch(); 9543 9544 if (task.NotifyAboutChanges()) 9545 { 9546 if (!fCreatingTarget) 9547 { 9548 if (!aFilterPropNames.empty()) 9549 m->pVirtualBox->i_onMediumConfigChanged(pTargetBase); 9550 m->pVirtualBox->i_onMediumConfigChanged(pParent); 9551 } 9552 else 9553 { 9554 m->pVirtualBox->i_onMediumRegistered(pTarget->i_getId(), pTarget->i_getDeviceType(), TRUE); 9555 } 9556 } 9448 9557 } 9449 9558 } … … 9621 9730 task.mpMediumLockList->Clear(); 9622 9731 9732 if (task.NotifyAboutChanges() && SUCCEEDED(mrc)) 9733 m->pVirtualBox->i_onMediumConfigChanged(this); 9623 9734 return mrc; 9624 9735 } … … 9688 9799 /* Reset UUID to prevent Create* from reusing it again */ 9689 9800 unconst(m->id).clear(); 9801 9802 if (task.NotifyAboutChanges() && SUCCEEDED(rc) && m->pParent.isNotNull()) 9803 m->pVirtualBox->i_onMediumConfigChanged(m->pParent); 9690 9804 9691 9805 return rc; … … 9831 9945 m->logicalSize = logicalSize; 9832 9946 m->variant = variant; 9947 9948 if (task.NotifyAboutChanges() && SUCCEEDED(rc)) 9949 m->pVirtualBox->i_onMediumConfigChanged(this); 9833 9950 9834 9951 /* Everything is explicitly unlocked when the task exits, … … 9928 10045 } 9929 10046 catch (HRESULT aRC) { rc = aRC; } 10047 10048 if (task.NotifyAboutChanges() && SUCCEEDED(rc)) 10049 m->pVirtualBox->i_onMediumConfigChanged(this); 9930 10050 9931 10051 /* Everything is explicitly unlocked when the task exits, … … 10044 10164 m->size = size; 10045 10165 m->logicalSize = logicalSize; 10166 10167 if (task.NotifyAboutChanges()) 10168 m->pVirtualBox->i_onMediumConfigChanged(this); 10046 10169 } 10047 10170 … … 10312 10435 task.mpTargetMediumLockList->Clear(); 10313 10436 10437 if (task.NotifyAboutChanges() && SUCCEEDED(mrc)) 10438 { 10439 if (pParent) 10440 m->pVirtualBox->i_onMediumConfigChanged(pParent); 10441 if (fCreatingTarget) 10442 m->pVirtualBox->i_onMediumConfigChanged(this); 10443 else 10444 m->pVirtualBox->i_onMediumRegistered(m->id, m->devType, TRUE); 10445 } 10446 10314 10447 return mrc; 10315 10448 } -
trunk/src/VBox/Main/src-server/SnapshotImpl.cpp
r75373 r76215 15 15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. 16 16 */ 17 18 #include <set> 19 #include <map> 17 20 18 21 #include "Logging.h" … … 1637 1640 BOOL fSuspendedBySave = FALSE; 1638 1641 1642 std::set<ComObjPtr<Medium> > pMediumsForNotify; 1643 std::map<Guid, DeviceType_T> uIdsForNotify; 1644 1639 1645 try 1640 1646 { … … 1773 1779 if (FAILED(rc)) 1774 1780 throw rc; 1781 } 1782 1783 // store parent of newly created diffs before commit for notify 1784 { 1785 MediumAttachmentList &oldAtts = *mMediumAttachments.backedUpData(); 1786 for (MediumAttachmentList::const_iterator 1787 it = mMediumAttachments->begin(); 1788 it != mMediumAttachments->end(); 1789 ++it) 1790 { 1791 MediumAttachment *pAttach = *it; 1792 Medium *pMedium = pAttach->i_getMedium(); 1793 1794 bool fFound = false; 1795 /* was this medium attached before? */ 1796 for (MediumAttachmentList::iterator 1797 oldIt = oldAtts.begin(); 1798 oldIt != oldAtts.end(); 1799 ++oldIt) 1800 { 1801 MediumAttachment *pOldAttach = *oldIt; 1802 if (pOldAttach->i_getMedium() == pMedium) 1803 { 1804 fFound = true; 1805 break; 1806 } 1807 } 1808 if (!fFound) 1809 { 1810 pMediumsForNotify.insert(pMedium->i_getParent()); 1811 uIdsForNotify[pMedium->i_getId()] = pMedium->i_getDeviceType(); 1812 } 1813 } 1775 1814 } 1776 1815 … … 1877 1916 mParent->i_onSnapshotTaken(mData->mUuid, task.m_uuidSnapshot); 1878 1917 LogFlowThisFuncLeave(); 1918 1919 if (SUCCEEDED(rc)) 1920 { 1921 for (std::map<Guid, DeviceType_T>::const_iterator it = uIdsForNotify.begin(); 1922 it != uIdsForNotify.end(); 1923 ++it) 1924 { 1925 mParent->i_onMediumRegistered(it->first, it->second, TRUE); 1926 } 1927 1928 for (std::set<ComObjPtr<Medium> >::const_iterator it = pMediumsForNotify.begin(); 1929 it != pMediumsForNotify.end(); 1930 ++it) 1931 { 1932 if (it->isNotNull()) 1933 mParent->i_onMediumConfigChanged(*it); 1934 } 1935 } 1879 1936 } 1880 1937 … … 2120 2177 HRESULT rc = S_OK; 2121 2178 Guid snapshotId; 2179 std::set<ComObjPtr<Medium> > pMediumsForNotify; 2180 std::map<Guid, DeviceType_T> uIdsForNotify; 2122 2181 2123 2182 try … … 2214 2273 /* make the snapshot we restored from the current snapshot */ 2215 2274 mData->mCurrentSnapshot = task.m_pSnapshot; 2275 } 2276 2277 // store parent of newly created diffs for notify 2278 { 2279 MediumAttachmentList &oldAtts = *mMediumAttachments.backedUpData(); 2280 for (MediumAttachmentList::const_iterator 2281 it = mMediumAttachments->begin(); 2282 it != mMediumAttachments->end(); 2283 ++it) 2284 { 2285 MediumAttachment *pAttach = *it; 2286 Medium *pMedium = pAttach->i_getMedium(); 2287 2288 bool fFound = false; 2289 /* was this medium attached before? */ 2290 for (MediumAttachmentList::iterator 2291 oldIt = oldAtts.begin(); 2292 oldIt != oldAtts.end(); 2293 ++oldIt) 2294 { 2295 MediumAttachment *pOldAttach = *oldIt; 2296 if (pOldAttach->i_getMedium() == pMedium) 2297 { 2298 fFound = true; 2299 break; 2300 } 2301 } 2302 if (!fFound) 2303 { 2304 pMediumsForNotify.insert(pMedium->i_getParent()); 2305 uIdsForNotify[pMedium->i_getId()] = pMedium->i_getDeviceType(); 2306 } 2307 } 2216 2308 } 2217 2309 … … 2314 2406 LogFlowThisFunc(("Deleting old current state in differencing image '%s'\n", pMedium->i_getName().c_str())); 2315 2407 2408 ComObjPtr<Medium> pParent = pMedium->i_getParent(); 2316 2409 HRESULT rc2 = pMedium->i_deleteStorage(NULL /* aProgress */, 2317 true /* aWait */); 2410 true /* aWait */, 2411 false /* aNotify */); 2318 2412 // ignore errors here because we cannot roll back after i_saveSettings() above 2319 2413 if (SUCCEEDED(rc2)) 2414 { 2415 pMediumsForNotify.insert(pParent); 2320 2416 pMedium->uninit(); 2417 } 2321 2418 } 2322 2419 } … … 2345 2442 2346 2443 if (SUCCEEDED(rc)) 2444 { 2347 2445 mParent->i_onSnapshotRestored(mData->mUuid, snapshotId); 2446 for (std::map<Guid, DeviceType_T>::const_iterator it = uIdsForNotify.begin(); 2447 it != uIdsForNotify.end(); 2448 ++it) 2449 { 2450 mParent->i_onMediumRegistered(it->first, it->second, TRUE); 2451 } 2452 for (std::set<ComObjPtr<Medium> >::const_iterator it = pMediumsForNotify.begin(); 2453 it != pMediumsForNotify.end(); 2454 ++it) 2455 { 2456 if (it->isNotNull()) 2457 mParent->i_onMediumConfigChanged(*it); 2458 } 2459 } 2348 2460 2349 2461 LogFlowThisFunc(("Done restoring snapshot (rc=%08X)\n", rc)); … … 2696 2808 MediumDeleteRecList toDelete; 2697 2809 Guid snapshotId; 2810 std::set<ComObjPtr<Medium> > pMediumsForNotify; 2811 std::map<Guid,DeviceType_T> uIdsForNotify; 2698 2812 2699 2813 try … … 3070 3184 /* No need to hold the lock any longer. */ 3071 3185 mLock.release(); 3186 ComObjPtr<Medium> pParent = pMedium->i_getParent(); 3187 Guid uMedium = pMedium->i_getId(); 3188 DeviceType_T uMediumType = pMedium->i_getDeviceType(); 3072 3189 rc = pMedium->i_deleteStorage(&task.m_pProgress, 3073 true /* aWait */); 3190 true /* aWait */, 3191 false /* aNotify */); 3074 3192 if (FAILED(rc)) 3075 3193 throw rc; 3194 3195 pMediumsForNotify.insert(pParent); 3196 uIdsForNotify[uMedium] = uMediumType; 3076 3197 3077 3198 // need to uninit the deleted medium … … 3081 3202 else 3082 3203 { 3204 { 3205 //store ids before merging for notify 3206 pMediumsForNotify.insert(it->mpTarget); 3207 if (it->mfMergeForward) 3208 pMediumsForNotify.insert(it->mpSource->i_getParent()); 3209 else 3210 { 3211 //children which will be reparented to target 3212 for (MediaList::const_iterator iit = it->mpSource->i_getChildren().begin(); 3213 iit != it->mpSource->i_getChildren().end(); 3214 ++iit) 3215 { 3216 pMediumsForNotify.insert(*iit); 3217 } 3218 } 3219 if (it->mfMergeForward) 3220 { 3221 for (ComObjPtr<Medium> pTmpMedium = it->mpTarget->i_getParent(); 3222 pTmpMedium != it->mpSource; 3223 pTmpMedium = pTmpMedium->i_getParent()) 3224 { 3225 uIdsForNotify[pTmpMedium->i_getId()] = pTmpMedium->i_getDeviceType(); 3226 } 3227 uIdsForNotify[it->mpSource->i_getId()] = it->mpSource->i_getDeviceType(); 3228 } 3229 else 3230 { 3231 for (ComObjPtr<Medium> pTmpMedium = it->mpSource->i_getParent(); 3232 pTmpMedium != it->mpTarget; 3233 pTmpMedium = pTmpMedium->i_getParent()) 3234 { 3235 uIdsForNotify[pTmpMedium->i_getId()] = pTmpMedium->i_getDeviceType(); 3236 } 3237 } 3238 } 3239 3083 3240 bool fNeedsSave = false; 3084 3241 if (it->mfNeedsOnlineMerge) … … 3111 3268 it->mpMediumLockList, 3112 3269 &task.m_pProgress, 3113 true /* aWait */); 3270 true /* aWait */, 3271 false /* aNotify */); 3114 3272 } 3115 3273 … … 3278 3436 3279 3437 if (SUCCEEDED(mrc)) 3438 { 3280 3439 mParent->i_onSnapshotDeleted(mData->mUuid, snapshotId); 3440 for (std::map<Guid, DeviceType_T>::const_iterator it = uIdsForNotify.begin(); 3441 it != uIdsForNotify.end(); 3442 ++it) 3443 { 3444 mParent->i_onMediumRegistered(it->first, it->second, FALSE); 3445 } 3446 for (std::set<ComObjPtr<Medium> >::const_iterator it = pMediumsForNotify.begin(); 3447 it != pMediumsForNotify.end(); 3448 ++it) 3449 { 3450 if (it->isNotNull()) 3451 mParent->i_onMediumConfigChanged(*it); 3452 } 3453 } 3281 3454 3282 3455 LogFlowThisFunc(("Done deleting snapshot (rc=%08X)\n", (HRESULT)mrc)); -
trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp
r76091 r76215 1963 1963 1964 1964 if (SUCCEEDED(rc)) 1965 { 1965 1966 medium.queryInterfaceTo(aMedium.asOutParam()); 1967 i_onMediumRegistered(medium->i_getId(), medium->i_getDeviceType(), TRUE); 1968 } 1966 1969 1967 1970 return rc; … … 2014 2017 } 2015 2018 2019 bool fMediumRegistered = false; 2016 2020 if (pMedium.isNull()) 2017 2021 { … … 2040 2044 rc = VBOX_E_OBJECT_NOT_FOUND; 2041 2045 } 2046 else 2047 { 2048 fMediumRegistered = true; 2049 } 2042 2050 } 2043 2051 else … … 2049 2057 2050 2058 if (SUCCEEDED(rc)) 2059 { 2051 2060 pMedium.queryInterfaceTo(aMedium.asOutParam()); 2061 if (fMediumRegistered) 2062 i_onMediumRegistered(pMedium->i_getId(), pMedium->i_getDeviceType() ,TRUE); 2063 } 2052 2064 2053 2065 return rc; … … 2252 2264 if (RT_FAILURE(vrc)) 2253 2265 fFailure = true; 2266 } 2267 if (!fFailure) 2268 { 2269 for (MediaList::const_iterator mt = m->allHardDisks.begin(); 2270 mt != m->allHardDisks.end(); 2271 ++mt) 2272 { 2273 i_onMediumConfigChanged(*mt); 2274 } 2254 2275 } 2255 2276 return fFailure ? VERR_INVALID_PARAMETER : VINF_SUCCESS; … … 2917 2938 } 2918 2939 2940 2941 /** Event for onMediumRegistered() */ 2942 struct MediumRegisteredEvent : public VirtualBox::CallbackEvent 2943 { 2944 MediumRegisteredEvent(VirtualBox *aVB, const Guid &aMediumId, 2945 const DeviceType_T aDevType, const BOOL aRegistered) 2946 : CallbackEvent(aVB, VBoxEventType_OnMediumRegistered) 2947 , mMediumId(aMediumId.toUtf16()), mDevType(aDevType), mRegistered(aRegistered) 2948 {} 2949 2950 virtual HRESULT prepareEventDesc(IEventSource *aSource, VBoxEventDesc &aEvDesc) 2951 { 2952 return aEvDesc.init(aSource, VBoxEventType_OnMediumRegistered, mMediumId.raw(), mDevType, mRegistered); 2953 } 2954 2955 Bstr mMediumId; 2956 DeviceType_T mDevType; 2957 BOOL mRegistered; 2958 }; 2959 2960 /** 2961 * @note Doesn't lock any object. 2962 */ 2963 void VirtualBox::i_onMediumRegistered(const Guid &aMediumId, const DeviceType_T aDevType, const BOOL aRegistered) 2964 { 2965 i_postEvent(new MediumRegisteredEvent(this, aMediumId, aDevType, aRegistered)); 2966 } 2967 2968 /** Event for onMediumConfigChanged() */ 2969 struct MediumConfigChangedEvent : public VirtualBox::CallbackEvent 2970 { 2971 MediumConfigChangedEvent(VirtualBox *aVB, IMedium *aMedium) 2972 : CallbackEvent(aVB, VBoxEventType_OnMediumConfigChanged) 2973 , mMedium(aMedium) 2974 {} 2975 2976 virtual HRESULT prepareEventDesc(IEventSource *aSource, VBoxEventDesc &aEvDesc) 2977 { 2978 return aEvDesc.init(aSource, VBoxEventType_OnMediumConfigChanged, mMedium); 2979 } 2980 2981 IMedium* mMedium; 2982 }; 2983 2984 void VirtualBox::i_onMediumConfigChanged(IMedium *aMedium) 2985 { 2986 i_postEvent(new MediumConfigChangedEvent(this, aMedium)); 2987 } 2988 2989 /** Event for onMediumChanged() */ 2990 struct MediumChangedEvent : public VirtualBox::CallbackEvent 2991 { 2992 MediumChangedEvent(VirtualBox *aVB, IMediumAttachment *aMediumAttachment) 2993 : CallbackEvent(aVB, VBoxEventType_OnMediumChanged) 2994 , mMediumAttachment(aMediumAttachment) 2995 {} 2996 2997 virtual HRESULT prepareEventDesc(IEventSource *aSource, VBoxEventDesc &aEvDesc) 2998 { 2999 return aEvDesc.init(aSource, VBoxEventType_OnMediumChanged, mMediumAttachment); 3000 } 3001 3002 IMediumAttachment* mMediumAttachment; 3003 }; 3004 3005 void VirtualBox::i_onMediumChanged(IMediumAttachment *aMediumAttachment) 3006 { 3007 i_postEvent(new MediumChangedEvent(this, aMediumAttachment)); 3008 } 3009 3010 /** Event for onStorageDeviceChanged() */ 3011 struct StorageDeviceChangedEvent : public VirtualBox::CallbackEvent 3012 { 3013 StorageDeviceChangedEvent(VirtualBox *aVB, IMediumAttachment *aStorageDevice, BOOL fRemoved, BOOL fSilent) 3014 : CallbackEvent(aVB, VBoxEventType_OnStorageDeviceChanged) 3015 , mStorageDevice(aStorageDevice) 3016 , mRemoved(fRemoved) 3017 , mSilent(fSilent) 3018 {} 3019 3020 virtual HRESULT prepareEventDesc(IEventSource *aSource, VBoxEventDesc &aEvDesc) 3021 { 3022 return aEvDesc.init(aSource, VBoxEventType_OnStorageDeviceChanged, mStorageDevice, mRemoved, mSilent); 3023 } 3024 3025 IMediumAttachment* mStorageDevice; 3026 BOOL mRemoved; 3027 BOOL mSilent; 3028 }; 3029 3030 void VirtualBox::i_onStorageDeviceChanged(IMediumAttachment *aStorageDevice, const BOOL fRemoved, const BOOL fSilent) 3031 { 3032 i_postEvent(new StorageDeviceChangedEvent(this, aStorageDevice, fRemoved, fSilent)); 3033 } 2919 3034 2920 3035 /**
Note:
See TracChangeset
for help on using the changeset viewer.