MachineImpl.h revision 1bf151411167b02ebdc6d6a18de8b97030341e1f
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync/* $Id$ */
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync/** @file
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync * Implementation of IMachine in VBoxSVC - Header.
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync */
1c898140fdfb6f3d207b0066f4fc8988226da7d4vboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync/*
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync * Copyright (C) 2006-2013 Oracle Corporation
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync *
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.
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync */
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync#ifndef ____H_MACHINEIMPL
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync#define ____H_MACHINEIMPL
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync#include "VirtualBoxBase.h"
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync#include "SnapshotImpl.h"
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync#include "ProgressImpl.h"
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync#include "VRDEServerImpl.h"
4651430e55b9df9726347e3e3968618e540fe729vboxsync#include "MediumAttachmentImpl.h"
4651430e55b9df9726347e3e3968618e540fe729vboxsync#include "PCIDeviceAttachmentImpl.h"
4651430e55b9df9726347e3e3968618e540fe729vboxsync#include "MediumLock.h"
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync#include "NetworkAdapterImpl.h"
4651430e55b9df9726347e3e3968618e540fe729vboxsync#include "AudioAdapterImpl.h"
4651430e55b9df9726347e3e3968618e540fe729vboxsync#include "SerialPortImpl.h"
4651430e55b9df9726347e3e3968618e540fe729vboxsync#include "ParallelPortImpl.h"
4651430e55b9df9726347e3e3968618e540fe729vboxsync#include "BIOSSettingsImpl.h"
4651430e55b9df9726347e3e3968618e540fe729vboxsync#include "StorageControllerImpl.h" // required for MachineImpl.h to compile on Windows
4651430e55b9df9726347e3e3968618e540fe729vboxsync#include "BandwidthControlImpl.h"
4651430e55b9df9726347e3e3968618e540fe729vboxsync#include "BandwidthGroupImpl.h"
4651430e55b9df9726347e3e3968618e540fe729vboxsync#include "VBox/settings.h"
4651430e55b9df9726347e3e3968618e540fe729vboxsync#ifdef VBOX_WITH_RESOURCE_USAGE_API
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync#include "Performance.h"
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync#include "PerformanceImpl.h"
4651430e55b9df9726347e3e3968618e540fe729vboxsync#endif /* VBOX_WITH_RESOURCE_USAGE_API */
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
5ff3fa0492332325f57e80636321619e2224027evboxsync// generated header
5ff3fa0492332325f57e80636321619e2224027evboxsync#include "SchemaDefs.h"
5ff3fa0492332325f57e80636321619e2224027evboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync#include "VBox/com/ErrorInfo.h"
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync#include <iprt/file.h>
4651430e55b9df9726347e3e3968618e540fe729vboxsync#include <iprt/thread.h>
4651430e55b9df9726347e3e3968618e540fe729vboxsync#include <iprt/time.h>
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
f32de6c198a491c28ace2b4c53f8d04a79fd6d69vboxsync#include <list>
0ce6ae9d6efed5d54222a13bbdabce9e688e4447vboxsync#include <vector>
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync// defines
e07acfb7f2dbb8bb40804024c79fd3139bdb3f24vboxsync////////////////////////////////////////////////////////////////////////////////
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync// helper declarations
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync////////////////////////////////////////////////////////////////////////////////
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsyncclass Progress;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsyncclass ProgressProxy;
c7a378ed2fbad681c0b674351d698ef20a368935vboxsyncclass Keyboard;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsyncclass Mouse;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsyncclass Display;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsyncclass MachineDebugger;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsyncclass USBController;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsyncclass Snapshot;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsyncclass SharedFolder;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsyncclass HostUSBDevice;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsyncclass StorageController;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
df4af4b66b5f26c3c06ae1592ec2e67afd82dd0cvboxsyncclass SessionMachine;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsyncnamespace settings
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync{
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync class MachineConfigFile;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync struct Snapshot;
83c86878d483df62ca8db465c671995984838338vboxsync struct Hardware;
30f7bd6bf198ae0489df375e5a17cb086acb30fbvboxsync struct Storage;
30f7bd6bf198ae0489df375e5a17cb086acb30fbvboxsync struct StorageController;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync struct MachineRegistryEntry;
30f7bd6bf198ae0489df375e5a17cb086acb30fbvboxsync}
30f7bd6bf198ae0489df375e5a17cb086acb30fbvboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync// Machine class
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync////////////////////////////////////////////////////////////////////////////////
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsyncclass ATL_NO_VTABLE Machine :
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync public VirtualBoxBase,
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync VBOX_SCRIPTABLE_IMPL(IMachine)
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync{
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync Q_OBJECT
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsyncpublic:
5a6bbb9c0d896e804f267c6919f52158a420b998vboxsync
5a6bbb9c0d896e804f267c6919f52158a420b998vboxsync enum StateDependency
5a6bbb9c0d896e804f267c6919f52158a420b998vboxsync {
5ff3fa0492332325f57e80636321619e2224027evboxsync AnyStateDep = 0,
5ff3fa0492332325f57e80636321619e2224027evboxsync MutableStateDep,
5ff3fa0492332325f57e80636321619e2224027evboxsync MutableOrSavedStateDep,
5ff3fa0492332325f57e80636321619e2224027evboxsync OfflineStateDep
5a6bbb9c0d896e804f267c6919f52158a420b998vboxsync };
5a6bbb9c0d896e804f267c6919f52158a420b998vboxsync
5a6bbb9c0d896e804f267c6919f52158a420b998vboxsync /**
83c86878d483df62ca8db465c671995984838338vboxsync * Internal machine data.
5a6bbb9c0d896e804f267c6919f52158a420b998vboxsync *
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 *
5a6bbb9c0d896e804f267c6919f52158a420b998vboxsync * @note |const| members are persistent during lifetime so can be
5a6bbb9c0d896e804f267c6919f52158a420b998vboxsync * accessed without locking.
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync *
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync * @note There is no need to lock anything inside init() or uninit()
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync * methods, because they are always serialized (see AutoCaller).
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync */
f32de6c198a491c28ace2b4c53f8d04a79fd6d69vboxsync struct Data
0ce6ae9d6efed5d54222a13bbdabce9e688e4447vboxsync {
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync /**
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync * Data structure to hold information about sessions opened for the
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync * given machine.
e07acfb7f2dbb8bb40804024c79fd3139bdb3f24vboxsync */
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync struct Session
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync {
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync /** Control of the direct session opened by lockMachine() */
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync ComPtr<IInternalSessionControl> mDirectControl;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync typedef std::list<ComPtr<IInternalSessionControl> > RemoteControlList;
c7a378ed2fbad681c0b674351d698ef20a368935vboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync /** list of controls of all opened remote sessions */
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync RemoteControlList mRemoteControls;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync /** launchVMProcess() and OnSessionEnd() progress indicator */
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync ComObjPtr<ProgressProxy> mProgress;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync /**
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 */
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync RTPROCESS mPID;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync /** Current session state */
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync SessionState_T mState;
f72cbd6a549c34992fa79cce84600fe2b92b3299vboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync /** Session type string (for indirect sessions) */
30f7bd6bf198ae0489df375e5a17cb086acb30fbvboxsync Bstr mType;
f72cbd6a549c34992fa79cce84600fe2b92b3299vboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync /** Session machine object */
4fd4258d68911eacb0b3d1f096b778d19da4e55avboxsync ComObjPtr<SessionMachine> mMachine;
4fd4258d68911eacb0b3d1f096b778d19da4e55avboxsync
4fd4258d68911eacb0b3d1f096b778d19da4e55avboxsync /** Medium object lock collection. */
f72cbd6a549c34992fa79cce84600fe2b92b3299vboxsync MediumLockListMap mLockedMedia;
4fd4258d68911eacb0b3d1f096b778d19da4e55avboxsync };
4fd4258d68911eacb0b3d1f096b778d19da4e55avboxsync
4fd4258d68911eacb0b3d1f096b778d19da4e55avboxsync Data();
f72cbd6a549c34992fa79cce84600fe2b92b3299vboxsync ~Data();
4fd4258d68911eacb0b3d1f096b778d19da4e55avboxsync
4fd4258d68911eacb0b3d1f096b778d19da4e55avboxsync const Guid mUuid;
4fd4258d68911eacb0b3d1f096b778d19da4e55avboxsync BOOL mRegistered;
f72cbd6a549c34992fa79cce84600fe2b92b3299vboxsync
49207a1552ff3752904e36b9269f08fe643ba871vboxsync Utf8Str m_strConfigFile;
49207a1552ff3752904e36b9269f08fe643ba871vboxsync Utf8Str m_strConfigFileFull;
49207a1552ff3752904e36b9269f08fe643ba871vboxsync
4fd4258d68911eacb0b3d1f096b778d19da4e55avboxsync // machine settings XML file
4fd4258d68911eacb0b3d1f096b778d19da4e55avboxsync settings::MachineConfigFile *pMachineConfigFile;
4fd4258d68911eacb0b3d1f096b778d19da4e55avboxsync uint32_t flModifications;
49207a1552ff3752904e36b9269f08fe643ba871vboxsync bool m_fAllowStateModification;
49207a1552ff3752904e36b9269f08fe643ba871vboxsync
49207a1552ff3752904e36b9269f08fe643ba871vboxsync BOOL mAccessible;
49207a1552ff3752904e36b9269f08fe643ba871vboxsync com::ErrorInfo mAccessError;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync MachineState_T mMachineState;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync RTTIMESPEC mLastStateChange;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
32529464ff2d4288a3c949ab8042126b0fa903devboxsync /* Note: These are guarded by VirtualBoxBase::stateLockHandle() */
32529464ff2d4288a3c949ab8042126b0fa903devboxsync uint32_t mMachineStateDeps;
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync RTSEMEVENTMULTI mMachineStateDepsSem;
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync uint32_t mMachineStateChangePending;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync
9c3f21ab6ba51a44403b662e1691293ab266e5e3vboxsync BOOL mCurrentStateModified;
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. */
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync BOOL mGuestPropertiesModified;
615105a2b89b7dd89a76504e6a9b8e099704c0d9vboxsync
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync Session mSession;
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync ComObjPtr<Snapshot> mFirstSnapshot;
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync ComObjPtr<Snapshot> mCurrentSnapshot;
df4af4b66b5f26c3c06ae1592ec2e67afd82dd0cvboxsync
df4af4b66b5f26c3c06ae1592ec2e67afd82dd0cvboxsync // list of files to delete in Delete(); this list is filled by Unregister()
d3361a18160600d3ba74c8dab5bbef532883826avboxsync std::list<Utf8Str> llFilesToDelete;
e6a899848410114df5f1db88a025d0843a98112cvboxsync };
cbf5a4260109bea05e1492f0b375b11a738cfb1dvboxsync
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync /**
561574402775590253d11504354bfe21d80e4858vboxsync * Saved state data.
561574402775590253d11504354bfe21d80e4858vboxsync *
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 *
6c5e2fff0e3fdfc7c3f3fb2e7b7ec8ebb2223cecvboxsync * The data variable is |mSSData|.
6c5e2fff0e3fdfc7c3f3fb2e7b7ec8ebb2223cecvboxsync */
6c5e2fff0e3fdfc7c3f3fb2e7b7ec8ebb2223cecvboxsync struct SSData
6c5e2fff0e3fdfc7c3f3fb2e7b7ec8ebb2223cecvboxsync {
6c5e2fff0e3fdfc7c3f3fb2e7b7ec8ebb2223cecvboxsync Utf8Str strStateFilePath;
561574402775590253d11504354bfe21d80e4858vboxsync };
6c5e2fff0e3fdfc7c3f3fb2e7b7ec8ebb2223cecvboxsync
615105a2b89b7dd89a76504e6a9b8e099704c0d9vboxsync /**
615105a2b89b7dd89a76504e6a9b8e099704c0d9vboxsync * User changeable machine data.
1f277e5b999f572b1ef1fe4ef593c603ea463be3vboxsync *
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 *
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync * SessionMachine instances can alter this data and discard changes.
0b6e534f55fcb5870df42b58ae354ad5fdbda66avboxsync *
615105a2b89b7dd89a76504e6a9b8e099704c0d9vboxsync * @note There is no need to lock anything inside init() or uninit()
f2fedb6cbb946e9dd6d418b1472373395e2ac34fvboxsync * methods, because they are always serialized (see AutoCaller).
615105a2b89b7dd89a76504e6a9b8e099704c0d9vboxsync */
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync struct UserData
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync {
05c28d9d4557bed6e320dfee1acca69408bc3c15vboxsync settings::MachineUserData s;
f6adf1a86574758258baa232172c965aed0d848dvboxsync };
/**
* Hardware data.
*
* This data is unique for a machine and for every machine snapshot.
* Stored using the util::Backupable template in the |mHWData| variable.
*
* SessionMachine instances can alter this data and discard changes.
*/
struct HWData
{
/**
* Data structure to hold information about a guest property.
*/
struct GuestProperty {
/** Property value */
Utf8Str strValue;
/** Property timestamp */
LONG64 mTimestamp;
/** Property flags */
ULONG mFlags;
};
HWData();
~HWData();
Bstr mHWVersion;
Guid mHardwareUUID; /**< If Null, use mData.mUuid. */
ULONG mMemorySize;
ULONG mMemoryBalloonSize;
BOOL mPageFusionEnabled;
GraphicsControllerType_T mGraphicsControllerType;
ULONG mVRAMSize;
ULONG mVideoCaptureWidth;
ULONG mVideoCaptureHeight;
ULONG mVideoCaptureRate;
ULONG mVideoCaptureFps;
Bstr mVideoCaptureFile;
BOOL mVideoCaptureEnabled;
ULONG mMonitorCount;
BOOL mHWVirtExEnabled;
BOOL mHWVirtExExclusive;
BOOL mHWVirtExNestedPagingEnabled;
BOOL mHWVirtExLargePagesEnabled;
BOOL mHWVirtExVPIDEnabled;
BOOL mHWVirtExUXEnabled;
BOOL mHWVirtExForceEnabled;
BOOL mAccelerate2DVideoEnabled;
BOOL mPAEEnabled;
settings::Hardware::LongModeType mLongMode;
BOOL mSyntheticCpu;
ULONG mCPUCount;
BOOL mCPUHotPlugEnabled;
ULONG mCpuExecutionCap;
BOOL mAccelerate3DEnabled;
BOOL mHPETEnabled;
BOOL mCPUAttached[SchemaDefs::MaxCPUCount];
settings::CpuIdLeaf mCpuIdStdLeafs[11];
settings::CpuIdLeaf mCpuIdExtLeafs[11];
DeviceType_T mBootOrder[SchemaDefs::MaxBootPosition];
typedef std::list<ComObjPtr<SharedFolder> > SharedFolderList;
SharedFolderList mSharedFolders;
ClipboardMode_T mClipboardMode;
DragAndDropMode_T mDragAndDropMode;
typedef std::map<Utf8Str, GuestProperty> GuestPropertyMap;
GuestPropertyMap mGuestProperties;
Utf8Str mGuestPropertyNotificationPatterns;
FirmwareType_T mFirmwareType;
KeyboardHIDType_T mKeyboardHIDType;
PointingHIDType_T mPointingHIDType;
ChipsetType_T mChipsetType;
BOOL mEmulatedUSBWebcamEnabled;
BOOL mEmulatedUSBCardReaderEnabled;
BOOL mIOCacheEnabled;
ULONG mIOCacheSize;
typedef std::list<ComObjPtr<PCIDeviceAttachment> > PCIDeviceAssignmentList;
PCIDeviceAssignmentList mPCIDeviceAssignments;
settings::Debugging mDebugging;
settings::Autostart mAutostart;
Utf8Str mDefaultFrontend;
};
/**
* Hard disk and other media data.
*
* The usage policy is the same as for HWData, but a separate structure
* is necessary because hard disk data requires different procedures when
* taking or deleting snapshots, etc.
*
* The data variable is |mMediaData|.
*/
struct MediaData
{
MediaData();
~MediaData();
typedef std::list<ComObjPtr<MediumAttachment> > AttachmentList;
AttachmentList mAttachments;
};
VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Machine, IMachine)
DECLARE_NOT_AGGREGATABLE(Machine)
DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_COM_MAP(Machine)
VBOX_DEFAULT_INTERFACE_ENTRIES(IMachine)
END_COM_MAP()
DECLARE_EMPTY_CTOR_DTOR(Machine)
HRESULT FinalConstruct();
void FinalRelease();
// public initializer/uninitializer for internal purposes only:
// initializer for creating a new, empty machine
HRESULT init(VirtualBox *aParent,
const Utf8Str &strConfigFile,
const Utf8Str &strName,
const StringsList &llGroups,
GuestOSType *aOsType,
const Guid &aId,
bool fForceOverwrite,
bool fDirectoryIncludesUUID);
// initializer for loading existing machine XML (either registered or not)
HRESULT initFromSettings(VirtualBox *aParent,
const Utf8Str &strConfigFile,
const Guid *aId);
// initializer for machine config in memory (OVF import)
HRESULT init(VirtualBox *aParent,
const Utf8Str &strName,
const settings::MachineConfigFile &config);
void uninit();
#ifdef VBOX_WITH_RESOURCE_USAGE_API
// Needed from VirtualBox, for the delayed metrics cleanup.
void unregisterMetrics(PerformanceCollector *aCollector, Machine *aMachine);
#endif /* VBOX_WITH_RESOURCE_USAGE_API */
protected:
HRESULT initImpl(VirtualBox *aParent,
const Utf8Str &strConfigFile);
HRESULT initDataAndChildObjects();
HRESULT registeredInit();
HRESULT tryCreateMachineConfigFile(bool fForceOverwrite);
void uninitDataAndChildObjects();
public:
// IMachine properties
STDMETHOD(COMGETTER(Parent))(IVirtualBox **aParent);
STDMETHOD(COMGETTER(Accessible))(BOOL *aAccessible);
STDMETHOD(COMGETTER(AccessError))(IVirtualBoxErrorInfo **aAccessError);
STDMETHOD(COMGETTER(Name))(BSTR *aName);
STDMETHOD(COMSETTER(Name))(IN_BSTR aName);
STDMETHOD(COMGETTER(Description))(BSTR *aDescription);
STDMETHOD(COMSETTER(Description))(IN_BSTR aDescription);
STDMETHOD(COMGETTER(Id))(BSTR *aId);
STDMETHOD(COMGETTER(Groups))(ComSafeArrayOut(BSTR, aGroups));
STDMETHOD(COMSETTER(Groups))(ComSafeArrayIn(IN_BSTR, aGroups));
STDMETHOD(COMGETTER(OSTypeId))(BSTR *aOSTypeId);
STDMETHOD(COMSETTER(OSTypeId))(IN_BSTR aOSTypeId);
STDMETHOD(COMGETTER(HardwareVersion))(BSTR *aVersion);
STDMETHOD(COMSETTER(HardwareVersion))(IN_BSTR aVersion);
STDMETHOD(COMGETTER(HardwareUUID))(BSTR *aUUID);
STDMETHOD(COMSETTER(HardwareUUID))(IN_BSTR aUUID);
STDMETHOD(COMGETTER(MemorySize))(ULONG *memorySize);
STDMETHOD(COMSETTER(MemorySize))(ULONG memorySize);
STDMETHOD(COMGETTER(CPUCount))(ULONG *cpuCount);
STDMETHOD(COMSETTER(CPUCount))(ULONG cpuCount);
STDMETHOD(COMGETTER(CPUHotPlugEnabled))(BOOL *enabled);
STDMETHOD(COMSETTER(CPUHotPlugEnabled))(BOOL enabled);
STDMETHOD(COMGETTER(CPUExecutionCap))(ULONG *aExecutionCap);
STDMETHOD(COMSETTER(CPUExecutionCap))(ULONG aExecutionCap);
STDMETHOD(COMGETTER(EmulatedUSBCardReaderEnabled))(BOOL *aEnabled);
STDMETHOD(COMSETTER(EmulatedUSBCardReaderEnabled))(BOOL aEnabled);
STDMETHOD(COMGETTER(EmulatedUSBWebcameraEnabled))(BOOL *aEnabled);
STDMETHOD(COMSETTER(EmulatedUSBWebcameraEnabled))(BOOL aEnabled);
STDMETHOD(COMGETTER(HPETEnabled))(BOOL *enabled);
STDMETHOD(COMSETTER(HPETEnabled))(BOOL enabled);
STDMETHOD(COMGETTER(MemoryBalloonSize))(ULONG *memoryBalloonSize);
STDMETHOD(COMSETTER(MemoryBalloonSize))(ULONG memoryBalloonSize);
STDMETHOD(COMGETTER(PageFusionEnabled))(BOOL *enabled);
STDMETHOD(COMSETTER(PageFusionEnabled))(BOOL enabled);
STDMETHOD(COMGETTER(GraphicsControllerType))(GraphicsControllerType_T *aGraphicsController);
STDMETHOD(COMSETTER(GraphicsControllerType))(GraphicsControllerType_T aGraphicsController);
STDMETHOD(COMGETTER(VRAMSize))(ULONG *memorySize);
STDMETHOD(COMSETTER(VRAMSize))(ULONG memorySize);
STDMETHOD(COMGETTER(Accelerate3DEnabled))(BOOL *aEnabled);
STDMETHOD(COMSETTER(Accelerate3DEnabled))(BOOL aEnabled);
STDMETHOD(COMGETTER(Accelerate2DVideoEnabled))(BOOL *aEnabled);
STDMETHOD(COMSETTER(Accelerate2DVideoEnabled))(BOOL aEnabled);
STDMETHOD(COMGETTER(MonitorCount))(ULONG *monitorCount);
STDMETHOD(COMSETTER(MonitorCount))(ULONG monitorCount);
STDMETHOD(COMGETTER(VideoCaptureEnabled))(BOOL *u8VideoRecEnabled);
STDMETHOD(COMSETTER(VideoCaptureEnabled))(BOOL u8VideoRecEnabled);
STDMETHOD(COMGETTER(VideoCaptureFile))(BSTR * ppChVideoRecFilename);
STDMETHOD(COMSETTER(VideoCaptureFile))(IN_BSTR pChVideoRecFilename);
STDMETHOD(COMGETTER(VideoCaptureWidth))(ULONG *aHorzRes);
STDMETHOD(COMSETTER(VideoCaptureWidth))(ULONG aorzRes);
STDMETHOD(COMGETTER(VideoCaptureHeight))(ULONG *aVertRes);
STDMETHOD(COMSETTER(VideoCaptureHeight))(ULONG aVertRes);
STDMETHOD(COMGETTER(VideoCaptureRate))(ULONG *aRate);
STDMETHOD(COMSETTER(VideoCaptureRate))(ULONG aRate);
STDMETHOD(COMGETTER(VideoCaptureFps))(ULONG *aFps);
STDMETHOD(COMSETTER(VideoCaptureFps))(ULONG aFps);
STDMETHOD(COMGETTER(BIOSSettings))(IBIOSSettings **biosSettings);
STDMETHOD(COMGETTER(SnapshotFolder))(BSTR *aSavedStateFolder);
STDMETHOD(COMSETTER(SnapshotFolder))(IN_BSTR aSavedStateFolder);
STDMETHOD(COMGETTER(MediumAttachments))(ComSafeArrayOut(IMediumAttachment *, aAttachments));
STDMETHOD(COMGETTER(VRDEServer))(IVRDEServer **vrdeServer);
STDMETHOD(COMGETTER(AudioAdapter))(IAudioAdapter **audioAdapter);
STDMETHOD(COMGETTER(USBController))(IUSBController * *aUSBController);
STDMETHOD(COMGETTER(SettingsFilePath))(BSTR *aFilePath);
STDMETHOD(COMGETTER(SettingsModified))(BOOL *aModified);
STDMETHOD(COMGETTER(SessionState))(SessionState_T *aSessionState);
STDMETHOD(COMGETTER(SessionType))(BSTR *aSessionType);
STDMETHOD(COMGETTER(SessionPID))(ULONG *aSessionPID);
STDMETHOD(COMGETTER(State))(MachineState_T *machineState);
STDMETHOD(COMGETTER(LastStateChange))(LONG64 *aLastStateChange);
STDMETHOD(COMGETTER(StateFilePath))(BSTR *aStateFilePath);
STDMETHOD(COMGETTER(LogFolder))(BSTR *aLogFolder);
STDMETHOD(COMGETTER(CurrentSnapshot))(ISnapshot **aCurrentSnapshot);
STDMETHOD(COMGETTER(SnapshotCount))(ULONG *aSnapshotCount);
STDMETHOD(COMGETTER(CurrentStateModified))(BOOL *aCurrentStateModified);
STDMETHOD(COMGETTER(SharedFolders))(ComSafeArrayOut(ISharedFolder *, aSharedFolders));
STDMETHOD(COMGETTER(ClipboardMode))(ClipboardMode_T *aClipboardMode);
STDMETHOD(COMSETTER(ClipboardMode))(ClipboardMode_T aClipboardMode);
STDMETHOD(COMGETTER(DragAndDropMode))(DragAndDropMode_T *aDragAndDropMode);
STDMETHOD(COMSETTER(DragAndDropMode))(DragAndDropMode_T aDragAndDropMode);
STDMETHOD(COMGETTER(GuestPropertyNotificationPatterns))(BSTR *aPattern);
STDMETHOD(COMSETTER(GuestPropertyNotificationPatterns))(IN_BSTR aPattern);
STDMETHOD(COMGETTER(StorageControllers))(ComSafeArrayOut(IStorageController *, aStorageControllers));
STDMETHOD(COMGETTER(TeleporterEnabled))(BOOL *aEnabled);
STDMETHOD(COMSETTER(TeleporterEnabled))(BOOL aEnabled);
STDMETHOD(COMGETTER(TeleporterPort))(ULONG *aPort);
STDMETHOD(COMSETTER(TeleporterPort))(ULONG aPort);
STDMETHOD(COMGETTER(TeleporterAddress))(BSTR *aAddress);
STDMETHOD(COMSETTER(TeleporterAddress))(IN_BSTR aAddress);
STDMETHOD(COMGETTER(TeleporterPassword))(BSTR *aPassword);
STDMETHOD(COMSETTER(TeleporterPassword))(IN_BSTR aPassword);
STDMETHOD(COMGETTER(FaultToleranceState))(FaultToleranceState_T *aEnabled);
STDMETHOD(COMSETTER(FaultToleranceState))(FaultToleranceState_T aEnabled);
STDMETHOD(COMGETTER(FaultToleranceAddress))(BSTR *aAddress);
STDMETHOD(COMSETTER(FaultToleranceAddress))(IN_BSTR aAddress);
STDMETHOD(COMGETTER(FaultTolerancePort))(ULONG *aPort);
STDMETHOD(COMSETTER(FaultTolerancePort))(ULONG aPort);
STDMETHOD(COMGETTER(FaultTolerancePassword))(BSTR *aPassword);
STDMETHOD(COMSETTER(FaultTolerancePassword))(IN_BSTR aPassword);
STDMETHOD(COMGETTER(FaultToleranceSyncInterval))(ULONG *aInterval);
STDMETHOD(COMSETTER(FaultToleranceSyncInterval))(ULONG aInterval);
STDMETHOD(COMGETTER(RTCUseUTC))(BOOL *aEnabled);
STDMETHOD(COMSETTER(RTCUseUTC))(BOOL aEnabled);
STDMETHOD(COMGETTER(FirmwareType))(FirmwareType_T *aFirmware);
STDMETHOD(COMSETTER(FirmwareType))(FirmwareType_T aFirmware);
STDMETHOD(COMGETTER(KeyboardHIDType))(KeyboardHIDType_T *aKeyboardHIDType);
STDMETHOD(COMSETTER(KeyboardHIDType))(KeyboardHIDType_T aKeyboardHIDType);
STDMETHOD(COMGETTER(PointingHIDType))(PointingHIDType_T *aPointingHIDType);
STDMETHOD(COMSETTER(PointingHIDType))(PointingHIDType_T aPointingHIDType);
STDMETHOD(COMGETTER(ChipsetType))(ChipsetType_T *aChipsetType);
STDMETHOD(COMSETTER(ChipsetType))(ChipsetType_T aChipsetType);
STDMETHOD(COMGETTER(IOCacheEnabled))(BOOL *aEnabled);
STDMETHOD(COMSETTER(IOCacheEnabled))(BOOL aEnabled);
STDMETHOD(COMGETTER(IOCacheSize))(ULONG *aIOCacheSize);
STDMETHOD(COMSETTER(IOCacheSize))(ULONG aIOCacheSize);
STDMETHOD(COMGETTER(PCIDeviceAssignments))(ComSafeArrayOut(IPCIDeviceAttachment *, aAssignments));
STDMETHOD(COMGETTER(BandwidthControl))(IBandwidthControl **aBandwidthControl);
STDMETHOD(COMGETTER(TracingEnabled))(BOOL *pfEnabled);
STDMETHOD(COMSETTER(TracingEnabled))(BOOL fEnabled);
STDMETHOD(COMGETTER(TracingConfig))(BSTR *pbstrConfig);
STDMETHOD(COMSETTER(TracingConfig))(IN_BSTR bstrConfig);
STDMETHOD(COMGETTER(AllowTracingToAccessVM))(BOOL *pfAllow);
STDMETHOD(COMSETTER(AllowTracingToAccessVM))(BOOL fAllow);
STDMETHOD(COMGETTER(AutostartEnabled))(BOOL *pfEnabled);
STDMETHOD(COMSETTER(AutostartEnabled))(BOOL fEnabled);
STDMETHOD(COMGETTER(AutostartDelay))(ULONG *puDelay);
STDMETHOD(COMSETTER(AutostartDelay))(ULONG uDelay);
STDMETHOD(COMGETTER(AutostopType))(AutostopType_T *penmAutostopType);
STDMETHOD(COMSETTER(AutostopType))(AutostopType_T enmAutostopType);
STDMETHOD(COMGETTER(DefaultFrontend))(BSTR *aDefaultFrontend);
STDMETHOD(COMSETTER(DefaultFrontend))(IN_BSTR aDefaultFrontend);
// IMachine methods
STDMETHOD(LockMachine)(ISession *aSession, LockType_T lockType);
STDMETHOD(LaunchVMProcess)(ISession *aSession, IN_BSTR aType, IN_BSTR aEnvironment, IProgress **aProgress);
STDMETHOD(SetBootOrder)(ULONG aPosition, DeviceType_T aDevice);
STDMETHOD(GetBootOrder)(ULONG aPosition, DeviceType_T *aDevice);
STDMETHOD(AttachDeviceWithoutMedium)(IN_BSTR aControllerName, LONG aControllerPort,
LONG aDevice, DeviceType_T aType);
STDMETHOD(AttachDevice)(IN_BSTR aControllerName, LONG aControllerPort,
LONG aDevice, DeviceType_T aType, IMedium *aMedium);
STDMETHOD(DetachDevice)(IN_BSTR aControllerName, LONG aControllerPort, LONG aDevice);
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(SetNoBandwidthGroupForDevice)(IN_BSTR aControllerName, LONG aControllerPort,
LONG aDevice);
STDMETHOD(SetBandwidthGroupForDevice)(IN_BSTR aControllerName, LONG aControllerPort,
LONG aDevice, IBandwidthGroup *aBandwidthGroup);
STDMETHOD(MountMedium)(IN_BSTR aControllerName, LONG aControllerPort,
LONG aDevice, IMedium *aMedium, BOOL aForce);
STDMETHOD(UnmountMedium)(IN_BSTR aControllerName, LONG aControllerPort,
LONG aDevice, BOOL aForce);
STDMETHOD(GetMedium)(IN_BSTR aControllerName, LONG aControllerPort, LONG aDevice,
IMedium **aMedium);
STDMETHOD(GetSerialPort)(ULONG slot, ISerialPort **port);
STDMETHOD(GetParallelPort)(ULONG slot, IParallelPort **port);
STDMETHOD(GetNetworkAdapter)(ULONG slot, INetworkAdapter **adapter);
STDMETHOD(GetExtraDataKeys)(ComSafeArrayOut(BSTR, aKeys));
STDMETHOD(GetExtraData)(IN_BSTR aKey, BSTR *aValue);
STDMETHOD(SetExtraData)(IN_BSTR aKey, IN_BSTR aValue);
STDMETHOD(GetCPUProperty)(CPUPropertyType_T property, BOOL *aVal);
STDMETHOD(SetCPUProperty)(CPUPropertyType_T property, BOOL aVal);
STDMETHOD(GetCPUIDLeaf)(ULONG id, ULONG *aValEax, ULONG *aValEbx, ULONG *aValEcx, ULONG *aValEdx);
STDMETHOD(SetCPUIDLeaf)(ULONG id, ULONG aValEax, ULONG aValEbx, ULONG aValEcx, ULONG aValEdx);
STDMETHOD(RemoveCPUIDLeaf)(ULONG id);
STDMETHOD(RemoveAllCPUIDLeaves)();
STDMETHOD(GetHWVirtExProperty)(HWVirtExPropertyType_T property, BOOL *aVal);
STDMETHOD(SetHWVirtExProperty)(HWVirtExPropertyType_T property, BOOL aVal);
STDMETHOD(SaveSettings)();
STDMETHOD(DiscardSettings)();
STDMETHOD(Unregister)(CleanupMode_T cleanupMode, ComSafeArrayOut(IMedium*, aMedia));
STDMETHOD(DeleteConfig)(ComSafeArrayIn(IMedium*, aMedia), IProgress **aProgress);
STDMETHOD(ExportTo)(IAppliance *aAppliance, IN_BSTR location, IVirtualSystemDescription **aDescription);
STDMETHOD(FindSnapshot)(IN_BSTR aNameOrId, ISnapshot **aSnapshot);
STDMETHOD(CreateSharedFolder)(IN_BSTR aName, IN_BSTR aHostPath, BOOL aWritable, BOOL aAutoMount);
STDMETHOD(RemoveSharedFolder)(IN_BSTR aName);
STDMETHOD(CanShowConsoleWindow)(BOOL *aCanShow);
STDMETHOD(ShowConsoleWindow)(LONG64 *aWinId);
STDMETHOD(GetGuestProperty)(IN_BSTR aName, BSTR *aValue, LONG64 *aTimestamp, BSTR *aFlags);
STDMETHOD(GetGuestPropertyValue)(IN_BSTR aName, BSTR *aValue);
STDMETHOD(GetGuestPropertyTimestamp)(IN_BSTR aName, LONG64 *aTimestamp);
STDMETHOD(SetGuestProperty)(IN_BSTR aName, IN_BSTR aValue, IN_BSTR aFlags);
STDMETHOD(SetGuestPropertyValue)(IN_BSTR aName, IN_BSTR aValue);
STDMETHOD(DeleteGuestProperty)(IN_BSTR aName);
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(RemoveStorageController(IN_BSTR aName));
STDMETHOD(GetStorageControllerByName(IN_BSTR aName, IStorageController **storageController));
STDMETHOD(GetStorageControllerByInstance(ULONG aInstance, IStorageController **storageController));
STDMETHOD(SetStorageControllerBootable)(IN_BSTR aName, BOOL fBootable);
STDMETHOD(QuerySavedGuestScreenInfo)(ULONG uScreenId, ULONG *puOriginX, ULONG *puOriginY, ULONG *puWidth, ULONG *puHeight, BOOL *pfEnabled);
STDMETHOD(QuerySavedThumbnailSize)(ULONG aScreenId, ULONG *aSize, ULONG *aWidth, ULONG *aHeight);
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(HotPlugCPU(ULONG aCpu));
STDMETHOD(HotUnplugCPU(ULONG aCpu));
STDMETHOD(GetCPUStatus(ULONG aCpu, BOOL *aCpuAttached));
STDMETHOD(QueryLogFilename(ULONG aIdx, BSTR *aName));
STDMETHOD(ReadLog(ULONG aIdx, LONG64 aOffset, LONG64 aSize, ComSafeArrayOut(BYTE, aData)));
STDMETHOD(AttachHostPCIDevice(LONG hostAddress, LONG desiredGuestAddress, BOOL tryToUnbind));
STDMETHOD(DetachHostPCIDevice(LONG hostAddress));
STDMETHOD(CloneTo(IMachine *pTarget, CloneMode_T mode, ComSafeArrayIn(CloneOptions_T, options), IProgress **pProgress));
// public methods only for internal purposes
virtual bool isSnapshotMachine() const
{
return false;
}
virtual bool isSessionMachine() const
{
return false;
}
/**
* Override of the default locking class to be used for validating lock
* order with the standard member lock handle.
*/
virtual VBoxLockingClass getLockingClass() const
{
return LOCKCLASS_MACHINEOBJECT;
}
/// @todo (dmik) add lock and make non-inlined after revising classes
// that use it. Note: they should enter Machine lock to keep the returned
// information valid!
bool isRegistered() { return !!mData->mRegistered; }
// unsafe inline public methods for internal purposes only (ensure there is
// a caller and a read lock before calling them!)
/**
* Returns the VirtualBox object this machine belongs to.
*
* @note This method doesn't check this object's readiness. Intended to be
* used by ready Machine children (whose readiness is bound to the parent's
* one) or after doing addCaller() manually.
*/
VirtualBox* getVirtualBox() const { return mParent; }
/**
* Checks if this machine is accessible, without attempting to load the
* config file.
*
* @note This method doesn't check this object's readiness. Intended to be
* used by ready Machine children (whose readiness is bound to the parent's
* one) or after doing addCaller() manually.
*/
bool isAccessible() const { return !!mData->mAccessible; }
/**
* Returns this machine ID.
*
* @note This method doesn't check this object's readiness. Intended to be
* used by ready Machine children (whose readiness is bound to the parent's
* one) or after adding a caller manually.
*/
const Guid& getId() const { return mData->mUuid; }
/**
* Returns the snapshot ID this machine represents or an empty UUID if this
* instance is not SnapshotMachine.
*
* @note This method doesn't check this object's readiness. Intended to be
* used by ready Machine children (whose readiness is bound to the parent's
* one) or after adding a caller manually.
*/
inline const Guid& getSnapshotId() const;
/**
* Returns this machine's full settings file path.
*
* @note This method doesn't lock this object or check its readiness.
* Intended to be used only after doing addCaller() manually and locking it
* for reading.
*/
const Utf8Str& getSettingsFileFull() const { return mData->m_strConfigFileFull; }
/**
* Returns this machine name.
*
* @note This method doesn't lock this object or check its readiness.
* Intended to be used only after doing addCaller() manually and locking it
* for reading.
*/
const Utf8Str& getName() const { return mUserData->s.strName; }
enum
{
IsModified_MachineData = 0x0001,
IsModified_Storage = 0x0002,
IsModified_NetworkAdapters = 0x0008,
IsModified_SerialPorts = 0x0010,
IsModified_ParallelPorts = 0x0020,
IsModified_VRDEServer = 0x0040,
IsModified_AudioAdapter = 0x0080,
IsModified_USB = 0x0100,
IsModified_BIOS = 0x0200,
IsModified_SharedFolders = 0x0400,
IsModified_Snapshots = 0x0800,
IsModified_BandwidthControl = 0x1000
};
/**
* Returns various information about this machine.
*
* @note This method doesn't lock this object or check its readiness.
* Intended to be used only after doing addCaller() manually and locking it
* for reading.
*/
ChipsetType_T getChipsetType() const { return mHWData->mChipsetType; }
void setModified(uint32_t fl, bool fAllowStateModification = true);
void setModifiedLock(uint32_t fl, bool fAllowStateModification = true);
bool isStateModificationAllowed() const { return mData->m_fAllowStateModification; }
void allowStateModification() { mData->m_fAllowStateModification = true; }
void disallowStateModification() { mData->m_fAllowStateModification = false; }
const StringsList &getGroups() const { return mUserData->s.llGroups; }
// callback handlers
virtual HRESULT onNetworkAdapterChange(INetworkAdapter * /* networkAdapter */, BOOL /* changeAdapter */) { return S_OK; }
virtual HRESULT onNATRedirectRuleChange(ULONG /* slot */, BOOL /* fRemove */ , IN_BSTR /* name */,
NATProtocol_T /* protocol */, IN_BSTR /* host ip */, LONG /* host port */, IN_BSTR /* guest port */, LONG /* guest port */ ) { return S_OK; }
virtual HRESULT onSerialPortChange(ISerialPort * /* serialPort */) { return S_OK; }
virtual HRESULT onParallelPortChange(IParallelPort * /* parallelPort */) { return S_OK; }
virtual HRESULT onVRDEServerChange(BOOL /* aRestart */) { return S_OK; }
virtual HRESULT onUSBControllerChange() { return S_OK; }
virtual HRESULT onStorageControllerChange() { return S_OK; }
virtual HRESULT onCPUChange(ULONG /* aCPU */, BOOL /* aRemove */) { return S_OK; }
virtual HRESULT onCPUExecutionCapChange(ULONG /* aExecutionCap */) { return S_OK; }
virtual HRESULT onMediumChange(IMediumAttachment * /* mediumAttachment */, BOOL /* force */) { return S_OK; }
virtual HRESULT onSharedFolderChange() { return S_OK; }
virtual HRESULT onClipboardModeChange(ClipboardMode_T /* aClipboardMode */) { return S_OK; }
virtual HRESULT onDragAndDropModeChange(DragAndDropMode_T /* aDragAndDropMode */) { return S_OK; }
virtual HRESULT onBandwidthGroupChange(IBandwidthGroup * /* aBandwidthGroup */) { return S_OK; }
virtual HRESULT onStorageDeviceChange(IMediumAttachment * /* mediumAttachment */, BOOL /* remove */, BOOL /* silent */) { return S_OK; }
HRESULT saveRegistryEntry(settings::MachineRegistryEntry &data);
int calculateFullPath(const Utf8Str &strPath, Utf8Str &aResult);
void copyPathRelativeToMachine(const Utf8Str &strSource, Utf8Str &strTarget);
void getLogFolder(Utf8Str &aLogFolder);
Utf8Str queryLogFilename(ULONG idx);
void composeSavedStateFilename(Utf8Str &strStateFilePath);
HRESULT launchVMProcess(IInternalSessionControl *aControl,
const Utf8Str &strType,
const Utf8Str &strEnvironment,
ProgressProxy *aProgress);
HRESULT getDirectControl(ComPtr<IInternalSessionControl> *directControl)
{
HRESULT rc;
*directControl = mData->mSession.mDirectControl;
if (!*directControl)
rc = E_ACCESSDENIED;
else
rc = S_OK;
return rc;
}
#if defined(RT_OS_WINDOWS)
bool isSessionOpen(ComObjPtr<SessionMachine> &aMachine,
ComPtr<IInternalSessionControl> *aControl = NULL,
HANDLE *aIPCSem = NULL, bool aAllowClosing = false);
bool isSessionSpawning(RTPROCESS *aPID = NULL);
bool isSessionOpenOrClosing(ComObjPtr<SessionMachine> &aMachine,
ComPtr<IInternalSessionControl> *aControl = NULL,
HANDLE *aIPCSem = NULL)
{ return isSessionOpen(aMachine, aControl, aIPCSem, true /* aAllowClosing */); }
#elif defined(RT_OS_OS2)
bool isSessionOpen(ComObjPtr<SessionMachine> &aMachine,
ComPtr<IInternalSessionControl> *aControl = NULL,
HMTX *aIPCSem = NULL, bool aAllowClosing = false);
bool isSessionSpawning(RTPROCESS *aPID = NULL);
bool isSessionOpenOrClosing(ComObjPtr<SessionMachine> &aMachine,
ComPtr<IInternalSessionControl> *aControl = NULL,
HMTX *aIPCSem = NULL)
{ return isSessionOpen(aMachine, aControl, aIPCSem, true /* aAllowClosing */); }
#else
bool isSessionOpen(ComObjPtr<SessionMachine> &aMachine,
ComPtr<IInternalSessionControl> *aControl = NULL,
bool aAllowClosing = false);
bool isSessionSpawning();
bool isSessionOpenOrClosing(ComObjPtr<SessionMachine> &aMachine,
ComPtr<IInternalSessionControl> *aControl = NULL)
{ return isSessionOpen(aMachine, aControl, true /* aAllowClosing */); }
#endif
bool checkForSpawnFailure();
HRESULT prepareRegister();
HRESULT getSharedFolder(CBSTR aName,
ComObjPtr<SharedFolder> &aSharedFolder,
bool aSetError = false)
{
AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
return findSharedFolder(aName, aSharedFolder, aSetError);
}
HRESULT addStateDependency(StateDependency aDepType = AnyStateDep,
MachineState_T *aState = NULL,
BOOL *aRegistered = NULL);
void releaseStateDependency();
HRESULT getBandwidthGroup(const Utf8Str &strBandwidthGroup,
ComObjPtr<BandwidthGroup> &pBandwidthGroup,
bool fSetError = false)
{
return mBandwidthControl->getBandwidthGroupByName(strBandwidthGroup,
pBandwidthGroup,
fSetError);
}
protected:
HRESULT checkStateDependency(StateDependency aDepType);
Machine *getMachine();
void ensureNoStateDependencies();
virtual HRESULT setMachineState(MachineState_T aMachineState);
HRESULT findSharedFolder(const Utf8Str &aName,
ComObjPtr<SharedFolder> &aSharedFolder,
bool aSetError = false);
HRESULT loadSettings(bool aRegistered);
HRESULT loadMachineDataFromSettings(const settings::MachineConfigFile &config,
const Guid *puuidRegistry);
HRESULT loadSnapshot(const settings::Snapshot &data,
const Guid &aCurSnapshotId,
Snapshot *aParentSnapshot);
HRESULT loadHardware(const settings::Hardware &data, const settings::Debugging *pDbg,
const settings::Autostart *pAutostart);
HRESULT loadDebugging(const settings::Debugging *pDbg);
HRESULT loadAutostart(const settings::Autostart *pAutostart);
HRESULT loadStorageControllers(const settings::Storage &data,
const Guid *puuidRegistry,
const Guid *puuidSnapshot);
HRESULT loadStorageDevices(StorageController *aStorageController,
const settings::StorageController &data,
const Guid *puuidRegistry,
const Guid *puuidSnapshot);
HRESULT findSnapshotById(const Guid &aId,
ComObjPtr<Snapshot> &aSnapshot,
bool aSetError = false);
HRESULT findSnapshotByName(const Utf8Str &strName,
ComObjPtr<Snapshot> &aSnapshot,
bool aSetError = false);
HRESULT getStorageControllerByName(const Utf8Str &aName,
ComObjPtr<StorageController> &aStorageController,
bool aSetError = false);
HRESULT getMediumAttachmentsOfController(CBSTR aName,
MediaData::AttachmentList &aAttachments);
enum
{
/* flags for #saveSettings() */
SaveS_ResetCurStateModified = 0x01,
SaveS_InformCallbacksAnyway = 0x02,
SaveS_Force = 0x04,
/* flags for #saveStateSettings() */
SaveSTS_CurStateModified = 0x20,
SaveSTS_StateFilePath = 0x40,
SaveSTS_StateTimeStamp = 0x80
};
HRESULT prepareSaveSettings(bool *pfNeedsGlobalSaveSettings);
HRESULT saveSettings(bool *pfNeedsGlobalSaveSettings, int aFlags = 0);
void copyMachineDataToSettings(settings::MachineConfigFile &config);
HRESULT saveAllSnapshots(settings::MachineConfigFile &config);
HRESULT saveHardware(settings::Hardware &data, settings::Debugging *pDbg,
settings::Autostart *pAutostart);
HRESULT saveStorageControllers(settings::Storage &data);
HRESULT saveStorageDevices(ComObjPtr<StorageController> aStorageController,
settings::StorageController &data);
HRESULT saveStateSettings(int aFlags);
void addMediumToRegistry(ComObjPtr<Medium> &pMedium);
HRESULT createImplicitDiffs(IProgress *aProgress,
ULONG aWeight,
bool aOnline);
HRESULT deleteImplicitDiffs(bool aOnline);
MediumAttachment* findAttachment(const MediaData::AttachmentList &ll,
IN_BSTR aControllerName,
LONG aControllerPort,
LONG aDevice);
MediumAttachment* findAttachment(const MediaData::AttachmentList &ll,
ComObjPtr<Medium> pMedium);
MediumAttachment* findAttachment(const MediaData::AttachmentList &ll,
Guid &id);
HRESULT detachDevice(MediumAttachment *pAttach,
AutoWriteLock &writeLock,
Snapshot *pSnapshot);
HRESULT detachAllMedia(AutoWriteLock &writeLock,
Snapshot *pSnapshot,
CleanupMode_T cleanupMode,
MediaList &llMedia);
void commitMedia(bool aOnline = false);
void rollbackMedia();
bool isInOwnDir(Utf8Str *aSettingsDir = NULL) const;
void rollback(bool aNotify);
void commit();
void copyFrom(Machine *aThat);
bool isControllerHotplugCapable(StorageControllerType_T enmCtrlType);
struct DeleteTask;
static DECLCALLBACK(int) deleteThread(RTTHREAD Thread, void *pvUser);
HRESULT deleteTaskWorker(DeleteTask &task);
Utf8Str getExtraData(const Utf8Str &strKey);
#ifdef VBOX_WITH_GUEST_PROPS
HRESULT getGuestPropertyFromService(IN_BSTR aName, BSTR *aValue,
LONG64 *aTimestamp, BSTR *aFlags) const;
HRESULT getGuestPropertyFromVM(IN_BSTR aName, BSTR *aValue,
LONG64 *aTimestamp, BSTR *aFlags) const;
HRESULT setGuestPropertyToService(IN_BSTR aName, IN_BSTR aValue,
IN_BSTR aFlags);
HRESULT setGuestPropertyToVM(IN_BSTR aName, IN_BSTR aValue,
IN_BSTR aFlags);
HRESULT enumerateGuestPropertiesInService
(IN_BSTR aPatterns, ComSafeArrayOut(BSTR, aNames),
ComSafeArrayOut(BSTR, aValues),
ComSafeArrayOut(LONG64, aTimestamps),
ComSafeArrayOut(BSTR, aFlags));
HRESULT enumerateGuestPropertiesOnVM
(IN_BSTR aPatterns, ComSafeArrayOut(BSTR, aNames),
ComSafeArrayOut(BSTR, aValues),
ComSafeArrayOut(LONG64, aTimestamps),
ComSafeArrayOut(BSTR, aFlags));
#endif /* VBOX_WITH_GUEST_PROPS */
#ifdef VBOX_WITH_RESOURCE_USAGE_API
void getDiskList(MediaList &list);
void registerMetrics(PerformanceCollector *aCollector, Machine *aMachine, RTPROCESS pid);
pm::CollectorGuest *mCollectorGuest;
#endif /* VBOX_WITH_RESOURCE_USAGE_API */
Machine * const mPeer;
VirtualBox * const mParent;
Shareable<Data> mData;
Shareable<SSData> mSSData;
Backupable<UserData> mUserData;
Backupable<HWData> mHWData;
Backupable<MediaData> mMediaData;
// the following fields need special backup/rollback/commit handling,
// so they cannot be a part of HWData
const ComObjPtr<VRDEServer> mVRDEServer;
const ComObjPtr<SerialPort> mSerialPorts[SchemaDefs::SerialPortCount];
const ComObjPtr<ParallelPort> mParallelPorts[SchemaDefs::ParallelPortCount];
const ComObjPtr<AudioAdapter> mAudioAdapter;
const ComObjPtr<USBController> mUSBController;
const ComObjPtr<BIOSSettings> mBIOSSettings;
typedef std::vector<ComObjPtr<NetworkAdapter> > NetworkAdapterVector;
NetworkAdapterVector mNetworkAdapters;
const ComObjPtr<BandwidthControl> mBandwidthControl;
typedef std::list<ComObjPtr<StorageController> > StorageControllerList;
Backupable<StorageControllerList> mStorageControllers;
uint64_t uRegistryNeedsSaving;
friend class SessionMachine;
friend class SnapshotMachine;
friend class Appliance;
friend class VirtualBox;
friend class MachineCloneVM;
};
// SessionMachine class
////////////////////////////////////////////////////////////////////////////////
/**
* @note Notes on locking objects of this class:
* SessionMachine shares some data with the primary Machine instance (pointed
* to by the |mPeer| member). In order to provide data consistency it also
* shares its lock handle. This means that whenever you lock a SessionMachine
* instance using Auto[Reader]Lock or AutoMultiLock, the corresponding Machine
* instance is also locked in the same lock mode. Keep it in mind.
*/
class ATL_NO_VTABLE SessionMachine :
public Machine,
VBOX_SCRIPTABLE_IMPL(IInternalMachineControl)
{
public:
VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(SessionMachine, IMachine)
DECLARE_NOT_AGGREGATABLE(SessionMachine)
DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_COM_MAP(SessionMachine)
VBOX_DEFAULT_INTERFACE_ENTRIES(IMachine)
COM_INTERFACE_ENTRY(IInternalMachineControl)
END_COM_MAP()
DECLARE_EMPTY_CTOR_DTOR(SessionMachine)
HRESULT FinalConstruct();
void FinalRelease();
// public initializer/uninitializer for internal purposes only
HRESULT init(Machine *aMachine);
void uninit() { uninit(Uninit::Unexpected); }
// util::Lockable interface
RWLockHandle *lockHandle() const;
// IInternalMachineControl methods
STDMETHOD(SetRemoveSavedStateFile)(BOOL aRemove);
STDMETHOD(UpdateState)(MachineState_T machineState);
STDMETHOD(GetIPCId)(BSTR *id);
STDMETHOD(BeginPowerUp)(IProgress *aProgress);
STDMETHOD(EndPowerUp)(LONG iResult);
STDMETHOD(BeginPoweringDown)(IProgress **aProgress);
STDMETHOD(EndPoweringDown)(LONG aResult, IN_BSTR aErrMsg);
STDMETHOD(RunUSBDeviceFilters)(IUSBDevice *aUSBDevice, BOOL *aMatched, ULONG *aMaskedIfs);
STDMETHOD(CaptureUSBDevice)(IN_BSTR aId);
STDMETHOD(DetachUSBDevice)(IN_BSTR aId, BOOL aDone);
STDMETHOD(AutoCaptureUSBDevices)();
STDMETHOD(DetachAllUSBDevices)(BOOL aDone);
STDMETHOD(OnSessionEnd)(ISession *aSession, IProgress **aProgress);
STDMETHOD(BeginSavingState)(IProgress **aProgress, BSTR *aStateFilePath);
STDMETHOD(EndSavingState)(LONG aResult, IN_BSTR aErrMsg);
STDMETHOD(AdoptSavedState)(IN_BSTR aSavedStateFile);
STDMETHOD(BeginTakingSnapshot)(IConsole *aInitiator,
IN_BSTR aName,
IN_BSTR aDescription,
IProgress *aConsoleProgress,
BOOL fTakingSnapshotOnline,
BSTR *aStateFilePath);
STDMETHOD(EndTakingSnapshot)(BOOL aSuccess);
STDMETHOD(DeleteSnapshot)(IConsole *aInitiator, IN_BSTR aStartId,
IN_BSTR aEndID, BOOL fDeleteAllChildren,
MachineState_T *aMachineState, IProgress **aProgress);
STDMETHOD(FinishOnlineMergeMedium)(IMediumAttachment *aMediumAttachment,
IMedium *aSource, IMedium *aTarget,
BOOL fMergeForward,
IMedium *pParentForTarget,
ComSafeArrayIn(IMedium *, aChildrenToReparent));
STDMETHOD(RestoreSnapshot)(IConsole *aInitiator,
ISnapshot *aSnapshot,
MachineState_T *aMachineState,
IProgress **aProgress);
STDMETHOD(PullGuestProperties)(ComSafeArrayOut(BSTR, aNames), ComSafeArrayOut(BSTR, aValues),
ComSafeArrayOut(LONG64, aTimestamps), ComSafeArrayOut(BSTR, aFlags));
STDMETHOD(PushGuestProperty)(IN_BSTR aName, IN_BSTR aValue,
LONG64 aTimestamp, IN_BSTR aFlags);
STDMETHOD(LockMedia)();
STDMETHOD(UnlockMedia)();
STDMETHOD(EjectMedium)(IMediumAttachment *aAttachment,
IMediumAttachment **aNewAttachment);
STDMETHOD(ReportVmStatistics)(ULONG aValidStats, ULONG aCpuUser,
ULONG aCpuKernel, ULONG aCpuIdle,
ULONG aMemTotal, ULONG aMemFree,
ULONG aMemBalloon, ULONG aMemShared,
ULONG aMemCache, ULONG aPageTotal,
ULONG aAllocVMM, ULONG aFreeVMM,
ULONG aBalloonedVMM, ULONG aSharedVMM,
ULONG aVmNetRx, ULONG aVmNetTx);
// public methods only for internal purposes
virtual bool isSessionMachine() const
{
return true;
}
bool checkForDeath();
HRESULT onNetworkAdapterChange(INetworkAdapter *networkAdapter, BOOL changeAdapter);
HRESULT onNATRedirectRuleChange(ULONG ulSlot, BOOL aNatRuleRemove, IN_BSTR aRuleName,
NATProtocol_T aProto, IN_BSTR aHostIp, LONG aHostPort, IN_BSTR aGuestIp, LONG aGuestPort);
HRESULT onStorageControllerChange();
HRESULT onMediumChange(IMediumAttachment *aMediumAttachment, BOOL aForce);
HRESULT onSerialPortChange(ISerialPort *serialPort);
HRESULT onParallelPortChange(IParallelPort *parallelPort);
HRESULT onCPUChange(ULONG aCPU, BOOL aRemove);
HRESULT onCPUExecutionCapChange(ULONG aCpuExecutionCap);
HRESULT onVRDEServerChange(BOOL aRestart);
HRESULT onUSBControllerChange();
HRESULT onUSBDeviceAttach(IUSBDevice *aDevice,
IVirtualBoxErrorInfo *aError,
ULONG aMaskedIfs);
HRESULT onUSBDeviceDetach(IN_BSTR aId,
IVirtualBoxErrorInfo *aError);
HRESULT onSharedFolderChange();
HRESULT onClipboardModeChange(ClipboardMode_T aClipboardMode);
HRESULT onDragAndDropModeChange(DragAndDropMode_T aDragAndDropMode);
HRESULT onBandwidthGroupChange(IBandwidthGroup *aBandwidthGroup);
HRESULT onStorageDeviceChange(IMediumAttachment *aMediumAttachment, BOOL aRemove, BOOL aSilent);
bool hasMatchingUSBFilter(const ComObjPtr<HostUSBDevice> &aDevice, ULONG *aMaskedIfs);
HRESULT lockMedia();
void unlockMedia();
private:
struct ConsoleTaskData
{
ConsoleTaskData()
: mLastState(MachineState_Null)
{ }
MachineState_T mLastState;
ComObjPtr<Progress> mProgress;
// used when taking snapshot
ComObjPtr<Snapshot> mSnapshot;
// used when saving state (either as part of a snapshot or separate)
Utf8Str strStateFilePath;
};
struct Uninit
{
enum Reason { Unexpected, Abnormal, Normal };
};
struct SnapshotTask;
struct DeleteSnapshotTask;
struct RestoreSnapshotTask;
friend struct DeleteSnapshotTask;
friend struct RestoreSnapshotTask;
void uninit(Uninit::Reason aReason);
HRESULT endSavingState(HRESULT aRC, const Utf8Str &aErrMsg);
void releaseSavedStateFile(const Utf8Str &strSavedStateFile, Snapshot *pSnapshotToIgnore);
void deleteSnapshotHandler(DeleteSnapshotTask &aTask);
void restoreSnapshotHandler(RestoreSnapshotTask &aTask);
HRESULT prepareDeleteSnapshotMedium(const ComObjPtr<Medium> &aHD,
const Guid &machineId,
const Guid &snapshotId,
bool fOnlineMergePossible,
MediumLockList *aVMMALockList,
ComObjPtr<Medium> &aSource,
ComObjPtr<Medium> &aTarget,
bool &fMergeForward,
ComObjPtr<Medium> &pParentForTarget,
MediaList &aChildrenToReparent,
bool &fNeedOnlineMerge,
MediumLockList * &aMediumLockList);
void cancelDeleteSnapshotMedium(const ComObjPtr<Medium> &aHD,
const ComObjPtr<Medium> &aSource,
const MediaList &aChildrenToReparent,
bool fNeedsOnlineMerge,
MediumLockList *aMediumLockList,
const Guid &aMediumId,
const Guid &aSnapshotId);
HRESULT onlineMergeMedium(const ComObjPtr<MediumAttachment> &aMediumAttachment,
const ComObjPtr<Medium> &aSource,
const ComObjPtr<Medium> &aTarget,
bool fMergeForward,
const ComObjPtr<Medium> &pParentForTarget,
const MediaList &aChildrenToReparent,
MediumLockList *aMediumLockList,
ComObjPtr<Progress> &aProgress,
bool *pfNeedsMachineSaveSettings);
HRESULT setMachineState(MachineState_T aMachineState);
HRESULT updateMachineStateOnClient();
HRESULT mRemoveSavedState;
ConsoleTaskData mConsoleTaskData;
/** interprocess semaphore handle for this machine */
#if defined(RT_OS_WINDOWS)
HANDLE mIPCSem;
Bstr mIPCSemName;
friend bool Machine::isSessionOpen(ComObjPtr<SessionMachine> &aMachine,
ComPtr<IInternalSessionControl> *aControl,
HANDLE *aIPCSem, bool aAllowClosing);
#elif defined(RT_OS_OS2)
HMTX mIPCSem;
Bstr mIPCSemName;
friend bool Machine::isSessionOpen(ComObjPtr<SessionMachine> &aMachine,
ComPtr<IInternalSessionControl> *aControl,
HMTX *aIPCSem, bool aAllowClosing);
#elif defined(VBOX_WITH_SYS_V_IPC_SESSION_WATCHER)
int mIPCSem;
# ifdef VBOX_WITH_NEW_SYS_V_KEYGEN
Bstr mIPCKey;
# endif /*VBOX_WITH_NEW_SYS_V_KEYGEN */
#else
# error "Port me!"
#endif
static DECLCALLBACK(int) taskHandler(RTTHREAD thread, void *pvUser);
};
// SnapshotMachine class
////////////////////////////////////////////////////////////////////////////////
/**
* @note Notes on locking objects of this class:
* SnapshotMachine shares some data with the primary Machine instance (pointed
* to by the |mPeer| member). In order to provide data consistency it also
* shares its lock handle. This means that whenever you lock a SessionMachine
* instance using Auto[Reader]Lock or AutoMultiLock, the corresponding Machine
* instance is also locked in the same lock mode. Keep it in mind.
*/
class ATL_NO_VTABLE SnapshotMachine :
public Machine
{
public:
VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(SnapshotMachine, IMachine)
DECLARE_NOT_AGGREGATABLE(SnapshotMachine)
DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_COM_MAP(SnapshotMachine)
VBOX_DEFAULT_INTERFACE_ENTRIES(IMachine)
END_COM_MAP()
DECLARE_EMPTY_CTOR_DTOR(SnapshotMachine)
HRESULT FinalConstruct();
void FinalRelease();
// public initializer/uninitializer for internal purposes only
HRESULT init(SessionMachine *aSessionMachine,
IN_GUID aSnapshotId,
const Utf8Str &aStateFilePath);
HRESULT initFromSettings(Machine *aMachine,
const settings::Hardware &hardware,
const settings::Debugging *pDbg,
const settings::Autostart *pAutostart,
const settings::Storage &storage,
IN_GUID aSnapshotId,
const Utf8Str &aStateFilePath);
void uninit();
// util::Lockable interface
RWLockHandle *lockHandle() const;
// public methods only for internal purposes
virtual bool isSnapshotMachine() const
{
return true;
}
HRESULT onSnapshotChange(Snapshot *aSnapshot);
// unsafe inline public methods for internal purposes only (ensure there is
// a caller and a read lock before calling them!)
const Guid& getSnapshotId() const { return mSnapshotId; }
private:
Guid mSnapshotId;
/** This field replaces mPeer for SessionMachine instances, as having
* a peer reference is plain meaningless and causes many subtle problems
* with saving settings and the like. */
Machine * const mMachine;
friend class Snapshot;
};
// third party methods that depend on SnapshotMachine definition
inline const Guid &Machine::getSnapshotId() const
{
return (isSnapshotMachine())
? static_cast<const SnapshotMachine*>(this)->getSnapshotId()
: Guid::Empty;
}
#endif // ____H_MACHINEIMPL
/* vi: set tabstop=4 shiftwidth=4 expandtab: */