Changeset 16517 in vbox
- Timestamp:
- Feb 4, 2009 4:25:29 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 42441
- Location:
- trunk/src/VBox
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageImport.cpp
r16515 r16517 54 54 55 55 Utf8Str strOvfFilename; 56 bool fExecute = false; // if true, then we actually do the import (-exec argument) 56 57 57 58 for (int i = 0; i < a->argc; i++) 58 59 { 59 if (!strOvfFilename) 60 if (!strcmp(a->argv[i], "-exec")) 61 fExecute = true; 62 else if (!strOvfFilename) 60 63 strOvfFilename = a->argv[i]; 61 64 else … … 219 222 } 220 223 } 221 RTPrintf("\n"); 222 } 224 225 if (fExecute) 226 { 227 ComPtr<IProgress> progress; 228 CHECK_ERROR_BREAK(appliance, 229 ImportAppliance(progress.asOutParam())); 230 231 showProgress(progress); 232 233 if (SUCCEEDED(rc)) 234 { 235 progress->COMGETTER(ResultCode)(&rc); 236 if (FAILED (rc)) 237 { 238 com::ProgressErrorInfo info(progress); 239 if (info.isBasicAvailable()) 240 RTPrintf("Error: failed to import appliance. Error message: %lS\n", info.getText().raw()); 241 else 242 RTPrintf("Error: failed to import appliance. No error message available!\n"); 243 } 244 else 245 RTPrintf("Successfully imported the appliance.\n"); 246 } 247 } 248 } // end if (aVirtualSystemDescriptions.size() > 0) 223 249 } while (0); 224 250 -
trunk/src/VBox/Main/ApplianceImpl.cpp
r16515 r16517 226 226 ss << val; 227 227 return Utf8Str(ss.str().c_str()); 228 } 229 230 static Utf8Str stripFilename(const Utf8Str &strFile) 231 { 232 Utf8Str str2(strFile); 233 RTPathStripFilename(str2.mutableRaw()); 234 return str2; 228 235 } 229 236 … … 433 440 pelmDisk->getLineNumber()); 434 441 435 // RTPrintf(" found disk: %s\n", d.strDiskId.c_str());436 442 m->mapDisks[d.strDiskId] = d; 437 443 } … … 1428 1434 pController->ulIndex); 1429 1435 pNewDesc->addEntry(VirtualSystemDescriptionType_HardDiskImage, 1430 "",1436 hd.strDiskId, 1431 1437 di.strHref, 1432 1438 strPath, … … 1498 1504 char *tmpName = RTStrDup(aName.c_str()); 1499 1505 int i = 1; 1500 /* @todo: Maybe to costintensive; try to find a lighter way */1506 /* @todo: Maybe too cost-intensive; try to find a lighter way */ 1501 1507 while (mVirtualBox->FindMachine(Bstr(tmpName), &machine) != VBOX_E_OBJECT_NOT_FOUND) 1502 1508 { … … 1518 1524 /* Check if the file exists or if a file with this path is registered 1519 1525 * already */ 1520 /* @todo: Maybe to costintensive; try to find a lighter way */1526 /* @todo: Maybe too cost-intensive; try to find a lighter way */ 1521 1527 while (RTPathExists(tmpName) || 1522 1528 mVirtualBox->FindHardDisk2(Bstr(tmpName), &harddisk) != VBOX_E_OBJECT_NOT_FOUND) … … 1527 1533 char *tmpFile = RTStrDup(RTPathFilename(aName.c_str())); 1528 1534 RTPathStripExt(tmpFile); 1529 c har *tmpExt = RTPathExt(aName.c_str());1535 const char *tmpExt = RTPathExt(aName.c_str()); 1530 1536 RTStrAPrintf(&tmpName, "%s/%s_%d%s", tmpDir, tmpFile, i, tmpExt); 1531 1537 RTStrFree(tmpFile); … … 1580 1586 std::list<VirtualSystemDescriptionEntry*> vsdeOS = vsdescThis->findByType(VirtualSystemDescriptionType_OS); 1581 1587 Assert(vsdeOS.size() == 1); 1582 const Utf8Str & osTypeVBox = vsdeOS.front()->strConfig;1588 const Utf8Str &strOsTypeVBox = vsdeOS.front()->strConfig; 1583 1589 1584 1590 /* Now that we know the base system get our internal defaults based on that. */ 1585 1591 ComPtr<IGuestOSType> osType; 1586 rc = app->mVirtualBox->GetGuestOSType(Bstr( osTypeVBox), osType.asOutParam());1592 rc = app->mVirtualBox->GetGuestOSType(Bstr(strOsTypeVBox), osType.asOutParam()); 1587 1593 CheckComRCThrowRC(rc); 1588 1594 … … 1591 1597 std::list<VirtualSystemDescriptionEntry*> vsdeName = vsdescThis->findByType(VirtualSystemDescriptionType_Name); 1592 1598 Assert(vsdeName.size() == 1); 1593 const Utf8Str & nameVBox = vsdeName.front()->strConfig;1594 ComPtr<IMachine> newMachine;1595 rc = app->mVirtualBox->CreateMachine(Bstr( nameVBox.c_str()), Bstr(osTypeVBox.c_str()),1599 const Utf8Str &strNameVBox = vsdeName.front()->strConfig; 1600 ComPtr<IMachine> pNewMachine; 1601 rc = app->mVirtualBox->CreateMachine(Bstr(strNameVBox), Bstr(strOsTypeVBox), 1596 1602 Bstr(), Guid(), 1597 newMachine.asOutParam());1603 pNewMachine.asOutParam()); 1598 1604 CheckComRCThrowRC(rc); 1599 1605 … … 1609 1615 uint64_t tt = RTStrToUInt64(memoryVBox.c_str()) / _1M; 1610 1616 1611 rc = newMachine->COMSETTER(MemorySize)(tt);1617 rc = pNewMachine->COMSETTER(MemorySize)(tt); 1612 1618 CheckComRCThrowRC(rc); 1613 1619 … … 1619 1625 CheckComRCThrowRC(rc); 1620 1626 /* Set the VRAM */ 1621 rc = newMachine->COMSETTER(VRAMSize)(vramVBox);1627 rc = pNewMachine->COMSETTER(VRAMSize)(vramVBox); 1622 1628 CheckComRCThrowRC(rc); 1623 1629 … … 1632 1638 uint32_t audio = RTStrToUInt32(audioAdapterVBox.c_str()); 1633 1639 ComPtr<IAudioAdapter> audioAdapter; 1634 rc = newMachine->COMGETTER(AudioAdapter)(audioAdapter.asOutParam());1640 rc = pNewMachine->COMGETTER(AudioAdapter)(audioAdapter.asOutParam()); 1635 1641 CheckComRCThrowRC(rc); 1636 1642 rc = audioAdapter->COMSETTER(Enabled)(true); … … 1670 1676 /* USB Controller */ 1671 1677 std::list<VirtualSystemDescriptionEntry*> vsdeUSBController = vsdescThis->findByType(VirtualSystemDescriptionType_USBController); 1672 /* If there is no USB controller entry it will be disabled */ 1678 // USB support is enabled if there's at least one such entry; to disable USB support, 1679 // the type of the USB item would have been changed to "ignore" 1673 1680 bool fUSBEnabled = vsdeUSBController.size() > 0; 1674 if (fUSBEnabled) 1675 { 1676 /* Check if the user has disabled the USB controller in the client */ 1677 const Utf8Str& usbVBox = vsdeUSBController.front()->strConfig; 1678 fUSBEnabled = usbVBox == "1"; 1679 } 1681 1680 1682 ComPtr<IUSBController> usbController; 1681 rc = newMachine->COMGETTER(USBController)(usbController.asOutParam());1683 rc = pNewMachine->COMGETTER(USBController)(usbController.asOutParam()); 1682 1684 CheckComRCThrowRC(rc); 1683 1685 rc = usbController->COMSETTER(Enabled)(fUSBEnabled); … … 1690 1692 /* No network adapters, so we have to disable our default one */ 1691 1693 ComPtr<INetworkAdapter> nwVBox; 1692 rc = newMachine->GetNetworkAdapter(0, nwVBox.asOutParam());1694 rc = pNewMachine->GetNetworkAdapter(0, nwVBox.asOutParam()); 1693 1695 CheckComRCThrowRC(rc); 1694 1696 rc = nwVBox->COMSETTER(Enabled)(false); … … 1699 1701 list<VirtualSystemDescriptionEntry*>::const_iterator nwIt; 1700 1702 /* Iterate through all network cards. We support 8 network adapters 1701 * at the maximum. (@todo: warn if itare more!) */1703 * at the maximum. (@todo: warn if there are more!) */ 1702 1704 size_t a = 0; 1703 1705 for (nwIt = vsdeNW.begin(); … … 1708 1710 uint32_t tt1 = RTStrToUInt32(nwTypeVBox.c_str()); 1709 1711 ComPtr<INetworkAdapter> nwVBox; 1710 rc = newMachine->GetNetworkAdapter((ULONG)a, nwVBox.asOutParam());1712 rc = pNewMachine->GetNetworkAdapter((ULONG)a, nwVBox.asOutParam()); 1711 1713 CheckComRCThrowRC(rc); 1712 1714 /* Enable the network card & set the adapter type */ … … 1721 1723 /* Floppy drive */ 1722 1724 std::list<VirtualSystemDescriptionEntry*> vsdeFloppy = vsdescThis->findByType(VirtualSystemDescriptionType_Floppy); 1723 /* If there is no floppy drive entry it will be disabled */ 1725 // Floppy support is enabled if there's at least one such entry; to disable floppy support, 1726 // the type of the floppy item would have been changed to "ignore" 1724 1727 bool fFloppyEnabled = vsdeFloppy.size() > 0; 1725 if (fFloppyEnabled)1726 {1727 /* Check if the user has disabled the floppy drive in the client */1728 const Utf8Str& floppyVBox = vsdeFloppy.front()->strConfig;1729 fFloppyEnabled = floppyVBox == "1";1730 }1731 1728 ComPtr<IFloppyDrive> floppyDrive; 1732 rc = newMachine->COMGETTER(FloppyDrive)(floppyDrive.asOutParam());1729 rc = pNewMachine->COMGETTER(FloppyDrive)(floppyDrive.asOutParam()); 1733 1730 CheckComRCThrowRC(rc); 1734 1731 rc = floppyDrive->COMSETTER(Enabled)(fFloppyEnabled); … … 1744 1741 if (vsdeHDCIDE.size() > 0) 1745 1742 { 1746 IDEControllerType_T hdcVBox = static_cast<IDEControllerType_T>(RTStrToUInt32(vsdeHDCIDE.front()->strConfig.c_str())); 1747 /* Set the appropriate IDE controller in the virtual BIOS of the 1748 * VM. */ 1743 // set the appropriate IDE controller in the virtual BIOS of the VM 1749 1744 ComPtr<IBIOSSettings> biosSettings; 1750 rc = newMachine->COMGETTER(BIOSSettings)(biosSettings.asOutParam());1745 rc = pNewMachine->COMGETTER(BIOSSettings)(biosSettings.asOutParam()); 1751 1746 CheckComRCThrowRC(rc); 1752 rc = biosSettings->COMSETTER(IDEControllerType)(hdcVBox); 1747 const char *pcszIDEType = vsdeHDCIDE.front()->strConfig.c_str(); 1748 if (!strcmp(pcszIDEType, "PIIX3")) 1749 rc = biosSettings->COMSETTER(IDEControllerType)(IDEControllerType_PIIX3); 1750 else if (!strcmp(pcszIDEType, "PIIX4")) 1751 rc = biosSettings->COMSETTER(IDEControllerType)(IDEControllerType_PIIX4); 1752 else 1753 throw setError(VBOX_E_FILE_ERROR, 1754 tr("Invalid IDE controller type \"%s\""), 1755 pcszIDEType); 1753 1756 CheckComRCThrowRC(rc); 1754 1757 } … … 1764 1767 /* For now we have just to enable the AHCI controller. */ 1765 1768 ComPtr<ISATAController> hdcSATAVBox; 1766 rc = newMachine->COMGETTER(SATAController)(hdcSATAVBox.asOutParam());1769 rc = pNewMachine->COMGETTER(SATAController)(hdcSATAVBox.asOutParam()); 1767 1770 CheckComRCThrowRC(rc); 1768 1771 rc = hdcSATAVBox->COMSETTER(Enabled)(true); … … 1775 1778 } 1776 1779 #endif /* VBOX_WITH_AHCI */ 1777 #ifdef VBOX_WITH_SCSI 1780 1778 1781 /* Hard disk controller SCSI */ 1779 EntriesListvsdeHDCSCSI = vsdescThis->findByType(VirtualSystemDescriptionType_HardDiskControllerSCSI);1782 std::list<VirtualSystemDescriptionEntry*> vsdeHDCSCSI = vsdescThis->findByType(VirtualSystemDescriptionType_HardDiskControllerSCSI); 1780 1783 /* @todo: do we support more than one SCSI controller? */ 1781 1784 if (vsdeHDCSCSI.size() > 0) 1782 1785 { 1783 /* @todo: Currently I have no idea how to enable this. Someone has 1784 * to write main support for SCSI at all. */ 1786 /* @todo: revisit when Main support for SCSI is ready */ 1785 1787 } 1786 #endif /* VBOX_WITH_SCSI */1787 1788 1788 1789 /* Now its time to register the machine before we add any hard disks */ 1789 rc = app->mVirtualBox->RegisterMachine( newMachine);1790 rc = app->mVirtualBox->RegisterMachine(pNewMachine); 1790 1791 CheckComRCThrowRC(rc); 1791 1792 … … 1798 1799 { 1799 1800 Guid newMachineId; 1800 rc = newMachine->COMGETTER(Id)(newMachineId.asOutParam());1801 rc = pNewMachine->COMGETTER(Id)(newMachineId.asOutParam()); 1801 1802 CheckComRCThrowRC(rc); 1802 1803 /* If in the next block an error occur we have to deregister … … 1805 1806 try 1806 1807 { 1807 /* That we can attach hard disks we need to open a session for the 1808 * new machine */ 1808 // in order to attach hard disks we need to open a session for the new machine 1809 1809 rc = session.createInprocObject(CLSID_Session); 1810 1810 CheckComRCThrowRC(rc); … … 1815 1815 /* The disk image has to be on the same place as the OVF file. So 1816 1816 * strip the filename out of the full file path. */ 1817 char *pszSrcDir = RTStrDup(Utf8Str(app->m->bstrPath).raw()); 1818 RTPathStripFilename(pszSrcDir); 1819 Utf8Str strSrcDir(pszSrcDir); 1820 RTStrFree(pszSrcDir); 1817 Utf8Str strSrcDir = stripFilename(Utf8Str(app->m->bstrPath).raw()); 1821 1818 1822 1819 /* Iterate over all given disk images */ … … 1831 1828 /* Check if the destination file exists already or the 1832 1829 * destination path is empty. */ 1833 if ( RTPathExists(pcszDstFilePath) ||1834 !RTStrCmp(pcszDstFilePath, ""))1835 {1830 if ( !(*pcszDstFilePath) 1831 || RTPathExists(pcszDstFilePath) 1832 ) 1836 1833 /* This isn't allowed */ 1837 1834 throw setError(VBOX_E_FILE_ERROR, 1838 1835 tr("Destination file '%s' exists", 1839 1836 pcszDstFilePath)); 1840 }1841 1837 1842 1838 // find the disk from the OVF's disk list 1843 1839 DiskImagesMap::const_iterator itDiskImage = app->m->mapDisks.find(vsdeHD->strRef); 1840 // vsdeHD->strRef contains the disk identifier (e.g. "vmdisk1", which should exist 1841 // in the virtual system's disks map under that ID and also in the global images map 1844 1842 VirtualDisksMap::const_iterator itVirtualDisk = vsysThis.mapVirtualDisks.find(vsdeHD->strRef); 1845 1843 … … 2048 2046 } 2049 2047 2048 STDMETHODIMP VirtualSystemDescription::DisableItem(ULONG index) 2049 { 2050 AutoCaller autoCaller(this); 2051 CheckComRCReturnRC(autoCaller.rc()); 2052 2053 AutoWriteLock alock(this); 2054 2055 list<VirtualSystemDescriptionEntry>::iterator it; 2056 for (it = m->descriptions.begin(); 2057 it != m->descriptions.end(); 2058 ++it) 2059 { 2060 VirtualSystemDescriptionEntry &e = *it; 2061 if (e.ulIndex == index) 2062 { 2063 e.type = VirtualSystemDescriptionType_Ignore; 2064 return S_OK; 2065 } 2066 } 2067 2068 return setError(VBOX_E_OBJECT_NOT_FOUND, 2069 tr("Array item index %d not found"), 2070 index); 2071 } 2072 2050 2073 STDMETHODIMP VirtualSystemDescription::SetFinalValues(ComSafeArrayIn(IN_BSTR, aFinalValues)) 2051 2074 { … … 2125 2148 return NULL; 2126 2149 } 2150 -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r16515 r16517 3118 3118 </method> 3119 3119 3120 <method name="disableItem"> 3121 <desc> 3122 Disables part of the configuration, as represented by the array items returned by 3123 <link to="getDescription" />. For example, to disable USB support for a given 3124 virtual system, pass in the array item index of the USB controller; its type will 3125 then be changed by this method from "USBController" to "Ignore". 3126 3127 This works only for items of the types HardDiskControllerIDE, HardDiskControllerSATA, 3128 HardDiskControllerSCSI, HardDiskImage, CDROM, Floppy, NetworkAdapter, USBController 3129 and SoundCard. 3130 </desc> 3131 3132 <param name="index" type="unsigned long" dir="in"> 3133 </param> 3134 </method> 3135 3120 3136 <method name="SetFinalValues"> 3121 3137 <desc></desc> -
trunk/src/VBox/Main/include/ApplianceImpl.h
r16515 r16517 149 149 ComSafeArrayOut(BSTR, aConfigValues), 150 150 ComSafeArrayOut(BSTR, aExtraConfigValues)); 151 STDMETHOD(DisableItem)(ULONG index); 151 152 STDMETHOD(SetFinalValues)(ComSafeArrayIn(IN_BSTR, aFinalValues)); 152 153
Note:
See TracChangeset
for help on using the changeset viewer.