Changeset 36575 in vbox for trunk/src/VBox/Main
- Timestamp:
- Apr 6, 2011 1:07:54 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 71014
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp
r36523 r36575 6 6 7 7 /* 8 * Copyright (C) 2008-201 0Oracle Corporation8 * Copyright (C) 2008-2011 Oracle Corporation 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 2568 2568 bool fDVD = vsdescThis->findByType(VirtualSystemDescriptionType_CDROM).size() > 0; 2569 2569 /* Iterate over all storage controller check the attachments and remove 2570 * them when necessary. */ 2570 * them when necessary. Also detect broken configs with more than one 2571 * attachment. Old VirtualBox versions (prior to 3.2.10) had all disk 2572 * attachments pointing to the last hard disk image, which causes import 2573 * failures. A long fixed bug, however the OVF files are long lived. */ 2571 2574 settings::StorageControllersList &llControllers = config.storageMachine.llStorageControllers; 2575 Guid hdUuid; 2576 uint32_t cHardDisks = 0; 2577 bool fInconsistent = false; 2578 bool fRepairDuplicate = false; 2572 2579 settings::StorageControllersList::iterator it3; 2573 2580 for (it3 = llControllers.begin(); … … 2587 2594 && it4->deviceType == DeviceType_Floppy)) 2588 2595 llAttachments.erase(it4++); 2596 else if (it4->deviceType == DeviceType_HardDisk) 2597 { 2598 const Guid &thisUuid = it4->uuid; 2599 cHardDisks++; 2600 if (cHardDisks == 1) 2601 { 2602 if (hdUuid.isEmpty()) 2603 hdUuid = thisUuid; 2604 else 2605 fInconsistent = true; 2606 } 2607 else 2608 { 2609 if (thisUuid.isEmpty()) 2610 fInconsistent = true; 2611 else if (thisUuid == hdUuid) 2612 fRepairDuplicate = true; 2613 } 2614 } 2589 2615 } 2590 2616 } 2591 2617 /* paranoia... */ 2618 if (fInconsistent || cHardDisks == 1) 2619 fRepairDuplicate = false; 2592 2620 2593 2621 /* … … 2596 2624 * 2597 2625 */ 2626 2627 /* Get all hard disk descriptions. */ 2628 std::list<VirtualSystemDescriptionEntry*> avsdeHDs = vsdescThis->findByType(VirtualSystemDescriptionType_HardDiskImage); 2629 std::list<VirtualSystemDescriptionEntry*>::iterator avsdeHDsIt = avsdeHDs.begin(); 2630 /* paranoia - if there is no 1:1 match do not try to repair. */ 2631 if (cHardDisks != avsdeHDs.size()) 2632 fRepairDuplicate = false; 2598 2633 2599 2634 // for each storage controller... … … 2617 2652 } 2618 2653 2619 /* Get all hard disk descriptions. */2620 std::list<VirtualSystemDescriptionEntry*> avsdeHDs = vsdescThis->findByType(VirtualSystemDescriptionType_HardDiskImage);2621 2622 2654 // for each medium attachment to this controller... 2623 2655 for (settings::AttachedDevicesList::iterator dit = sc.llAttachedDevices.begin(); … … 2631 2663 continue; 2632 2664 2665 // When repairing a broken VirtualBox xml config section (written 2666 // by VirtualBox versions earlier than 3.2.10) assume the disks 2667 // show up in the same order as in the OVF description. 2668 if (fRepairDuplicate) 2669 { 2670 VirtualSystemDescriptionEntry *vsdeHD = *avsdeHDsIt; 2671 ovf::DiskImagesMap::const_iterator itDiskImage = stack.mapDisks.find(vsdeHD->strRef); 2672 if (itDiskImage != stack.mapDisks.end()) 2673 { 2674 const ovf::DiskImage &di = itDiskImage->second; 2675 d.uuid = Guid(di.uuidVbox); 2676 } 2677 ++avsdeHDsIt; 2678 } 2679 2633 2680 // convert the Guid to string 2634 2681 Utf8Str strUuid = d.uuid.toString(); 2635 2636 2682 2637 2683 // there must be an image in the OVF disk structs with the same UUID
Note:
See TracChangeset
for help on using the changeset viewer.