Changeset 20842 in vbox
- Timestamp:
- Jun 23, 2009 2:48:10 PM (15 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 11 edited
-
Frontends/VBoxManage/VBoxInternalManage.cpp (modified) (1 diff)
-
Frontends/VBoxManage/VBoxManageDisk.cpp (modified) (13 diffs)
-
Frontends/VBoxManage/VBoxManageModifyVM.cpp (modified) (5 diffs)
-
Frontends/VBoxSDL/VBoxSDL.cpp (modified) (3 diffs)
-
Frontends/VirtualBox/src/VBoxMediaManagerDlg.cpp (modified) (1 diff)
-
Main/ApplianceImpl.cpp (modified) (1 diff)
-
Main/HardDiskImpl.cpp (modified) (6 diffs)
-
Main/VirtualBoxImpl.cpp (modified) (2 diffs)
-
Main/idl/VirtualBox.xidl (modified) (2 diffs)
-
Main/include/HardDiskImpl.h (modified) (3 diffs)
-
Main/include/VirtualBoxImpl.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp
r20629 r20842 1265 1265 { 1266 1266 ComPtr<IHardDisk> hardDisk; 1267 CHECK_ERROR(aVirtualBox, OpenHardDisk(filename, AccessMode_ReadWrite, hardDisk.asOutParam()));1267 CHECK_ERROR(aVirtualBox, OpenHardDisk(filename, AccessMode_ReadWrite, false, Bstr(""), false, Bstr(""), hardDisk.asOutParam())); 1268 1268 } 1269 1269 -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageDisk.cpp
r20221 r20842 447 447 { 448 448 unknown = true; 449 rc = a->virtualBox->OpenHardDisk(Bstr(FilenameOrUuid), AccessMode_ReadWrite, hardDisk.asOutParam());449 rc = a->virtualBox->OpenHardDisk(Bstr(FilenameOrUuid), AccessMode_ReadWrite, false, Bstr(""), false, Bstr(""), hardDisk.asOutParam()); 450 450 if (rc == VBOX_E_FILE_ERROR) 451 451 { … … 457 457 return 1; 458 458 } 459 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(szFilenameAbs), AccessMode_ReadWrite, hardDisk.asOutParam()));459 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(szFilenameAbs), AccessMode_ReadWrite, false, Bstr(""), false, Bstr(""), hardDisk.asOutParam())); 460 460 } 461 461 else if (FAILED(rc)) 462 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(FilenameOrUuid), AccessMode_ReadWrite, hardDisk.asOutParam()));462 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(FilenameOrUuid), AccessMode_ReadWrite, false, Bstr(""), false, Bstr(""), hardDisk.asOutParam())); 463 463 } 464 464 if (SUCCEEDED(rc) && hardDisk) … … 594 594 if (FAILED (rc)) 595 595 { 596 rc = a->virtualBox->OpenHardDisk(src, AccessMode_ReadWrite, srcDisk.asOutParam());596 rc = a->virtualBox->OpenHardDisk(src, AccessMode_ReadWrite, false, Bstr(""), false, Bstr(""), srcDisk.asOutParam()); 597 597 if (rc == VBOX_E_FILE_ERROR) 598 598 { … … 604 604 return 1; 605 605 } 606 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(szFilenameAbs), AccessMode_ReadWrite, srcDisk.asOutParam()));606 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(szFilenameAbs), AccessMode_ReadWrite, false, Bstr(""), false, Bstr(""), srcDisk.asOutParam())); 607 607 } 608 608 else if (FAILED(rc)) 609 CHECK_ERROR(a->virtualBox, OpenHardDisk(src, AccessMode_ReadWrite, srcDisk.asOutParam()));609 CHECK_ERROR(a->virtualBox, OpenHardDisk(src, AccessMode_ReadWrite, false, Bstr(""), false, Bstr(""), srcDisk.asOutParam())); 610 610 if (SUCCEEDED (rc)) 611 611 { … … 1111 1111 if (FAILED (rc)) 1112 1112 { 1113 rc = a->virtualBox->OpenHardDisk(Bstr(FilenameOrUuid), AccessMode_ReadWrite, hardDisk.asOutParam());1113 rc = a->virtualBox->OpenHardDisk(Bstr(FilenameOrUuid), AccessMode_ReadWrite, false, Bstr(""), false, Bstr(""), hardDisk.asOutParam()); 1114 1114 if (rc == VBOX_E_FILE_ERROR) 1115 1115 { … … 1121 1121 return 1; 1122 1122 } 1123 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(szFilenameAbs), AccessMode_ReadWrite, hardDisk.asOutParam()));1123 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(szFilenameAbs), AccessMode_ReadWrite, false, Bstr(""), false, Bstr(""), hardDisk.asOutParam())); 1124 1124 } 1125 1125 else if (FAILED(rc)) 1126 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(FilenameOrUuid), AccessMode_ReadWrite, hardDisk.asOutParam()));1126 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(FilenameOrUuid), AccessMode_ReadWrite, false, Bstr(""), false, Bstr(""), hardDisk.asOutParam())); 1127 1127 if (SUCCEEDED (rc)) 1128 1128 { … … 1244 1244 { "--type", 't', RTGETOPT_REQ_STRING }, 1245 1245 { "-type", 't', RTGETOPT_REQ_STRING }, // deprecated 1246 { "--uuid", 'u', RTGETOPT_REQ_UUID }, 1247 { "--parentuuid", 'p', RTGETOPT_REQ_UUID }, 1246 1248 }; 1247 1249 … … 1259 1261 HardDiskType_T DiskType = HardDiskType_Normal; 1260 1262 bool fDiskType = false; 1263 bool fSetImageId = false; 1264 bool fSetParentId = false; 1265 Guid ImageId; 1266 ImageId.clear(); 1267 Guid ParentId; 1268 ParentId.clear(); 1261 1269 1262 1270 int c; … … 1292 1300 return errorArgument("Invalid hard disk type '%s'", ValueUnion.psz); 1293 1301 fDiskType = true; 1302 break; 1303 1304 case 'u': // --uuid 1305 ImageId = ValueUnion.Uuid; 1306 fSetImageId = true; 1307 break; 1308 1309 case 'p': // --parentuuid 1310 ParentId = ValueUnion.Uuid; 1311 fSetParentId = true; 1294 1312 break; 1295 1313 … … 1334 1352 { 1335 1353 ComPtr<IHardDisk> hardDisk; 1336 rc = a->virtualBox->OpenHardDisk(Bstr(Filename), AccessMode_ReadWrite, hardDisk.asOutParam()); 1354 Bstr ImageIdStr = BstrFmt("%RTuuid", &ImageId); 1355 Bstr ParentIdStr = BstrFmt("%RTuuid", &ParentId); 1356 rc = a->virtualBox->OpenHardDisk(Bstr(Filename), AccessMode_ReadWrite, fSetImageId, ImageIdStr, fSetParentId, ParentIdStr, hardDisk.asOutParam()); 1337 1357 if (rc == VBOX_E_FILE_ERROR) 1338 1358 { … … 1344 1364 return 1; 1345 1365 } 1346 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(szFilenameAbs), AccessMode_ReadWrite, hardDisk.asOutParam()));1366 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(szFilenameAbs), AccessMode_ReadWrite, fSetImageId, ImageIdStr, fSetParentId, ParentIdStr, hardDisk.asOutParam())); 1347 1367 } 1348 1368 else if (FAILED(rc)) 1349 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(Filename), AccessMode_ReadWrite, hardDisk.asOutParam()));1369 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(Filename), AccessMode_ReadWrite, fSetImageId, ImageIdStr, fSetParentId, ParentIdStr, hardDisk.asOutParam())); 1350 1370 if (SUCCEEDED(rc) && hardDisk) 1351 1371 { … … 1359 1379 else if (cmd == CMD_DVD) 1360 1380 { 1361 if (fDiskType )1381 if (fDiskType || fSetImageId || fSetParentId) 1362 1382 return errorSyntax(USAGE_OPENMEDIUM, "Invalid option for DVD images"); 1363 1383 ComPtr<IDVDImage> dvdImage; … … 1379 1399 else if (cmd == CMD_FLOPPY) 1380 1400 { 1381 if (fDiskType )1382 return errorSyntax(USAGE_OPENMEDIUM, "Invalid option for DVDimages");1401 if (fDiskType || fSetImageId || fSetParentId) 1402 return errorSyntax(USAGE_OPENMEDIUM, "Invalid option for floppy images"); 1383 1403 ComPtr<IFloppyImage> floppyImage; 1384 1404 rc = a->virtualBox->OpenFloppyImage(Bstr(Filename), Bstr(), floppyImage.asOutParam()); -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp
r20501 r20842 1135 1135 { 1136 1136 /* open the new hard disk object */ 1137 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[0]), AccessMode_ReadWrite, hardDisk.asOutParam()));1137 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[0]), AccessMode_ReadWrite, false, Bstr(""), false, Bstr(""), hardDisk.asOutParam())); 1138 1138 } 1139 1139 } … … 1168 1168 { 1169 1169 /* open the new hard disk object */ 1170 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[1]), AccessMode_ReadWrite, hardDisk.asOutParam()));1170 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[1]), AccessMode_ReadWrite, false, Bstr(""), false, Bstr(""), hardDisk.asOutParam())); 1171 1171 } 1172 1172 } … … 1201 1201 { 1202 1202 /* open the new hard disk object */ 1203 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[2]), AccessMode_ReadWrite, hardDisk.asOutParam()));1203 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[2]), AccessMode_ReadWrite, false, Bstr(""), false, Bstr(""), hardDisk.asOutParam())); 1204 1204 } 1205 1205 } … … 1930 1930 { 1931 1931 /* open the new hard disk object */ 1932 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[i]), AccessMode_ReadWrite, hardDisk.asOutParam()));1932 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[i]), AccessMode_ReadWrite, false, Bstr(""), false, Bstr(""), hardDisk.asOutParam())); 1933 1933 } 1934 1934 } … … 2019 2019 { 2020 2020 /* open the new hard disk object */ 2021 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[i]), AccessMode_ReadWrite, hardDisk.asOutParam()));2021 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[i]), AccessMode_ReadWrite, false, Bstr(""), false, Bstr(""), hardDisk.asOutParam())); 2022 2022 } 2023 2023 } -
trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp
r20627 r20842 1743 1743 /* we've not found the image */ 1744 1744 RTPrintf("Adding hard disk '%S'...\n", hdaFile); 1745 virtualBox->OpenHardDisk(hdaFileBstr, AccessMode_ReadWrite, hardDisk.asOutParam());1745 virtualBox->OpenHardDisk(hdaFileBstr, AccessMode_ReadWrite, false, Bstr(""), false, Bstr(""), hardDisk.asOutParam()); 1746 1746 } 1747 1747 /* do we have the right image now? */ … … 2452 2452 } 2453 2453 } 2454 #else 2454 #else 2455 2455 case SDL_VIDEOEXPOSE: 2456 2456 { … … 2972 2972 2973 2973 for (unsigned i = 0; i < gcMonitors; i++) 2974 { 2974 { 2975 2975 if (gpFramebuffer[i]) 2976 2976 { -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxMediaManagerDlg.cpp
r20078 r20842 1549 1549 case VBoxDefs::MediaType_HardDisk: 1550 1550 { 1551 CHardDisk hd = mVBox.OpenHardDisk(aLocation, KAccessMode_ReadWrite );1551 CHardDisk hd = mVBox.OpenHardDisk(aLocation, KAccessMode_ReadWrite, false, "", false, ""); 1552 1552 if (mVBox.isOk()) 1553 1553 { -
trunk/src/VBox/Main/ApplianceImpl.cpp
r20576 r20842 2330 2330 rc = pVirtualBox->OpenHardDisk(Bstr(strSrcFilePath), 2331 2331 AccessMode_ReadOnly, 2332 false, Bstr(""), false, Bstr(""), 2332 2333 srcHdVBox.asOutParam()); 2333 2334 if (FAILED(rc)) throw rc; -
trunk/src/VBox/Main/HardDiskImpl.cpp
r20215 r20842 737 737 * 738 738 * @param aVirtualBox VirtualBox object. 739 * @param aLoca iton Storage unit location.739 * @param aLocation Storage unit location. 740 740 */ 741 741 HRESULT HardDisk::init (VirtualBox *aVirtualBox, … … 811 811 /** 812 812 * Initializes the hard disk object by opening the storage unit at the specified 813 * location. If the fWrite parameter is true, thenthe image will be opened814 * read/write , otherwise it will be openedread-only.813 * location. The enOpenMode parameter defines whether the image will be opened 814 * read/write or read-only. 815 815 * 816 816 * Note that the UUID, format and the parent of this hard disk will be 817 * determined when reading the hard disk storage unit. If the detected parent is 817 * determined when reading the hard disk storage unit, unless new values are 818 * specified by the parameters. If the detected or set parent is 818 819 * not known to VirtualBox, then this method will fail. 819 820 * 820 821 * @param aVirtualBox VirtualBox object. 821 * @param aLocaiton Storage unit location. 822 * @param aLocation Storage unit location. 823 * @param enOpenMode Whether to open the image read/write or read-only. 824 * @param aSetImageId Whether to set the image UUID or not. 825 * @param aImageId New image UUID if @aSetId is true. Empty string means 826 * create a new UUID, and a zero UUID is invalid. 827 * @param aSetParentId Whether to set the parent UUID or not. 828 * @param aParentId New parent UUID if @aSetParentId is true. Empty string 829 * means create a new UUID, and a zero UUID is valid. 822 830 */ 823 831 HRESULT HardDisk::init(VirtualBox *aVirtualBox, 824 832 CBSTR aLocation, 825 HDDOpenMode enOpenMode) 833 HDDOpenMode enOpenMode, 834 BOOL aSetImageId, 835 const Guid &aImageId, 836 BOOL aSetParentId, 837 const Guid &aParentId) 826 838 { 827 839 AssertReturn (aVirtualBox, E_INVALIDARG); … … 849 861 rc = setLocation (aLocation); 850 862 CheckComRCReturnRC (rc); 863 864 /* save the new uuid values, will be used by queryInfo() */ 865 mm.setImageId = aSetImageId; 866 unconst(mm.imageId) = aImageId; 867 mm.setParentId = aSetParentId; 868 unconst(mm.parentId) = aParentId; 851 869 852 870 /* get all the information about the medium from the storage unit */ … … 3207 3225 flags |= VD_OPEN_FLAGS_READONLY; 3208 3226 3227 /** @todo This kind of opening of images is assuming that diff 3228 * images can be opened as base images. Not very clean, and should 3229 * be fixed eventually. */ 3209 3230 vrc = VDOpen(hdd, 3210 3231 Utf8Str(mm.format), … … 3222 3243 if (mm.formatObj->capabilities() & HardDiskFormatCapabilities_Uuid) 3223 3244 { 3245 /* modify the UUIDs if necessary */ 3246 if (mm.setImageId) 3247 { 3248 vrc = VDSetUuid(hdd, 0, mm.imageId); 3249 ComAssertRCThrow(vrc, E_FAIL); 3250 } 3251 if (mm.setParentId) 3252 { 3253 vrc = VDSetUuid(hdd, 0, mm.parentId); 3254 ComAssertRCThrow(vrc, E_FAIL); 3255 } 3256 /* zap the information, these are no long-term members */ 3257 mm.setImageId = false; 3258 unconst(mm.imageId).clear(); 3259 mm.setParentId = false; 3260 unconst(mm.parentId).clear(); 3261 3224 3262 /* check the UUID */ 3225 3263 RTUUID uuid; … … 3258 3296 /* generate an UUID for an imported UUID-less hard disk */ 3259 3297 if (isImport) 3260 unconst(m.id).create(); 3298 { 3299 if (mm.setImageId) 3300 unconst(m.id) = mm.imageId; 3301 else 3302 unconst(m.id).create(); 3303 } 3261 3304 } 3262 3305 -
trunk/src/VBox/Main/VirtualBoxImpl.cpp
r20630 r20842 1136 1136 STDMETHODIMP VirtualBox::OpenHardDisk(IN_BSTR aLocation, 1137 1137 AccessMode_T accessMode, 1138 BOOL aSetImageId, IN_BSTR aImageId, 1139 BOOL aSetParentId, IN_BSTR aParentId, 1138 1140 IHardDisk **aHardDisk) 1139 1141 { 1140 1142 CheckComArgNotNull(aLocation); 1143 CheckComArgNotNull(aImageId); 1144 CheckComArgNotNull(aParentId); 1141 1145 CheckComArgOutSafeArrayPointerValid(aHardDisk); 1142 1146 … … 1150 1154 ComObjPtr<HardDisk> hardDisk; 1151 1155 hardDisk.createObject(); 1156 Guid imageId, parentId; 1157 if (aSetImageId) 1158 { 1159 imageId = Guid(aImageId); 1160 if (imageId.isEmpty()) 1161 return setError (E_INVALIDARG, tr ("Argument %s is empty"), "aImageId"); 1162 } 1163 if (aSetParentId) 1164 parentId = Guid(aParentId); 1152 1165 rc = hardDisk->init(this, 1153 1166 aLocation, 1154 (accessMode == AccessMode_ReadWrite) ? HardDisk::OpenReadWrite : HardDisk::OpenReadOnly ); 1167 (accessMode == AccessMode_ReadWrite) ? HardDisk::OpenReadWrite : HardDisk::OpenReadOnly, 1168 aSetImageId, imageId, 1169 aSetParentId, parentId); 1155 1170 1156 1171 if (SUCCEEDED (rc)) -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r20831 r20842 1903 1903 <method name="openHardDisk"> 1904 1904 <desc> 1905 Opens a hard disk from an existing location. 1905 Opens a hard disk from an existing location, optionally replacing 1906 the image UUID and/or parent UUID. 1906 1907 1907 1908 After the hard disk is successfully opened by this method, it gets … … 1954 1955 <desc> 1955 1956 Determines whether to open the image in read/write or read-only mode. 1957 </desc> 1958 </param> 1959 <param name="setImageId" type="boolean" dir="in"> 1960 <desc> 1961 Select whether a new image UUID is set or not. 1962 </desc> 1963 </param> 1964 <param name="imageId" type="wstring" dir="in"> 1965 <desc> 1966 New UUID for the image. If an empty string is passed, then a new 1967 UUID is automatically created. Specifying a zero UUIDs is not valid. 1968 </desc> 1969 </param> 1970 <param name="setParentId" type="boolean" dir="in"> 1971 <desc> 1972 Select whether a new parent UUID is set or not. 1973 </desc> 1974 </param> 1975 <param name="parentId" type="wstring" dir="in"> 1976 <desc> 1977 New parent UUID for the image. If an empty string is passed, then a 1978 new UUID is automatically created, provided @a setParentId is 1979 @c true. A zero UUID is valid. 1956 1980 </desc> 1957 1981 </param> -
trunk/src/VBox/Main/include/HardDiskImpl.h
r19239 r20842 90 90 HRESULT init(VirtualBox *aVirtualBox, 91 91 CBSTR aLocation, 92 HDDOpenMode enOpenMode); 92 HDDOpenMode enOpenMode, 93 BOOL aSetImageId, 94 const Guid &aImageId, 95 BOOL aSetParentId, 96 const Guid &aParentId); 93 97 HRESULT init(VirtualBox *aVirtualBox, 94 98 HardDisk *aParent, … … 294 298 hddOpenMode(OpenReadWrite), 295 299 autoReset(false), 300 setImageId(false), 301 setParentId(false), 296 302 implicit(false), 297 303 numCreateDiffTasks(0), … … 310 316 BOOL autoReset : 1; 311 317 318 /** the following members are invalid after changing UUID on open */ 319 BOOL setImageId : 1; 320 BOOL setParentId : 1; 321 const Guid imageId; 322 const Guid parentId; 323 312 324 typedef std::map <Bstr, Bstr> PropertyMap; 313 325 PropertyMap properties; -
trunk/src/VBox/Main/include/VirtualBoxImpl.h
r20630 r20842 151 151 STDMETHOD(CreateHardDisk)(IN_BSTR aFormat, IN_BSTR aLocation, 152 152 IHardDisk **aHardDisk); 153 STDMETHOD(OpenHardDisk) (IN_BSTR aLocation, AccessMode_T accessMode, IHardDisk **aHardDisk); 153 STDMETHOD(OpenHardDisk) (IN_BSTR aLocation, AccessMode_T accessMode, 154 BOOL aSetImageId, IN_BSTR aImageId, 155 BOOL aSetParentId, IN_BSTR aParentId, 156 IHardDisk **aHardDisk); 154 157 STDMETHOD(GetHardDisk) (IN_BSTR aId, IHardDisk **aHardDisk); 155 158 STDMETHOD(FindHardDisk) (IN_BSTR aLocation, IHardDisk **aHardDisk);
Note:
See TracChangeset
for help on using the changeset viewer.

