- Timestamp:
- Mar 4, 2009 5:54:03 PM (16 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/HardDiskImpl.cpp
r17086 r17359 59 59 { 60 60 enum Operation { CreateDynamic, CreateFixed, CreateDiff, 61 Merge, Clone, Delete };61 Merge, Clone, Delete, Reset }; 62 62 63 63 HardDisk *that; … … 509 509 * @param aLocaiton Storage unit location. 510 510 */ 511 HRESULT HardDisk::init (VirtualBox *aVirtualBox, CBSTR aFormat,512 CBSTR aLocation)511 HRESULT HardDisk::init (VirtualBox *aVirtualBox, CBSTR aFormat, 512 CBSTR aLocation) 513 513 { 514 514 AssertReturn (aVirtualBox != NULL, E_FAIL); … … 644 644 * 645 645 * @param aVirtualBox VirtualBox object. 646 * @param aParent Parent hard disk or NULL for a root hard disk.646 * @param aParent Parent hard disk or NULL for a root (base) hard disk. 647 647 * @param aNode <HardDisk> settings node. 648 648 * 649 649 * @note Locks VirtualBox lock for writing, treeLock() for writing. 650 650 */ 651 HRESULT HardDisk::init (VirtualBox *aVirtualBox, HardDisk *aParent,652 const settings::Key &aNode)651 HRESULT HardDisk::init (VirtualBox *aVirtualBox, HardDisk *aParent, 652 const settings::Key &aNode) 653 653 { 654 654 using namespace settings; … … 698 698 rc = setFormat (format); 699 699 CheckComRCReturnRC (rc); 700 701 /* optional, only for diffs, default is false */ 702 if (aParent != NULL) 703 mm.autoReset = aNode.value <bool> ("autoReset"); 704 else 705 mm.autoReset = false; 700 706 701 707 /* properties (after setting the format as it populates the map). Note that … … 976 982 STDMETHODIMP HardDisk::COMGETTER(LogicalSize) (ULONG64 *aLogicalSize) 977 983 { 978 if (aLogicalSize == NULL) 979 return E_POINTER; 984 CheckComArgOutPointerValid (aLogicalSize); 980 985 981 986 { … … 1003 1008 1004 1009 return root()->COMGETTER (LogicalSize) (aLogicalSize); 1010 } 1011 1012 STDMETHODIMP HardDisk::COMGETTER(AutoReset) (BOOL *aAutoReset) 1013 { 1014 CheckComArgOutPointerValid (aAutoReset); 1015 1016 AutoCaller autoCaller (this); 1017 CheckComRCReturnRC (autoCaller.rc()); 1018 1019 AutoReadLock alock (this); 1020 1021 if (mParent.isNull()) 1022 *aAutoReset = FALSE; 1023 1024 *aAutoReset = mm.autoReset; 1025 1026 return S_OK; 1027 } 1028 1029 STDMETHODIMP HardDisk::COMSETTER(AutoReset) (BOOL aAutoReset) 1030 { 1031 AutoCaller autoCaller (this); 1032 CheckComRCReturnRC (autoCaller.rc()); 1033 1034 /* VirtualBox::saveSettings() needs a write lock */ 1035 AutoMultiWriteLock2 alock (mVirtualBox, this); 1036 1037 if (mParent.isNull()) 1038 return setError (VBOX_E_NOT_SUPPORTED, 1039 tr ("Hard disk '%ls' is not differencing"), 1040 m.locationFull.raw()); 1041 1042 if (mm.autoReset != aAutoReset) 1043 { 1044 mm.autoReset = aAutoReset; 1045 1046 return mVirtualBox->saveSettings(); 1047 } 1048 1049 return S_OK; 1005 1050 } 1006 1051 … … 1394 1439 } 1395 1440 1441 STDMETHODIMP HardDisk::Reset (IProgress **aProgress) 1442 { 1443 CheckComArgOutPointerValid (aProgress); 1444 1445 AutoCaller autoCaller (this); 1446 CheckComRCReturnRC (autoCaller.rc()); 1447 1448 AutoWriteLock alock (this); 1449 1450 HRESULT rc = LockWrite (NULL); 1451 CheckComRCReturnRC (rc); 1452 1453 ComObjPtr <Progress> progress; 1454 1455 try 1456 { 1457 progress.createObject(); 1458 rc = progress->init (mVirtualBox, static_cast <IHardDisk *> (this), 1459 BstrFmt (tr ("Resettng differencing hard disk '%ls'"), 1460 m.locationFull.raw()), 1461 FALSE /* aCancelable */); 1462 CheckComRCThrowRC (rc); 1463 1464 /* setup task object and thread to carry out the operation 1465 * asynchronously */ 1466 1467 std::auto_ptr <Task> task (new Task (this, progress, Task::Reset)); 1468 AssertComRCThrowRC (task->autoCaller.rc()); 1469 1470 rc = task->startThread(); 1471 CheckComRCThrowRC (rc); 1472 1473 /* task is now owned (or already deleted) by taskThread() so release it */ 1474 task.release(); 1475 } 1476 catch (HRESULT aRC) 1477 { 1478 rc = aRC; 1479 } 1480 1481 if (FAILED (rc)) 1482 { 1483 HRESULT rc2 = UnlockWrite (NULL); 1484 AssertComRC (rc2); 1485 /* Note: on success, taskThread() will unlock this */ 1486 } 1487 else 1488 { 1489 /* return progress to the caller */ 1490 progress.queryInterfaceTo (aProgress); 1491 } 1492 1493 return rc; 1494 } 1495 1396 1496 // public methods for internal purposes only 1397 1497 //////////////////////////////////////////////////////////////////////////////// … … 1553 1653 /* required */ 1554 1654 diskNode.setValue <Bstr> ("format", mm.format); 1655 /* optional, only for diffs, default is false */ 1656 if (!mParent.isNull()) 1657 diskNode.setValueOr <bool> ("autoReset", !!mm.autoReset, false); 1555 1658 /* optional */ 1556 1659 if (!m.description.isNull()) … … 4052 4155 } 4053 4156 4157 case Task::Reset: 4158 { 4159 /// @todo 4160 4161 if (isAsync) 4162 { 4163 /* unlock ourselves when done */ 4164 HRESULT rc2 = that->UnlockWrite (NULL); 4165 AssertComRC (rc2); 4166 } 4167 4168 /* Note that in sync mode, it's the caller's responsibility to 4169 * unlock the hard disk */ 4170 4171 break; 4172 } 4173 4054 4174 default: 4055 4175 AssertFailedReturn (VERR_GENERAL_FAILURE); -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r17358 r17359 8314 8314 <interface 8315 8315 name="IHardDisk" extends="IMedium" 8316 uuid=" 244f89fe-1943-464d-baad-2efd73e5d532"8316 uuid="a4d391a5-e2b1-474d-824e-2ff668a92d58" 8317 8317 wsmap="managed" 8318 8318 > … … 8711 8711 </attribute> 8712 8712 8713 <attribute name="autoReset" type="boolean"> 8714 <desc> 8715 Whether this differencing hard disk will be automatically reset each 8716 time a virtual machine it is attached to is powered up. 8717 8718 See <link to="#reset()"/> for more information about resetting 8719 differencing hard disks. 8720 8721 <note> 8722 Reading this property on a base (non-differencing) hard disk will 8723 always <tt>false</tt>. Changing the value of this property in this 8724 case is not supported. 8725 </note> 8726 8727 <result name="VBOX_E_NOT_SUPPORTED"> 8728 This is not a differencing hard disk (when changing the attribute 8729 value). 8730 </result> 8731 </desc> 8732 </attribute> 8733 8713 8734 <!-- storage methods --> 8714 8735 … … 9118 9139 </method> 9119 9140 9141 <!-- other methods --> 9142 9120 9143 <method name="compact"> 9121 9144 <desc> … … 9125 9148 substantial amount of additional disk space. 9126 9149 9127 After the returned progress object reports that the operation is 9128 successfully complete, the media state will be set back to the 9129 current state. 9130 9131 <note> 9132 This hard disk and all its parent hard disks will be placed to <link 9133 to="MediaState_LockedRead"/> state for the duration of this 9134 operation. 9135 </note> 9150 This hard disk will be placed to <link to="MediaState_LockedWrite"/> 9151 state and all its parent hard disks (if any) will be placed to 9152 <link to="MediaState_LockedRead"/> state for the duration of this 9153 operation. 9154 </desc> 9155 <param name="progress" type="IProgress" dir="return"> 9156 <desc>Progress object to track the operation completion.</desc> 9157 </param> 9158 </method> 9159 9160 <method name="reset"> 9161 <desc> 9162 Starts erasing the contents of this differencing hard disk. 9163 9164 This operation will reset the differencing hard disk to its initial 9165 state when it does not contain any sector data and any read operation is 9166 redirected to its parent hard disk. 9167 9168 This hard disk will be placed to <link to="MediaState_LockedWrite"/> 9169 for the duration of this operation. 9170 9171 <result name="VBOX_E_NOT_SUPPORTED"> 9172 This is not a differencing hard disk. 9173 </result> 9174 <result name="VBOX_E_INVALID_OBJECT_STATE"> 9175 Hard disk is not in <link to="MediaState_Created"/> or 9176 <link to="MediaState_Inaccessible"/> state. 9177 </result> 9136 9178 </desc> 9137 9179 <param name="progress" type="IProgress" dir="return"> -
trunk/src/VBox/Main/include/HardDiskImpl.h
r16873 r17359 97 97 STDMETHOD(COMGETTER(ReadOnly)) (BOOL *aReadOnly); 98 98 STDMETHOD(COMGETTER(LogicalSize)) (ULONG64 *aLogicalSize); 99 STDMETHOD(COMGETTER(AutoReset)) (BOOL *aAutoReset); 100 STDMETHOD(COMSETTER(AutoReset)) (BOOL aAutoReset); 99 101 100 102 // IHardDisk methods … … 114 116 STDMETHOD(FlattenTo) (IHardDisk *aTarget, IProgress **aProgress); 115 117 STDMETHOD(Compact) (IProgress **aProgress); 118 STDMETHOD(Reset) (IProgress **aProgress); 116 119 117 120 // public methods for internal purposes only … … 269 272 struct Data 270 273 { 271 Data() : type (HardDiskType_Normal), logicalSize (0) 274 Data() : type (HardDiskType_Normal), logicalSize (0), autoReset (false) 272 275 , implicit (false), numCreateDiffTasks (0) 273 276 , vdProgress (NULL) , vdDiskIfaces (NULL) {} … … 279 282 uint64_t logicalSize; /*< In MBytes. */ 280 283 284 BOOL autoReset : 1; 285 281 286 typedef std::map <Bstr, Bstr> PropertyMap; 282 287 PropertyMap properties; -
trunk/src/VBox/Main/xml/VirtualBox-settings-common.xsd
r17075 r17359 263 263 --> 264 264 265 <xsd:complexType name="T DiffHardDisk2">265 <xsd:complexType name="THardDiskBase"> 266 266 <xsd:sequence> 267 267 <xsd:element name="Description" type="xsd:string" minOccurs="0"/> … … 272 272 </xsd:complexType> 273 273 </xsd:element> 274 <xsd:element name="HardDisk" type="TDiffHardDisk 2" minOccurs="0" maxOccurs="unbounded"/>274 <xsd:element name="HardDisk" type="TDiffHardDisk" minOccurs="0" maxOccurs="unbounded"/> 275 275 </xsd:sequence> 276 276 <xsd:attribute name="uuid" type="TNonNullUUID" use="required"/> … … 279 279 </xsd:complexType> 280 280 281 <xsd:complexType name="T HardDisk2">281 <xsd:complexType name="TDiffHardDisk"> 282 282 <xsd:complexContent> 283 <xsd:extension base="TDiffHardDisk2"> 283 <xsd:extension base="THardDiskBase"> 284 <xsd:attribute name="autoReset" type="xsd:boolean" default="false"/> 285 </xsd:extension> 286 </xsd:complexContent> 287 </xsd:complexType> 288 289 <xsd:complexType name="THardDisk"> 290 <xsd:complexContent> 291 <xsd:extension base="THardDiskBase"> 284 292 <xsd:attribute name="type" use="required"> 285 293 <xsd:simpleType> … … 374 382 <xsd:complexType> 375 383 <xsd:sequence> 376 <xsd:element name="HardDisk" type="THardDisk 2" minOccurs="0" maxOccurs="unbounded"/>384 <xsd:element name="HardDisk" type="THardDisk" minOccurs="0" maxOccurs="unbounded"/> 377 385 </xsd:sequence> 378 386 </xsd:complexType>
Note:
See TracChangeset
for help on using the changeset viewer.