VirtualBox

source: vbox/trunk/src/VBox/Main/include/MediumAttachmentImpl.h@ 35164

Last change on this file since 35164 was 34587, checked in by vboxsync, 14 years ago

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.

  • Property svn:eol-style set to native
File size: 3.4 KB
Line 
1/** @file
2 *
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006-2009 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef ____H_MEDIUMATTACHMENTIMPL
19#define ____H_MEDIUMATTACHMENTIMPL
20
21#include "VirtualBoxBase.h"
22#include "BandwidthGroupImpl.h"
23
24class ATL_NO_VTABLE MediumAttachment :
25 public VirtualBoxBase,
26 VBOX_SCRIPTABLE_IMPL(IMediumAttachment)
27{
28public:
29 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(MediumAttachment, IMediumAttachment)
30
31 DECLARE_NOT_AGGREGATABLE(MediumAttachment)
32
33 DECLARE_PROTECT_FINAL_CONSTRUCT()
34
35 BEGIN_COM_MAP(MediumAttachment)
36 COM_INTERFACE_ENTRY(ISupportErrorInfo)
37 COM_INTERFACE_ENTRY(IMediumAttachment)
38 COM_INTERFACE_ENTRY(IDispatch)
39 END_COM_MAP()
40
41 MediumAttachment() { };
42 ~MediumAttachment() { };
43
44 // public initializer/uninitializer for internal purposes only
45 HRESULT init(Machine *aParent,
46 Medium *aMedium,
47 const Bstr &aControllerName,
48 LONG aPort,
49 LONG aDevice,
50 DeviceType_T aType,
51 bool fPassthrough,
52 BandwidthGroup *aBandwidthGroup);
53 void uninit();
54
55 HRESULT FinalConstruct();
56 void FinalRelease();
57
58 // IMediumAttachment properties
59 STDMETHOD(COMGETTER(Medium))(IMedium **aMedium);
60 STDMETHOD(COMGETTER(Controller))(BSTR *aController);
61 STDMETHOD(COMGETTER(Port))(LONG *aPort);
62 STDMETHOD(COMGETTER(Device))(LONG *aDevice);
63 STDMETHOD(COMGETTER(Type))(DeviceType_T *aType);
64 STDMETHOD(COMGETTER(Passthrough))(BOOL *aPassthrough);
65 STDMETHOD(COMGETTER(BandwidthGroup))(IBandwidthGroup **aBwGroup);
66
67 // public internal methods
68 void rollback();
69 void commit();
70
71 // unsafe public methods for internal purposes only (ensure there is
72 // a caller and a read lock before calling them!)
73 bool isImplicit() const;
74 void setImplicit(bool aImplicit);
75
76 const ComObjPtr<Medium>& getMedium() const;
77 Bstr getControllerName() const;
78 LONG getPort() const;
79 LONG getDevice() const;
80 DeviceType_T getType() const;
81 bool getPassthrough() const;
82 const ComObjPtr<BandwidthGroup>& getBandwidthGroup() const;
83
84 bool matches(CBSTR aControllerName, LONG aPort, LONG aDevice);
85
86 /** Must be called from under this object's write lock. */
87 void updateMedium(const ComObjPtr<Medium> &aMedium);
88
89 /** Must be called from under this object's write lock. */
90 void updatePassthrough(bool aPassthrough);
91
92 /** Must be called from under this object's write lock. */
93 void updateBandwidthGroup(const ComObjPtr<BandwidthGroup> &aBandwidthGroup);
94
95 /** Get a unique and somewhat descriptive name for logging. */
96 const char* getLogName(void) const { return mLogName.c_str(); }
97
98private:
99 struct Data;
100 Data *m;
101
102 Utf8Str mLogName; /**< For logging purposes */
103};
104
105#endif // ____H_MEDIUMATTACHMENTIMPL
106/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

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