VirtualBox

Changeset 23825 in vbox


Ignore:
Timestamp:
Oct 16, 2009 2:42:34 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
53581
Message:

VBoxSDL: removed hardcoded controller names and now controllers are added only when needed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp

    r23801 r23825  
    871871    char *fdaFile   = NULL;
    872872#ifdef VBOX_WITH_VRDP
    873     char *portVRDP = NULL;
     873    const char *portVRDP = NULL;
    874874#endif
    875875    bool fDiscardState = false;
     
    15191519         * Strategy: iterate through all registered hard disk
    15201520         * and see if one of them points to the same file. If
    1521          * so, assign it. If not, register a new image and assing
     1521         * so, assign it. If not, register a new image and assign
    15221522         * it to the VM.
    15231523         */
     
    15381538             */
    15391539            Bstr uuid;
     1540            Bstr storageCtlName;
    15401541            hardDisk->COMGETTER(Id)(uuid.asOutParam());
    1541             gMachine->DetachDevice(Bstr("IDE Controller"), 0, 0);
    1542             gMachine->AttachDevice(Bstr("IDE Controller"), 0, 0, DeviceType_HardDisk, uuid);
     1542
     1543            /* get the first IDE controller to attach the harddisk to
     1544             * and if there is none, add one temporarily
     1545             */
     1546            {
     1547                ComPtr<IStorageController> storageCtl;
     1548                com::SafeIfaceArray<IStorageController> aStorageControllers;
     1549                CHECK_ERROR (gMachine, COMGETTER(StorageControllers)(ComSafeArrayAsOutParam(aStorageControllers)));
     1550                for (size_t i = 0; i < aStorageControllers.size(); ++ i)
     1551                {
     1552                    StorageBus_T storageBus = StorageBus_Null;
     1553
     1554                    CHECK_ERROR (aStorageControllers[i], COMGETTER(Bus)(&storageBus));
     1555                    if (storageBus == StorageBus_IDE)
     1556                    {
     1557                        storageCtl = aStorageControllers[i];
     1558                        break;
     1559                    }
     1560                }
     1561
     1562                if (storageCtl)
     1563                {
     1564                    CHECK_ERROR (storageCtl, COMGETTER(Name)(storageCtlName.asOutParam()));
     1565                    gMachine->DetachDevice(storageCtlName, 0, 0);
     1566                }
     1567                else
     1568                {
     1569                    storageCtlName = "IDE Controller";
     1570                    CHECK_ERROR (gMachine, AddStorageController(storageCtlName,
     1571                                                                StorageBus_IDE,
     1572                                                                storageCtl.asOutParam()));
     1573                }
     1574            }
     1575
     1576            gMachine->AttachDevice(storageCtlName, 0, 0, DeviceType_HardDisk, uuid);
    15431577            /// @todo why is this attachment saved?
    15441578        }
     
    15841618            }
    15851619        }
     1620
    15861621        Bstr id;
     1622        Bstr storageCtlName;
    15871623        floppyMedium->COMGETTER(Id)(id.asOutParam());
    1588         CHECK_ERROR(gMachine, MountMedium(Bstr("Floppy Controller"), 0, 0, id));
     1624
     1625        /* get the first floppy controller to attach the floppy to
     1626         * and if there is none, add one temporarily
     1627         */
     1628        {
     1629            ComPtr<IStorageController> storageCtl;
     1630            com::SafeIfaceArray<IStorageController> aStorageControllers;
     1631            CHECK_ERROR (gMachine, COMGETTER(StorageControllers)(ComSafeArrayAsOutParam(aStorageControllers)));
     1632            for (size_t i = 0; i < aStorageControllers.size(); ++ i)
     1633            {
     1634                StorageBus_T storageBus = StorageBus_Null;
     1635
     1636                CHECK_ERROR (aStorageControllers[i], COMGETTER(Bus)(&storageBus));
     1637                if (storageBus == StorageBus_Floppy)
     1638                {
     1639                    storageCtl = aStorageControllers[i];
     1640                    break;
     1641                }
     1642            }
     1643
     1644            if (storageCtl)
     1645            {
     1646                ComPtr<IMediumAttachment> floppyAttachment;
     1647
     1648                CHECK_ERROR (storageCtl, COMGETTER(Name)(storageCtlName.asOutParam()));
     1649                rc = gMachine->GetMediumAttachment(storageCtlName, 0, 0, floppyAttachment.asOutParam());
     1650                if (FAILED(rc))
     1651                    CHECK_ERROR (gMachine, AttachDevice(storageCtlName, 0, 0,
     1652                                                        DeviceType_Floppy, NULL));
     1653            }
     1654            else
     1655            {
     1656                storageCtlName = "Floppy Controller";
     1657                CHECK_ERROR (gMachine, AddStorageController(storageCtlName,
     1658                                                            StorageBus_Floppy,
     1659                                                            storageCtl.asOutParam()));
     1660                CHECK_ERROR (gMachine, AttachDevice(storageCtlName, 0, 0,
     1661                                                    DeviceType_Floppy, NULL));
     1662            }
     1663        }
     1664
     1665        CHECK_ERROR (gMachine, MountMedium(storageCtlName, 0, 0, id));
    15891666    }
    15901667    while (0);
     
    16261703            }
    16271704        }
     1705
    16281706        Bstr id;
     1707        Bstr storageCtlName;
    16291708        dvdMedium->COMGETTER(Id)(id.asOutParam());
    1630         CHECK_ERROR(gMachine, MountMedium(Bstr("IDE Controller"), 1, 0, id));
     1709
     1710        /* get the first IDE controller to attach the DVD Drive to
     1711         * and if there is none, add one temporarily
     1712         */
     1713        {
     1714            ComPtr<IStorageController> storageCtl;
     1715            com::SafeIfaceArray<IStorageController> aStorageControllers;
     1716            CHECK_ERROR (gMachine, COMGETTER(StorageControllers)(ComSafeArrayAsOutParam(aStorageControllers)));
     1717            for (size_t i = 0; i < aStorageControllers.size(); ++ i)
     1718            {
     1719                StorageBus_T storageBus = StorageBus_Null;
     1720
     1721                CHECK_ERROR (aStorageControllers[i], COMGETTER(Bus)(&storageBus));
     1722                if (storageBus == StorageBus_IDE)
     1723                {
     1724                    storageCtl = aStorageControllers[i];
     1725                    break;
     1726                }
     1727            }
     1728
     1729            if (storageCtl)
     1730            {
     1731                ComPtr<IMediumAttachment> dvdAttachment;
     1732
     1733                CHECK_ERROR (storageCtl, COMGETTER(Name)(storageCtlName.asOutParam()));
     1734                gMachine->DetachDevice(storageCtlName, 1, 0);
     1735                CHECK_ERROR (gMachine, AttachDevice(storageCtlName, 1, 0,
     1736                                                    DeviceType_DVD, NULL));
     1737            }
     1738            else
     1739            {
     1740                storageCtlName = "IDE Controller";
     1741                CHECK_ERROR (gMachine, AddStorageController(storageCtlName,
     1742                                                            StorageBus_IDE,
     1743                                                            storageCtl.asOutParam()));
     1744                CHECK_ERROR (gMachine, AttachDevice(storageCtlName, 1, 0,
     1745                                                    DeviceType_DVD, NULL));
     1746            }
     1747        }
     1748
     1749        CHECK_ERROR(gMachine, MountMedium(storageCtlName, 1, 0, id));
    16311750    }
    16321751    while (0);
Note: See TracChangeset for help on using the changeset viewer.

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