Changeset 29422 in vbox
- Timestamp:
- May 12, 2010 2:08:52 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 61537
- Location:
- trunk/src/VBox/Main
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ApplianceImplImport.cpp
r29102 r29422 821 821 * @param ulAddressOnParent in: the AddressOnParent parameter from OVF. 822 822 * @param controllerType out: the name of the hard disk controller to attach to (e.g. "IDE Controller"). 823 * @param lC hannelout: the channel (controller port) of the controller to attach to.823 * @param lControllerPort out: the channel (controller port) of the controller to attach to. 824 824 * @param lDevice out: the device number to attach to. 825 825 */ … … 827 827 uint32_t ulAddressOnParent, 828 828 Bstr &controllerType, 829 int32_t &lC hannel,829 int32_t &lControllerPort, 830 830 int32_t &lDevice) 831 831 { 832 Log(("Appliance::convertDiskAttachmentValues: hdc.system=%d, hdc.fPrimary=%d, ulAddressOnParent=%d\n", hdc.system, hdc.fPrimary, ulAddressOnParent)); 833 832 834 switch (hdc.system) 833 835 { 834 836 case ovf::HardDiskController::IDE: 835 // For the IDE bus, the channelparameter can be either 0 or 1, to specify the primary837 // For the IDE bus, the port parameter can be either 0 or 1, to specify the primary 836 838 // or secondary IDE controller, respectively. For the primary controller of the IDE bus, 837 839 // the device number can be either 0 or 1, to specify the master or the slave device, … … 842 844 { 843 845 case 0: // master 844 if ( hdc.ulAddress == 1)846 if (!hdc.fPrimary) 845 847 { 846 // IDE controller has address 1: then it was exported from VMware and is the secondary controller847 lC hannel= (long)1;848 // secondary master 849 lControllerPort = (long)1; 848 850 lDevice = (long)0; 849 851 } 850 else // interpret this asprimary master852 else // primary master 851 853 { 852 lC hannel= (long)0;854 lControllerPort = (long)0; 853 855 lDevice = (long)0; 854 856 } … … 856 858 857 859 case 1: // slave 858 if ( hdc.ulAddress == 1)860 if (!hdc.fPrimary) 859 861 { 860 // IDE controller has address 1: then it was exported from VMware and is the secondary controller861 lC hannel= (long)1;862 // secondary slave 863 lControllerPort = (long)1; 862 864 lDevice = (long)1; 863 865 } 864 else // interpret this asprimary slave866 else // primary slave 865 867 { 866 lC hannel= (long)0;868 lControllerPort = (long)0; 867 869 lDevice = (long)1; 868 870 } … … 871 873 // used by older VBox exports 872 874 case 2: // interpret this as secondary master 873 lC hannel= (long)1;875 lControllerPort = (long)1; 874 876 lDevice = (long)0; 875 877 break; … … 877 879 // used by older VBox exports 878 880 case 3: // interpret this as secondary slave 879 lC hannel= (long)1;881 lControllerPort = (long)1; 880 882 lDevice = (long)1; 881 883 break; … … 890 892 case ovf::HardDiskController::SATA: 891 893 controllerType = Bstr("SATA Controller"); 892 lC hannel= (long)ulAddressOnParent;894 lControllerPort = (long)ulAddressOnParent; 893 895 lDevice = (long)0; 894 896 break; … … 896 898 case ovf::HardDiskController::SCSI: 897 899 controllerType = Bstr("SCSI Controller"); 898 lC hannel= (long)ulAddressOnParent;900 lControllerPort = (long)ulAddressOnParent; 899 901 lDevice = (long)0; 900 902 break; … … 902 904 default: break; 903 905 } 906 907 Log(("=> lControllerPort=%d, lDevice=%d\n", lControllerPort, lDevice)); 904 908 } 905 909 … … 1176 1180 if (SUCCEEDED(rc2)) 1177 1181 { 1178 rc2 = sMachine->DetachDevice(Bstr(mhda.controllerType), mhda.lC hannel, mhda.lDevice);1182 rc2 = sMachine->DetachDevice(Bstr(mhda.controllerType), mhda.lControllerPort, mhda.lDevice); 1179 1183 rc2 = sMachine->SaveSettings(); 1180 1184 } … … 1740 1744 mhda.pMachine = pNewMachine; 1741 1745 mhda.controllerType = bstrName; 1742 mhda.lC hannel= 0;1746 mhda.lControllerPort = 0; 1743 1747 mhda.lDevice = 0; 1744 1748 … … 1746 1750 1747 1751 rc = sMachine->AttachDevice(mhda.controllerType, 1748 mhda.lC hannel,1752 mhda.lControllerPort, 1749 1753 mhda.lDevice, 1750 1754 DeviceType_Floppy, … … 1789 1793 2, // interpreted as secondary master 1790 1794 mhda.controllerType, // Bstr 1791 mhda.lC hannel,1795 mhda.lControllerPort, 1792 1796 mhda.lDevice); 1793 1797 1794 Log(("Attaching CD-ROM to channel %d on device %d\n", mhda.lChannel, mhda.lDevice));1798 Log(("Attaching CD-ROM to port %d on device %d\n", mhda.lControllerPort, mhda.lDevice)); 1795 1799 1796 1800 rc = sMachine->AttachDevice(mhda.controllerType, 1797 mhda.lC hannel,1801 mhda.lControllerPort, 1798 1802 mhda.lDevice, 1799 1803 DeviceType_DVD, … … 1882 1886 ovfVdisk.ulAddressOnParent, 1883 1887 mhda.controllerType, // Bstr 1884 mhda.lC hannel,1888 mhda.lControllerPort, 1885 1889 mhda.lDevice); 1886 1890 1887 Log(("Attaching disk %s to channel %d on device %d\n", vsdeHD->strVbox.c_str(), mhda.lChannel, mhda.lDevice));1891 Log(("Attaching disk %s to port %d on device %d\n", vsdeHD->strVbox.c_str(), mhda.lControllerPort, mhda.lDevice)); 1888 1892 1889 1893 rc = sMachine->AttachDevice(mhda.controllerType, // wstring name 1890 mhda.lC hannel, // long controllerPort1894 mhda.lControllerPort, // long controllerPort 1891 1895 mhda.lDevice, // long device 1892 1896 DeviceType_HardDisk, // DeviceType_T type -
trunk/src/VBox/Main/MachineImpl.cpp
r29386 r29422 2766 2766 AutoReadLock mediumLock(pMedium COMMA_LOCKVAL_SRC_POS); 2767 2767 return setError(VBOX_E_OBJECT_IN_USE, 2768 tr("Medium '%s' is already attached to device slot %d on port%d of controller '%ls' of this virtual machine"),2768 tr("Medium '%s' is already attached to port %d, device %d of controller '%ls' of this virtual machine"), 2769 2769 pMedium->getLocationFull().raw(), 2770 aControllerPort, 2770 2771 aDevice, 2771 aControllerPort,2772 2772 aControllerName); 2773 2773 } 2774 2774 else 2775 2775 return setError(VBOX_E_OBJECT_IN_USE, 2776 tr("Device is already attached to slot %d on port%d of controller '%ls' of this virtual machine"),2777 a Device, aControllerPort, aControllerName);2776 tr("Device is already attached to port %d, device %d of controller '%ls' of this virtual machine"), 2777 aControllerPort, aDevice, aControllerName); 2778 2778 } 2779 2779 -
trunk/src/VBox/Main/include/ApplianceImpl.h
r28800 r29422 141 141 uint32_t ulAddressOnParent, 142 142 Bstr &controllerType, 143 int32_t &lC hannel,143 int32_t &lControllerPort, 144 144 int32_t &lDevice); 145 145 -
trunk/src/VBox/Main/include/ApplianceImplPrivate.h
r28800 r29422 127 127 ComPtr<IMachine> pMachine; 128 128 Bstr controllerType; 129 int32_t lC hannel;130 int32_t lDevice; 129 int32_t lControllerPort; // 0-29 for SATA 130 int32_t lDevice; // IDE: 0 or 1, otherwise 0 always 131 131 }; 132 132 -
trunk/src/VBox/Main/include/ovfreader.h
r29087 r29422 217 217 // a network adapter depending on the network name. 218 218 iprt::MiniString strAddress; // "Device-specific. For an Ethernet adapter, this specifies the MAC address." 219 int32_t lAddress; // strAddress as an integer, if applicable. 219 220 iprt::MiniString strAddressOnParent; // "For a device, this specifies its location on the controller." 220 221 iprt::MiniString strAllocationUnits; // "Specifies the units of allocation used. For example, “byte * 2^20”." … … 262 263 // treats it as a fourth class besides IDE, SATA, SCSI 263 264 264 uint32_t ulAddress; // controller index; this is determined heuristically by the OVF reader and will 265 // be 0 for the first controller of this type (e.g. IDE primary ctler), 1 for the 266 // next (e.g. IDE secondary ctler) 265 int32_t lAddress; // value from OVF "Address" element 266 bool fPrimary; // controller index; this is determined heuristically by the OVF reader and will 267 // be true for the first controller of this type (e.g. IDE primary ctler) or 268 // false for the next (e.g. IDE secondary ctler) 267 269 268 270 HardDiskController() 269 271 : idController(0), 270 ulAddress(0) 272 lAddress(0), 273 fPrimary(true) 271 274 { } 272 275 }; -
trunk/src/VBox/Main/xml/ovfreader.cpp
r28800 r29422 401 401 i.strConnection = pelmItemChild->getValue(); 402 402 else if (!strcmp(pcszItemChildName, "Address")) 403 { 403 404 i.strAddress = pelmItemChild->getValue(); 405 pelmItemChild->copyValue(i.lAddress); 406 } 404 407 else if (!strcmp(pcszItemChildName, "AddressOnParent")) 405 408 i.strAddressOnParent = pelmItemChild->getValue(); … … 433 436 } 434 437 438 HardDiskController *pPrimaryIDEController = NULL; // will be set once found 439 435 440 // now go thru all hardware items and handle them according to their type; 436 441 // in this first loop we handle all items _except_ hard disk images, … … 491 496 hdc.strControllerType = i.strResourceSubType; 492 497 493 // if there is a numeric address tag for the IDE controller, use that; 494 // VMware uses "0" and "1" to keep the two OVF IDE controllers apart; 495 // otherwise use the "bus number" field which was specified in some old 496 // OVF files (but not the standard) 497 if (i.strAddress == "0") 498 hdc.ulAddress = 0; 499 else if (i.strAddress == "1") 500 hdc.ulAddress = 1; 501 else if (i.strAddress == "2") // just to be sure, this doesn't seem to be used by VMware 502 hdc.ulAddress = 2; 503 else if (i.strAddress == "3") 504 hdc.ulAddress = 3; 498 hdc.lAddress = i.lAddress; 499 500 if (!pPrimaryIDEController) 501 // this is the first IDE controller found: then mark it as "primary" 502 hdc.fPrimary = true; 505 503 else 506 hdc.ulAddress = i.ulBusNumber; 504 { 505 // this is the second IDE controller found: If VMware exports two 506 // IDE controllers, it seems that they are given an "Address" of 0 507 // an 1, respectively, so assume address=0 means primary controller 508 if ( pPrimaryIDEController->lAddress == 0 509 && hdc.lAddress == 1 510 ) 511 { 512 pPrimaryIDEController->fPrimary = true; 513 hdc.fPrimary = false; 514 } 515 else if ( pPrimaryIDEController->lAddress == 1 516 && hdc.lAddress == 0 517 ) 518 { 519 pPrimaryIDEController->fPrimary = false; 520 hdc.fPrimary = false; 521 } 522 else 523 // then we really can't tell, just hope for the best 524 hdc.fPrimary = false; 525 } 507 526 508 527 vsys.mapControllers[i.ulInstanceID] = hdc; 528 if (!pPrimaryIDEController) 529 pPrimaryIDEController = &vsys.mapControllers[i.ulInstanceID]; 509 530 } 510 531 break;
Note:
See TracChangeset
for help on using the changeset viewer.