- Timestamp:
- Mar 23, 2009 7:28:13 PM (16 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp
r17970 r18162 1249 1249 { 1250 1250 ComPtr<IHardDisk> hardDisk; 1251 CHECK_ERROR(aVirtualBox, OpenHardDisk(filename, hardDisk.asOutParam()));1251 CHECK_ERROR(aVirtualBox, OpenHardDisk(filename, TRUE /* fWrite */, hardDisk.asOutParam())); 1252 1252 } 1253 1253 -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageDisk.cpp
r18108 r18162 521 521 if (FAILED (rc)) 522 522 { 523 CHECK_ERROR(a->virtualBox, OpenHardDisk(src, srcDisk.asOutParam()));523 CHECK_ERROR(a->virtualBox, OpenHardDisk(src, TRUE /* fWrite */, srcDisk.asOutParam())); 524 524 if (SUCCEEDED (rc)) 525 525 { … … 943 943 if (FAILED (rc)) 944 944 { 945 CHECK_ERROR(a->virtualBox, OpenHardDisk(filepath, hardDisk.asOutParam()));945 CHECK_ERROR(a->virtualBox, OpenHardDisk(filepath, TRUE /* fWrite */, hardDisk.asOutParam())); 946 946 if (SUCCEEDED (rc)) 947 947 { … … 1083 1083 1084 1084 ComPtr<IHardDisk> hardDisk; 1085 CHECK_ERROR(a->virtualBox, OpenHardDisk(filepath, hardDisk.asOutParam()));1085 CHECK_ERROR(a->virtualBox, OpenHardDisk(filepath, TRUE /* fWrite */, hardDisk.asOutParam())); 1086 1086 if (SUCCEEDED(rc) && hardDisk) 1087 1087 { -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp
r18072 r18162 1054 1054 { 1055 1055 /* open the new hard disk object */ 1056 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[0]), hardDisk.asOutParam()));1056 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[0]), TRUE /* fWrite */, hardDisk.asOutParam())); 1057 1057 } 1058 1058 } … … 1087 1087 { 1088 1088 /* open the new hard disk object */ 1089 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[1]), hardDisk.asOutParam()));1089 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[1]), TRUE /* fWrite */, hardDisk.asOutParam())); 1090 1090 } 1091 1091 } … … 1120 1120 { 1121 1121 /* open the new hard disk object */ 1122 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[2]), hardDisk.asOutParam()));1122 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[2]), TRUE /* fWrite */, hardDisk.asOutParam())); 1123 1123 } 1124 1124 } … … 1833 1833 { 1834 1834 /* open the new hard disk object */ 1835 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[i]), hardDisk.asOutParam()));1835 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[i]), TRUE /* fWrite */, hardDisk.asOutParam())); 1836 1836 } 1837 1837 } … … 1922 1922 { 1923 1923 /* open the new hard disk object */ 1924 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[i]), hardDisk.asOutParam()));1924 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[i]), TRUE /* fWrite */, hardDisk.asOutParam())); 1925 1925 } 1926 1926 } -
trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp
r17737 r18162 1670 1670 /* we've not found the image */ 1671 1671 RTPrintf("Adding hard disk '%S'...\n", hdaFile); 1672 virtualBox->OpenHardDisk(hdaFileBstr, hardDisk.asOutParam());1672 virtualBox->OpenHardDisk(hdaFileBstr, TRUE /* fWrite */, hardDisk.asOutParam()); 1673 1673 } 1674 1674 /* do we have the right image now? */ -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxMediaManagerDlg.cpp
r17669 r18162 1545 1545 case VBoxDefs::MediaType_HardDisk: 1546 1546 { 1547 CHardDisk hd = mVBox.OpenHardDisk(aLocation );1547 CHardDisk hd = mVBox.OpenHardDisk(aLocation, TRUE /* fWrite */); 1548 1548 if (mVBox.isOk()) 1549 1549 { -
trunk/src/VBox/Main/ApplianceImpl.cpp
r18153 r18162 2311 2311 2312 2312 /* First open the existing disk image */ 2313 rc = pVirtualBox->OpenHardDisk(Bstr(strSrcFilePath), srcHdVBox.asOutParam()); 2313 rc = pVirtualBox->OpenHardDisk(Bstr(strSrcFilePath), 2314 FALSE, // read-only 2315 srcHdVBox.asOutParam()); 2314 2316 if (FAILED(rc)) throw rc; 2315 2317 fSourceHdNeedsClosing = true; -
trunk/src/VBox/Main/HardDiskImpl.cpp
r18121 r18162 624 624 * @param aLocaiton Storage unit location. 625 625 */ 626 HRESULT HardDisk::init (VirtualBox *aVirtualBox, CBSTR aFormat, 626 HRESULT HardDisk::init (VirtualBox *aVirtualBox, 627 CBSTR aFormat, 627 628 CBSTR aLocation) 628 629 { … … 695 696 /** 696 697 * Initializes the hard disk object by opening the storage unit at the specified 697 * location. 698 * location. If the fWrite parameter is true, then the image will be opened 699 * read/write, otherwise it will be opened read-only. 698 700 * 699 701 * Note that the UUID, format and the parent of this hard disk will be … … 704 706 * @param aLocaiton Storage unit location. 705 707 */ 706 HRESULT HardDisk::init (VirtualBox *aVirtualBox, CBSTR aLocation) 708 HRESULT HardDisk::init(VirtualBox *aVirtualBox, 709 CBSTR aLocation, 710 HDDOpenMode enOpenMode) 707 711 { 708 712 AssertReturn (aVirtualBox, E_INVALIDARG); … … 729 733 730 734 /* get all the information about the medium from the storage unit */ 731 rc = queryInfo( );735 rc = queryInfo((enOpenMode == OpenReadWrite) /* fWrite */ ); 732 736 if (SUCCEEDED (rc)) 733 737 { … … 756 760 /** 757 761 * Initializes the hard disk object by loading its data from the given settings 758 * node. 762 * node. In this mode, the image will always be opened read/write. 759 763 * 760 764 * @param aVirtualBox VirtualBox object. … … 764 768 * @note Locks VirtualBox lock for writing, treeLock() for writing. 765 769 */ 766 HRESULT HardDisk::init (VirtualBox *aVirtualBox, HardDisk *aParent, 770 HRESULT HardDisk::init (VirtualBox *aVirtualBox, 771 HardDisk *aParent, 767 772 const settings::Key &aNode) 768 773 { … … 869 874 ComObjPtr<HardDisk> hardDisk; 870 875 hardDisk.createObject(); 871 rc = hardDisk->init 876 rc = hardDisk->init(aVirtualBox, this, *it); 872 877 CheckComRCBreakRC (rc); 873 878 … … 2991 2996 * writing. 2992 2997 */ 2993 HRESULT HardDisk::queryInfo( )2998 HRESULT HardDisk::queryInfo(bool fWrite) 2994 2999 { 2995 3000 AutoWriteLock alock (this); … … 3074 3079 * time in VirtualBox (such as VMDK for which VDOpen() needs to 3075 3080 * generate an UUID if it is missing) */ 3076 if (! isImport)3081 if (!fWrite || !isImport) 3077 3082 flags |= VD_OPEN_FLAGS_READONLY; 3078 3083 -
trunk/src/VBox/Main/MachineImpl.cpp
r18158 r18162 2152 2152 ComObjPtr<HardDisk> diff; 2153 2153 diff.createObject(); 2154 rc = diff->init (mParent, hd->preferredDiffFormat(), 2155 BstrFmt ("%ls"RTPATH_SLASH_STR, 2156 mUserData->mSnapshotFolderFull.raw())); 2154 rc = diff->init(mParent, 2155 hd->preferredDiffFormat(), 2156 BstrFmt ("%ls"RTPATH_SLASH_STR, 2157 mUserData->mSnapshotFolderFull.raw())); 2157 2158 CheckComRCReturnRC (rc); 2158 2159 -
trunk/src/VBox/Main/VirtualBoxImpl.cpp
r18049 r18162 1125 1125 ComObjPtr<HardDisk> hardDisk; 1126 1126 hardDisk.createObject(); 1127 rc = hardDisk->init 1127 rc = hardDisk->init(this, format, aLocation); 1128 1128 1129 1129 if (SUCCEEDED (rc)) … … 1133 1133 } 1134 1134 1135 STDMETHODIMP VirtualBox::OpenHardDisk(IN_BSTR aLocation, 1136 IHardDisk **aHardDisk) 1135 STDMETHODIMP VirtualBox::OpenHardDisk(IN_BSTR aLocation, BOOL fWrite, IHardDisk **aHardDisk) 1137 1136 { 1138 1137 CheckComArgNotNull(aLocation); … … 1148 1147 ComObjPtr<HardDisk> hardDisk; 1149 1148 hardDisk.createObject(); 1150 rc = hardDisk->init (this, aLocation); 1149 rc = hardDisk->init(this, 1150 aLocation, 1151 (fWrite) ? HardDisk::OpenReadWrite : HardDisk::OpenReadOnly ); 1151 1152 1152 1153 if (SUCCEEDED (rc)) … … 3091 3092 ComObjPtr<HardDisk> hardDisk; 3092 3093 hardDisk.createObject(); 3093 rc = hardDisk->init 3094 rc = hardDisk->init(this, NULL, *it); 3094 3095 CheckComRCBreakRC (rc); 3095 3096 -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r18107 r18162 1874 1874 by reading hard disk data at the specified location. 1875 1875 1876 If @write is true, the image is opened for read/write access and must 1877 have according permissions, as VirtualBox may actually write status 1878 information into the disk's metadata sections. Note that write access 1879 is required for all typical image usage in VirtualBox, since VirtualBox 1880 may need to write metadata such as a UUID into the image. The only 1881 exception is opening a source image temporarily for copying and 1882 cloning when the image will quickly be closed againl. 1883 1876 1884 Note that the format of the location string is storage format specific. 1877 1885 See <link to="IMedium::location"/>, IHardDisk and 1878 1886 <link to="ISystemProperties::defaultHardDiskFolder"/> for more details. 1879 1887 1880 1881 1888 <result name="VBOX_E_FILE_ERROR"> 1882 1889 Invalid hard disk storage file location. … … 1895 1902 the supported storage formats. 1896 1903 </desc> 1904 </param> 1905 <param name="write" type="boolean" dir="in"> 1906 <desc> 1907 If true, opens for read/write access. If false, opens for read access only. 1908 </desc> 1897 1909 </param> 1898 1910 <param name="hardDisk" type="IHardDisk" dir="return"> … … 3352 3364 3353 3365 <method name="getDescriptionByType"> 3354 <desc>This is the same as <link to="getDescription" /> except that you can specify which types 3366 <desc>This is the same as <link to="getDescription" /> except that you can specify which types 3355 3367 should be returned.</desc> 3356 3368 -
trunk/src/VBox/Main/include/HardDiskImpl.h
r18115 r18162 77 77 void FinalRelease(); 78 78 79 enum HDDOpenMode { OpenReadWrite, OpenReadOnly }; 80 // have to use a special enum or otherwise the overloaded init() is ambiguous 81 79 82 // public initializer/uninitializer for internal purposes only 80 HRESULT init (VirtualBox *aVirtualBox, CBSTR aFormat, 81 CBSTR aLocation); 82 HRESULT init (VirtualBox *aVirtualBox, 83 CBSTR aLocation); 84 HRESULT init (VirtualBox *aVirtualBox, HardDisk *aParent, 85 const settings::Key &aNode); 83 HRESULT init(VirtualBox *aVirtualBox, 84 CBSTR aFormat, 85 CBSTR aLocation); 86 HRESULT init(VirtualBox *aVirtualBox, 87 CBSTR aLocation, 88 HDDOpenMode enOpenMode); 89 HRESULT init(VirtualBox *aVirtualBox, 90 HardDisk *aParent, 91 const settings::Key &aNode); 86 92 void uninit(); 87 93 … … 248 254 HRESULT setFormat (CBSTR aFormat); 249 255 250 HRESULT queryInfo( );256 HRESULT queryInfo(bool fWrite); 251 257 252 258 HRESULT canClose(); -
trunk/src/VBox/Main/include/VirtualBoxImpl.h
r18023 r18162 151 151 STDMETHOD(CreateHardDisk)(IN_BSTR aFormat, IN_BSTR aLocation, 152 152 IHardDisk **aHardDisk); 153 STDMETHOD(OpenHardDisk) (IN_BSTR aLocation, IHardDisk **aHardDisk);153 STDMETHOD(OpenHardDisk) (IN_BSTR aLocation, BOOL fWrite, IHardDisk **aHardDisk); 154 154 STDMETHOD(GetHardDisk) (IN_GUID aId, IHardDisk **aHardDisk); 155 155 STDMETHOD(FindHardDisk) (IN_BSTR aLocation, IHardDisk **aHardDisk);
Note:
See TracChangeset
for help on using the changeset viewer.