MachineImpl.h revision 28d4dbbfa7d1c70c7005970547915b8a3a1eefbe
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync/* $Id$ */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
5b281ba489ca18f0380d7efc7a5108b606cce449vboxsync/** @file
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync *
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * VirtualBox COM class declaration
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync */
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync/*
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * Copyright (C) 2006-2007 Sun Microsystems, Inc.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync *
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * available from http://www.virtualbox.org. This file is free software;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * you can redistribute it and/or modify it under the terms of the GNU
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * General Public License (GPL) as published by the Free Software
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync *
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * additional information or have any questions.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync#ifndef ____H_MACHINEIMPL
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync#define ____H_MACHINEIMPL
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
3aad980b92149dd95a1ab72ddb8d11d61a28ace6vboxsync#include "VirtualBoxBase.h"
3aad980b92149dd95a1ab72ddb8d11d61a28ace6vboxsync#include "ProgressImpl.h"
ab93606043a9881487aa83be04191d2f4ea24071vboxsync#include "SnapshotImpl.h"
3aad980b92149dd95a1ab72ddb8d11d61a28ace6vboxsync#include "VRDPServerImpl.h"
0a7b20727716a00270f358a1c546473d8c36e8f3vboxsync#include "DVDDriveImpl.h"
0a7b20727716a00270f358a1c546473d8c36e8f3vboxsync#include "FloppyDriveImpl.h"
0a7b20727716a00270f358a1c546473d8c36e8f3vboxsync#include "HardDiskAttachmentImpl.h"
5981e6935987b08737b730b63a41acc1dd696377vboxsync#include "Collection.h"
0a7b20727716a00270f358a1c546473d8c36e8f3vboxsync#include "NetworkAdapterImpl.h"
0a7b20727716a00270f358a1c546473d8c36e8f3vboxsync#include "AudioAdapterImpl.h"
0a7b20727716a00270f358a1c546473d8c36e8f3vboxsync#include "SerialPortImpl.h"
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync#include "ParallelPortImpl.h"
0a7b20727716a00270f358a1c546473d8c36e8f3vboxsync#include "BIOSSettingsImpl.h"
0a7b20727716a00270f358a1c546473d8c36e8f3vboxsync#include "SATAControllerImpl.h"
0a7b20727716a00270f358a1c546473d8c36e8f3vboxsync#ifdef VBOX_WITH_RESOURCE_USAGE_API
3aad980b92149dd95a1ab72ddb8d11d61a28ace6vboxsync#include "PerformanceImpl.h"
3aad980b92149dd95a1ab72ddb8d11d61a28ace6vboxsync#endif /* VBOX_WITH_RESOURCE_USAGE_API */
3aad980b92149dd95a1ab72ddb8d11d61a28ace6vboxsync
3aad980b92149dd95a1ab72ddb8d11d61a28ace6vboxsync// generated header
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync#include "SchemaDefs.h"
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync#include <VBox/types.h>
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync#include <iprt/file.h>
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync#include <iprt/thread.h>
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync#include <iprt/time.h>
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync#include <list>
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync// defines
7ccd30dd4bbced565b32c255a11640cd4093abb6vboxsync////////////////////////////////////////////////////////////////////////////////
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync// helper declarations
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync////////////////////////////////////////////////////////////////////////////////
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncclass VirtualBox;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncclass Progress;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncclass CombinedProgress;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncclass Keyboard;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncclass Mouse;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncclass Display;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncclass MachineDebugger;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncclass USBController;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncclass Snapshot;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncclass SharedFolder;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncclass HostUSBDevice;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncclass SessionMachine;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync// Machine class
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync////////////////////////////////////////////////////////////////////////////////
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncclass ATL_NO_VTABLE Machine :
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync public VirtualBoxBaseWithChildrenNEXT,
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync public VirtualBoxSupportErrorInfoImpl <Machine, IMachine>,
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync public VirtualBoxSupportTranslation <Machine>,
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync public IMachine
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync{
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync Q_OBJECT
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncpublic:
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
d605d5391db09e6395a1c091f148f4b86af84bd3vboxsync enum InstanceType { IsMachine, IsSessionMachine, IsSnapshotMachine };
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /**
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * Internal machine data.
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync *
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * Only one instance of this data exists per every machine --
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * it is shared by the Machine, SessionMachine and all SnapshotMachine
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * instances associated with the given machine using the util::Shareable
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * template through the mData variable.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync *
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * @note |const| members are persistent during lifetime so can be
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * accessed without locking.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync *
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * @note There is no need to lock anything inside init() or uninit()
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * methods, because they are always serialized (see AutoCaller).
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync struct Data
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync {
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /**
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * Data structure to hold information about sessions opened for the
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * given machine.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync struct Session
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync {
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** Control of the direct session opened by openSession() */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync ComPtr <IInternalSessionControl> mDirectControl;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync typedef std::list <ComPtr <IInternalSessionControl> > RemoteControlList;
ab93606043a9881487aa83be04191d2f4ea24071vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** list of controls of all opened remote sessions */
ab93606043a9881487aa83be04191d2f4ea24071vboxsync RemoteControlList mRemoteControls;
ab93606043a9881487aa83be04191d2f4ea24071vboxsync
ab93606043a9881487aa83be04191d2f4ea24071vboxsync /** openRemoteSession() and OnSessionEnd() progress indicator */
ab93606043a9881487aa83be04191d2f4ea24071vboxsync ComObjPtr <Progress> mProgress;
ab93606043a9881487aa83be04191d2f4ea24071vboxsync
ab93606043a9881487aa83be04191d2f4ea24071vboxsync /**
ab93606043a9881487aa83be04191d2f4ea24071vboxsync * PID of the session object that must be passed to openSession()
ab93606043a9881487aa83be04191d2f4ea24071vboxsync * to finalize the openRemoteSession() request
ab93606043a9881487aa83be04191d2f4ea24071vboxsync * (i.e., PID of the process created by openRemoteSession())
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync RTPROCESS mPid;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsync /** Current session state */
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsync SessionState_T mState;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync /** Session type string (for indirect sessions) */
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync Bstr mType;
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync
2e42e0850e182e37277fe28ba5b5d1c37018e783vboxsync /** Session machine object */
2e42e0850e182e37277fe28ba5b5d1c37018e783vboxsync ComObjPtr <SessionMachine> mMachine;
2e42e0850e182e37277fe28ba5b5d1c37018e783vboxsync };
2e42e0850e182e37277fe28ba5b5d1c37018e783vboxsync
2e42e0850e182e37277fe28ba5b5d1c37018e783vboxsync Data();
2e42e0850e182e37277fe28ba5b5d1c37018e783vboxsync ~Data();
2e42e0850e182e37277fe28ba5b5d1c37018e783vboxsync
2e42e0850e182e37277fe28ba5b5d1c37018e783vboxsync const Guid mUuid;
2e42e0850e182e37277fe28ba5b5d1c37018e783vboxsync BOOL mRegistered;
2e42e0850e182e37277fe28ba5b5d1c37018e783vboxsync
2e42e0850e182e37277fe28ba5b5d1c37018e783vboxsync Bstr mConfigFile;
2e42e0850e182e37277fe28ba5b5d1c37018e783vboxsync Bstr mConfigFileFull;
2e42e0850e182e37277fe28ba5b5d1c37018e783vboxsync
2e42e0850e182e37277fe28ba5b5d1c37018e783vboxsync Utf8Str mSettingsFileVersion;
2e42e0850e182e37277fe28ba5b5d1c37018e783vboxsync
2e42e0850e182e37277fe28ba5b5d1c37018e783vboxsync BOOL mAccessible;
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync com::ErrorInfo mAccessError;
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync
ab93606043a9881487aa83be04191d2f4ea24071vboxsync MachineState_T mMachineState;
ab93606043a9881487aa83be04191d2f4ea24071vboxsync RTTIMESPEC mLastStateChange;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /* Note: These are guarded by VirtualBoxBase::stateLockHandle() */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync uint32_t mMachineStateDeps;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync RTSEMEVENTMULTI mMachineStateDepsSem;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync uint32_t mMachineStateChangePending;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
ab93606043a9881487aa83be04191d2f4ea24071vboxsync BOOL mCurrentStateModified;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync RTFILE mHandleCfgFile;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync Session mSession;
ab93606043a9881487aa83be04191d2f4ea24071vboxsync
ab93606043a9881487aa83be04191d2f4ea24071vboxsync ComObjPtr <Snapshot> mFirstSnapshot;
ab93606043a9881487aa83be04191d2f4ea24071vboxsync ComObjPtr <Snapshot> mCurrentSnapshot;
ab93606043a9881487aa83be04191d2f4ea24071vboxsync
ab93606043a9881487aa83be04191d2f4ea24071vboxsync };
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /**
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * Saved state data.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync *
81cfcb51c89626fd5d331d92dcec81c94a5e9d2fvboxsync * It's actually only the state file path string, but it needs to be
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsync * separate from Data, because Machine and SessionMachine instances
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * share it, while SnapshotMachine does not.
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsync *
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * The data variable is |mSSData|.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync struct SSData
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync {
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync Bstr mStateFilePath;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync };
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync /**
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * User changeable machine data.
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsync *
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * This data is common for all machine snapshots, i.e. it is shared
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * by all SnapshotMachine instances associated with the given machine
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * using the util::Backupable template through the |mUserData| variable.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync *
ab93606043a9881487aa83be04191d2f4ea24071vboxsync * SessionMachine instances can alter this data and discard changes.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync *
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * @note There is no need to lock anything inside init() or uninit()
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * methods, because they are always serialized (see AutoCaller).
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync */
ab93606043a9881487aa83be04191d2f4ea24071vboxsync struct UserData
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync {
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync UserData();
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync ~UserData();
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync bool operator== (const UserData &that) const
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync {
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync return this == &that ||
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync (mName == that.mName &&
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync mNameSync == that.mNameSync &&
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync mDescription == that.mDescription &&
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync mOSTypeId == that.mOSTypeId &&
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync mSnapshotFolderFull == that.mSnapshotFolderFull);
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync }
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync Bstr mName;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync BOOL mNameSync;
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsync Bstr mDescription;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync Bstr mOSTypeId;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync Bstr mSnapshotFolder;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync Bstr mSnapshotFolderFull;
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsync };
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /**
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * Hardware data.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync *
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * This data is unique for a machine and for every machine snapshot.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * Stored using the util::Backupable template in the |mHWData| variable.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync *
ab93606043a9881487aa83be04191d2f4ea24071vboxsync * SessionMachine instances can alter this data and discard changes.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync struct HWData
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync {
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /**
ab93606043a9881487aa83be04191d2f4ea24071vboxsync * Data structure to hold information about a guest property.
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync struct GuestProperty {
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** Property name */
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsync Bstr mName;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** Property value */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync Bstr mValue;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** Property timestamp */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync ULONG64 mTimestamp;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** Property flags */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync ULONG mFlags;
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsync };
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync HWData();
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync ~HWData();
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync bool operator== (const HWData &that) const;
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync Bstr mHWVersion;
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync ULONG mMemorySize;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync ULONG mMemoryBalloonSize;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync ULONG mStatisticsUpdateInterval;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync ULONG mVRAMSize;
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync ULONG mMonitorCount;
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync TSBool_T mHWVirtExEnabled;
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync BOOL mHWVirtExNestedPagingEnabled;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync BOOL mHWVirtExVPIDEnabled;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync BOOL mAccelerate3DEnabled;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync BOOL mPAEEnabled;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync ULONG mCPUCount;
8fdb63a0d23d1618724f651b8c3d11be48b44d35vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync DeviceType_T mBootOrder [SchemaDefs::MaxBootPosition];
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync typedef std::list <ComObjPtr <SharedFolder> > SharedFolderList;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync SharedFolderList mSharedFolders;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync ClipboardMode_T mClipboardMode;
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync typedef std::list <GuestProperty> GuestPropertyList;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync GuestPropertyList mGuestProperties;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync BOOL mPropertyServiceActive;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync Bstr mGuestPropertyNotificationPatterns;
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync };
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /**
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * Hard disk data.
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync *
d605d5391db09e6395a1c091f148f4b86af84bd3vboxsync * The usage policy is the same as for HWData, but a separate structure
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync * is necessary because hard disk data requires different procedures when
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync * taking or discarding snapshots, etc.
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync *
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync * The data variable is |mHWData|.
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync */
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync struct HDData
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync {
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync HDData();
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync ~HDData();
9364fd364e57542419416d69895877915c344826vboxsync
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync bool operator== (const HDData &that) const;
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync typedef std::list< ComObjPtr<HardDiskAttachment> > AttachmentList;
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync AttachmentList mAttachments;
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync };
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync enum StateDependency
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync {
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync AnyStateDep = 0, MutableStateDep, MutableOrSavedStateDep
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync };
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync /**
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync * Helper class that safely manages the machine state dependency by
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync * calling Machine::addStateDependency() on construction and
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync * Machine::releaseStateDependency() on destruction. Intended for Machine
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync * children. The usage pattern is:
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync *
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * @code
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * AutoCaller autoCaller (this);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * CheckComRCReturnRC (autoCaller.rc());
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync *
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * Machine::AutoStateDependency <MutableStateDep> adep (mParent);
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * CheckComRCReturnRC (stateDep.rc());
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * ...
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * // code that depends on the particular machine state
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * ...
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * @endcode
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync *
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * Note that it is more convenient to use the following individual
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * shortcut classes instead of using this template directly:
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * AutoAnyStateDependency, AutoMutableStateDependency and
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * AutoMutableOrSavedStateDependency. The usage pattern is exactly the
8fdb63a0d23d1618724f651b8c3d11be48b44d35vboxsync * same as above except that there is no need to specify the template
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * argument because it is already done by the shortcut class.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync *
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsync * @param taDepType Dependecy type to manage.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync */
7e10aea6606a51d35041e5a85f9e4f1bd19c4062vboxsync template <StateDependency taDepType = AnyStateDep>
e190faad3061288ae099cd3ea8a858bd224c00a7vboxsync class AutoStateDependency
7e10aea6606a51d35041e5a85f9e4f1bd19c4062vboxsync {
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync public:
0a79c9258d8fae34fa527f125009ab507561b4edvboxsync
7e10aea6606a51d35041e5a85f9e4f1bd19c4062vboxsync AutoStateDependency (Machine *aThat)
259e900197d37d0f84ed72e1d4a4eb6c11b4e301vboxsync : mThat (aThat), mRC (S_OK)
259e900197d37d0f84ed72e1d4a4eb6c11b4e301vboxsync , mMachineState (MachineState_Null)
7e10aea6606a51d35041e5a85f9e4f1bd19c4062vboxsync , mRegistered (FALSE)
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync {
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync Assert (aThat);
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync mRC = aThat->addStateDependency (taDepType, &mMachineState,
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync &mRegistered);
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync }
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync ~AutoStateDependency()
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync {
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync if (SUCCEEDED (mRC))
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync mThat->releaseStateDependency();
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync }
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsync
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync /** Decreases the number of dependencies before the instance is
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * destroyed. Note that will reset #rc() to E_FAIL. */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync void release()
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync {
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync AssertReturnVoid (SUCCEEDED (mRC));
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync mThat->releaseStateDependency();
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync mRC = E_FAIL;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync }
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** Restores the number of callers after by #release(). #rc() will be
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * reset to the result of calling addStateDependency() and must be
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * rechecked to ensure the operation succeeded. */
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync void add()
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync {
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync AssertReturnVoid (!SUCCEEDED (mRC));
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync mRC = mThat->addStateDependency (taDepType, &mMachineState,
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync &mRegistered);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync }
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** Returns the result of Machine::addStateDependency(). */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync HRESULT rc() const { return mRC; }
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** Shortcut to SUCCEEDED (rc()). */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync bool isOk() const { return SUCCEEDED (mRC); }
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** Returns the machine state value as returned by
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * Machine::addStateDependency(). */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync MachineState_T machineState() const { return mMachineState; }
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** Returns the machine state value as returned by
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * Machine::addStateDependency(). */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync BOOL machineRegistered() const { return mRegistered; }
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync protected:
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync Machine *mThat;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync HRESULT mRC;
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync MachineState_T mMachineState;
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync BOOL mRegistered;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync private:
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP (AutoStateDependency)
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync DECLARE_CLS_NEW_DELETE_NOOP (AutoStateDependency)
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync };
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /**
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * Shortcut to AutoStateDependency <AnyStateDep>.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * See AutoStateDependency to get the usage pattern.
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync *
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync * Accepts any machine state and guarantees the state won't change before
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * this object is destroyed. If the machine state cannot be protected (as
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync * a result of the state change currently in progress), this instance's
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync * #rc() method will indicate a failure, and the caller is not allowed to
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * rely on any particular machine state and should return the failed
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * result code to the upper level.
333e7ab9cd83b32080826d06ac7b1951c684ccb5vboxsync */
333e7ab9cd83b32080826d06ac7b1951c684ccb5vboxsync typedef AutoStateDependency <AnyStateDep> AutoAnyStateDependency;
333e7ab9cd83b32080826d06ac7b1951c684ccb5vboxsync
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync /**
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * Shortcut to AutoStateDependency <MutableStateDep>.
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * See AutoStateDependency to get the usage pattern.
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync *
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * Succeeds only if the machine state is in one of the mutable states, and
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * guarantees the given mutable state won't change before this object is
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * destroyed. If the machine is not mutable, this instance's #rc() method
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * will indicate a failure, and the caller is not allowed to rely on any
333e7ab9cd83b32080826d06ac7b1951c684ccb5vboxsync * particular machine state and should return the failed result code to
333e7ab9cd83b32080826d06ac7b1951c684ccb5vboxsync * the upper level.
333e7ab9cd83b32080826d06ac7b1951c684ccb5vboxsync *
333e7ab9cd83b32080826d06ac7b1951c684ccb5vboxsync * Intended to be used within all setter methods of IMachine
333e7ab9cd83b32080826d06ac7b1951c684ccb5vboxsync * children objects (DVDDrive, NetworkAdapter, AudioAdapter, etc.) to
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * provide data protection and consistency.
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync */
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync typedef AutoStateDependency <MutableStateDep> AutoMutableStateDependency;
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync /**
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * Shortcut to AutoStateDependency <MutableOrSavedStateDep>.
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * See AutoStateDependency to get the usage pattern.
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync *
333e7ab9cd83b32080826d06ac7b1951c684ccb5vboxsync * Succeeds only if the machine state is in one of the mutable states, or
333e7ab9cd83b32080826d06ac7b1951c684ccb5vboxsync * if the machine is in the Saved state, and guarantees the given mutable
333e7ab9cd83b32080826d06ac7b1951c684ccb5vboxsync * state won't change before this object is destroyed. If the machine is
333e7ab9cd83b32080826d06ac7b1951c684ccb5vboxsync * not mutable, this instance's #rc() method will indicate a failure, and
333e7ab9cd83b32080826d06ac7b1951c684ccb5vboxsync * the caller is not allowed to rely on any particular machine state and
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * should return the failed result code to the upper level.
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync *
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * Intended to be used within setter methods of IMachine
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * children objects that may also operate on Saved machines.
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync */
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync typedef AutoStateDependency <MutableOrSavedStateDep> AutoMutableOrSavedStateDependency;
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync
333e7ab9cd83b32080826d06ac7b1951c684ccb5vboxsync
333e7ab9cd83b32080826d06ac7b1951c684ccb5vboxsync VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (Machine)
d605d5391db09e6395a1c091f148f4b86af84bd3vboxsync
d605d5391db09e6395a1c091f148f4b86af84bd3vboxsync DECLARE_NOT_AGGREGATABLE(Machine)
DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_COM_MAP(Machine)
COM_INTERFACE_ENTRY(ISupportErrorInfo)
COM_INTERFACE_ENTRY(IMachine)
END_COM_MAP()
NS_DECL_ISUPPORTS
DECLARE_EMPTY_CTOR_DTOR (Machine)
HRESULT FinalConstruct();
void FinalRelease();
enum InitMode { Init_New, Init_Existing, Init_Registered };
// public initializer/uninitializer for internal purposes only
HRESULT init (VirtualBox *aParent, CBSTR aConfigFile,
InitMode aMode, CBSTR aName = NULL,
GuestOSType *aOsType = NULL,
BOOL aNameSync = TRUE, const Guid *aId = NULL);
void uninit();
// 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))(OUT_GUID aId);
STDMETHOD(COMGETTER(OSTypeId)) (BSTR *aOSTypeId);
STDMETHOD(COMSETTER(OSTypeId)) (IN_BSTR aOSTypeId);
STDMETHOD(COMGETTER(HardwareVersion))(BSTR *aVersion);
STDMETHOD(COMSETTER(HardwareVersion))(IN_BSTR aVersion);
STDMETHOD(COMGETTER(MemorySize))(ULONG *memorySize);
STDMETHOD(COMSETTER(MemorySize))(ULONG memorySize);
STDMETHOD(COMGETTER(CPUCount))(ULONG *cpuCount);
STDMETHOD(COMSETTER(CPUCount))(ULONG cpuCount);
STDMETHOD(COMGETTER(MemoryBalloonSize))(ULONG *memoryBalloonSize);
STDMETHOD(COMSETTER(MemoryBalloonSize))(ULONG memoryBalloonSize);
STDMETHOD(COMGETTER(StatisticsUpdateInterval))(ULONG *statisticsUpdateInterval);
STDMETHOD(COMSETTER(StatisticsUpdateInterval))(ULONG statisticsUpdateInterval);
STDMETHOD(COMGETTER(VRAMSize))(ULONG *memorySize);
STDMETHOD(COMSETTER(VRAMSize))(ULONG memorySize);
STDMETHOD(COMGETTER(MonitorCount))(ULONG *monitorCount);
STDMETHOD(COMSETTER(MonitorCount))(ULONG monitorCount);
STDMETHOD(COMGETTER(Accelerate3DEnabled))(BOOL *enabled);
STDMETHOD(COMSETTER(Accelerate3DEnabled))(BOOL enabled);
STDMETHOD(COMGETTER(BIOSSettings))(IBIOSSettings **biosSettings);
STDMETHOD(COMGETTER(HWVirtExEnabled))(TSBool_T *enabled);
STDMETHOD(COMSETTER(HWVirtExEnabled))(TSBool_T enabled);
STDMETHOD(COMGETTER(HWVirtExNestedPagingEnabled))(BOOL *enabled);
STDMETHOD(COMSETTER(HWVirtExNestedPagingEnabled))(BOOL enabled);
STDMETHOD(COMGETTER(HWVirtExVPIDEnabled))(BOOL *enabled);
STDMETHOD(COMSETTER(HWVirtExVPIDEnabled))(BOOL enabled);
STDMETHOD(COMGETTER(PAEEnabled))(BOOL *enabled);
STDMETHOD(COMSETTER(PAEEnabled))(BOOL enabled);
STDMETHOD(COMGETTER(SnapshotFolder))(BSTR *aSavedStateFolder);
STDMETHOD(COMSETTER(SnapshotFolder))(IN_BSTR aSavedStateFolder);
STDMETHOD(COMGETTER(HardDiskAttachments))(ComSafeArrayOut (IHardDiskAttachment *, aAttachments));
STDMETHOD(COMGETTER(VRDPServer))(IVRDPServer **vrdpServer);
STDMETHOD(COMGETTER(DVDDrive))(IDVDDrive **dvdDrive);
STDMETHOD(COMGETTER(FloppyDrive))(IFloppyDrive **floppyDrive);
STDMETHOD(COMGETTER(AudioAdapter))(IAudioAdapter **audioAdapter);
STDMETHOD(COMGETTER(USBController)) (IUSBController * *aUSBController);
STDMETHOD(COMGETTER(SATAController)) (ISATAController **aSATAController);
STDMETHOD(COMGETTER(SettingsFilePath)) (BSTR *aFilePath);
STDMETHOD(COMGETTER(SettingsFileVersion)) (BSTR *aSettingsFileVersion);
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(GuestPropertyNotificationPatterns)) (BSTR *aPattern);
STDMETHOD(COMSETTER(GuestPropertyNotificationPatterns)) (IN_BSTR aPattern);
// IMachine methods
STDMETHOD(SetBootOrder)(ULONG aPosition, DeviceType_T aDevice);
STDMETHOD(GetBootOrder)(ULONG aPosition, DeviceType_T *aDevice);
STDMETHOD(AttachHardDisk)(IN_GUID aId, StorageBus_T aBus,
LONG aChannel, LONG aDevice);
STDMETHOD(GetHardDisk)(StorageBus_T aBus, LONG aChannel, LONG aDevice,
IHardDisk **aHardDisk);
STDMETHOD(DetachHardDisk)(StorageBus_T aBus, LONG aChannel, LONG aDevice);
STDMETHOD(GetSerialPort) (ULONG slot, ISerialPort **port);
STDMETHOD(GetParallelPort) (ULONG slot, IParallelPort **port);
STDMETHOD(GetNetworkAdapter) (ULONG slot, INetworkAdapter **adapter);
STDMETHOD(GetNextExtraDataKey)(IN_BSTR aKey, BSTR *aNextKey, BSTR *aNextValue);
STDMETHOD(GetExtraData)(IN_BSTR aKey, BSTR *aValue);
STDMETHOD(SetExtraData)(IN_BSTR aKey, IN_BSTR aValue);
STDMETHOD(SaveSettings)();
STDMETHOD(SaveSettingsWithBackup) (BSTR *aBakFileName);
STDMETHOD(DiscardSettings)();
STDMETHOD(DeleteSettings)();
STDMETHOD(Export)(IAppliance *appliance);
STDMETHOD(GetSnapshot) (IN_GUID aId, ISnapshot **aSnapshot);
STDMETHOD(FindSnapshot) (IN_BSTR aName, ISnapshot **aSnapshot);
STDMETHOD(SetCurrentSnapshot) (IN_GUID aId);
STDMETHOD(CreateSharedFolder) (IN_BSTR aName, IN_BSTR aHostPath, BOOL aWritable);
STDMETHOD(RemoveSharedFolder) (IN_BSTR aName);
STDMETHOD(CanShowConsoleWindow) (BOOL *aCanShow);
STDMETHOD(ShowConsoleWindow) (ULONG64 *aWinId);
STDMETHOD(GetGuestProperty) (IN_BSTR aName, BSTR *aValue, ULONG64 *aTimestamp, BSTR *aFlags);
STDMETHOD(GetGuestPropertyValue) (IN_BSTR aName, BSTR *aValue);
STDMETHOD(GetGuestPropertyTimestamp) (IN_BSTR aName, ULONG64 *aTimestamp);
STDMETHOD(SetGuestProperty) (IN_BSTR aName, IN_BSTR aValue, IN_BSTR aFlags);
STDMETHOD(SetGuestPropertyValue) (IN_BSTR aName, IN_BSTR aValue);
STDMETHOD(EnumerateGuestProperties) (IN_BSTR aPattern, ComSafeArrayOut(BSTR, aNames), ComSafeArrayOut(BSTR, aValues), ComSafeArrayOut(ULONG64, aTimestamps), ComSafeArrayOut(BSTR, aFlags));
// public methods only for internal purposes
InstanceType type() const { return mType; }
/// @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.
*/
const ComObjPtr <VirtualBox, ComWeakRef> &virtualBox() const { return mParent; }
/**
* 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 &id() 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 &snapshotId() 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 Bstr &settingsFileFull() const { return mData->mConfigFileFull; }
/**
* 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 Bstr &name() const { return mUserData->mName; }
// callback handlers
virtual HRESULT onDVDDriveChange() { return S_OK; }
virtual HRESULT onFloppyDriveChange() { return S_OK; }
virtual HRESULT onNetworkAdapterChange(INetworkAdapter *networkAdapter) { return S_OK; }
virtual HRESULT onSerialPortChange(ISerialPort *serialPort) { return S_OK; }
virtual HRESULT onParallelPortChange(IParallelPort *ParallelPort) { return S_OK; }
virtual HRESULT onVRDPServerChange() { return S_OK; }
virtual HRESULT onUSBControllerChange() { return S_OK; }
virtual HRESULT onSATAControllerChange() { return S_OK; }
virtual HRESULT onSharedFolderChange() { return S_OK; }
HRESULT saveRegistryEntry (settings::Key &aEntryNode);
int calculateFullPath (const char *aPath, Utf8Str &aResult);
void calculateRelativePath (const char *aPath, Utf8Str &aResult);
void getLogFolder (Utf8Str &aLogFolder);
HRESULT openSession (IInternalSessionControl *aControl);
HRESULT openRemoteSession (IInternalSessionControl *aControl,
IN_BSTR aType, IN_BSTR aEnvironment,
Progress *aProgress);
HRESULT openExistingSession (IInternalSessionControl *aControl);
#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 trySetRegistered (BOOL aRegistered);
HRESULT getSharedFolder (CBSTR aName,
ComObjPtr <SharedFolder> &aSharedFolder,
bool aSetError = false)
{
AutoWriteLock alock (this);
return findSharedFolder (aName, aSharedFolder, aSetError);
}
HRESULT addStateDependency (StateDependency aDepType = AnyStateDep,
MachineState_T *aState = NULL,
BOOL *aRegistered = NULL);
void releaseStateDependency();
// for VirtualBoxSupportErrorInfoImpl
static const wchar_t *getComponentName() { return L"Machine"; }
protected:
HRESULT registeredInit();
HRESULT checkStateDependency (StateDependency aDepType);
inline Machine *machine();
HRESULT initDataAndChildObjects();
void uninitDataAndChildObjects();
void ensureNoStateDependencies();
virtual HRESULT setMachineState (MachineState_T aMachineState);
HRESULT findSharedFolder (CBSTR aName,
ComObjPtr <SharedFolder> &aSharedFolder,
bool aSetError = false);
HRESULT loadSettings (bool aRegistered);
HRESULT loadSnapshot (const settings::Key &aNode, const Guid &aCurSnapshotId,
Snapshot *aParentSnapshot);
HRESULT loadHardware (const settings::Key &aNode);
HRESULT loadHardDisks (const settings::Key &aNode, bool aRegistered,
const Guid *aSnapshotId = NULL);
HRESULT findSnapshotNode (Snapshot *aSnapshot, settings::Key &aMachineNode,
settings::Key *aSnapshotsNode,
settings::Key *aSnapshotNode);
HRESULT findSnapshot (const Guid &aId, ComObjPtr <Snapshot> &aSnapshot,
bool aSetError = false);
HRESULT findSnapshot (IN_BSTR aName, ComObjPtr <Snapshot> &aSnapshot,
bool aSetError = false);
enum
{
/* flags for #saveSettings() */
SaveS_ResetCurStateModified = 0x01,
SaveS_InformCallbacksAnyway = 0x02,
/* ops for #saveSnapshotSettings() */
SaveSS_NoOp = 0x00, SaveSS_AddOp = 0x01,
SaveSS_UpdateAttrsOp = 0x02, SaveSS_UpdateAllOp = 0x03,
SaveSS_OpMask = 0xF,
/* flags for #saveSnapshotSettings() */
SaveSS_CurStateModified = 0x40,
SaveSS_CurrentId = 0x80,
/* flags for #saveStateSettings() */
SaveSTS_CurStateModified = 0x20,
SaveSTS_StateFilePath = 0x40,
SaveSTS_StateTimeStamp = 0x80,
};
HRESULT prepareSaveSettings (bool &aRenamed, bool &aNew);
HRESULT saveSettings (int aFlags = 0);
HRESULT saveSnapshotSettings (Snapshot *aSnapshot, int aOpFlags);
HRESULT saveSnapshotSettingsWorker (settings::Key &aMachineNode,
Snapshot *aSnapshot, int aOpFlags);
HRESULT saveSnapshot (settings::Key &aNode, Snapshot *aSnapshot, bool aAttrsOnly);
HRESULT saveHardware (settings::Key &aNode);
HRESULT saveHardDisks (settings::Key &aNode);
HRESULT saveStateSettings (int aFlags);
HRESULT createImplicitDiffs (const Bstr &aFolder,
ComObjPtr <Progress> &aProgress,
bool aOnline);
HRESULT deleteImplicitDiffs();
void fixupHardDisks(bool aCommit, bool aOnline = false);
HRESULT lockConfig();
HRESULT unlockConfig();
/** @note This method is not thread safe */
BOOL isConfigLocked()
{
return !!mData && mData->mHandleCfgFile != NIL_RTFILE;
}
bool isInOwnDir (Utf8Str *aSettingsDir = NULL);
bool isModified();
bool isReallyModified (bool aIgnoreUserData = false);
void rollback (bool aNotify);
void commit();
void copyFrom (Machine *aThat);
#ifdef VBOX_WITH_RESOURCE_USAGE_API
void registerMetrics (PerformanceCollector *aCollector, Machine *aMachine, RTPROCESS pid);
void unregisterMetrics (PerformanceCollector *aCollector, Machine *aMachine);
#endif /* VBOX_WITH_RESOURCE_USAGE_API */
const InstanceType mType;
const ComObjPtr <Machine, ComWeakRef> mPeer;
const ComObjPtr <VirtualBox, ComWeakRef> mParent;
Shareable <Data> mData;
Shareable <SSData> mSSData;
Backupable <UserData> mUserData;
Backupable <HWData> mHWData;
Backupable <HDData> mHDData;
// the following fields need special backup/rollback/commit handling,
// so they cannot be a part of HWData
const ComObjPtr <VRDPServer> mVRDPServer;
const ComObjPtr <DVDDrive> mDVDDrive;
const ComObjPtr <FloppyDrive> mFloppyDrive;
const ComObjPtr <SerialPort>
mSerialPorts [SchemaDefs::SerialPortCount];
const ComObjPtr <ParallelPort>
mParallelPorts [SchemaDefs::ParallelPortCount];
const ComObjPtr <AudioAdapter> mAudioAdapter;
const ComObjPtr <USBController> mUSBController;
const ComObjPtr <SATAController> mSATAController;
const ComObjPtr <BIOSSettings> mBIOSSettings;
const ComObjPtr <NetworkAdapter>
mNetworkAdapters [SchemaDefs::NetworkAdapterCount];
friend class SessionMachine;
friend class SnapshotMachine;
};
// 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 VirtualBoxSupportTranslation <SessionMachine>,
public Machine,
public IInternalMachineControl
{
public:
VIRTUALBOXSUPPORTTRANSLATION_OVERRIDE(SessionMachine)
DECLARE_NOT_AGGREGATABLE(SessionMachine)
DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_COM_MAP(SessionMachine)
COM_INTERFACE_ENTRY(ISupportErrorInfo)
COM_INTERFACE_ENTRY(IMachine)
COM_INTERFACE_ENTRY(IInternalMachineControl)
END_COM_MAP()
NS_DECL_ISUPPORTS
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(UpdateState)(MachineState_T machineState);
STDMETHOD(GetIPCId)(BSTR *id);
STDMETHOD(RunUSBDeviceFilters) (IUSBDevice *aUSBDevice, BOOL *aMatched, ULONG *aMaskedIfs);
STDMETHOD(CaptureUSBDevice) (IN_GUID aId);
STDMETHOD(DetachUSBDevice) (IN_GUID aId, BOOL aDone);
STDMETHOD(AutoCaptureUSBDevices)();
STDMETHOD(DetachAllUSBDevices)(BOOL aDone);
STDMETHOD(OnSessionEnd)(ISession *aSession, IProgress **aProgress);
STDMETHOD(BeginSavingState) (IProgress *aProgress, BSTR *aStateFilePath);
STDMETHOD(EndSavingState) (BOOL aSuccess);
STDMETHOD(AdoptSavedState) (IN_BSTR aSavedStateFile);
STDMETHOD(BeginTakingSnapshot) (IConsole *aInitiator,
IN_BSTR aName, IN_BSTR aDescription,
IProgress *aProgress, BSTR *aStateFilePath,
IProgress **aServerProgress);
STDMETHOD(EndTakingSnapshot) (BOOL aSuccess);
STDMETHOD(DiscardSnapshot) (IConsole *aInitiator, IN_GUID aId,
MachineState_T *aMachineState, IProgress **aProgress);
STDMETHOD(DiscardCurrentState) (
IConsole *aInitiator, MachineState_T *aMachineState, IProgress **aProgress);
STDMETHOD(DiscardCurrentSnapshotAndState) (
IConsole *aInitiator, MachineState_T *aMachineState, IProgress **aProgress);
STDMETHOD(PullGuestProperties) (ComSafeArrayOut(BSTR, aNames), ComSafeArrayOut(BSTR, aValues),
ComSafeArrayOut(ULONG64, aTimestamps), ComSafeArrayOut(BSTR, aFlags));
STDMETHOD(PushGuestProperties) (ComSafeArrayIn(IN_BSTR, aNames), ComSafeArrayIn(IN_BSTR, aValues),
ComSafeArrayIn(ULONG64, aTimestamps), ComSafeArrayIn(IN_BSTR, aFlags));
STDMETHOD(PushGuestProperty) (IN_BSTR aName, IN_BSTR aValue,
ULONG64 aTimestamp, IN_BSTR aFlags);
// public methods only for internal purposes
bool checkForDeath();
HRESULT onDVDDriveChange();
HRESULT onFloppyDriveChange();
HRESULT onNetworkAdapterChange(INetworkAdapter *networkAdapter);
HRESULT onSerialPortChange(ISerialPort *serialPort);
HRESULT onParallelPortChange(IParallelPort *parallelPort);
HRESULT onVRDPServerChange();
HRESULT onUSBControllerChange();
HRESULT onUSBDeviceAttach (IUSBDevice *aDevice,
IVirtualBoxErrorInfo *aError,
ULONG aMaskedIfs);
HRESULT onUSBDeviceDetach (IN_GUID aId,
IVirtualBoxErrorInfo *aError);
HRESULT onSharedFolderChange();
bool hasMatchingUSBFilter (const ComObjPtr <HostUSBDevice> &aDevice, ULONG *aMaskedIfs);
private:
struct SnapshotData
{
SnapshotData() : mLastState (MachineState_Null) {}
MachineState_T mLastState;
// used when taking snapshot
ComObjPtr <Snapshot> mSnapshot;
ComObjPtr <Progress> mServerProgress;
ComObjPtr <CombinedProgress> mCombinedProgress;
// used when saving state
Guid mProgressId;
Bstr mStateFilePath;
};
struct Uninit
{
enum Reason { Unexpected, Abnormal, Normal };
};
struct Task;
struct TakeSnapshotTask;
struct DiscardSnapshotTask;
struct DiscardCurrentStateTask;
friend struct TakeSnapshotTask;
friend struct DiscardSnapshotTask;
friend struct DiscardCurrentStateTask;
void uninit (Uninit::Reason aReason);
HRESULT endSavingState (BOOL aSuccess);
HRESULT endTakingSnapshot (BOOL aSuccess);
typedef std::map <ComObjPtr <Machine>, MachineState_T> AffectedMachines;
void takeSnapshotHandler (TakeSnapshotTask &aTask);
void discardSnapshotHandler (DiscardSnapshotTask &aTask);
void discardCurrentStateHandler (DiscardCurrentStateTask &aTask);
HRESULT setMachineState (MachineState_T aMachineState);
HRESULT updateMachineStateOnClient();
SnapshotData mSnapshotData;
/** 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 VirtualBoxSupportTranslation <SnapshotMachine>,
public Machine
{
public:
VIRTUALBOXSUPPORTTRANSLATION_OVERRIDE(SnapshotMachine)
DECLARE_NOT_AGGREGATABLE(SnapshotMachine)
DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_COM_MAP(SnapshotMachine)
COM_INTERFACE_ENTRY(ISupportErrorInfo)
COM_INTERFACE_ENTRY(IMachine)
END_COM_MAP()
NS_DECL_ISUPPORTS
DECLARE_EMPTY_CTOR_DTOR (SnapshotMachine)
HRESULT FinalConstruct();
void FinalRelease();
// public initializer/uninitializer for internal purposes only
HRESULT init (SessionMachine *aSessionMachine,
IN_GUID aSnapshotId, IN_BSTR aStateFilePath);
HRESULT init (Machine *aMachine,
const settings::Key &aHWNode, const settings::Key &aHDAsNode,
IN_GUID aSnapshotId, IN_BSTR aStateFilePath);
void uninit();
// util::Lockable interface
RWLockHandle *lockHandle() const;
// public methods only for internal purposes
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 &snapshotId() const { return mSnapshotId; }
private:
Guid mSnapshotId;
friend class Snapshot;
};
// third party methods that depend on SnapshotMachine definiton
inline const Guid &Machine::snapshotId() const
{
return mType != IsSnapshotMachine ? Guid::Empty :
static_cast <const SnapshotMachine *> (this)->snapshotId();
}
////////////////////////////////////////////////////////////////////////////////
/**
* Returns a pointer to the Machine object for this machine that acts like a
* parent for complex machine data objects such as shared folders, etc.
*
* For primary Machine objects and for SnapshotMachine objects, returns this
* object's pointer itself. For SessoinMachine objects, returns the peer
* (primary) machine pointer.
*/
inline Machine *Machine::machine()
{
if (mType == IsSessionMachine)
return mPeer;
return this;
}
#endif // ____H_MACHINEIMPL
/* vi: set tabstop=4 shiftwidth=4 expandtab: */