Changeset 37525 in vbox
- Timestamp:
- Jun 17, 2011 10:09:21 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 17 edited
-
doc/manual/en_US/SDKRef.xml (modified) (1 diff)
-
doc/manual/en_US/user_VBoxManage.xml (modified) (2 diffs)
-
src/VBox/Frontends/VBoxManage/VBoxManage.h (modified) (2 diffs)
-
src/VBox/Frontends/VBoxManage/VBoxManageDisk.cpp (modified) (7 diffs)
-
src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp (modified) (1 diff)
-
src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp (modified) (4 diffs)
-
src/VBox/Frontends/VBoxManage/VBoxManageStorageController.cpp (modified) (5 diffs)
-
src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp (modified) (4 diffs)
-
src/VBox/Frontends/VirtualBox/src/VBoxMediaManagerDlg.cpp (modified) (2 diffs)
-
src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp (modified) (1 diff)
-
src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp (modified) (2 diffs)
-
src/VBox/Main/idl/VirtualBox.xidl (modified) (2 diffs)
-
src/VBox/Main/include/MediumImpl.h (modified) (2 diffs)
-
src/VBox/Main/include/VirtualBoxImpl.h (modified) (1 diff)
-
src/VBox/Main/src-server/MediumImpl.cpp (modified) (13 diffs)
-
src/VBox/Main/src-server/VirtualBoxImpl.cpp (modified) (2 diffs)
-
src/VBox/Main/testcase/tstVBoxAPILinux.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/manual/en_US/SDKRef.xml
r37200 r37525 3448 3448 <itemizedlist> 3449 3449 <listitem> 3450 <para>The method <xref linkend="IVirtualBox__openMedium" 3451 xreflabel="IVirtualBox::openMedium()" /> has one more parameter 3452 now, which allows resolving duplicate medium UUIDs without the need 3453 for external tools.</para> 3454 </listitem> 3455 3456 <listitem> 3450 3457 <para>The <xref linkend="INetworkAdapter" xreflabel="INetworkAdapter"/> 3451 3458 interface has been cleaned up. The various methods to activate an -
trunk/doc/manual/en_US/user_VBoxManage.xml
r37489 r37525 1507 1507 [--mtype normal|writethrough|immutable|shareable] 1508 1508 [--comment <text>] 1509 [--setuuid <uuid>] 1510 [--setparentuuid <uuid>] 1509 1511 [--passthrough on|off] 1510 1512 [--bandwidthgroup name|none] … … 1643 1645 server downstairs"). This is purely descriptive and not needed for 1644 1646 the medium to function correctly.</para> 1647 </glossdef> 1648 </glossentry> 1649 1650 <glossentry> 1651 <glossterm>setuuid, setparentuuid</glossterm> 1652 1653 <glossdef> 1654 <para>Modifies the UUID or parent UUID of a medium before 1655 attaching it to a VM. This is an expert option. Inappropriate use 1656 can make the medium unusable or lead to broken VM configurations 1657 if any other VM is referring to the same media already. The most 1658 frequently used variant is <code>--setuuid ""</code>, which assigns 1659 a new (random) UUID to an image. This is useful to resolve the 1660 duplicate UUID errors if one duplicated an image using file copy 1661 utilities.</para> 1645 1662 </glossdef> 1646 1663 </glossentry> -
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.h
r37074 r37525 5 5 6 6 /* 7 * Copyright (C) 2006-201 0Oracle Corporation7 * Copyright (C) 2006-2011 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 227 227 HRESULT findOrOpenMedium(HandlerArg *a, const char *pszFilenameOrUuid, 228 228 DeviceType_T enmDevType, ComPtr<IMedium> &pMedium, 229 bool *pfWasUnknown);229 bool fForceNewUuidOnOpen, bool *pfWasUnknown); 230 230 int handleCreateHardDisk(HandlerArg *a); 231 231 int handleModifyHardDisk(HandlerArg *a); -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageDisk.cpp
r36527 r37525 5 5 6 6 /* 7 * Copyright (C) 2006-201 0Oracle Corporation7 * Copyright (C) 2006-2011 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 181 181 HRESULT findOrOpenMedium(HandlerArg *a, const char *pszFilenameOrUuid, 182 182 DeviceType_T enmDevType, ComPtr<IMedium> &pMedium, 183 bool *pfWasUnknown)183 bool fForceNewUuidOnOpen, bool *pfWasUnknown) 184 184 { 185 185 HRESULT rc; … … 207 207 CHECK_ERROR(a->virtualBox, OpenMedium(Bstr(pszFilenameOrUuid).raw(), 208 208 enmDevType, AccessMode_ReadWrite, 209 fForceNewUuidOnOpen, 209 210 pMedium.asOutParam())); 210 211 if (SUCCEEDED(rc)) … … 476 477 else 477 478 rc = findOrOpenMedium(a, FilenameOrUuid, DeviceType_HardDisk, 478 hardDisk, &unknown);479 hardDisk, false /* fForceNewUuidOnOpen */, &unknown); 479 480 if (FAILED(rc)) 480 481 return 1; … … 630 631 bool fDstUnknown = false; 631 632 632 rc = findOrOpenMedium(a, pszSrc, DeviceType_HardDisk, srcDisk, &fSrcUnknown); 633 rc = findOrOpenMedium(a, pszSrc, DeviceType_HardDisk, srcDisk, 634 false /* fForceNewUuidOnOpen */, &fSrcUnknown); 633 635 if (FAILED(rc)) 634 636 return 1; … … 639 641 if (fExisting) 640 642 { 641 rc = findOrOpenMedium(a, pszDst, DeviceType_HardDisk, dstDisk, &fDstUnknown); 643 rc = findOrOpenMedium(a, pszDst, DeviceType_HardDisk, dstDisk, 644 false /* fForceNewUuidOnOpen */, &fDstUnknown); 642 645 if (FAILED(rc)) 643 646 break; … … 925 928 bool unknown = false; 926 929 927 rc = findOrOpenMedium(a, FilenameOrUuid, DeviceType_HardDisk, hardDisk, &unknown); 930 rc = findOrOpenMedium(a, FilenameOrUuid, DeviceType_HardDisk, hardDisk, 931 false /* fForceNewUuidOnOpen */, &unknown); 928 932 if (FAILED(rc)) 929 933 return 1; -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp
r37450 r37525 462 462 " readonly|multiattach]\n" 463 463 " [--comment <text>]\n" 464 " [--setuuid <uuid>]\n" 465 " [--setparentuuid <uuid>]\n" 464 466 " [--passthrough on|off]\n" 465 467 " [--bandwidthgroup <name>]\n" -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp
r37202 r37525 712 712 ComPtr<IMedium> hardDisk; 713 713 rc = findOrOpenMedium(a, ValueUnion.psz, DeviceType_HardDisk, 714 hardDisk, NULL); 714 hardDisk, false /* fForceNewUuidOnOpen */, 715 NULL); 715 716 if (FAILED(rc)) 716 717 break; … … 807 808 ComPtr<IMedium> hardDisk; 808 809 rc = findOrOpenMedium(a, ValueUnion.psz, DeviceType_HardDisk, 809 hardDisk, NULL); 810 hardDisk, false /* fForceNewUuidOnOpen */, 811 NULL); 810 812 if (FAILED(rc)) 811 813 break; … … 934 936 { 935 937 rc = findOrOpenMedium(a, ValueUnion.psz, DeviceType_DVD, 936 dvdMedium, NULL); 938 dvdMedium, false /* fForceNewUuidOnOpen */, 939 NULL); 937 940 if (FAILED(rc)) 938 941 break; … … 997 1000 { 998 1001 rc = findOrOpenMedium(a, ValueUnion.psz, DeviceType_Floppy, 999 floppyMedium, NULL); 1002 floppyMedium, false /* fForceNewUuidOnOpen */, 1003 NULL); 1000 1004 if (FAILED(rc)) 1001 1005 break; -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageStorageController.cpp
r36652 r37525 55 55 { "--forceunmount", 'f', RTGETOPT_REQ_NOTHING }, 56 56 { "--comment", 'C', RTGETOPT_REQ_STRING }, 57 { "--setuuid", 'q', RTGETOPT_REQ_STRING }, 58 { "--setparentuuid", 'Q', RTGETOPT_REQ_STRING }, 57 59 // iSCSI options 58 60 { "--server", 'S', RTGETOPT_REQ_STRING }, … … 74 76 bool fForceUnmount = false; 75 77 bool fSetMediumType = false; 78 bool fSetNewUuid = false; 79 bool fSetNewParentUuid = false; 76 80 MediumType_T mediumType = MediumType_Normal; 77 81 Bstr bstrComment; … … 81 85 const char *pszPassThrough = NULL; 82 86 const char *pszBandwidthGroup = NULL; 87 Bstr bstrNewUuid; 88 Bstr bstrNewParentUuid; 83 89 // iSCSI options 84 90 Bstr bstrServer; … … 181 187 else 182 188 rc = E_FAIL; 183 break; 189 break; 190 191 case 'q': 192 if (ValueUnion.psz) 193 { 194 bstrNewUuid = ValueUnion.psz; 195 fSetNewUuid = true; 196 } 197 else 198 rc = E_FAIL; 199 break; 200 201 case 'Q': 202 if (ValueUnion.psz) 203 { 204 bstrNewParentUuid = ValueUnion.psz; 205 fSetNewParentUuid = true; 206 } 207 else 208 rc = E_FAIL; 209 break; 184 210 185 211 case 'S': // --server … … 544 570 545 571 rc = findOrOpenMedium(a, pszMedium, devTypeRequested, 546 pMedium2Mount, NULL);572 pMedium2Mount, fSetNewUuid, NULL); 547 573 if (FAILED(rc) || !pMedium2Mount) 548 574 throw Utf8StrFmt("Invalid UUID or filename \"%s\"", pszMedium); 575 } 576 577 // set medium/parent medium UUID, if so desired 578 if (fSetNewUuid || fSetNewParentUuid) 579 { 580 CHECK_ERROR(pMedium2Mount, SetIDs(fSetNewUuid, bstrNewUuid.raw(), 581 fSetNewParentUuid, bstrNewParentUuid.raw())); 582 if (FAILED(rc)) 583 throw Utf8Str("Failed to set the medium/parent medium UUID"); 549 584 } 550 585 -
trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp
r37423 r37525 5 5 6 6 /* 7 * Copyright (C) 2006-201 0Oracle Corporation7 * Copyright (C) 2006-2011 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 1459 1459 RTPrintf("Adding hard disk '%s'...\n", hdaFile); 1460 1460 pVirtualBox->OpenMedium(bstrHdaFile.raw(), DeviceType_HardDisk, 1461 AccessMode_ReadWrite, pMedium.asOutParam()); 1461 AccessMode_ReadWrite, FALSE /* fForceNewUuid */, 1462 pMedium.asOutParam()); 1462 1463 } 1463 1464 /* do we have the right image now? */ … … 1544 1545 DeviceType_Floppy, 1545 1546 AccessMode_ReadWrite, 1547 FALSE /* fForceNewUuid */, 1546 1548 pMedium.asOutParam())); 1547 1549 } … … 1624 1626 DeviceType_DVD, 1625 1627 AccessMode_ReadWrite, 1628 FALSE /* fForceNewUuid */, 1626 1629 pMedium.asOutParam())); 1627 1630 } -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxMediaManagerDlg.cpp
r37470 r37525 7 7 8 8 /* 9 * Copyright (C) 2006-201 0Oracle Corporation9 * Copyright (C) 2006-2011 Oracle Corporation 10 10 * 11 11 * This file is part of VirtualBox Open Source Edition (OSE), as … … 1651 1651 } 1652 1652 1653 CMedium med = mVBox.OpenMedium(aLocation, devType, KAccessMode_ReadWrite );1653 CMedium med = mVBox.OpenMedium(aLocation, devType, KAccessMode_ReadWrite, false /* fForceNewUuid */); 1654 1654 if (mVBox.isOk()) 1655 1655 medium = VBoxMedium(CMedium(med), aType, KMediumState_Created); -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
r37374 r37525 2754 2754 2755 2755 /* Open corresponding medium: */ 2756 CMedium comMedium = vbox.OpenMedium(strMediumLocation, mediumTypeToGlobal(mediumType), KAccessMode_ReadWrite );2756 CMedium comMedium = vbox.OpenMedium(strMediumLocation, mediumTypeToGlobal(mediumType), KAccessMode_ReadWrite, false); 2757 2757 2758 2758 if (vbox.isOk()) -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
r36364 r37525 7 7 8 8 /* 9 * Copyright (C) 20 11 Oracle Corporation9 * Copyright (C) 2006-2011 Oracle Corporation 10 10 * 11 11 * This file is part of VirtualBox Open Source Edition (OSE), as … … 426 426 if (image.isNull()) 427 427 { 428 image = vbox.OpenMedium(strSource, KDeviceType_DVD, KAccessMode_ReadWrite );428 image = vbox.OpenMedium(strSource, KDeviceType_DVD, KAccessMode_ReadWrite, false /* fForceNewUuid */); 429 429 if (vbox.isOk()) 430 430 strUuid = image.GetId(); -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r37487 r37525 1392 1392 <interface 1393 1393 name="IVirtualBox" extends="$unknown" 1394 uuid=" bc166b9b-9b62-4145-b1f6-6c39068aaf00"1394 uuid="d627bf11-2758-46be-9a4d-7d9ef794c247" 1395 1395 wsmap="managed" 1396 1396 > … … 1913 1913 <desc>Whether to open the image in read/write or read-only mode. For 1914 1914 a "DVD" device type, this is ignored and read-only mode is always assumed.</desc> 1915 </param> 1916 <param name="forceNewUuid" type="boolean" dir="in"> 1917 <desc>Allows the caller to request a completely new medium UUID for 1918 the image which is to be opened. Useful if one intends to open an exact 1919 copy of a previously opened image, as this would normally fail due to 1920 the duplicate UUID.</desc> 1915 1921 </param> 1916 1922 <param name="medium" type="IMedium" dir="return"> -
trunk/src/VBox/Main/include/MediumImpl.h
r35982 r37525 7 7 8 8 /* 9 * Copyright (C) 2008-201 0Oracle Corporation9 * Copyright (C) 2008-2011 Oracle Corporation 10 10 * 11 11 * This file is part of VirtualBox Open Source Edition (OSE), as … … 78 78 const Utf8Str &aLocation, 79 79 HDDOpenMode enOpenMode, 80 bool fForceNewUuid, 80 81 DeviceType_T aDeviceType); 81 82 -
trunk/src/VBox/Main/include/VirtualBoxImpl.h
r37244 r37525 140 140 DeviceType_T deviceType, 141 141 AccessMode_T accessMode, 142 BOOL fForceNewUuid, 142 143 IMedium **aMedium); 143 144 STDMETHOD(FindMedium)(IN_BSTR aLocation, -
trunk/src/VBox/Main/src-server/MediumImpl.cpp
r37162 r37525 138 138 bool autoReset : 1; 139 139 140 /** New UUID to be set on the next queryInfo() call. */ 140 141 const Guid uuidImage; 142 /** New parent UUID to be set on the next queryInfo() call. */ 141 143 const Guid uuidParentImage; 142 144 … … 929 931 * @param aFormat 930 932 * @param aLocation Storage unit location. 931 * @param uuidMachineRegistry The registry to which this medium should be added (global registry UUI or mediumUUID or empty if none).933 * @param uuidMachineRegistry The registry to which this medium should be added (global registry UUID or machine UUID or empty if none). 932 934 * @param pllRegistriesThatNeedSaving Optional list to receive the UUIDs of the media registries that need saving. 933 935 */ … … 1012 1014 * @param aLocation Storage unit location. 1013 1015 * @param enOpenMode Whether to open the medium read/write or read-only. 1016 * @param fForceNewUuid Whether a new UUID should be set to avoid duplicates. 1014 1017 * @param aDeviceType Device type of medium. 1015 1018 */ … … 1017 1020 const Utf8Str &aLocation, 1018 1021 HDDOpenMode enOpenMode, 1022 bool fForceNewUuid, 1019 1023 DeviceType_T aDeviceType) 1020 1024 { … … 1051 1055 1052 1056 /* get all the information about the medium from the storage unit */ 1053 rc = queryInfo(false /* fSetImageId */, false /* fSetParentId */); 1057 if (fForceNewUuid) 1058 unconst(m->uuidImage).create(); 1059 rc = queryInfo(fForceNewUuid /* fSetImageId */, false /* fSetParentId */); 1054 1060 1055 1061 if (SUCCEEDED(rc)) … … 1089 1095 * @param aParent Parent medium disk or NULL for a root (base) medium. 1090 1096 * @param aDeviceType Device type of the medium. 1091 * @param uuidMachineRegistry The registry to which this medium should be added (global registry UUI or mediumUUID).1097 * @param uuidMachineRegistry The registry to which this medium should be added (global registry UUID or machine UUID). 1092 1098 * @param aNode Configuration settings. 1093 1099 * @param strMachineFolder The machine folder with which to resolve relative paths; if empty, then we use the VirtualBox home directory … … 1953 1959 if (aSetImageId) 1954 1960 { 1955 imageId = Guid(aImageId); 1956 if (imageId.isEmpty()) 1957 return setError(E_INVALIDARG, tr("Argument %s is empty"), "aImageId"); 1961 if (Bstr(aImageId).isEmpty()) 1962 imageId.create(); 1963 else 1964 { 1965 imageId = Guid(aImageId); 1966 if (imageId.isEmpty()) 1967 return setError(E_INVALIDARG, tr("Argument %s is empty"), "aImageId"); 1968 } 1958 1969 } 1959 1970 if (aSetParentId) 1960 parentId = Guid(aParentId); 1971 { 1972 if (Bstr(aParentId).isEmpty()) 1973 parentId.create(); 1974 else 1975 parentId = Guid(aParentId); 1976 } 1961 1977 1962 1978 unconst(m->uuidImage) = imageId; … … 5090 5106 * time in VirtualBox (such as VMDK for which VDOpen() needs to 5091 5107 * generate an UUID if it is missing) */ 5092 if ( (m->hddOpenMode == OpenReadOnly)5108 if ( m->hddOpenMode == OpenReadOnly 5093 5109 || m->type == MediumType_Readonly 5094 || !isImport5110 || (!isImport && !fSetImageId && !fSetParentId) 5095 5111 ) 5096 5112 uOpenFlags |= VD_OPEN_FLAGS_READONLY; … … 5169 5185 vrc = VDSetUuid(hdd, 0, m->uuidImage.raw()); 5170 5186 ComAssertRCThrow(vrc, E_FAIL); 5187 mediumId = m->uuidImage; 5171 5188 } 5172 5189 if (fSetParentId) … … 5198 5215 if (mediumId != uuid) 5199 5216 { 5217 /** @todo r=klaus this always refers to VirtualBox.xml as the medium registry, even for new VMs */ 5200 5218 lastAccessError = Utf8StrFmt( 5201 5219 tr("UUID {%RTuuid} of the medium '%s' does not match the value {%RTuuid} stored in the media registry ('%s')"), … … 5213 5231 * underlying storage so use what we store in XML */ 5214 5232 5215 /* generate an UUID for an imported UUID-less medium */ 5216 if (isImport) 5233 if (fSetImageId) 5217 5234 { 5218 if (fSetImageId) 5219 mediumId = m->uuidImage; 5220 else 5221 mediumId.create(); 5235 /* set the UUID if an API client wants to change it */ 5236 mediumId = m->uuidImage; 5237 } 5238 else if (isImport) 5239 { 5240 /* generate an UUID for an imported UUID-less medium */ 5241 mediumId.create(); 5222 5242 } 5223 5243 } … … 5305 5325 && m->pParent->getId() != parentId) 5306 5326 { 5327 /** @todo r=klaus this always refers to VirtualBox.xml as the medium registry, even for new VMs */ 5307 5328 lastAccessError = Utf8StrFmt( 5308 5329 tr("Parent UUID {%RTuuid} of the medium '%s' does not match UUID {%RTuuid} of its parent medium stored in the media registry ('%s')"), … … 5338 5359 alock.enter(); 5339 5360 5340 if (isImport )5361 if (isImport || fSetImageId) 5341 5362 unconst(m->id) = mediumId; 5342 5363 -
trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp
r37244 r37525 1482 1482 DeviceType_T deviceType, 1483 1483 AccessMode_T accessMode, 1484 BOOL fForceNewUuid, 1484 1485 IMedium **aMedium) 1485 1486 { … … 1529 1530 aLocation, 1530 1531 (accessMode == AccessMode_ReadWrite) ? Medium::OpenReadWrite : Medium::OpenReadOnly, 1532 fForceNewUuid, 1531 1533 deviceType); 1532 1534 -
trunk/src/VBox/Main/testcase/tstVBoxAPILinux.cpp
r33604 r37525 8 8 9 9 /* 10 * Copyright (C) 2006-201 0Oracle Corporation10 * Copyright (C) 2006-2011 Oracle Corporation 11 11 * 12 12 * This file is part of VirtualBox Open Source Edition (OSE), as … … 359 359 DeviceType_DVD, 360 360 AccessMode_ReadOnly, 361 false /* fForceNewUuid */, 361 362 getter_AddRefs(dvdImage)); 362 363 if (NS_FAILED(rc))
Note:
See TracChangeset
for help on using the changeset viewer.

