VirtualBox

source: vbox/trunk/src/VBox/Main/include/SessionImpl.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
  • Property svn:keywords set to Author Date Id Revision
File size: 5.1 KB
Line 
1/** @file
2 *
3 * VBox Client Session COM Class definition
4 */
5
6/*
7 * Copyright (C) 2006-2010 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_SESSIONIMPL
19#define ____H_SESSIONIMPL
20
21#include "VirtualBoxBase.h"
22#include "ConsoleImpl.h"
23
24#ifdef RT_OS_WINDOWS
25# include "win/resource.h"
26#endif
27
28/** @def VBOX_WITH_SYS_V_IPC_SESSION_WATCHER
29 * Use SYS V IPC for watching a session.
30 * This is defined in the Makefile since it's also used by MachineImpl.h/cpp.
31 */
32#ifdef DOXYGEN_RUNNING
33# define VBOX_WITH_SYS_V_IPC_SESSION_WATCHER
34#endif
35
36class ATL_NO_VTABLE Session :
37 public VirtualBoxBase,
38 VBOX_SCRIPTABLE_IMPL(ISession),
39 VBOX_SCRIPTABLE_IMPL(IInternalSessionControl)
40#ifdef RT_OS_WINDOWS
41 , public CComCoClass<Session, &CLSID_Session>
42#endif
43{
44public:
45
46 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Session, ISession)
47
48 DECLARE_CLASSFACTORY()
49
50 DECLARE_REGISTRY_RESOURCEID(IDR_VIRTUALBOX)
51 DECLARE_NOT_AGGREGATABLE(Session)
52
53 DECLARE_PROTECT_FINAL_CONSTRUCT()
54
55 BEGIN_COM_MAP(Session)
56 COM_INTERFACE_ENTRY2(IDispatch, ISession)
57 COM_INTERFACE_ENTRY2(IDispatch, IInternalSessionControl)
58 COM_INTERFACE_ENTRY(IInternalSessionControl)
59 COM_INTERFACE_ENTRY(ISupportErrorInfo)
60 COM_INTERFACE_ENTRY(ISession)
61 END_COM_MAP()
62
63 HRESULT FinalConstruct();
64 void FinalRelease();
65
66 // public initializers/uninitializers only for internal purposes
67 HRESULT init();
68 void uninit();
69
70 // ISession properties
71 STDMETHOD(COMGETTER(State))(SessionState_T *aState);
72 STDMETHOD(COMGETTER(Type))(SessionType_T *aType);
73 STDMETHOD(COMGETTER(Machine))(IMachine **aMachine);
74 STDMETHOD(COMGETTER(Console))(IConsole **aConsole);
75
76 // ISession methods
77 STDMETHOD(UnlockMachine)();
78
79 // IInternalSessionControl methods
80 STDMETHOD(GetPID)(ULONG *aPid);
81 STDMETHOD(GetRemoteConsole)(IConsole **aConsole);
82 STDMETHOD(AssignMachine)(IMachine *aMachine);
83 STDMETHOD(AssignRemoteMachine)(IMachine *aMachine, IConsole *aConsole);
84 STDMETHOD(UpdateMachineState)(MachineState_T aMachineState);
85 STDMETHOD(Uninitialize)();
86 STDMETHOD(OnNetworkAdapterChange)(INetworkAdapter *networkAdapter, BOOL changeAdapter);
87 STDMETHOD(OnSerialPortChange)(ISerialPort *serialPort);
88 STDMETHOD(OnParallelPortChange)(IParallelPort *parallelPort);
89 STDMETHOD(OnStorageControllerChange)();
90 STDMETHOD(OnMediumChange)(IMediumAttachment *aMediumAttachment, BOOL aForce);
91 STDMETHOD(OnCPUChange)(ULONG aCPU, BOOL aRemove);
92 STDMETHOD(OnCPUExecutionCapChange)(ULONG aExecutionCap);
93 STDMETHOD(OnVRDEServerChange)(BOOL aRestart);
94 STDMETHOD(OnUSBControllerChange)();
95 STDMETHOD(OnSharedFolderChange)(BOOL aGlobal);
96 STDMETHOD(OnUSBDeviceAttach)(IUSBDevice *aDevice, IVirtualBoxErrorInfo *aError, ULONG aMaskedIfs);
97 STDMETHOD(OnUSBDeviceDetach)(IN_BSTR aId, IVirtualBoxErrorInfo *aError);
98 STDMETHOD(OnShowWindow)(BOOL aCheck, BOOL *aCanShow, LONG64 *aWinId);
99 STDMETHOD(OnBandwidthGroupChange)(IBandwidthGroup *aBandwidthGroup);
100 STDMETHOD(AccessGuestProperty)(IN_BSTR aName, IN_BSTR aValue, IN_BSTR aFlags,
101 BOOL aIsSetter, BSTR *aRetValue, LONG64 *aRetTimestamp, BSTR *aRetFlags);
102 STDMETHOD(EnumerateGuestProperties)(IN_BSTR aPatterns,
103 ComSafeArrayOut(BSTR, aNames),
104 ComSafeArrayOut(BSTR, aValues),
105 ComSafeArrayOut(LONG64, aTimestamps),
106 ComSafeArrayOut(BSTR, aFlags));
107 STDMETHOD(OnlineMergeMedium)(IMediumAttachment *aMediumAttachment,
108 ULONG aSourceIdx, ULONG aTargetIdx,
109 IMedium *aSource, IMedium *aTarget,
110 BOOL aMergeForward, IMedium *aParentForTarget,
111 ComSafeArrayIn(IMedium *, aChildrenToReparent),
112 IProgress *aProgress);
113
114private:
115
116 HRESULT unlockMachine(bool aFinalRelease, bool aFromServer);
117 HRESULT grabIPCSemaphore();
118 void releaseIPCSemaphore();
119
120 SessionState_T mState;
121 SessionType_T mType;
122
123 ComPtr<IInternalMachineControl> mControl;
124
125 ComObjPtr<Console> mConsole;
126
127 ComPtr<IMachine> mRemoteMachine;
128 ComPtr<IConsole> mRemoteConsole;
129
130 ComPtr<IVirtualBox> mVirtualBox;
131
132 /* interprocess semaphore handle (id) for the opened machine */
133#if defined(RT_OS_WINDOWS)
134 HANDLE mIPCSem;
135 HANDLE mIPCThreadSem;
136#elif defined(RT_OS_OS2)
137 RTTHREAD mIPCThread;
138 RTSEMEVENT mIPCThreadSem;
139#elif defined(VBOX_WITH_SYS_V_IPC_SESSION_WATCHER)
140 int mIPCSem;
141#else
142# error "Port me!"
143#endif
144};
145
146#endif // ____H_SESSIONIMPL
147/* 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