VirtualBox

Changeset 29422 in vbox


Ignore:
Timestamp:
May 12, 2010 2:08:52 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
61537
Message:

Main/OVF: fix IDE channel confusion introduced with earlier OVF two-channel IDE fix (trunk regression)

Location:
trunk/src/VBox/Main
Files:
6 edited

Legend:

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

    r29102 r29422  
    821821 * @param ulAddressOnParent in: the AddressOnParent parameter from OVF.
    822822 * @param controllerType out: the name of the hard disk controller to attach to (e.g. "IDE Controller").
    823  * @param lChannel out: the channel (controller port) of the controller to attach to.
     823 * @param lControllerPort out: the channel (controller port) of the controller to attach to.
    824824 * @param lDevice out: the device number to attach to.
    825825 */
     
    827827                                            uint32_t ulAddressOnParent,
    828828                                            Bstr &controllerType,
    829                                             int32_t &lChannel,
     829                                            int32_t &lControllerPort,
    830830                                            int32_t &lDevice)
    831831{
     832    Log(("Appliance::convertDiskAttachmentValues: hdc.system=%d, hdc.fPrimary=%d, ulAddressOnParent=%d\n", hdc.system, hdc.fPrimary, ulAddressOnParent));
     833
    832834    switch (hdc.system)
    833835    {
    834836        case ovf::HardDiskController::IDE:
    835             // For the IDE bus, the channel parameter can be either 0 or 1, to specify the primary
     837            // For the IDE bus, the port parameter can be either 0 or 1, to specify the primary
    836838            // or secondary IDE controller, respectively. For the primary controller of the IDE bus,
    837839            // the device number can be either 0 or 1, to specify the master or the slave device,
     
    842844            {
    843845                case 0: // master
    844                     if (hdc.ulAddress == 1)
     846                    if (!hdc.fPrimary)
    845847                    {
    846                         // IDE controller has address 1: then it was exported from VMware and is the secondary controller
    847                         lChannel = (long)1;
     848                        // secondary master
     849                        lControllerPort = (long)1;
    848850                        lDevice = (long)0;
    849851                    }
    850                     else // interpret this as primary master
     852                    else // primary master
    851853                    {
    852                         lChannel = (long)0;
     854                        lControllerPort = (long)0;
    853855                        lDevice = (long)0;
    854856                    }
     
    856858
    857859                case 1: // slave
    858                     if (hdc.ulAddress == 1)
     860                    if (!hdc.fPrimary)
    859861                    {
    860                         // IDE controller has address 1: then it was exported from VMware and is the secondary controller
    861                         lChannel = (long)1;
     862                        // secondary slave
     863                        lControllerPort = (long)1;
    862864                        lDevice = (long)1;
    863865                    }
    864                     else // interpret this as primary slave
     866                    else // primary slave
    865867                    {
    866                         lChannel = (long)0;
     868                        lControllerPort = (long)0;
    867869                        lDevice = (long)1;
    868870                    }
     
    871873                // used by older VBox exports
    872874                case 2:     // interpret this as secondary master
    873                     lChannel = (long)1;
     875                    lControllerPort = (long)1;
    874876                    lDevice = (long)0;
    875877                break;
     
    877879                // used by older VBox exports
    878880                case 3:     // interpret this as secondary slave
    879                     lChannel = (long)1;
     881                    lControllerPort = (long)1;
    880882                    lDevice = (long)1;
    881883                break;
     
    890892        case ovf::HardDiskController::SATA:
    891893            controllerType = Bstr("SATA Controller");
    892             lChannel = (long)ulAddressOnParent;
     894            lControllerPort = (long)ulAddressOnParent;
    893895            lDevice = (long)0;
    894896        break;
     
    896898        case ovf::HardDiskController::SCSI:
    897899            controllerType = Bstr("SCSI Controller");
    898             lChannel = (long)ulAddressOnParent;
     900            lControllerPort = (long)ulAddressOnParent;
    899901            lDevice = (long)0;
    900902        break;
     
    902904        default: break;
    903905    }
     906
     907    Log(("=> lControllerPort=%d, lDevice=%d\n", lControllerPort, lDevice));
    904908}
    905909
     
    11761180                if (SUCCEEDED(rc2))
    11771181                {
    1178                     rc2 = sMachine->DetachDevice(Bstr(mhda.controllerType), mhda.lChannel, mhda.lDevice);
     1182                    rc2 = sMachine->DetachDevice(Bstr(mhda.controllerType), mhda.lControllerPort, mhda.lDevice);
    11791183                    rc2 = sMachine->SaveSettings();
    11801184                }
     
    17401744                mhda.pMachine = pNewMachine;
    17411745                mhda.controllerType = bstrName;
    1742                 mhda.lChannel = 0;
     1746                mhda.lControllerPort = 0;
    17431747                mhda.lDevice = 0;
    17441748
     
    17461750
    17471751                rc = sMachine->AttachDevice(mhda.controllerType,
    1748                                             mhda.lChannel,
     1752                                            mhda.lControllerPort,
    17491753                                            mhda.lDevice,
    17501754                                            DeviceType_Floppy,
     
    17891793                                            2,     // interpreted as secondary master
    17901794                                            mhda.controllerType,        // Bstr
    1791                                             mhda.lChannel,
     1795                                            mhda.lControllerPort,
    17921796                                            mhda.lDevice);
    17931797
    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));
    17951799
    17961800                rc = sMachine->AttachDevice(mhda.controllerType,
    1797                                             mhda.lChannel,
     1801                                            mhda.lControllerPort,
    17981802                                            mhda.lDevice,
    17991803                                            DeviceType_DVD,
     
    18821886                                            ovfVdisk.ulAddressOnParent,
    18831887                                            mhda.controllerType,        // Bstr
    1884                                             mhda.lChannel,
     1888                                            mhda.lControllerPort,
    18851889                                            mhda.lDevice);
    18861890
    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));
    18881892
    18891893                rc = sMachine->AttachDevice(mhda.controllerType,    // wstring name
    1890                                             mhda.lChannel,          // long controllerPort
     1894                                            mhda.lControllerPort,          // long controllerPort
    18911895                                            mhda.lDevice,           // long device
    18921896                                            DeviceType_HardDisk,    // DeviceType_T type
  • trunk/src/VBox/Main/MachineImpl.cpp

    r29386 r29422  
    27662766            AutoReadLock mediumLock(pMedium COMMA_LOCKVAL_SRC_POS);
    27672767            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"),
    27692769                            pMedium->getLocationFull().raw(),
     2770                            aControllerPort,
    27702771                            aDevice,
    2771                             aControllerPort,
    27722772                            aControllerName);
    27732773        }
    27742774        else
    27752775            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                             aDevice, aControllerPort, aControllerName);
     2776                            tr("Device is already attached to port %d, device %d of controller '%ls' of this virtual machine"),
     2777                            aControllerPort, aDevice, aControllerName);
    27782778    }
    27792779
  • trunk/src/VBox/Main/include/ApplianceImpl.h

    r28800 r29422  
    141141                                     uint32_t ulAddressOnParent,
    142142                                     Bstr &controllerType,
    143                                      int32_t &lChannel,
     143                                     int32_t &lControllerPort,
    144144                                     int32_t &lDevice);
    145145
  • trunk/src/VBox/Main/include/ApplianceImplPrivate.h

    r28800 r29422  
    127127    ComPtr<IMachine>    pMachine;
    128128    Bstr                controllerType;
    129     int32_t             lChannel;
    130     int32_t             lDevice;
     129    int32_t             lControllerPort;        // 0-29 for SATA
     130    int32_t             lDevice;                // IDE: 0 or 1, otherwise 0 always
    131131};
    132132
  • trunk/src/VBox/Main/include/ovfreader.h

    r29087 r29422  
    217217                                        // a network adapter depending on the network name.
    218218    iprt::MiniString strAddress;                 // "Device-specific. For an Ethernet adapter, this specifies the MAC address."
     219    int32_t lAddress;                   // strAddress as an integer, if applicable.
    219220    iprt::MiniString strAddressOnParent;         // "For a device, this specifies its location on the controller."
    220221    iprt::MiniString strAllocationUnits;         // "Specifies the units of allocation used. For example, “byte * 2^20”."
     
    262263            // treats it as a fourth class besides IDE, SATA, SCSI
    263264
    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)
    267269
    268270    HardDiskController()
    269271        : idController(0),
    270           ulAddress(0)
     272          lAddress(0),
     273          fPrimary(true)
    271274    { }
    272275};
  • trunk/src/VBox/Main/xml/ovfreader.cpp

    r28800 r29422  
    401401                        i.strConnection = pelmItemChild->getValue();
    402402                    else if (!strcmp(pcszItemChildName, "Address"))
     403                    {
    403404                        i.strAddress = pelmItemChild->getValue();
     405                        pelmItemChild->copyValue(i.lAddress);
     406                    }
    404407                    else if (!strcmp(pcszItemChildName, "AddressOnParent"))
    405408                        i.strAddressOnParent = pelmItemChild->getValue();
     
    433436            }
    434437
     438            HardDiskController *pPrimaryIDEController = NULL;       // will be set once found
     439
    435440            // now go thru all hardware items and handle them according to their type;
    436441            // in this first loop we handle all items _except_ hard disk images,
     
    491496                        hdc.strControllerType = i.strResourceSubType;
    492497
    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;
    505503                        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                        }
    507526
    508527                        vsys.mapControllers[i.ulInstanceID] = hdc;
     528                        if (!pPrimaryIDEController)
     529                            pPrimaryIDEController = &vsys.mapControllers[i.ulInstanceID];
    509530                    }
    510531                    break;
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