- Timestamp:
- Dec 3, 2008 12:33:47 AM (16 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/HardDisk2Impl.cpp
r14929 r14931 1874 1874 HardDiskFormatCapabilities_CreateFixed))) 1875 1875 return setError (VBOX_E_NOT_SUPPORTED, 1876 tr ("Hard disk format '%ls' does not support storage deletion 1876 tr ("Hard disk format '%ls' does not support storage deletion"), 1877 1877 mm.format.raw()); 1878 1878 … … 2410 2410 E_FAIL); 2411 2411 2412 /* are we dealing with a hard disk just opened from the existing path? */ 2413 bool isNew = mm.format.isNull(); 2414 2415 if (isNew || 2412 /* are we dealing with a new hard disk constructed using the existing 2413 * location? */ 2414 bool isImport = mm.format.isNull(); 2415 2416 if (isImport || 2416 2417 (mm.formatObj->capabilities() & HardDiskFormatCapabilities_File)) 2417 2418 { … … 2466 2467 location.raw(), vrc); 2467 2468 2468 /* detect the backend from the storage unit if new*/2469 if (is New)2469 /* detect the backend from the storage unit if importing */ 2470 if (isImport) 2470 2471 { 2471 2472 char *backendName = NULL; … … 2510 2511 m.locationFull = locationFull; 2511 2512 2512 /* assign a new UUID if we generated it */ 2513 if (!id.isEmpty()) 2513 if (m.state == MediaState_NotCreated) 2514 { 2515 /* assign a new UUID (this UUID will be used when calling 2516 * VDCreateBase/VDCreateDiff as a wanted UUID). Note that we 2517 * also do that if we didn't generate it to make sure it is 2518 * either generated by us or reset to null */ 2514 2519 unconst (m.id) = id; 2520 } 2515 2521 } 2516 2522 else … … 2657 2663 Utf8Str location (m.locationFull); 2658 2664 2659 /* are we dealing with a hard disk opened from the existing path? */ 2660 bool isNew = m.id.isEmpty(); 2665 /* are we dealing with a new hard disk constructed using the existing 2666 * location? */ 2667 bool isImport = m.id.isEmpty(); 2661 2668 2662 2669 PVBOXHDD hdd; … … 2673 2680 * time in VirtualBox (such as VMDK for which VDOpen() needs to 2674 2681 * generate an UUID if it is missing) */ 2675 if (!is New)2682 if (!isImport) 2676 2683 flags |= VD_OPEN_FLAGS_READONLY; 2677 2684 … … 2686 2693 } 2687 2694 2688 /* check the UUID */ 2689 RTUUID uuid; 2690 vrc = VDGetUuid (hdd, 0, &uuid); 2691 ComAssertRCThrow (vrc, E_FAIL); 2692 2693 if (isNew) 2695 if (mm.formatObj->capabilities() & HardDiskFormatCapabilities_Uuid) 2694 2696 { 2695 unconst (m.id) = uuid; 2697 /* check the UUID */ 2698 RTUUID uuid; 2699 vrc = VDGetUuid (hdd, 0, &uuid); 2700 ComAssertRCThrow (vrc, E_FAIL); 2701 2702 if (isImport) 2703 { 2704 unconst (m.id) = uuid; 2705 } 2706 else 2707 { 2708 Assert (!m.id.isEmpty()); 2709 2710 if (m.id != uuid) 2711 { 2712 lastAccessError = Utf8StrFmt ( 2713 tr ("UUID {%RTuuid} of the hard disk '%ls' does " 2714 "not match the value {%RTuuid} stored in the " 2715 "media registry ('%ls')"), 2716 &uuid, m.locationFull.raw(), m.id.raw(), 2717 mVirtualBox->settingsFileName().raw()); 2718 throw S_OK; 2719 } 2720 } 2696 2721 } 2697 2722 else 2698 2723 { 2699 if (m.id != uuid) 2700 { 2701 lastAccessError = Utf8StrFmt ( 2702 tr ("UUID {%RTuuid} of the hard disk '%ls' " 2703 "does not match the value {%RTuuid} stored in the " 2704 "media registry ('%ls')"), 2705 &uuid, m.locationFull.raw(), m.id.raw(), 2706 mVirtualBox->settingsFileName().raw()); 2707 throw S_OK; 2708 } 2724 /* the backend does not support storing UUIDs within the 2725 * underlying storage so use what we store in XML */ 2726 2727 /* generate an UUID for an imported UUID-less hard disk */ 2728 if (isImport) 2729 unconst (m.id).create(); 2709 2730 } 2710 2731 … … 2716 2737 if (type == VD_IMAGE_TYPE_DIFF) 2717 2738 { 2718 vrc = VDGetParentUuid (hdd, 0, &uuid); 2739 RTUUID parentId; 2740 vrc = VDGetParentUuid (hdd, 0, &parentId); 2719 2741 ComAssertRCThrow (vrc, E_FAIL); 2720 2742 2721 if (is New)2743 if (isImport) 2722 2744 { 2723 2745 /* the parent must be known to us. Note that we freely … … 2728 2750 * fail if this method reporst MediaState_Inaccessible) */ 2729 2751 2730 Guid id = uuid;2752 Guid id = parentId; 2731 2753 ComObjPtr <HardDisk2> parent; 2732 2754 rc = mVirtualBox->findHardDisk2 (&id, NULL, … … 2739 2761 "hard disk '%ls' is not found in the media " 2740 2762 "registry ('%ls')"), 2741 & uuid, m.locationFull.raw(),2763 &parentId, m.locationFull.raw(), 2742 2764 mVirtualBox->settingsFileName().raw()); 2743 2765 throw S_OK; … … 2777 2799 AutoReadLock parentLock (mParent); 2778 2800 if (mParent->state() != MediaState_Inaccessible && 2779 mParent->id() != uuid)2801 mParent->id() != parentId) 2780 2802 { 2781 2803 lastAccessError = Utf8StrFmt ( … … 2783 2805 "does not match UUID {%RTuuid} of its parent " 2784 2806 "hard disk stored in the media registry ('%ls')"), 2785 & uuid, m.locationFull.raw(),2807 &parentId, m.locationFull.raw(), 2786 2808 mParent->id().raw(), 2787 2809 mVirtualBox->settingsFileName().raw()); … … 3118 3140 3119 3141 /* these parameters we need after creation */ 3120 RTUUID uuid;3121 3142 uint64_t size = 0, logicalSize = 0; 3143 3144 /* the object may request a specific UUID (through a special 3145 * form of the setLocation() argumet) */ 3146 Guid id = that->m.id; 3122 3147 3123 3148 try … … 3129 3154 Utf8Str format (that->mm.format); 3130 3155 Utf8Str location (that->m.locationFull); 3156 ULONG capabilities = that->mm.formatObj->capabilities(); 3131 3157 3132 3158 /* unlock before the potentially lengthy operation */ … … 3151 3177 task->d.size * _1M, 3152 3178 VD_IMAGE_FLAGS_NONE, 3153 NULL, &geo, &geo, NULL, 3179 NULL, &geo, &geo, 3180 id.isEmpty() ? NULL : id.raw(), 3154 3181 VD_OPEN_FLAGS_NORMAL, 3155 3182 NULL, that->mm.vdDiskIfaces); … … 3163 3190 } 3164 3191 3165 vrc = VDGetUuid (hdd, 0, &uuid); 3166 ComAssertRCThrow (vrc, E_FAIL); 3192 if (capabilities & HardDiskFormatCapabilities_Uuid) 3193 { 3194 RTUUID uuid; 3195 vrc = VDGetUuid (hdd, 0, &uuid); 3196 ComAssertRCThrow (vrc, E_FAIL); 3197 3198 if (!id.isEmpty()) 3199 Assert (id == uuid); 3200 else 3201 id = uuid; 3202 } 3203 else 3204 { 3205 /* we have to generate an UUID ourselves */ 3206 id.create(); 3207 } 3167 3208 3168 3209 size = VDGetFileSize (hdd, 0); … … 3181 3222 thatLock.enter(); 3182 3223 3183 unconst (that->m.id) = uuid;3224 unconst (that->m.id) = id; 3184 3225 3185 3226 that->m.size = size; … … 3707 3748 that->m.state = MediaState_NotCreated; 3708 3749 3750 /* Reset UUID to prevent Create* from reusing it again */ 3751 unconst (that->m.id).clear(); 3752 3709 3753 break; 3710 3754 } -
trunk/src/VBox/Main/MediumImpl.cpp
r14772 r14931 59 59 CheckComRCReturnRC (autoCaller.rc()); 60 60 61 /* m.id is constant during life time, no need to lock */ 61 AutoReadLock alock (this); 62 62 63 m.id.cloneTo (aId); 63 64 -
trunk/src/VBox/Main/VirtualBoxImpl.cpp
r14922 r14931 490 490 # error "Port me!" 491 491 #endif 492 /* Unload plugin backends. */ 492 493 /* Unload hard disk plugin backends. */ 493 494 VDShutdown(); 494 495 -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r14874 r14931 6647 6647 UUID of the medium. For a newly created medium, this value is a randomly 6648 6648 generated UUID. 6649 6650 <note> 6651 For media in one of MediaState::NotCreated, MediaState::Creating or 6652 MediaState::Deleting states, the value of this property is undefined 6653 and will most likely be an empty UUID. 6654 </note> 6649 6655 </desc> 6650 6656 </attribute> … … 7601 7607 <link to="IHardDiskFormat::capabilities"/>. 7602 7608 </result> 7609 7610 <note> 7611 If the deletion operation fails, it is not guaranteed that the storage 7612 unit still exists. You may check the <link to="IMedium::state"/> value 7613 to answer this question. 7614 </note> 7603 7615 </desc> 7604 7616 <param name="progress" type="IProgress" dir="return">
Note:
See TracChangeset
for help on using the changeset viewer.