- Timestamp:
- Nov 17, 2009 3:27:03 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/MediumImpl.cpp
r24691 r24725 103 103 implicit(false), 104 104 numCreateDiffTasks(0), 105 vdProgress(NULL),106 105 vdDiskIfaces(NULL) 107 106 {} … … 150 149 151 150 Utf8Str vdError; /*< Error remembered by the VD error callback. */ 152 Progress *vdProgress; /*< Progress for the VD progress callback. */153 151 154 152 VDINTERFACE vdIfError; 155 153 VDINTERFACEERROR vdIfCallsError; 156 157 VDINTERFACE vdIfProgress;158 VDINTERFACEPROGRESS vdIfCallsProgress;159 154 160 155 VDINTERFACE vdIfConfig; … … 798 793 m->vdIfCallsError.pfnMessage = NULL; 799 794 800 /* Initialize the callbacks of the VD progress interface */801 m->vdIfCallsProgress.cbSize = sizeof(VDINTERFACEPROGRESS);802 m->vdIfCallsProgress.enmInterface = VDINTERFACETYPE_PROGRESS;803 m->vdIfCallsProgress.pfnProgress = vdProgressCall;804 805 795 /* Initialize the callbacks of the VD config interface */ 806 796 m->vdIfCallsConfig.cbSize = sizeof(VDINTERFACECONFIG); … … 811 801 812 802 /* Initialize the callbacks of the VD TCP interface (we always use the host 813 ** IP stack for now) */803 * IP stack for now) */ 814 804 m->vdIfCallsTcpNet.cbSize = sizeof(VDINTERFACETCPNET); 815 805 m->vdIfCallsTcpNet.enmInterface = VDINTERFACETYPE_TCPNET; … … 829 819 AssertRCReturn(vrc, E_FAIL); 830 820 831 vrc = VDInterfaceAdd(&m->vdIfProgress,832 "Medium::vdInterfaceProgress",833 VDINTERFACETYPE_PROGRESS,834 &m->vdIfCallsProgress, this, &m->vdDiskIfaces);835 AssertRCReturn(vrc, E_FAIL);836 821 vrc = VDInterfaceAdd(&m->vdIfConfig, 837 822 "Medium::vdInterfaceConfig", … … 4767 4752 void *pvUser) 4768 4753 { 4769 Medium *that = static_cast<Medium*>(pvUser); 4770 AssertReturn(that != NULL, VERR_GENERAL_FAILURE); 4771 4772 if (that->m->vdProgress != NULL) 4754 Progress *that = static_cast<Progress *>(pvUser); 4755 4756 if (that != NULL) 4773 4757 { 4774 4758 /* update the progress object, capping it at 99% as the final percent 4775 4759 * is used for additional operations like setting the UUIDs and similar. */ 4776 HRESULT rc = that-> m->vdProgress->SetCurrentOperationProgress(uPercent * 99 / 100);4760 HRESULT rc = that->SetCurrentOperationProgress(uPercent * 99 / 100); 4777 4761 if (FAILED(rc)) 4778 4762 { … … 4866 4850 4867 4851 Medium *that = task->that; 4852 4853 /* Set up a per-operation progress interface, can be used freely (for 4854 * binary operations you can use it either on the source or target). */ 4855 VDINTERFACEPROGRESS vdIfCallsProgress; 4856 vdIfCallsProgress.cbSize = sizeof(VDINTERFACEPROGRESS); 4857 vdIfCallsProgress.enmInterface = VDINTERFACETYPE_PROGRESS; 4858 vdIfCallsProgress.pfnProgress = Medium::vdProgressCall; 4859 VDINTERFACE vdIfProgress; 4860 PVDINTERFACE vdOperationIfaces = NULL; 4861 int vrc = VDInterfaceAdd(&vdIfProgress, 4862 "Medium::vdInterfaceProgress", 4863 VDINTERFACETYPE_PROGRESS, 4864 &vdIfCallsProgress, task->progress, &vdOperationIfaces); 4865 AssertRCReturn(vrc, E_FAIL); 4868 4866 4869 4867 /// @todo ugly hack, fix ComAssert... later … … 4923 4921 PDMMEDIAGEOMETRY geo = { 0 }; /* auto-detect */ 4924 4922 4925 /* needed for vdProgressCallback */4926 that->m->vdProgress = task->progress;4927 4928 4923 vrc = VDCreateBase(hdd, format.c_str(), location.c_str(), 4929 4924 task->d.size * _1M, … … 4931 4926 NULL, &geo, &geo, id.raw(), 4932 4927 VD_OPEN_FLAGS_NORMAL, 4933 NULL, that->m->vdDiskIfaces); 4934 4928 NULL, vdOperationIfaces); 4935 4929 if (RT_FAILURE(vrc)) 4936 4930 { … … 5042 5036 CheckComRCThrowRC(rc); 5043 5037 5044 /* needed for vdProgressCallback */5045 that->m->vdProgress = task->progress;5046 5047 5038 /** @todo add VD_IMAGE_FLAGS_DIFF to the image flags, to 5048 5039 * be on the safe side. */ … … 5054 5045 VD_OPEN_FLAGS_NORMAL, 5055 5046 target->m->vdDiskIfaces, 5056 that->m->vdDiskIfaces); 5057 5058 that->m->vdProgress = NULL; 5059 5047 vdOperationIfaces); 5060 5048 if (RT_FAILURE(vrc)) 5061 5049 { … … 5079 5067 * here), but lock VirtualBox first to follow the rule */ 5080 5068 AutoMultiWriteLock2 alock(that->mVirtualBox->lockHandle(), 5081 5069 that->treeLock()); 5082 5070 5083 5071 Assert(target->mParent.isNull()); … … 5089 5077 target->mVirtualBox->removeDependentChild(target); 5090 5078 5079 /** @todo r=klaus neither target nor that->base() are locked, 5080 * potential race! */ 5091 5081 /* diffs for immutable hard disks are auto-reset by default */ 5092 5082 target->m->autoReset = … … 5215 5205 } 5216 5206 5217 /* needed for vdProgressCallback */5218 that->m->vdProgress = task->progress;5219 5220 5207 unsigned start = chain->isForward() ? 5221 5208 0 : (unsigned)chain->size() - 1; … … 5225 5212 LogFlow(("*** MERGE from %d to %d\n", start, end)); 5226 5213 #endif 5227 vrc = VDMerge(hdd, start, end, that->m->vdDiskIfaces); 5228 5229 that->m->vdProgress = NULL; 5230 5214 vrc = VDMerge(hdd, start, end, vdOperationIfaces); 5231 5215 if (RT_FAILURE(vrc)) 5232 5216 throw vrc; … … 5507 5491 } 5508 5492 5509 /* unlock before the potentially lengthy operation */5510 thatLock.leave();5511 5512 5493 Utf8Str targetFormat(target->m->strFormat); 5513 5494 Utf8Str targetLocation(target->m->strLocationFull); … … 5518 5499 Assert(parent.isNull() || parent->m->state == MediumState_LockedRead); 5519 5500 5501 /* unlock before the potentially lengthy operation */ 5502 thatLock.leave(); 5503 5520 5504 /* ensure the target directory exists */ 5521 5505 rc = VirtualBox::ensureFilePathExists(targetLocation); 5522 5506 CheckComRCThrowRC(rc); 5523 5524 /* needed for vdProgressCallback */5525 that->m->vdProgress = task->progress;5526 5507 5527 5508 PVBOXHDD targetHdd; … … 5535 5516 it != parentChain->end(); ++ it) 5536 5517 { 5518 /** @todo r=klaus (*it) is not locked, lots of 5519 * race opportunities below */ 5537 5520 /* sanity check */ 5538 5521 Assert( (*it)->m->state == MediumState_LockedRead … … 5553 5536 } 5554 5537 5538 /** @todo r=klaus target isn't locked, race getting the state */ 5555 5539 vrc = VDCopy(hdd, VD_LAST_IMAGE, targetHdd, 5556 5540 targetFormat.c_str(), … … 5559 5543 task->d.variant, targetId.raw(), NULL, 5560 5544 target->m->vdDiskIfaces, 5561 that->m->vdDiskIfaces); 5562 5563 that->m->vdProgress = NULL; 5564 5545 vdOperationIfaces); 5565 5546 if (RT_FAILURE(vrc)) 5566 5547 { … … 5770 5751 } 5771 5752 5772 /* needed for vdProgressCallback */5773 that->m->vdProgress = task->progress;5774 5775 5753 vrc = VDCreateDiff(hdd, format.c_str(), location.c_str(), 5776 5754 /// @todo use the same image variant as before … … 5780 5758 VD_OPEN_FLAGS_NORMAL, 5781 5759 that->m->vdDiskIfaces, 5782 that->m->vdDiskIfaces); 5783 5784 that->m->vdProgress = NULL; 5785 5760 vdOperationIfaces); 5786 5761 if (RT_FAILURE(vrc)) 5787 5762 { … … 5863 5838 } 5864 5839 5840 Assert(that->m->state == MediumState_LockedWrite); 5841 5842 Utf8Str location(that->m->strLocationFull); 5843 5865 5844 /* unlock before the potentially lengthy operation */ 5866 5845 thatLock.leave(); 5867 5846 5868 Assert(that->m->state == MediumState_LockedWrite); 5869 5870 /* needed for vdProgressCallback */ 5871 that->m->vdProgress = task->progress; 5872 5873 vrc = VDCompact(hdd, VD_LAST_IMAGE, that->m->vdDiskIfaces); 5874 5875 that->m->vdProgress = NULL; 5876 5847 vrc = VDCompact(hdd, VD_LAST_IMAGE, vdOperationIfaces); 5877 5848 if (RT_FAILURE(vrc)) 5878 5849 { … … 5880 5851 throw setError(VBOX_E_NOT_SUPPORTED, 5881 5852 tr("Compacting is not yet supported for hard disk '%s'"), 5882 that->m->strLocationFull.raw());5853 location.raw()); 5883 5854 else if (vrc == VERR_NOT_IMPLEMENTED) 5884 5855 throw setError(E_NOTIMPL, 5885 5856 tr("Compacting is not implemented, hard disk '%s'"), 5886 that->m->strLocationFull.raw());5857 location.raw()); 5887 5858 else 5888 5859 throw setError(E_FAIL, 5889 5860 tr("Could not compact hard disk '%s'%s"), 5890 that->m->strLocationFull.raw(),5861 location.raw(), 5891 5862 that->vdError(vrc).raw()); 5892 5863 }
Note:
See TracChangeset
for help on using the changeset viewer.