Changeset 28531 in vbox for trunk/src/VBox/Main
- Timestamp:
- Apr 20, 2010 4:22:41 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 60336
- Location:
- trunk/src/VBox/Main
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ApplianceImplExport.cpp
r28195 r28531 165 165 strMemory); 166 166 167 int32_t lIDEControllerIndex = 0; 167 // the one VirtualBox IDE controller has two channels with two ports each, which is 168 // considered two IDE controllers with two ports each by OVF, so export it as two 169 int32_t lIDEControllerPrimaryIndex = 0; 170 int32_t lIDEControllerSecondaryIndex = 0; 168 171 int32_t lSATAControllerIndex = 0; 169 172 int32_t lSCSIControllerIndex = 0; … … 217 220 if (strVbox.length()) 218 221 { 219 lIDEController Index = (int32_t)pNewDesc->m->llDescriptions.size();222 lIDEControllerPrimaryIndex = (int32_t)pNewDesc->m->llDescriptions.size(); 220 223 pNewDesc->addEntry(VirtualSystemDescriptionType_HardDiskControllerIDE, 221 Utf8StrFmt("%d", lIDEControllerIndex), 224 Utf8StrFmt("%d", lIDEControllerPrimaryIndex), 225 strVbox, 226 strVbox); 227 lIDEControllerSecondaryIndex = lIDEControllerPrimaryIndex + 1; 228 pNewDesc->addEntry(VirtualSystemDescriptionType_HardDiskControllerIDE, 229 Utf8StrFmt("%d", lIDEControllerSecondaryIndex), 222 230 strVbox, 223 231 strVbox); … … 354 362 // this is the exact reverse to what we're doing in Appliance::taskThreadImportMachines, 355 363 // and it must be updated when that is changed! 364 // Before 3.2 we exported one IDE controller with channel 0-3, but we now maintain 365 // compatibility with what VMware does and export two IDE controllers with two channels each 356 366 357 367 if (lChannel == 0 && lDevice == 0) // primary master 368 { 369 lControllerVsys = lIDEControllerPrimaryIndex; 358 370 lChannelVsys = 0; 371 } 359 372 else if (lChannel == 0 && lDevice == 1) // primary slave 373 { 374 lControllerVsys = lIDEControllerPrimaryIndex; 360 375 lChannelVsys = 1; 376 } 361 377 else if (lChannel == 1 && lDevice == 0) // secondary master; by default this is the CD-ROM but as of VirtualBox 3.1 that can change 362 lChannelVsys = 2; 378 { 379 lControllerVsys = lIDEControllerSecondaryIndex; 380 lChannelVsys = 0; 381 } 363 382 else if (lChannel == 1 && lDevice == 1) // secondary slave 364 lChannelVsys = 3; 383 { 384 lControllerVsys = lIDEControllerSecondaryIndex; 385 lChannelVsys = 1; 386 } 365 387 else 366 388 throw setError(VBOX_E_NOT_SUPPORTED, 367 389 tr("Cannot handle medium attachment: channel is %d, device is %d"), lChannel, lDevice); 368 369 lControllerVsys = lIDEControllerIndex;370 390 break; 371 391 … … 825 845 // assigning them first 826 846 827 uint32_t idIDEController = 0; 828 int32_t lIDEControllerIndex = 0; 847 uint32_t idIDEPrimaryController = 0; 848 int32_t lIDEPrimaryControllerIndex = 0; 849 uint32_t idIDESecondaryController = 0; 850 int32_t lIDESecondaryControllerIndex = 0; 829 851 uint32_t idSATAController = 0; 830 852 int32_t lSATAControllerIndex = 0; … … 919 941 { 920 942 strDescription = "IDE Controller"; 921 strCaption = "ideController0";922 943 type = ovf::ResourceType_IDEController; // 5 923 944 strResourceSubType = desc.strVbox; 924 // it seems that OVFTool always writes these two, and since we can only 925 // have one IDE controller, we'll use this as well 926 lAddress = 1; 927 lBusNumber = 1; 928 929 // remember this ID 930 idIDEController = ulInstanceID; 931 lIDEControllerIndex = lIndexThis; 945 946 if (desc.strRef != "1") 947 { 948 // first IDE controller: 949 strCaption = "ideController0"; 950 lAddress = 0; 951 lBusNumber = 0; 952 // remember this ID 953 idIDEPrimaryController = ulInstanceID; 954 lIDEPrimaryControllerIndex = lIndexThis; 955 } 956 else 957 { 958 // second IDE controller: 959 strCaption = "ideController1"; 960 lAddress = 1; 961 lBusNumber = 1; 962 // remember this ID 963 idIDESecondaryController = ulInstanceID; 964 lIDESecondaryControllerIndex = lIndexThis; 965 } 932 966 } 933 967 break; … … 1033 1067 int32_t lControllerIndex = -1; 1034 1068 RTStrToInt32Ex(desc.strExtraConfig.c_str() + pos1 + 11, NULL, 0, &lControllerIndex); 1035 if (lControllerIndex == lIDEControllerIndex) 1036 ulParent = idIDEController; 1069 if (lControllerIndex == lIDEPrimaryControllerIndex) 1070 ulParent = idIDEPrimaryController; 1071 else if (lControllerIndex == lIDESecondaryControllerIndex) 1072 ulParent = idIDESecondaryController; 1037 1073 else if (lControllerIndex == lSCSIControllerIndex) 1038 1074 ulParent = idSCSIController; … … 1044 1080 1045 1081 if ( !ulParent 1046 1047 1082 || lAddressOnParent == -1 1083 ) 1048 1084 throw setError(VBOX_E_NOT_SUPPORTED, 1049 1085 tr("Missing or bad extra config string in hard disk image: \"%s\""), desc.strExtraConfig.c_str()); … … 1068 1104 { 1069 1105 // we can't have a CD without an IDE controller 1070 if (!idIDE Controller)1106 if (!idIDESecondaryController) 1071 1107 throw setError(VBOX_E_NOT_SUPPORTED, 1072 tr("Can't have CD-ROM without IDE controller"));1108 tr("Can't have CD-ROM without secondary IDE controller")); 1073 1109 1074 1110 strDescription = "CD-ROM Drive"; … … 1076 1112 type = ovf::ResourceType_CDDrive; // 15 1077 1113 lAutomaticAllocation = 1; 1078 ulParent = idIDE Controller;1114 ulParent = idIDESecondaryController; 1079 1115 lAddressOnParent = 0; // this is what OVFTool writes 1080 1116 } -
trunk/src/VBox/Main/ApplianceImplImport.cpp
r28189 r28531 838 838 * Throws HRESULT values on errors! 839 839 * 840 * @param hdc 841 * @param vd 842 * @param mhda 840 * @param hdc in: the HardDiskController structure to attach to. 841 * @param ulAddressOnParent in: the AddressOnParent parameter from OVF. 842 * @param controllerType out: the name of the hard disk controller to attach to (e.g. "IDE Controller"). 843 * @param lChannel out: the channel (controller port) of the controller to attach to. 844 * @param lDevice out: the device number to attach to. 843 845 */ 844 846 void Appliance::convertDiskAttachmentValues(const ovf::HardDiskController &hdc, … … 859 861 switch (ulAddressOnParent) 860 862 { 861 case 0: // interpret this as primary master 862 lChannel = (long)0; 863 lDevice = (long)0; 863 case 0: // master 864 if (hdc.ulAddress == 1) 865 { 866 // IDE controller has address 1: then it was exported from VMware and is the secondary controller 867 lChannel = (long)1; 868 lDevice = (long)0; 869 } 870 else // interpret this as primary master 871 { 872 lChannel = (long)0; 873 lDevice = (long)0; 874 } 864 875 break; 865 876 866 case 1: // interpret this as primary slave 867 lChannel = (long)0; 868 lDevice = (long)1; 877 case 1: // slave 878 if (hdc.ulAddress == 1) 879 { 880 // IDE controller has address 1: then it was exported from VMware and is the secondary controller 881 lChannel = (long)1; 882 lDevice = (long)1; 883 } 884 else // interpret this as primary slave 885 { 886 lChannel = (long)0; 887 lDevice = (long)1; 888 } 869 889 break; 870 890 891 // used by older VBox exports 871 892 case 2: // interpret this as secondary master 872 893 lChannel = (long)1; … … 874 895 break; 875 896 897 // used by older VBox exports 876 898 case 3: // interpret this as secondary slave 877 899 lChannel = (long)1; … … 1603 1625 } 1604 1626 1605 / * Hard disk controller IDE */1627 // IDE Hard disk controller 1606 1628 std::list<VirtualSystemDescriptionEntry*> vsdeHDCIDE = vsdescThis->findByType(VirtualSystemDescriptionType_HardDiskControllerIDE); 1607 if (vsdeHDCIDE.size() > 1) 1629 // In OVF (at least VMware's version of it), an IDE controller has two ports, so VirtualBox's single IDE controller 1630 // with two channels and two ports each counts as two OVF IDE controllers -- so we accept one or two such IDE controllers 1631 uint32_t cIDEControllers = vsdeHDCIDE.size(); 1632 if (cIDEControllers > 2) 1608 1633 throw setError(VBOX_E_FILE_ERROR, 1609 tr("Too many IDE controllers in OVF; import facility only supports one")); 1610 if (vsdeHDCIDE.size() == 1) 1611 { 1634 tr("Too many IDE controllers in OVF; import facility only supports two")); 1635 if (vsdeHDCIDE.size() > 0) 1636 { 1637 // one or two IDE controllers present in OVF: add one VirtualBox controller 1612 1638 ComPtr<IStorageController> pController; 1613 1639 rc = pNewMachine->AddStorageController(Bstr("IDE Controller"), StorageBus_IDE, pController.asOutParam()); … … 1701 1727 try 1702 1728 { 1703 /* In order to attach things we need to open a session 1704 * for the new machine */ 1729 // to attach things we need to open a session for the new machine 1705 1730 rc = mVirtualBox->OpenSession(stack.pSession, bstrNewMachineId); 1706 1731 if (FAILED(rc)) throw rc; … … 1749 1774 // for now always attach to secondary master on IDE controller; 1750 1775 // there seems to be no useful information in OVF where else to 1751 // attach jt (@todo test with latest versions of OVF software)1776 // attach it (@todo test with latest versions of OVF software) 1752 1777 1753 1778 // find the IDE controller … … 1808 1833 } 1809 1834 1810 / * Create the hard disks & connect them to the appropriate controllers. */1835 // create the hard disks & connect them to the appropriate controllers 1811 1836 std::list<VirtualSystemDescriptionEntry*> avsdeHDs = vsdescThis->findByType(VirtualSystemDescriptionType_HardDiskImage); 1812 1837 if (avsdeHDs.size() > 0) … … 1816 1841 try 1817 1842 { 1818 /* In order to attach hard disks we need to open a session 1819 * for the new machine */ 1843 // to attach things we need to open a session for the new machine 1820 1844 rc = mVirtualBox->OpenSession(stack.pSession, bstrNewMachineId); 1821 1845 if (FAILED(rc)) throw rc; … … 1839 1863 ) 1840 1864 throw setError(E_FAIL, 1841 tr("Internal inconsistency looking up disk images.")); 1842 1843 const ovf::DiskImage &di = itDiskImage->second; 1844 const ovf::VirtualDisk &vd = itVirtualDisk->second; 1865 tr("Internal inconsistency looking up disk image '%s'"), 1866 vsdeHD->strRef.c_str()); 1867 1868 const ovf::DiskImage &ovfDiskImage = itDiskImage->second; 1869 const ovf::VirtualDisk &ovfVdisk = itVirtualDisk->second; 1845 1870 1846 1871 ComPtr<IMedium> pTargetHD; 1847 importOneDiskImage( di,1872 importOneDiskImage(ovfDiskImage, 1848 1873 vsdeHD->strVbox, 1849 1874 pTargetHD, 1850 1875 stack); 1851 1876 1852 / * Now use the new uuid to attach the disk image to our new machine */1877 // now use the new uuid to attach the disk image to our new machine 1853 1878 ComPtr<IMachine> sMachine; 1854 1879 rc = stack.pSession->COMGETTER(Machine)(sMachine.asOutParam()); … … 1858 1883 if (FAILED(rc)) throw rc; 1859 1884 1860 / * For now we assume we have one controller of every type only */1861 ovf::HardDiskController hdc = (*vsysThis.mapControllers.find( vd.idController)).second;1885 // find the hard disk controller to which we should attach 1886 ovf::HardDiskController hdc = (*vsysThis.mapControllers.find(ovfVdisk.idController)).second; 1862 1887 1863 1888 // this is for rollback later … … 1867 1892 1868 1893 convertDiskAttachmentValues(hdc, 1869 vd.ulAddressOnParent,1894 ovfVdisk.ulAddressOnParent, 1870 1895 mhda.controllerType, // Bstr 1871 1896 mhda.lChannel, … … 1874 1899 Log(("Attaching disk %s to channel %d on device %d\n", vsdeHD->strVbox.c_str(), mhda.lChannel, mhda.lDevice)); 1875 1900 1876 rc = sMachine->AttachDevice(mhda.controllerType, 1877 mhda.lChannel, 1878 mhda.lDevice, 1879 DeviceType_HardDisk, 1880 hdId); 1901 rc = sMachine->AttachDevice(mhda.controllerType, // wstring name 1902 mhda.lChannel, // long controllerPort 1903 mhda.lDevice, // long device 1904 DeviceType_HardDisk, // DeviceType_T type 1905 hdId); // uuid id 1881 1906 if (FAILED(rc)) throw rc; 1882 1907 -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r28485 r28531 3494 3494 3495 3495 The list below identifies the value sets that are possible depending on the 3496 <link to="VirtualSystemDescriptionType" /> enum value in the array item in aTypes[]. In each case,3497 the array item with the same index in aOvfValues[] will contain the original value as contained3498 in the OVF file (just for informational purposes), and the corresponding item in aVBoxValues[]3496 <link to="VirtualSystemDescriptionType" /> enum value in the array item in @a aTypes[]. In each case, 3497 the array item with the same index in @a aOvfValues[] will contain the original value as contained 3498 in the OVF file (just for informational purposes), and the corresponding item in @a aVBoxValues[] 3499 3499 will contain a suggested value to be used for VirtualBox. Depending on the description type, 3500 the aExtraConfigValues[] array item may also be used.3500 the @a aExtraConfigValues[] array item may also be used. 3501 3501 3502 3502 <ul> 3503 3503 <li> 3504 3504 "OS": the guest operating system type. There must be exactly one such array item on import. The 3505 corresponding item in aVBoxValues[] contains the suggested guest operating system for VirtualBox.3505 corresponding item in @a aVBoxValues[] contains the suggested guest operating system for VirtualBox. 3506 3506 This will be one of the values listed in <link to="IVirtualBox::guestOSTypes" />. The corresponding 3507 item in aOvfValues[] will contain a numerical value that described the operating system in the OVF.3507 item in @a aOvfValues[] will contain a numerical value that described the operating system in the OVF. 3508 3508 </li> 3509 3509 <li> 3510 3510 "Name": the name to give to the new virtual machine. There can be at most one such array item; 3511 3511 if none is present on import, then an automatic name will be created from the operating system 3512 type. The correponding item im aOvfValues[] will contain the suggested virtual machine name3513 from the OVF file, and aVBoxValues[] will contain a suggestion for a unique VirtualBox3512 type. The correponding item im @a aOvfValues[] will contain the suggested virtual machine name 3513 from the OVF file, and @a aVBoxValues[] will contain a suggestion for a unique VirtualBox 3514 3514 <link to="IMachine" /> name that does not exist yet. 3515 3515 </li> … … 3533 3533 </li> 3534 3534 <li> 3535 "Hard diskControllerIDE": an IDE hard disk controller. There can be at most one such item. This3536 has no value in aOvfValues[] oraVBoxValues[].3537 The matching item in the aRefs[] array will contain an integer that items of the "Harddisk"3535 "HardDiskControllerIDE": an IDE hard disk controller. There can be at most two such items. 3536 This has no value in @a aOvfValues[] or @a aVBoxValues[]. 3537 The matching item in the @a aRefs[] array will contain an integer that items of the "Harddisk" 3538 3538 type can use to specify which hard disk controller a virtual disk should be connected to. 3539 Note that in OVF, an IDE controller has two channels, corresponding to "master" and "slave" 3540 in traditional terminology, whereas the IDE storage controller that VirtualBox supports in 3541 its virtual machines supports four channels (primary master, primary slave, secondary master, 3542 secondary slave) and thus maps to two IDE controllers in the OVF sense. 3539 3543 </li> 3540 3544 <li> 3541 "Hard diskControllerSATA": an SATA hard disk controller. There can be at most one such item. This3542 has no value in aOvfValues[] oraVBoxValues[].3543 The matching item in the aRefs[] array will be used as with IDE controllers (see above).3545 "HardDiskControllerSATA": an SATA hard disk controller. There can be at most one such item. This 3546 has no value in @a aOvfValues[] or @a aVBoxValues[]. 3547 The matching item in the @a aRefs[] array will be used as with IDE controllers (see above). 3544 3548 </li> 3545 3549 <li> 3546 "Hard diskControllerSCSI": a SCSI hard disk controller. There can be at most one such item.3547 The items in aOvfValues[] andaVBoxValues[] will either be "LsiLogic" or "BusLogic".3548 The matching item in the aRefs[] array will be used as with IDE controllers (see above).3550 "HardDiskControllerSCSI": a SCSI hard disk controller. There can be at most one such item. 3551 The items in @a aOvfValues[] and @a aVBoxValues[] will either be "LsiLogic" or "BusLogic". 3552 The matching item in the @a aRefs[] array will be used as with IDE controllers (see above). 3549 3553 </li> 3550 3554 <li> … … 3552 3556 arbitrary number of these items, one for each virtual disk image that accompanies the OVF. 3553 3557 3554 The array item in aOvfValues[] will contain the file specification from the OVF file (without3558 The array item in @a aOvfValues[] will contain the file specification from the OVF file (without 3555 3559 a path since the image file should be in the same location as the OVF file itself), whereas the 3556 item in aVBoxValues[] will contain a qualified path specification to where VirtualBox uses the3560 item in @a aVBoxValues[] will contain a qualified path specification to where VirtualBox uses the 3557 3561 hard disk image. This means that on import the image will be copied and converted from the 3558 3562 "ovf" location to the "vbox" location; on export, this will be handled the other way round. 3559 3563 On import, the target image will also be registered with VirtualBox. 3560 3564 3561 The matching item in the aExtraConfigValues[] array must contain a string of the following3565 The matching item in the @a aExtraConfigValues[] array must contain a string of the following 3562 3566 format: "controller=<index>;channel=<c>" 3563 3567 In this string, <index> must be an integer specifying the hard disk controller to connect 3564 3568 the image to. That number must be the index of an array item with one of the hard disk controller 3565 types (Hard diskControllerSCSI, HarddiskControllerSATA, HarddiskControllerIDE).3569 types (HardDiskControllerSCSI, HardDiskControllerSATA, HardDiskControllerIDE). 3566 3570 In addition, <c> must specify the channel to use on that controller. For IDE controllers, 3567 this can range from 0-3 (which VirtualBox will interpret as primary master, primary slave, secondary master and 3568 secondary slave. For SATA and SCSI controllers, the channel can range from 0-29. 3571 this can be 0 or 1 for master or slave, respectively. For compatibility with VirtualBox versions 3572 before 3.2, the values 2 and 3 (for secondary master and secondary slave) are also supported, but 3573 no longer exported. For SATA and SCSI controllers, the channel can range from 0-29. 3569 3574 </li> 3570 3575 <li> 3571 "CDROM": a virtual CD-ROM drive. The matching item in aExtraConfigValue[] contains the same3576 "CDROM": a virtual CD-ROM drive. The matching item in @a aExtraConfigValue[] contains the same 3572 3577 attachment information as with "HardDiskImage" items. 3573 3578 </li> 3574 3579 <li> 3575 "CDROM": a virtual floppy drive. The matching item in aExtraConfigValue[] contains the same3580 "CDROM": a virtual floppy drive. The matching item in @a aExtraConfigValue[] contains the same 3576 3581 attachment information as with "HardDiskImage" items. 3577 3582 </li> 3578 3583 <li> 3579 "NetworkAdapter": a network adapter. The array item in aVBoxValues[] will specify the hardware3580 for the network adapter, whereas the array item in aExtraConfigValues[] will have a string3584 "NetworkAdapter": a network adapter. The array item in @a aVBoxValues[] will specify the hardware 3585 for the network adapter, whereas the array item in @a aExtraConfigValues[] will have a string 3581 3586 of the "type=<X>" format, where <X> must be either "NAT" or "Bridged". 3582 3587 </li> -
trunk/src/VBox/Main/include/ovfreader.h
r28165 r28531 256 256 struct HardDiskController 257 257 { 258 uint32_t idController; // instance ID (Item/InstanceId); this gets referenced from HardDisk 258 uint32_t idController; // instance ID (Item/InstanceId); this gets referenced from VirtualDisk 259 259 260 enum ControllerSystemType { IDE, SATA, SCSI }; 260 ControllerSystemType system; // one of IDE, SATA, SCSI 261 iprt::MiniString strControllerType; // controller subtype (Item/ResourceSubType); e.g. "LsiLogic"; can be empty (esp. for IDE) 262 iprt::MiniString strAddress; // for IDE 263 uint32_t ulBusNumber; // for IDE 261 ControllerSystemType system; // one of IDE, SATA, SCSI 262 263 iprt::MiniString strControllerType; // controller subtype (Item/ResourceSubType); e.g. "LsiLogic"; can be empty (esp. for IDE) 264 265 uint32_t ulAddress; // controller index; this is determined heuristically by the OVF reader and will 266 // be 0 for the first controller of this type (e.g. IDE primary ctler), 1 for the 267 // next (e.g. IDE secondary ctler) 264 268 265 269 HardDiskController() 266 270 : idController(0), 267 ulBusNumber(0) 268 { 269 } 271 ulAddress(0) 272 { } 270 273 }; 271 274 … … 275 278 { 276 279 uint32_t idController; // SCSI (or IDE) controller this disk is connected to; 280 // this must match HardDiskController.idController and 277 281 // points into VirtualSystem.mapControllers 278 282 uint32_t ulAddressOnParent; // parsed strAddressOnParent of hardware item; will be 0 or 1 for IDE -
trunk/src/VBox/Main/xml/ovfreader.cpp
r28165 r28531 424 424 else if (!strcmp(pcszItemChildName, "PoolID")) 425 425 i.strPoolID = pelmItemChild->getValue(); 426 else if (!strcmp(pcszItemChildName, "BusNumber")) 426 else if (!strcmp(pcszItemChildName, "BusNumber")) // seen in some old OVF, but it's not listed in the OVF specs 427 427 pelmItemChild->copyValue(i.ulBusNumber); 428 428 else … … 494 494 hdc.idController = i.ulInstanceID; 495 495 hdc.strControllerType = i.strResourceSubType; 496 hdc.strAddress = i.strAddress; 497 hdc.ulBusNumber = i.ulBusNumber; 496 497 // if there is a numeric address tag for the IDE controller, use that; 498 // VMware uses "0" and "1" to keep the two OVF IDE controllers apart; 499 // otherwise use the "bus number" field which was specified in some old 500 // OVF files (but not the standard) 501 if (i.strAddress == "0") 502 hdc.ulAddress = 0; 503 else if (i.strAddress == "1") 504 hdc.ulAddress = 1; 505 else if (i.strAddress == "2") // just to be sure, this doesn't seem to be used by VMware 506 hdc.ulAddress = 2; 507 else if (i.strAddress == "3") 508 hdc.ulAddress = 3; 509 else 510 hdc.ulAddress = i.ulBusNumber; 498 511 499 512 vsys.mapControllers[i.ulInstanceID] = hdc;
Note:
See TracChangeset
for help on using the changeset viewer.