Changeset 28152 in vbox for trunk/src/VBox/Main
- Timestamp:
- Apr 9, 2010 5:38:56 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ApplianceImplImport.cpp
r28110 r28152 1225 1225 if (vsdeOS.size() < 1) 1226 1226 throw setError(VBOX_E_FILE_ERROR, 1227 1227 tr("Missing guest OS type")); 1228 1228 const Utf8Str &strOsTypeVBox = vsdeOS.front()->strVbox; 1229 1229 … … 1238 1238 if (vsdeName.size() < 1) 1239 1239 throw setError(VBOX_E_FILE_ERROR, 1240 1240 tr("Missing VM name")); 1241 1241 const Utf8Str &strNameVBox = vsdeName.front()->strVbox; 1242 1242 rc = mVirtualBox->CreateMachine(Bstr(strNameVBox), … … 1292 1292 if (FAILED(rc)) throw rc; 1293 1293 1294 /* I/O APIC: so far we have no setting for this. Enable it if we 1295 import a Windows VM because if if Windows was installed without IOAPIC, 1296 it will not mind finding an one later on, but if Windows was installed 1297 _with_ an IOAPIC, it will bluescreen if it's not found */ 1298 Bstr bstrFamilyId; 1299 rc = osType->COMGETTER(FamilyId)(bstrFamilyId.asOutParam()); 1300 if (FAILED(rc)) throw rc; 1301 1302 Utf8Str strFamilyId(bstrFamilyId); 1303 if (strFamilyId == "Windows") 1304 fEnableIOApic = true; 1305 1306 /* If IP-APIC should be enabled could be have different reasons. 1307 See CPU count & the Win test above. Here we enable it if it was 1308 previously requested. */ 1294 // I/O APIC: Generic OVF has no setting for this. Enable it if we 1295 // import a Windows VM because if if Windows was installed without IOAPIC, 1296 // it will not mind finding an one later on, but if Windows was installed 1297 // _with_ an IOAPIC, it will bluescreen if it's not found 1298 if (!fEnableIOApic) 1299 { 1300 Bstr bstrFamilyId; 1301 rc = osType->COMGETTER(FamilyId)(bstrFamilyId.asOutParam()); 1302 if (FAILED(rc)) throw rc; 1303 if (bstrFamilyId == "Windows") 1304 fEnableIOApic = true; 1305 } 1306 1309 1307 if (fEnableIOApic) 1310 1308 { … … 1361 1359 if (FAILED(rc)) throw rc; 1362 1360 } 1361 else if (vsdeNW.size() > SchemaDefs::NetworkAdapterCount) 1362 throw setError(VBOX_E_FILE_ERROR, 1363 tr("Too many network adapters: OVF requests %d network adapters, but VirtualBox only supports %d"), 1364 vsdeNW.size(), SchemaDefs::NetworkAdapterCount); 1363 1365 else 1364 1366 { 1365 1367 list<VirtualSystemDescriptionEntry*>::const_iterator nwIt; 1366 /* Iterate through all network cards. We support 8 network adapters1367 * at the maximum. (@todo: warn if there are more!) */1368 1368 size_t a = 0; 1369 1369 for (nwIt = vsdeNW.begin(); 1370 (nwIt != vsdeNW.end() && a < SchemaDefs::NetworkAdapterCount);1370 nwIt != vsdeNW.end(); 1371 1371 ++nwIt, ++a) 1372 1372 { … … 1396 1396 rc = host->COMGETTER(NetworkInterfaces)(ComSafeArrayAsOutParam(nwInterfaces)); 1397 1397 if (FAILED(rc)) throw rc; 1398 / *We search for the first host network interface which1399 * is usable for bridged networking */1398 // We search for the first host network interface which 1399 // is usable for bridged networking 1400 1400 for (size_t j = 0; 1401 1402 1401 j < nwInterfaces.size(); 1402 ++j) 1403 1403 { 1404 1404 HostNetworkInterfaceType_T itype; … … 1429 1429 rc = host->COMGETTER(NetworkInterfaces)(ComSafeArrayAsOutParam(nwInterfaces)); 1430 1430 if (FAILED(rc)) throw rc; 1431 / *We search for the first host network interface which1432 * is usable for host only networking */1431 // We search for the first host network interface which 1432 // is usable for host only networking 1433 1433 for (size_t j = 0; 1434 1435 1434 j < nwInterfaces.size(); 1435 ++j) 1436 1436 { 1437 1437 HostNetworkInterfaceType_T itype; … … 1457 1457 if (vsdeHDCIDE.size() > 1) 1458 1458 throw setError(VBOX_E_FILE_ERROR, 1459 1459 tr("Too many IDE controllers in OVF; import facility only supports one")); 1460 1460 if (vsdeHDCIDE.size() == 1) 1461 1461 { … … 1482 1482 if (vsdeHDCSATA.size() > 1) 1483 1483 throw setError(VBOX_E_FILE_ERROR, 1484 1484 tr("Too many SATA controllers in OVF; import facility only supports one")); 1485 1485 if (vsdeHDCSATA.size() > 0) 1486 1486 { … … 1494 1494 else 1495 1495 throw setError(VBOX_E_FILE_ERROR, 1496 1497 1496 tr("Invalid SATA controller type \"%s\""), 1497 hdcVBox.c_str()); 1498 1498 } 1499 1499 #endif /* VBOX_WITH_AHCI */ … … 1504 1504 if (vsdeHDCSCSI.size() > 1) 1505 1505 throw setError(VBOX_E_FILE_ERROR, 1506 1506 tr("Too many SCSI controllers in OVF; import facility only supports one")); 1507 1507 if (vsdeHDCSCSI.size() > 0) 1508 1508 { … … 1516 1516 else 1517 1517 throw setError(VBOX_E_FILE_ERROR, 1518 1519 1518 tr("Invalid SCSI controller type \"%s\""), 1519 hdcVBox.c_str()); 1520 1520 1521 1521 rc = pNewMachine->AddStorageController(Bstr("SCSI Controller"), StorageBus_SCSI, pController.asOutParam()); … … 1540 1540 if (vsdeFloppy.size() > 1) 1541 1541 throw setError(VBOX_E_FILE_ERROR, 1542 1542 tr("Too many floppy controllers in OVF; import facility only supports one")); 1543 1543 std::list<VirtualSystemDescriptionEntry*> vsdeCDROM = vsdescThis->findByType(VirtualSystemDescriptionType_CDROM); 1544 1544 if ( (vsdeFloppy.size() > 0) 1545 1546 1545 || (vsdeCDROM.size() > 0) 1546 ) 1547 1547 { 1548 1548 // If there's an error here we need to close the session, so … … 1552 1552 { 1553 1553 /* In order to attach things we need to open a session 1554 1554 * for the new machine */ 1555 1555 rc = mVirtualBox->OpenSession(stack.pSession, bstrNewMachineId); 1556 1556 if (FAILED(rc)) throw rc; … … 1592 1592 } 1593 1593 1594 1595 1594 // CD-ROMs next 1596 1595 for (std::list<VirtualSystemDescriptionEntry*>::const_iterator jt = vsdeCDROM.begin(); 1597 1598 1596 jt != vsdeCDROM.end(); 1597 ++jt) 1599 1598 { 1600 1599 // for now always attach to secondary master on IDE controller; … … 1695 1694 /* This isn't allowed */ 1696 1695 throw setError(VBOX_E_FILE_ERROR, 1697 tr("Destination file '%s' exists",1698 vsdeHD->strVbox.c_str()));1696 tr("Destination file '%s' exists"), 1697 vsdeHD->strVbox.c_str()); 1699 1698 1700 1699 /* Find the disk from the OVF's disk list */ 1701 1700 ovf::DiskImagesMap::const_iterator itDiskImage = stack.mapDisks.find(vsdeHD->strRef); 1702 / *vsdeHD->strRef contains the disk identifier (e.g. "vmdisk1"), which should exist1703 in the virtual system's disks map under that ID and also in the global images map. */1701 // vsdeHD->strRef contains the disk identifier (e.g. "vmdisk1"), which should exist 1702 // in the virtual system's disks map under that ID and also in the global images map 1704 1703 ovf::VirtualDisksMap::const_iterator itVirtualDisk = vsysThis.mapVirtualDisks.find(vsdeHD->strRef); 1705 1704 … … 1708 1707 ) 1709 1708 throw setError(E_FAIL, 1710 1709 tr("Internal inconsistency looking up disk images.")); 1711 1710 1712 1711 const ovf::DiskImage &di = itDiskImage->second; … … 1753 1752 strSrcFilePath.c_str()); 1754 1753 1755 / *Clone the disk image (this is necessary cause the id has1756 *to be recreated for the case the same hard disk is1757 * attached already from a previous import) */1758 1759 / * First open the existing disk image */1754 // Clone the disk image (this is necessary cause the id has 1755 // to be recreated for the case the same hard disk is 1756 // attached already from a previous import) 1757 1758 // First open the existing disk image 1760 1759 rc = mVirtualBox->OpenHardDisk(Bstr(strSrcFilePath), 1761 1760 AccessMode_ReadOnly, … … 1879 1878 HRESULT rc = pNewMachine.createObject(); 1880 1879 if (FAILED(rc)) throw rc; 1881 rc = pNewMachine->init(mVirtualBox, strNameVBox, config); 1880 1881 // this magic constructor fills the new machine object with the MachineConfig 1882 // instance that we created from the vbox:Machine 1883 rc = pNewMachine->init(mVirtualBox, 1884 strNameVBox, // name from just above (can be suffixed to avoid duplicates) 1885 config); // the whole machine config 1882 1886 if (FAILED(rc)) throw rc; 1883 1887 1888 // return the new machine as an IMachine 1884 1889 IMachine *p; 1885 1890 rc = pNewMachine.queryInterfaceTo(&p); 1886 1891 if (FAILED(rc)) throw rc; 1887 1888 1892 pReturnNewMachine = p; 1889 1893 1894 // and register it 1890 1895 rc = mVirtualBox->RegisterMachine(pNewMachine); 1891 1896 if (FAILED(rc)) throw rc;
Note:
See TracChangeset
for help on using the changeset viewer.