Changeset 90438 in vbox for trunk/src/VBox/Main/xml
- Timestamp:
- Jul 30, 2021 4:25:55 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/xml/ovfreader.cpp
r85222 r90438 84 84 85 85 if (!pRootElem || strcmp(pRootElem->getName(), "Envelope")) 86 throw OVFLogicError(N_("Root element in OVF file must be \"Envelope\"."));86 throw OVFLogicError(N_("Root element in OVF file must be 'Envelope'.")); 87 87 88 88 pcszNamespaceURI = pRootElem->getNamespaceURI(); 89 if (pcszNamespaceURI.isEmpty())89 if (pcszNamespaceURI.isEmpty()) 90 90 { 91 91 throw OVFLogicError(N_("Error reading namespace URI in 'Envelope' element, line %d"), pRootElem->getLineNumber()); … … 277 277 } 278 278 else 279 throw OVFLogicError(N_("Error reading \"%s\": cannot find References/File element for ID '%s'referenced by 'Disk' element, line %d"),279 throw OVFLogicError(N_("Error reading \"%s\": cannot find References/File element for ID \"%s\" referenced by 'Disk' element, line %d"), 280 280 m_strPath.c_str(), 281 281 pcszFileRef, … … 364 364 pcszTypeAttr = pTypeAttr->getValueN(RT_XML_ATTR_TINY); 365 365 else 366 throw OVFLogicError(N_("Error reading \"%s\": element \"Section\" has no \"type\"attribute, line %d"),366 throw OVFLogicError(N_("Error reading \"%s\": element 'Section' has no 'type' attribute, line %d"), 367 367 m_strPath.c_str(), 368 368 pelmThis->getLineNumber()); … … 430 430 /* Parse the items into the hardware item vector. */ 431 431 { 432 std::map< uint32_t, const VirtualHardwareItem *> mapHardwareItems;432 std::map<RTCString, const VirtualHardwareItem *> mapHardwareItems; 433 433 xml::NodesLoop childrenIterator(*pelmThis); 434 434 const xml::ElementNode *pelmItem; … … 461 461 462 462 /* Add to mapping vector (for parent ID lookups) if it has a valid instance ID. */ 463 if ( pItem->ulInstanceID != 0)463 if (!pItem->strInstanceID.isEmpty()) 464 464 { 465 std::map< uint32_t, const VirtualHardwareItem *>::const_iterator itDup;466 itDup = mapHardwareItems.find(pItem-> ulInstanceID);465 std::map<RTCString, const VirtualHardwareItem *>::const_iterator itDup; 466 itDup = mapHardwareItems.find(pItem->strInstanceID); 467 467 if (itDup == mapHardwareItems.end()) 468 mapHardwareItems[pItem-> ulInstanceID] = pItem;468 mapHardwareItems[pItem->strInstanceID] = pItem; 469 469 else 470 470 #if 1 471 LogRel(("OVFREADER: Warning reading '%s'! Duplicate ulInstanceID %uon line %d, previous at %d!\n",472 m_strPath.c_str(), pItem-> ulInstanceID, pItem->m_iLineNumber, itDup->second->m_iLineNumber));471 LogRel(("OVFREADER: Warning reading \"%s\": Duplicate InstanceID \"%s\" on line %d, previous at %d!\n", 472 m_strPath.c_str(), pItem->strInstanceID.c_str(), pItem->m_iLineNumber, itDup->second->m_iLineNumber)); 473 473 #else 474 throw OVFLogicError(N_("Error reading '%s': Duplicate ulInstanceID %uon line %d, previous at %d"),475 m_strPath.c_str(), pItem-> ulInstanceID,474 throw OVFLogicError(N_("Error reading \"%s\": Duplicate InstanceID \"%s\" on line %d, previous at %d"), 475 m_strPath.c_str(), pItem->strInstanceID.c_str(), 476 476 pItem->m_iLineNumber, itDup->second->m_iLineNumber); 477 477 #endif … … 535 535 HardDiskController hdc; 536 536 hdc.system = HardDiskController::IDE; 537 hdc. idController = i.ulInstanceID;537 hdc.strIdController = i.strInstanceID; 538 538 hdc.strControllerType = i.strResourceSubType; 539 539 … … 567 567 } 568 568 569 vsys.mapControllers[i. ulInstanceID] = hdc;569 vsys.mapControllers[i.strInstanceID] = hdc; 570 570 if (!pPrimaryIDEController) 571 pPrimaryIDEController = &vsys.mapControllers[i. ulInstanceID];571 pPrimaryIDEController = &vsys.mapControllers[i.strInstanceID]; 572 572 break; 573 573 } … … 585 585 HardDiskController hdc; 586 586 hdc.system = HardDiskController::SCSI; 587 hdc. idController = i.ulInstanceID;587 hdc.strIdController = i.strInstanceID; 588 588 hdc.strControllerType = i.strResourceSubType; 589 589 590 vsys.mapControllers[i. ulInstanceID] = hdc;590 vsys.mapControllers[i.strInstanceID] = hdc; 591 591 break; 592 592 } … … 657 657 HardDiskController hdc; 658 658 hdc.system = HardDiskController::SATA; 659 hdc. idController = i.ulInstanceID;659 hdc.strIdController = i.strInstanceID; 660 660 hdc.strControllerType = i.strResourceSubType; 661 661 662 vsys.mapControllers[i. ulInstanceID] = hdc;662 vsys.mapControllers[i.strInstanceID] = hdc; 663 663 } 664 else if ( i.strResourceSubType.compare("VirtioSCSI", RTCString::CaseInsensitive) == 0 ) 664 else if ( i.strResourceSubType.compare("VirtioSCSI", RTCString::CaseInsensitive) == 0 665 || i.strResourceSubType.compare("virtio-scsi", RTCString::CaseInsensitive) == 0 ) 665 666 { 666 667 HardDiskController hdc; 667 hdc.system = HardDiskController::VIRTIOSCSI; 668 hdc. idController = i.ulInstanceID;668 hdc.system = HardDiskController::VIRTIOSCSI; /**< r=klaus: GUI needs to learn about this in the import dialog, currently shown as "Unknown Hardware Item". */ 669 hdc.strIdController = i.strInstanceID; 669 670 //<rasd:ResourceSubType>VirtioSCSI</rasd:ResourceSubType> 670 671 hdc.strControllerType = i.strResourceSubType; 671 vsys.mapControllers[i. ulInstanceID] = hdc;672 vsys.mapControllers[i.strInstanceID] = hdc; 672 673 } 673 674 else 674 throw OVFLogicError(N_("Error reading \"%s\": Host resource of type \"Other Storage Device (%d)\" is supported with SATA AHCI controllers only, line %d (subtype:%s)"),675 throw OVFLogicError(N_("Error reading \"%s\": Host resource of type \"Other Storage Device (%d)\" is supported with SATA AHCI or virtio-scsi controllers only, line %d (subtype:%s)"), 675 676 m_strPath.c_str(), 676 677 ResourceType_OtherStorageDevice, … … 751 752 // look up the hard disk controller element whose InstanceID equals our Parent; 752 753 // this is how the connection is specified in OVF 753 ControllersMap::const_iterator it = vsys.mapControllers.find(i. ulParent);754 ControllersMap::const_iterator it = vsys.mapControllers.find(i.strParent); 754 755 if (it == vsys.mapControllers.end()) 755 throw OVFLogicError(N_("Error reading \"%s\": Disk item with instance ID %d specifies invalid parent %d, line %d"),756 throw OVFLogicError(N_("Error reading \"%s\": Disk item with instance ID \"%s\" specifies invalid parent \"%s\", line %d"), 756 757 m_strPath.c_str(), 757 i. ulInstanceID,758 i. ulParent,758 i.strInstanceID.c_str(), 759 i.strParent.c_str(), 759 760 i.m_iLineNumber); 760 761 761 762 VirtualDisk vd; 762 vd. idController = i.ulParent;763 vd.strIdController = i.strParent; 763 764 i.strAddressOnParent.toInt(vd.ulAddressOnParent); 764 765 // ovf://disk/lamp … … 774 775 if ((vd.strDiskId.isEmpty() || (m_mapDisks.find(vd.strDiskId) == m_mapDisks.end())) 775 776 && i.resourceType == ResourceType_HardDisk) 776 throw OVFLogicError(N_("Error reading \"%s\": Disk item with instance ID %dspecifies invalid host resource \"%s\", line %d"),777 throw OVFLogicError(N_("Error reading \"%s\": Disk item with instance ID \"%s\" specifies invalid host resource \"%s\", line %d"), 777 778 m_strPath.c_str(), 778 i. ulInstanceID,779 i.strInstanceID.c_str(), 779 780 i.strHostResource.c_str(), 780 781 i.m_iLineNumber); … … 834 835 else if ( !strcmp(pcszItemChildName, "InstanceID") 835 836 || !strcmp(pcszItemChildName, "InstanceId") ) 836 pelmItemChild->copyValue(ulInstanceID);837 strInstanceID = pelmItemChild->getValueN(RT_XML_CONTENT_SMALL); 837 838 else if (!strcmp(pcszItemChildName, "HostResource")) 838 839 strHostResource = pelmItemChild->getValueN(RT_XML_CONTENT_SMALL); … … 841 842 uint32_t ulType; 842 843 pelmItemChild->copyValue(ulType); 844 if (ulType > 0xffff) 845 ulType = 0xffff; 843 846 resourceType = (ResourceType_T)ulType; 844 847 fResourceRequired = true; … … 859 862 fAutomaticDeallocation = (!strcmp(pelmItemChild->getValueN(RT_XML_CONTENT_SMALL), "true")) ? true : false; 860 863 else if (!strcmp(pcszItemChildName, "Parent")) 861 pelmItemChild->copyValue(ulParent);864 strParent = pelmItemChild->getValueN(RT_XML_CONTENT_SMALL); 862 865 else if (!strcmp(pcszItemChildName, "Connection")) 863 866 strConnection = pelmItemChild->getValueN(RT_XML_CONTENT_SMALL); … … 889 892 // else if (pelmItemChild->getPrefix() == NULL 890 893 // || strcmp(pelmItemChild->getPrefix(), "vmw")) 891 // throw OVFLogicError(N_("Unknown element \"%s\"under Item element, line %d"),894 // throw OVFLogicError(N_("Unknown element '%s' under Item element, line %d"), 892 895 // pcszItemChildName, 893 896 // m_iLineNumber); … … 902 905 name.c_str(), m_iLineNumber, DTMF_SPECS_URI); 903 906 904 /* Don't be too uptight about the ulInstanceID value. There are OVAs out905 there which have ulInstanceID="%iid%for memory for instance, which is907 /* Don't be too uptight about the strInstanceID value. There are OVAs out 908 there which have InstanceID="%iid%" for memory for instance, which is 906 909 no good reason for not being able to process them. bugref:8997 */ 907 if ( ulInstanceID == 0)910 if (strInstanceID.isEmpty()) 908 911 { 909 912 if ( resourceType == ResourceType_IDEController … … 915 918 name.c_str(), m_iLineNumber, DTMF_SPECS_URI); 916 919 else 917 LogRel(("OVFREADER: Warning: Ignoring missing or invalid ulInstanceID under element %s, line %u\n",920 LogRel(("OVFREADER: Warning: Ignoring missing or invalid InstanceID under element %s, line %u\n", 918 921 name.c_str(), m_iLineNumber)); 919 922 }
Note:
See TracChangeset
for help on using the changeset viewer.