Changeset 18313 in vbox for trunk/src/VBox/Main/HardDiskImpl.cpp
- Timestamp:
- Mar 26, 2009 1:59:14 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 45082
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/HardDiskImpl.cpp
r18269 r18313 729 729 m.state = MediaState_Created; 730 730 731 /* remember the open mode (defaults to ReadWrite) */ 732 mm.hddOpenMode = enOpenMode; 733 731 734 rc = setLocation (aLocation); 732 735 CheckComRCReturnRC (rc); 733 736 734 737 /* get all the information about the medium from the storage unit */ 735 rc = queryInfo((enOpenMode == OpenReadWrite) /* fWrite */ ); 736 if (SUCCEEDED (rc)) 738 rc = queryInfo(); 739 740 if (SUCCEEDED(rc)) 737 741 { 738 742 /* if the storage unit is not accessible, it's not acceptable for the … … 745 749 else 746 750 { 747 /* storage format must be detected by queryInfo() if the medium is 748 * accessible */ 749 AssertReturn (!m.id.isEmpty() && !mm.format.isNull(), E_FAIL); 751 AssertReturn(!m.id.isEmpty(), E_FAIL); 752 753 /* storage format must be detected by queryInfo() if the medium is accessible */ 754 AssertReturn(!mm.format.isNull(), E_FAIL); 750 755 } 751 756 } … … 2996 3001 * writing. 2997 3002 */ 2998 HRESULT HardDisk::queryInfo( bool fWrite)3003 HRESULT HardDisk::queryInfo() 2999 3004 { 3000 3005 AutoWriteLock alock (this); … … 3079 3084 * time in VirtualBox (such as VMDK for which VDOpen() needs to 3080 3085 * generate an UUID if it is missing) */ 3081 if (!fWrite || !isImport) 3086 if ( (mm.hddOpenMode == OpenReadOnly) 3087 || !isImport 3088 ) 3082 3089 flags |= VD_OPEN_FLAGS_READONLY; 3083 3090 3084 vrc = VDOpen (hdd, Utf8Str (mm.format), location, flags, 3085 mm.vdDiskIfaces); 3091 vrc = VDOpen(hdd, 3092 Utf8Str(mm.format), 3093 location, 3094 flags, 3095 mm.vdDiskIfaces); 3086 3096 if (RT_FAILURE (vrc)) 3087 3097 { … … 3096 3106 /* check the UUID */ 3097 3107 RTUUID uuid; 3098 vrc = VDGetUuid 3099 ComAssertRCThrow 3108 vrc = VDGetUuid(hdd, 0, &uuid); 3109 ComAssertRCThrow(vrc, E_FAIL); 3100 3110 3101 3111 if (isImport) 3102 3112 { 3103 unconst (m.id) = uuid; 3113 unconst(m.id) = uuid; 3114 3115 if (m.id.isEmpty() && (mm.hddOpenMode == OpenReadOnly)) 3116 // only when importing a VDMK that has no UUID, create one in memory 3117 unconst(m.id).create(); 3104 3118 } 3105 3119 else … … 3126 3140 /* generate an UUID for an imported UUID-less hard disk */ 3127 3141 if (isImport) 3128 unconst 3142 unconst(m.id).create(); 3129 3143 } 3130 3144
Note:
See TracChangeset
for help on using the changeset viewer.