Changeset 18152 in vbox
- Timestamp:
- Mar 23, 2009 4:46:05 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ApplianceImpl.cpp
r18114 r18152 805 805 } 806 806 807 // now go thru all hardware items and handle them according to their type; 808 // in this first loop we handle all items _except_ hard disk images, 809 // which we'll handle in a second loop below 807 810 HardwareItemsMap::const_iterator itH; 808 809 811 for (itH = vsys.mapHardwareItems.begin(); 810 812 itH != vsys.mapHardwareItems.end(); … … 933 935 934 936 case OVFResourceType_HardDisk: // 17 935 { 936 /* <Item> 937 <rasd:Caption>Harddisk 1</rasd:Caption> 938 <rasd:Description>HD</rasd:Description> 939 <rasd:ElementName>Hard Disk</rasd:ElementName> 940 <rasd:HostResource>ovf://disk/lamp</rasd:HostResource> 941 <rasd:InstanceID>5</rasd:InstanceID> 942 <rasd:Parent>4</rasd:Parent> 943 <rasd:ResourceType>17</rasd:ResourceType> 944 </Item> */ 945 946 // look up the hard disk controller element whose InstanceID equals our Parent; 947 // this is how the connection is specified in OVF 948 ControllersMap::const_iterator it = vsys.mapControllers.find(i.ulParent); 949 if (it == vsys.mapControllers.end()) 950 return setError(VBOX_E_FILE_ERROR, 951 tr("Error reading \"%s\": Hard disk item with instance ID %d specifies invalid parent %d, line %d"), 952 pcszPath, 953 i.ulInstanceID, 954 i.ulParent, 955 i.ulLineNumber); 956 //const HardDiskController &hdc = it->second; 957 958 VirtualDisk vd; 959 vd.idController = i.ulParent; 960 i.strAddressOnParent.toInt(vd.ulAddressOnParent); 961 // ovf://disk/lamp 962 // 123456789012345 963 if (i.strHostResource.substr(0, 11) == "ovf://disk/") 964 vd.strDiskId = i.strHostResource.substr(11); 965 else if (i.strHostResource.substr(0, 6) == "/disk/") 966 vd.strDiskId = i.strHostResource.substr(6); 967 968 if ( !(vd.strDiskId.length()) 969 || (m->mapDisks.find(vd.strDiskId) == m->mapDisks.end()) 970 ) 971 return setError(VBOX_E_FILE_ERROR, 972 tr("Error reading \"%s\": Hard disk item with instance ID %d specifies invalid host resource \"%s\", line %d"), 973 pcszPath, 974 i.ulInstanceID, 975 i.strHostResource.c_str(), 976 i.ulLineNumber); 977 978 vsys.mapVirtualDisks[vd.strDiskId] = vd; 979 } 937 // handled separately in second loop below 980 938 break; 981 939 … … 1041 999 i.resourceType, 1042 1000 i.ulLineNumber); 1001 } // end switch 1002 } 1003 1004 // now run through the items for a second time, but handle only 1005 // hard disk images; otherwise the code would fail if a hard 1006 // disk image appears in the OVF before its hard disk controller 1007 for (itH = vsys.mapHardwareItems.begin(); 1008 itH != vsys.mapHardwareItems.end(); 1009 ++itH) 1010 { 1011 const VirtualHardwareItem &i = itH->second; 1012 1013 // do some analysis 1014 switch (i.resourceType) 1015 { 1016 case OVFResourceType_HardDisk: // 17 1017 { 1018 /* <Item> 1019 <rasd:Caption>Harddisk 1</rasd:Caption> 1020 <rasd:Description>HD</rasd:Description> 1021 <rasd:ElementName>Hard Disk</rasd:ElementName> 1022 <rasd:HostResource>ovf://disk/lamp</rasd:HostResource> 1023 <rasd:InstanceID>5</rasd:InstanceID> 1024 <rasd:Parent>4</rasd:Parent> 1025 <rasd:ResourceType>17</rasd:ResourceType> 1026 </Item> */ 1027 1028 // look up the hard disk controller element whose InstanceID equals our Parent; 1029 // this is how the connection is specified in OVF 1030 ControllersMap::const_iterator it = vsys.mapControllers.find(i.ulParent); 1031 if (it == vsys.mapControllers.end()) 1032 return setError(VBOX_E_FILE_ERROR, 1033 tr("Error reading \"%s\": Hard disk item with instance ID %d specifies invalid parent %d, line %d"), 1034 pcszPath, 1035 i.ulInstanceID, 1036 i.ulParent, 1037 i.ulLineNumber); 1038 //const HardDiskController &hdc = it->second; 1039 1040 VirtualDisk vd; 1041 vd.idController = i.ulParent; 1042 i.strAddressOnParent.toInt(vd.ulAddressOnParent); 1043 // ovf://disk/lamp 1044 // 123456789012345 1045 if (i.strHostResource.substr(0, 11) == "ovf://disk/") 1046 vd.strDiskId = i.strHostResource.substr(11); 1047 else if (i.strHostResource.substr(0, 6) == "/disk/") 1048 vd.strDiskId = i.strHostResource.substr(6); 1049 1050 if ( !(vd.strDiskId.length()) 1051 || (m->mapDisks.find(vd.strDiskId) == m->mapDisks.end()) 1052 ) 1053 return setError(VBOX_E_FILE_ERROR, 1054 tr("Error reading \"%s\": Hard disk item with instance ID %d specifies invalid host resource \"%s\", line %d"), 1055 pcszPath, 1056 i.ulInstanceID, 1057 i.strHostResource.c_str(), 1058 i.ulLineNumber); 1059 1060 vsys.mapVirtualDisks[vd.strDiskId] = vd; 1061 } 1062 break; 1043 1063 } 1044 1064 }
Note:
See TracChangeset
for help on using the changeset viewer.