MachineImpl.h revision 1bf151411167b02ebdc6d6a18de8b97030341e1f
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync * Implementation of IMachine in VBoxSVC - Header.
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync * Copyright (C) 2006-2013 Oracle Corporation
e64031e20c39650a7bc902a3e1aba613b9415deevboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync * available from http://www.virtualbox.org. This file is free software;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync * you can redistribute it and/or modify it under the terms of the GNU
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync * General Public License (GPL) as published by the Free Software
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
4651430e55b9df9726347e3e3968618e540fe729vboxsync#include "StorageControllerImpl.h" // required for MachineImpl.h to compile on Windows
4651430e55b9df9726347e3e3968618e540fe729vboxsync#endif /* VBOX_WITH_RESOURCE_USAGE_API */
5ff3fa0492332325f57e80636321619e2224027evboxsync// generated header
e07acfb7f2dbb8bb40804024c79fd3139bdb3f24vboxsync////////////////////////////////////////////////////////////////////////////////
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync// helper declarations
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync////////////////////////////////////////////////////////////////////////////////
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync// Machine class
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync////////////////////////////////////////////////////////////////////////////////
83c86878d483df62ca8db465c671995984838338vboxsync * Internal machine data.
5a6bbb9c0d896e804f267c6919f52158a420b998vboxsync * Only one instance of this data exists per every machine -- it is shared
5a6bbb9c0d896e804f267c6919f52158a420b998vboxsync * by the Machine, SessionMachine and all SnapshotMachine instances
5a6bbb9c0d896e804f267c6919f52158a420b998vboxsync * associated with the given machine using the util::Shareable template
5a6bbb9c0d896e804f267c6919f52158a420b998vboxsync * through the mData variable.
5a6bbb9c0d896e804f267c6919f52158a420b998vboxsync * @note |const| members are persistent during lifetime so can be
5a6bbb9c0d896e804f267c6919f52158a420b998vboxsync * accessed without locking.
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync * @note There is no need to lock anything inside init() or uninit()
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync * methods, because they are always serialized (see AutoCaller).
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync * Data structure to hold information about sessions opened for the
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync * given machine.
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync /** Control of the direct session opened by lockMachine() */
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync typedef std::list<ComPtr<IInternalSessionControl> > RemoteControlList;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync /** list of controls of all opened remote sessions */
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync /** launchVMProcess() and OnSessionEnd() progress indicator */
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync * PID of the session object that must be passed to openSession()
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync * to finalize the launchVMProcess() request (i.e., PID of the
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync * process created by launchVMProcess())
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync /** Current session state */
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync /** Session type string (for indirect sessions) */
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync /** Session machine object */
4fd4258d68911eacb0b3d1f096b778d19da4e55avboxsync /** Medium object lock collection. */
4fd4258d68911eacb0b3d1f096b778d19da4e55avboxsync // machine settings XML file
32529464ff2d4288a3c949ab8042126b0fa903devboxsync /* Note: These are guarded by VirtualBoxBase::stateLockHandle() */
9c3f21ab6ba51a44403b662e1691293ab266e5e3vboxsync /** Guest properties have been modified and need saving since the
9c3f21ab6ba51a44403b662e1691293ab266e5e3vboxsync * machine was started, or there are transient properties which need
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync * deleting and the machine is being shut down. */
df4af4b66b5f26c3c06ae1592ec2e67afd82dd0cvboxsync // list of files to delete in Delete(); this list is filled by Unregister()
561574402775590253d11504354bfe21d80e4858vboxsync * Saved state data.
f2fedb6cbb946e9dd6d418b1472373395e2ac34fvboxsync * It's actually only the state file path string, but it needs to be
f2fedb6cbb946e9dd6d418b1472373395e2ac34fvboxsync * separate from Data, because Machine and SessionMachine instances
f2fedb6cbb946e9dd6d418b1472373395e2ac34fvboxsync * share it, while SnapshotMachine does not.
6c5e2fff0e3fdfc7c3f3fb2e7b7ec8ebb2223cecvboxsync * The data variable is |mSSData|.
615105a2b89b7dd89a76504e6a9b8e099704c0d9vboxsync * User changeable machine data.
615105a2b89b7dd89a76504e6a9b8e099704c0d9vboxsync * This data is common for all machine snapshots, i.e. it is shared
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync * by all SnapshotMachine instances associated with the given machine
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync * using the util::Backupable template through the |mUserData| variable.
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync * SessionMachine instances can alter this data and discard changes.
615105a2b89b7dd89a76504e6a9b8e099704c0d9vboxsync * @note There is no need to lock anything inside init() or uninit()
f2fedb6cbb946e9dd6d418b1472373395e2ac34fvboxsync * methods, because they are always serialized (see AutoCaller).
struct HWData
struct GuestProperty {
HWData();
~HWData();
struct MediaData
MediaData();
~MediaData();
void FinalRelease();
// public initializer/uninitializer for internal purposes only:
bool fForceOverwrite,
bool fDirectoryIncludesUUID);
void uninit();
#ifdef VBOX_WITH_RESOURCE_USAGE_API
void uninitDataAndChildObjects();
STDMETHOD(COMGETTER(StorageControllers))(ComSafeArrayOut(IStorageController *, aStorageControllers));
STDMETHOD(LaunchVMProcess)(ISession *aSession, IN_BSTR aType, IN_BSTR aEnvironment, IProgress **aProgress);
STDMETHOD(PassthroughDevice)(IN_BSTR aControllerName, LONG aControllerPort, LONG aDevice, BOOL aPassthrough);
STDMETHOD(TemporaryEjectDevice)(IN_BSTR aControllerName, LONG aControllerPort, LONG aDevice, BOOL aTempEject);
STDMETHOD(NonRotationalDevice)(IN_BSTR aControllerName, LONG aControllerPort, LONG aDevice, BOOL aNonRotational);
STDMETHOD(SetAutoDiscardForDevice)(IN_BSTR aControllerName, LONG aControllerPort, LONG aDevice, BOOL aDiscard);
STDMETHOD(ExportTo)(IAppliance *aAppliance, IN_BSTR location, IVirtualSystemDescription **aDescription);
STDMETHOD(EnumerateGuestProperties)(IN_BSTR aPattern, ComSafeArrayOut(BSTR, aNames), ComSafeArrayOut(BSTR, aValues), ComSafeArrayOut(LONG64, 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(QuerySavedGuestScreenInfo)(ULONG uScreenId, ULONG *puOriginX, ULONG *puOriginY, ULONG *puWidth, ULONG *puHeight, BOOL *pfEnabled);
STDMETHOD(ReadSavedThumbnailToArray)(ULONG aScreenId, BOOL aBGR, ULONG *aWidth, ULONG *aHeight, ComSafeArrayOut(BYTE, aData));
STDMETHOD(ReadSavedThumbnailPNGToArray)(ULONG aScreenId, ULONG *aWidth, ULONG *aHeight, ComSafeArrayOut(BYTE, aData));
STDMETHOD(QuerySavedScreenshotPNGSize)(ULONG aScreenId, ULONG *aSize, ULONG *aWidth, ULONG *aHeight);
STDMETHOD(ReadSavedScreenshotPNGToArray)(ULONG aScreenId, ULONG *aWidth, ULONG *aHeight, ComSafeArrayOut(BYTE, aData));
STDMETHOD(CloneTo(IMachine *pTarget, CloneMode_T mode, ComSafeArrayIn(CloneOptions_T, options), IProgress **pProgress));
return LOCKCLASS_MACHINEOBJECT;
virtual HRESULT onNetworkAdapterChange(INetworkAdapter * /* networkAdapter */, BOOL /* changeAdapter */) { return S_OK; }
NATProtocol_T /* protocol */, IN_BSTR /* host ip */, LONG /* host port */, IN_BSTR /* guest port */, LONG /* guest port */ ) { return S_OK; }
virtual HRESULT onMediumChange(IMediumAttachment * /* mediumAttachment */, BOOL /* force */) { return S_OK; }
virtual HRESULT onStorageDeviceChange(IMediumAttachment * /* mediumAttachment */, BOOL /* remove */, BOOL /* silent */) { return S_OK; }
if (!*directControl)
return rc;
#if defined(RT_OS_WINDOWS)
bool aAllowClosing = false);
bool isSessionSpawning();
bool checkForSpawnFailure();
bool aSetError = false)
void releaseStateDependency();
bool fSetError = false)
void ensureNoStateDependencies();
bool aSetError = false);
bool aSetError = false);
bool aSetError = false);
bool aSetError = false);
bool aOnline);
void rollbackMedia();
void commit();
struct DeleteTask;
#ifdef VBOX_WITH_GUEST_PROPS
#ifdef VBOX_WITH_RESOURCE_USAGE_API
void FinalRelease();
// public initializer/uninitializer for internal purposes only
bool checkForDeath();
void unlockMedia();
struct ConsoleTaskData
struct Uninit
struct SnapshotTask;
struct DeleteSnapshotTask;
struct RestoreSnapshotTask;
bool fOnlineMergePossible,
bool &fMergeForward,
bool &fNeedOnlineMerge,
bool fNeedsOnlineMerge,
bool fMergeForward,
bool *pfNeedsMachineSaveSettings);
#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();
return (isSnapshotMachine())