VirtualBox

Ignore:
Timestamp:
Dec 1, 2010 8:30:02 PM (14 years ago)
Author:
vboxsync
Message:

Main: Bandwidth groups for disks (and later network)

This introduces two new interfaces. The first one named IBandwidthGroup
represents one I/O limit and can be assigned to several mediums which
share this limit (which works only for harddisk images with the disabled
host cache).
The second one IBandwdithControl manages the groups and can create new ones
and destroy them if not required anymore.

VBoxManage: commands to access the bandwidth groups

Syntax:
VBoxManage storageattach <uuid|vmname>

...
--bandwidthgroup <name>

--bandwidthgroup assigns the specified device to the given group.

VBoxManage bandwidthctl <uuid|vmname>

--name <name>
--add disk|network
--limit <megabytes per second>
--delete

The --name parameter gives the name of the bandwidth group.
--add creates a new group of the given type (only disk is implemented so far)

with the given name.

--limit sets the limit to the given amount of MB/s

Note that limit can be changed while the VM is running. The VM
will immediately pick up the new limit for the given group name.

--delete deletes the group with the given name if it isn't used anymore.

Trying to delete a still used group will result in an error.

Example:

VBoxManage bandwidthctl "Test VM" --name Limit --add disk --limit 20
Creates a group named Test having a 20 MB/s limit.

VBoxManage storageattach "Test VM" --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium test.vdi --bandwidthgroup Limit
Adds a new disk to the SATA controller and assigns the bandwidth group Limit to it.

VBoxManage storageattach "Test VM" --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium test.vdi --bandwidthgroup none
Removes the bandwidth limit from the disk.

VBoxManage bandwidthctl "Test VM" --name Limit --add disk --limit 10
Changes the limit of bandwidth group Limit to 10 MB/s. If the VM is running the limit will be picked up
immediately.

Location:
trunk/src/VBox/Frontends/VBoxManage
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/Makefile.kmk

    r33590 r34587  
    5050        VBoxManageSnapshot.cpp \
    5151        VBoxManageStorageController.cpp \
    52         VBoxManageUSB.cpp
     52        VBoxManageUSB.cpp \
     53        VBoxManageBandwidthControl.cpp
    5354endif # !VBOX_ONLY_DOCS
    5455
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp

    r34244 r34587  
    432432            { "dhcpserver",       USAGE_DHCPSERVER,        handleDHCPServer},
    433433            { "extpack",          USAGE_EXTPACK,           handleExtPack},
     434            { "bandwidthctl",     USAGE_BANDWIDTHCONTROL,  handleBandwidthControl},
    434435            { NULL,               0,                       NULL }
    435436        };
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManage.h

    r34244 r34587  
    9898#define USAGE_PASSWORDHASH          RT_BIT_64(54)
    9999#define USAGE_EXTPACK               RT_BIT_64(55)
     100#define USAGE_BANDWIDTHCONTROL      RT_BIT_64(56)
    100101#define USAGE_ALL                   (~(uint64_t)0)
    101102/** @} */
     
    241242int handleDHCPServer(HandlerArg *a);
    242243
     244/* VBoxManageBandwidthControl.cpp */
     245int handleBandwidthControl(HandlerArg *a);
     246
    243247#endif /* !VBOX_ONLY_DOCS */
    244248
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp

    r34574 r34587  
    464464                     "                                      <uuid>|<filename>|host:<drive>]\n"
    465465                     "                            [--passthrough on|off]\n"
     466                     "                            [--bandwidthgroup <name>]\n"
    466467                     "                            [--forceunmount]\n"
    467468                     "\n");
     
    481482                     "                            [--bootable on|off]\n"
    482483                     "                            [--remove]\n"
     484                     "\n");
     485    }
     486
     487    if (u64Cmd & USAGE_BANDWIDTHCONTROL)
     488    {
     489        RTStrmPrintf(pStrm,
     490                     "VBoxManage bandwidthctl     <uuid|vmname>\n"
     491                     "                            --name <name>\n"
     492                     "                            [--add disk|network]\n"
     493                     "                            [--limit <megabytes per second>\n"
     494                     "                            [--delete]\n"
    483495                     "\n");
    484496    }
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageStorageController.cpp

    r34010 r34587  
    5151    { "--type",           't', RTGETOPT_REQ_STRING },
    5252    { "--passthrough",    'h', RTGETOPT_REQ_STRING },
     53    { "--bandwidthgroup", 'b', RTGETOPT_REQ_STRING },
    5354    { "--forceunmount",   'f', RTGETOPT_REQ_NOTHING },
    5455};
     
    6566    const char *pszMedium = NULL;
    6667    const char *pszPassThrough = NULL;
     68    const char *pszBandwidthGroup = NULL;
    6769    RTGETOPTUNION ValueUnion;
    6870    RTGETOPTSTATE GetState;
     
    127129                if (ValueUnion.psz)
    128130                    pszPassThrough = ValueUnion.psz;
     131                else
     132                    rc = E_FAIL;
     133                break;
     134            }
     135
     136            case 'b':   // bandwidthgroup <name>
     137            {
     138                if (ValueUnion.psz)
     139                    pszBandwidthGroup = ValueUnion.psz;
    129140                else
    130141                    rc = E_FAIL;
     
    185196    {
    186197        errorArgument("Drive passthrough state can't be changed while the VM is running\n");
     198        goto leave;
     199    }
     200
     201    if (fRunTime && pszBandwidthGroup)
     202    {
     203        errorArgument("Bandwidth group can't be changed while the VM is running\n");
    187204        goto leave;
    188205    }
     
    626643    }
    627644
     645    if (   pszBandwidthGroup
     646        && !fRunTime
     647        && SUCCEEDED(rc))
     648    {
     649
     650        if (!RTStrICmp(pszBandwidthGroup, "none"))
     651        {
     652            /* Just remove the bandwidth gorup. */
     653            CHECK_ERROR(machine, SetBandwidthGroupForDevice(Bstr(pszCtl).raw(),
     654                                                            port, device, NULL));
     655        }
     656        else
     657        {
     658            ComPtr<IBandwidthControl> bwCtrl;
     659            ComPtr<IBandwidthGroup> bwGroup;
     660
     661            CHECK_ERROR(machine, COMGETTER(BandwidthControl)(bwCtrl.asOutParam()));
     662
     663            if (SUCCEEDED(rc))
     664            {
     665                CHECK_ERROR(bwCtrl, GetBandwidthGroup(Bstr(pszBandwidthGroup).raw(), bwGroup.asOutParam()));
     666                if (SUCCEEDED(rc))
     667                {
     668                    CHECK_ERROR(machine, SetBandwidthGroupForDevice(Bstr(pszCtl).raw(),
     669                                                                    port, device, bwGroup));
     670                }
     671            }
     672        }
     673    }
     674
    628675    /* commit changes */
    629676    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