VirtualBox

Changeset 16360 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jan 29, 2009 10:51:37 AM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
42200
Message:

OVF: HD Controller, Audio, Floppy, USB Controller support

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/ApplianceImpl.cpp

    r16325 r16360  
    12291229        vsd->addEntry(VirtualSystemDescriptionType_Memory, "", toString<uint64_t>(vs.ullMemorySize), toString<uint64_t>(ullMemSizeVBox));
    12301230
     1231        /* Audio */
     1232        if (!vs.strSoundCardType.isNull())
     1233            /* Currently we set the AC97 always.
     1234               @todo: figure out the hardware which could be possible */
     1235            vsd->addEntry(VirtualSystemDescriptionType_SoundCard, "", vs.strSoundCardType, toString<uint32_t>(AudioControllerType_AC97));
     1236
     1237        /* USB Controller */
     1238        if (vs.fHasUsbController)
     1239            vsd->addEntry(VirtualSystemDescriptionType_USBController, "", "", "1");
     1240
     1241        /* Network Controller */
     1242        // @todo: is there no hardware specified in the OVF-Format?
     1243        if (vs.llNetworkNames.size() > 0)
     1244        {
     1245            /* Get the default network adapter type for the selected guest OS */
     1246            NetworkAdapterType_T nwAdapterVBox = NetworkAdapterType_Am79C970A;
     1247            rc = osType->COMGETTER(AdapterType)(&nwAdapterVBox);
     1248            ComAssertComRCThrowRC(rc);
     1249            list<Utf8Str>::const_iterator nwIt;
     1250            /* Iterate through all abstract networks. We support 8 network
     1251             * adapters at the maximum. (@todo: warn if it are more!) */
     1252            size_t a = 0;
     1253            for (nwIt = vs.llNetworkNames.begin();
     1254                 nwIt != vs.llNetworkNames.end() && a < SchemaDefs::NetworkAdapterCount;
     1255                 ++nwIt, ++a)
     1256            {
     1257                // Utf8Str nwController = *nwIt; // @todo: not used yet
     1258                vsd->addEntry(VirtualSystemDescriptionType_NetworkAdapter, "", "", toString<ULONG>(nwAdapterVBox));
     1259            }
     1260        }
     1261
     1262        /* Floppy Drive */
     1263        if (vs.fHasFloppyDrive)
     1264            vsd->addEntry(VirtualSystemDescriptionType_Floppy, "", "", "1");
     1265
     1266        /* CD Drive */
     1267        /* @todo: I can't disable the CDROM. So nothing to do for now. */
     1268        //if (vs.fHasCdromDrive)
     1269        //    vsd->addEntry(VirtualSystemDescriptionType_CDROM, "", "", "1");
     1270
    12311271        /* Hard disk Controller */
    12321272        ControllersMap::const_iterator hdcIt;
     
    13311371        }
    13321372
    1333         /* Network Controller */
    1334         // @todo: is there no hardware specified in the OVF-Format?
    1335         if (vs.llNetworkNames.size() > 0)
    1336         {
    1337             /* Get the default network adapter type for the selected guest OS */
    1338             NetworkAdapterType_T nwAdapterVBox = NetworkAdapterType_Am79C970A;
    1339             rc = osType->COMGETTER(AdapterType)(&nwAdapterVBox);
    1340             ComAssertComRCThrowRC(rc);
    1341             list<Utf8Str>::const_iterator nwIt;
    1342             /* Iterate through all abstract networks. We support 8 network
    1343              * adapters at the maximum. (@todo: warn if it are more!) */
    1344             size_t a = 0;
    1345             for (nwIt = vs.llNetworkNames.begin();
    1346                  nwIt != vs.llNetworkNames.end() && a < SchemaDefs::NetworkAdapterCount;
    1347                  ++nwIt, ++a)
    1348             {
    1349                 // Utf8Str nwController = *nwIt; // @todo: not used yet
    1350                 vsd->addEntry(VirtualSystemDescriptionType_NetworkAdapter, "", "", toString<ULONG>(nwAdapterVBox));
    1351             }
    1352         }
    13531373        m->virtualSystemDescriptions.push_back(vsd);
    13541374    }
     
    14201440        /* Set the VRAM */
    14211441        rc = newMachine->COMSETTER(VRAMSize)(vramVBox);
     1442        ComAssertComRCThrowRC(rc);
     1443
     1444
     1445        /* Audio Adapter */
     1446        std::list<VirtualSystemDescriptionEntry*> vsdeAudioAdapter = vsd->findByType(VirtualSystemDescriptionType_SoundCard);
     1447        /* @todo: we support one audio adapter only */
     1448        if (vsdeAudioAdapter.size() > 0)
     1449        {
     1450            const Utf8Str& audioAdapterVBox = vsdeAudioAdapter.front()->strFinalValue;
     1451            if (RTStrICmp(audioAdapterVBox, "null") != 0)
     1452            {
     1453                ComPtr<IAudioAdapter> audioAdapter;
     1454                rc = newMachine->COMGETTER(AudioAdapter)(audioAdapter.asOutParam());
     1455                ComAssertComRCThrowRC(rc);
     1456                rc = audioAdapter->COMSETTER(Enabled)(true);
     1457                ComAssertComRCThrowRC(rc);
     1458                /* @todo: For now this is preselected, but on Linux for example
     1459                   more drivers are possible. The user should be able to change
     1460                   this also. */
     1461                AudioDriverType_T adt = AudioDriverType_Null;
     1462#if defined(RT_OS_WINDOWS)
     1463# ifdef VBOX_WITH_WINMM
     1464                adt = AudioDriverType_WinMM;
     1465# else
     1466                adt = AudioDriverType_DirectSound;
     1467# endif
     1468#elif defined(RT_OS_LINUX)
     1469# ifdef VBOX_WITH_ALSA
     1470                adt = AudioDriverType_Alsa;
     1471# elif defined(VBOX_WITH_PULSE)
     1472                adt = AudioDriverType_Pulse;
     1473# else
     1474                adt = AudioDriverType_OSS;
     1475# endif
     1476#elif defined(RT_OS_DARWIN)
     1477                adt = AudioDriverType_CoreAudio;
     1478#elif defined(RT_OS_SOLARIS)
     1479                adt = AudioDriverType_SolAudio;
     1480#elif defined(RT_OS_OS2)
     1481                adt = AudioDriverType_MMPM;
     1482#endif
     1483                rc = audioAdapter->COMSETTER(AudioDriver)(adt);
     1484                ComAssertComRCThrowRC(rc);
     1485                rc = audioAdapter->COMSETTER(AudioController)(audioAdapterVBox);
     1486                ComAssertComRCThrowRC(rc);
     1487            }
     1488        }
     1489
     1490        /* USB Controller */
     1491        std::list<VirtualSystemDescriptionEntry*> vsdeUSBController = vsd->findByType(VirtualSystemDescriptionType_USBController);
     1492        /* If there is no USB controller entry it will be disabled */
     1493        bool fUSBEnabled = vsdeUSBController.size() > 0;
     1494        if (fUSBEnabled)
     1495        {
     1496            /* Check if the user has disabled the USB controller in the client */
     1497            const Utf8Str& usbVBox = vsdeUSBController.front()->strFinalValue;
     1498            fUSBEnabled = usbVBox == "1";
     1499        }
     1500        ComPtr<IUSBController> usbController;
     1501        rc = newMachine->COMGETTER(USBController)(usbController.asOutParam());
     1502        ComAssertComRCThrowRC(rc);
     1503        rc = usbController->COMSETTER(Enabled)(fUSBEnabled);
    14221504        ComAssertComRCThrowRC(rc);
    14231505
     
    14571539        }
    14581540
     1541        /* Floppy drive */
     1542        std::list<VirtualSystemDescriptionEntry*> vsdeFloppy = vsd->findByType(VirtualSystemDescriptionType_Floppy);
     1543        /* If there is no floppy drive entry it will be disabled */
     1544        bool fFloppyEnabled = vsdeFloppy.size() > 0;
     1545        if (fFloppyEnabled)
     1546        {
     1547            /* Check if the user has disabled the floppy drive in the client */
     1548            const Utf8Str& floppyVBox = vsdeFloppy.front()->strFinalValue;
     1549            fFloppyEnabled = floppyVBox == "1";
     1550        }
     1551        ComPtr<IFloppyDrive> floppyDrive;
     1552        rc = newMachine->COMGETTER(FloppyDrive)(floppyDrive.asOutParam());
     1553        ComAssertComRCThrowRC(rc);
     1554        rc = floppyDrive->COMSETTER(Enabled)(fFloppyEnabled);
     1555        ComAssertComRCThrowRC(rc);
     1556
     1557        /* CDROM drive */
     1558        /* @todo: I can't disable the CDROM. So nothing to do for now */
     1559        // std::list<VirtualSystemDescriptionEntry*> vsdeFloppy = vsd->findByType(VirtualSystemDescriptionType_CDROM);
     1560
    14591561        /* Hard disk controller IDE */
    14601562        std::list<VirtualSystemDescriptionEntry*> vsdeHDCIDE = vsd->findByType(VirtualSystemDescriptionType_HardDiskControllerIDE);
     
    15421644                    /* @todo: what now? For now we override in no
    15431645                     * circumstances. */
    1544 //                    continue;
     1646                    continue;
    15451647                }
    15461648                const Utf8Str &strRef = (*hdIt)->strRef;
    15471649                /* Get the associated disk image */
    1548                 if (m->mapDisks.find(strRef) == m->mapDisks.end())
     1650                if (m->mapDisks.find(strRef) == m->mapDisks.end() ||
     1651                    vs.mapVirtualDisks.find(strRef) == vs.mapVirtualDisks.end())
    15491652                {
    15501653                    /* @todo: error: entry doesn't exists */
    15511654                }
    15521655                DiskImage di = m->mapDisks[strRef];
     1656                VirtualDisk vd = (*vs.mapVirtualDisks.find(strRef)).second;
    15531657                /* Construct the source file path */
    15541658                char *srcFilePath;
     
    15941698                    rc = dstHdVBox->COMGETTER(Id)(hdId.asOutParam());;
    15951699                    CheckComRCReturnRC(rc);
    1596                     rc = sMachine->AttachHardDisk2(hdId, StorageBus_IDE, 0, 0); //
     1700                    /* For now we assume we have one controller of every type only */
     1701                    HardDiskController hdc = (*vs.mapControllers.find(vd.idController)).second;
     1702                    StorageBus_T sbt = StorageBus_IDE;
     1703                    switch (hdc.controllerSystem)
     1704                    {
     1705                        case IDE: sbt = StorageBus_IDE; break;
     1706                        case SATA: sbt = StorageBus_SATA; break;
     1707                        //case SCSI: sbt = StorageBus_SCSI; break; // @todo: not available yet
     1708                        default: break;
     1709                    }
     1710                    rc = sMachine->AttachHardDisk2(hdId, sbt, hdc.ulBusNumber, 0);
    15971711                    CheckComRCReturnRC(rc);
    15981712                    rc = sMachine->SaveSettings();
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette