MachineImpl.h revision 21fb3856ccbe237638614ec4f937a7f524036a24
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * VirtualBox COM class declaration
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * Copyright (C) 2006-2010 Sun Microsystems, Inc.
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * available from http://www.virtualbox.org. This file is free software;
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * you can redistribute it and/or modify it under the terms of the GNU
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * General Public License (GPL) as published by the Free Software
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * additional information or have any questions.
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync#include "StorageControllerImpl.h" // required for MachineImpl.h to compile on Windows
9040f019271f91b98e1320c0a8c38a42636e3979vboxsync#endif /* VBOX_WITH_RESOURCE_USAGE_API */
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync// generated header
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync////////////////////////////////////////////////////////////////////////////////
9040f019271f91b98e1320c0a8c38a42636e3979vboxsync// helper declarations
9040f019271f91b98e1320c0a8c38a42636e3979vboxsync////////////////////////////////////////////////////////////////////////////////
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync// Machine class
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync////////////////////////////////////////////////////////////////////////////////
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync public VirtualBoxSupportErrorInfoImpl<Machine, IMachine>,
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync enum InitMode { Init_New, Init_Import, Init_Registered };
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * Internal machine data.
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * Only one instance of this data exists per every machine -- it is shared
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * by the Machine, SessionMachine and all SnapshotMachine instances
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * associated with the given machine using the util::Shareable template
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * through the mData variable.
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * @note |const| members are persistent during lifetime so can be
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * accessed without locking.
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * @note There is no need to lock anything inside init() or uninit()
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * methods, because they are always serialized (see AutoCaller).
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * Data structure to hold information about sessions opened for the
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * given machine.
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync /** Control of the direct session opened by openSession() */
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync typedef std::list<ComPtr<IInternalSessionControl> > RemoteControlList;
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync /** list of controls of all opened remote sessions */
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync /** openRemoteSession() and OnSessionEnd() progress indicator */
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * PID of the session object that must be passed to openSession() to
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * finalize the openRemoteSession() request (i.e., PID of the
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * process created by openRemoteSession())
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync /** Current session state */
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync /** Session type string (for indirect sessions) */
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync /** Session machine object */
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * Successfully locked media list. The 2nd value in the pair is true
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * if the medium is locked for writing and false if locked for
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync typedef std::list<std::pair<ComPtr<IMedium>, bool > > LockedMedia;
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync /** Flag indicating that the config file is read-only. */
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync // machine settings XML file
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync /* Note: These are guarded by VirtualBoxBase::stateLockHandle() */
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * Saved state data.
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * It's actually only the state file path string, but it needs to be
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * separate from Data, because Machine and SessionMachine instances
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * share it, while SnapshotMachine does not.
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * The data variable is |mSSData|.
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * User changeable machine data.
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * This data is common for all machine snapshots, i.e. it is shared
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * by all SnapshotMachine instances associated with the given machine
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * using the util::Backupable template through the |mUserData| variable.
bbf3d430bae83177ab9ce3097f49d89cc873e7c0vboxsync * SessionMachine instances can alter this data and discard changes.
bbf3d430bae83177ab9ce3097f49d89cc873e7c0vboxsync * @note There is no need to lock anything inside init() or uninit()
bbf3d430bae83177ab9ce3097f49d89cc873e7c0vboxsync * methods, because they are always serialized (see AutoCaller).
struct HWData
struct GuestProperty {
HWData();
~HWData();
struct MediaData
MediaData();
~MediaData();
enum StateDependency
&mRegistered);
void release()
void add()
&mRegistered);
void FinalRelease();
// public initializer/uninitializer for internal purposes only
void uninit();
void uninitDataAndChildObjects();
STDMETHOD(COMGETTER(StorageControllers))(ComSafeArrayOut(IStorageController *, aStorageControllers));
STDMETHOD(PassthroughDevice)(IN_BSTR aControllerName, LONG aControllerPort, LONG aDevice, BOOL aPassthrough);
STDMETHOD(EnumerateGuestProperties)(IN_BSTR aPattern, ComSafeArrayOut(BSTR, aNames), ComSafeArrayOut(BSTR, aValues), ComSafeArrayOut(ULONG64, aTimestamps), ComSafeArrayOut(BSTR, aFlags));
STDMETHOD(GetMediumAttachmentsOfController)(IN_BSTR aName, ComSafeArrayOut(IMediumAttachment *, aAttachments));
STDMETHOD(GetMediumAttachment)(IN_BSTR aConstrollerName, LONG aControllerPort, LONG aDevice, IMediumAttachment **aAttachment);
STDMETHOD(AddStorageController)(IN_BSTR aName, StorageBus_T aConnectionType, IStorageController **controller);
STDMETHOD(ReadSavedThumbnailToArray)(BOOL aBGR, ULONG *aWidth, ULONG *aHeight, ComSafeArrayOut(BYTE, aData));
STDMETHOD(ReadSavedScreenshotPNGToArray)(ULONG *aWidth, ULONG *aHeight, ComSafeArrayOut(BYTE, aData));
* The class IDs are defined in VirtualBoxBase.h.
return clsidMachine;
return LOCKCLASS_MACHINEOBJECT;
virtual HRESULT onNetworkAdapterChange(INetworkAdapter * /* networkAdapter */, BOOL /* changeAdapter */) { return S_OK; }
virtual HRESULT onMediumChange(IMediumAttachment * /* mediumAttachment */, BOOL /* force */) { return S_OK; }
#if defined(RT_OS_WINDOWS)
bool aAllowClosing = false);
bool isSessionSpawning();
bool checkForSpawnFailure();
bool aSetError = false)
void releaseStateDependency();
void ensureNoStateDependencies();
bool aSetError = false);
bool aRegistered,
bool aRegistered,
bool aSetError = false);
bool aSetError = false);
bool aSetError = false);
bool aOnline,
bool *pfNeedsSaveSettings);
void rollbackMedia();
bool isModified();
void commit();
#ifdef VBOX_WITH_RESOURCE_USAGE_API
void FinalRelease();
// public initializer/uninitializer for internal purposes only
* The class IDs are defined in VirtualBoxBase.h.
return clsidSessionMachine;
bool checkForDeath();
struct SnapshotData
struct Uninit
struct SnapshotTask;
struct DeleteSnapshotTask;
struct RestoreSnapshotTask;
void unlockMedia();
#if defined(RT_OS_WINDOWS)
int mIPCSem;
# ifdef VBOX_WITH_NEW_SYS_V_KEYGEN
void FinalRelease();
// public initializer/uninitializer for internal purposes only
void uninit();
* The class IDs are defined in VirtualBoxBase.h.
return clsidSnapshotMachine;
return mPeer;
return this;