VirtualBox

Ignore:
Timestamp:
Jul 13, 2011 6:34:49 PM (14 years ago)
Author:
vboxsync
Message:

Frontends/VBoxManage: make --port and --device parameter for storageattach optional if there is only one port or device per port

Location:
trunk/src/VBox/Frontends/VBoxManage
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp

    r37925 r37929  
    458458                     "VBoxManage storageattach    <uuid|vmname>\n"
    459459                     "                            --storagectl <name>\n"
    460                      "                            --port <number>\n"
     460                     "                            [--port <number>]\n"
    461461                     "                            [--device <number>]\n"
    462462                     "                            [--type dvddrive|hdd|fdd]\n"
     
    475475                     "                            [--server <name>|<ip>]\n"
    476476                     "                            [--target <target>]\n"
    477                      "                            [--port <port>]\n"
     477                     "                            [--tport <port>]\n"
    478478                     "                            [--lun <lun>]\n"
    479479                     "                            [--encodedlun <lun>]\n"
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageStorageController.cpp

    r37925 r37929  
    6262    { "--server",           'S', RTGETOPT_REQ_STRING },
    6363    { "--target",           'T', RTGETOPT_REQ_STRING },
    64     { "--port",             'P', RTGETOPT_REQ_STRING },
     64    { "--tport",            'P', RTGETOPT_REQ_STRING },
    6565    { "--lun",              'L', RTGETOPT_REQ_STRING },
    6666    { "--encodedlun",       'E', RTGETOPT_REQ_STRING },
     
    7575    HRESULT rc = S_OK;
    7676    ULONG port   = ~0U;
    77     ULONG device = 0;                   /* device is optional, default is 0 */
     77    ULONG device = ~0U;
    7878    bool fForceUnmount = false;
    7979    bool fSetMediumType = false;
     
    239239                break;
    240240
    241             case 'P':   // --port
     241            case 'P':   // --tport
    242242                bstrPort = ValueUnion.psz;
    243243                break;
     
    286286    if (!pszCtl)
    287287        return errorSyntax(USAGE_STORAGEATTACH, "Storage controller name not specified");
    288     if (port == ~0U)
    289         return errorSyntax(USAGE_STORAGEATTACH, "Port not specified");
    290288
    291289    /* get the virtualbox system properties */
     
    317315        if (FAILED(rc))
    318316            throw Utf8StrFmt("Could not find a controller named '%s'\n", pszCtl);
     317
     318        StorageBus_T storageBus = StorageBus_Null;
     319        CHECK_ERROR_RET(storageCtl, COMGETTER(Bus)(&storageBus), 1);
     320        ULONG maxPorts = 0;
     321        CHECK_ERROR_RET(systemProperties, GetMaxPortCountForStorageBus(storageBus, &maxPorts), 1);
     322        ULONG maxDevices = 0;
     323        CHECK_ERROR_RET(systemProperties, GetMaxDevicesPerPortForStorageBus(storageBus, &maxDevices), 1);
     324
     325        if (port == ~0U)
     326        {
     327            if (maxPorts == 1)
     328                port = 0;
     329            else
     330                return errorSyntax(USAGE_STORAGEATTACH, "Port not specified");
     331        }
     332        if (device == ~0U)
     333        {
     334            if (maxDevices == 1)
     335                device = 0;
     336            else
     337                return errorSyntax(USAGE_STORAGEATTACH, "Device not specified");
     338        }
    319339
    320340        /* for sata controller check if the port count is big enough
     
    376396            else
    377397            {
    378                 StorageBus_T storageBus = StorageBus_Null;
    379398                DeviceType_T deviceType = DeviceType_Null;
    380399                com::SafeArray <DeviceType_T> saDeviceTypes;
     
    382401
    383402                /* check if the device type is supported by the controller */
    384                 CHECK_ERROR(storageCtl, COMGETTER(Bus)(&storageBus));
    385403                CHECK_ERROR(systemProperties, GetDeviceTypesForStorageBus(storageBus, ComSafeArrayAsOutParam(saDeviceTypes)));
    386404                for (size_t i = 0; i < saDeviceTypes.size(); ++ i)
     
    461479            /* check if the device type is supported by the controller */
    462480            {
    463                 StorageBus_T storageBus = StorageBus_Null;
    464481                com::SafeArray <DeviceType_T> saDeviceTypes;
    465482
    466                 CHECK_ERROR(storageCtl, COMGETTER(Bus)(&storageBus));
    467483                CHECK_ERROR(systemProperties, GetDeviceTypesForStorageBus(storageBus, ComSafeArrayAsOutParam(saDeviceTypes)));
    468484                if (SUCCEEDED(rc))
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