VirtualBox

source: vbox/trunk/src/VBox/Main/include/MachineImpl.h@ 27166

Last change on this file since 27166 was 27166, checked in by vboxsync, 15 years ago

Added large page property.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 40.6 KB
Line 
1/* $Id: MachineImpl.h 27166 2010-03-08 14:16:00Z vboxsync $ */
2
3/** @file
4 *
5 * VirtualBox COM class declaration
6 */
7
8/*
9 * Copyright (C) 2006-2010 Sun Microsystems, Inc.
10 *
11 * This file is part of VirtualBox Open Source Edition (OSE), as
12 * available from http://www.virtualbox.org. This file is free software;
13 * you can redistribute it and/or modify it under the terms of the GNU
14 * General Public License (GPL) as published by the Free Software
15 * Foundation, in version 2 as it comes in the "COPYING" file of the
16 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
20 * Clara, CA 95054 USA or visit http://www.sun.com if you need
21 * additional information or have any questions.
22 */
23
24#ifndef ____H_MACHINEIMPL
25#define ____H_MACHINEIMPL
26
27#include "VirtualBoxBase.h"
28#include "SnapshotImpl.h"
29#include "VRDPServerImpl.h"
30#include "MediumAttachmentImpl.h"
31#include "NetworkAdapterImpl.h"
32#include "AudioAdapterImpl.h"
33#include "SerialPortImpl.h"
34#include "ParallelPortImpl.h"
35#include "BIOSSettingsImpl.h"
36#include "StorageControllerImpl.h" // required for MachineImpl.h to compile on Windows
37#include "VBox/settings.h"
38#ifdef VBOX_WITH_RESOURCE_USAGE_API
39#include "PerformanceImpl.h"
40#endif /* VBOX_WITH_RESOURCE_USAGE_API */
41
42// generated header
43#include "SchemaDefs.h"
44
45#include <VBox/types.h>
46
47#include <iprt/file.h>
48#include <iprt/thread.h>
49#include <iprt/time.h>
50
51#include <list>
52
53// defines
54////////////////////////////////////////////////////////////////////////////////
55
56// helper declarations
57////////////////////////////////////////////////////////////////////////////////
58
59class Progress;
60class Keyboard;
61class Mouse;
62class Display;
63class MachineDebugger;
64class USBController;
65class Snapshot;
66class SharedFolder;
67class HostUSBDevice;
68class StorageController;
69
70class SessionMachine;
71
72namespace settings
73{
74 class MachineConfigFile;
75 struct Snapshot;
76 struct Hardware;
77 struct Storage;
78 struct StorageController;
79 struct MachineRegistryEntry;
80}
81
82// Machine class
83////////////////////////////////////////////////////////////////////////////////
84
85class ATL_NO_VTABLE Machine :
86 public VirtualBoxBaseWithChildrenNEXT,
87 public VirtualBoxSupportErrorInfoImpl<Machine, IMachine>,
88 public VirtualBoxSupportTranslation<Machine>,
89 VBOX_SCRIPTABLE_IMPL(IMachine)
90{
91 Q_OBJECT
92
93public:
94
95 enum InitMode { Init_New, Init_Import, Init_Registered };
96
97 enum StateDependency
98 {
99 AnyStateDep = 0, MutableStateDep, MutableOrSavedStateDep
100 };
101
102 /**
103 * Internal machine data.
104 *
105 * Only one instance of this data exists per every machine -- it is shared
106 * by the Machine, SessionMachine and all SnapshotMachine instances
107 * associated with the given machine using the util::Shareable template
108 * through the mData variable.
109 *
110 * @note |const| members are persistent during lifetime so can be
111 * accessed without locking.
112 *
113 * @note There is no need to lock anything inside init() or uninit()
114 * methods, because they are always serialized (see AutoCaller).
115 */
116 struct Data
117 {
118 /**
119 * Data structure to hold information about sessions opened for the
120 * given machine.
121 */
122 struct Session
123 {
124 /** Control of the direct session opened by openSession() */
125 ComPtr<IInternalSessionControl> mDirectControl;
126
127 typedef std::list<ComPtr<IInternalSessionControl> > RemoteControlList;
128
129 /** list of controls of all opened remote sessions */
130 RemoteControlList mRemoteControls;
131
132 /** openRemoteSession() and OnSessionEnd() progress indicator */
133 ComObjPtr<Progress> mProgress;
134
135 /**
136 * PID of the session object that must be passed to openSession() to
137 * finalize the openRemoteSession() request (i.e., PID of the
138 * process created by openRemoteSession())
139 */
140 RTPROCESS mPid;
141
142 /** Current session state */
143 SessionState_T mState;
144
145 /** Session type string (for indirect sessions) */
146 Bstr mType;
147
148 /** Session machine object */
149 ComObjPtr<SessionMachine> mMachine;
150
151 /**
152 * Successfully locked media list. The 2nd value in the pair is true
153 * if the medium is locked for writing and false if locked for
154 * reading.
155 */
156 typedef std::list<std::pair<ComPtr<IMedium>, bool > > LockedMedia;
157 LockedMedia mLockedMedia;
158 };
159
160 Data();
161 ~Data();
162
163 const Guid mUuid;
164 BOOL mRegistered;
165 InitMode mInitMode;
166
167 /** Flag indicating that the config file is read-only. */
168 BOOL mConfigFileReadonly;
169 Utf8Str m_strConfigFile;
170 Utf8Str m_strConfigFileFull;
171
172 // machine settings XML file
173 settings::MachineConfigFile *m_pMachineConfigFile;
174
175 BOOL mAccessible;
176 com::ErrorInfo mAccessError;
177
178 MachineState_T mMachineState;
179 RTTIMESPEC mLastStateChange;
180
181 /* Note: These are guarded by VirtualBoxBase::stateLockHandle() */
182 uint32_t mMachineStateDeps;
183 RTSEMEVENTMULTI mMachineStateDepsSem;
184 uint32_t mMachineStateChangePending;
185
186 BOOL mCurrentStateModified;
187
188 RTFILE mHandleCfgFile;
189
190 Session mSession;
191
192 ComObjPtr<Snapshot> mFirstSnapshot;
193 ComObjPtr<Snapshot> mCurrentSnapshot;
194 };
195
196 /**
197 * Saved state data.
198 *
199 * It's actually only the state file path string, but it needs to be
200 * separate from Data, because Machine and SessionMachine instances
201 * share it, while SnapshotMachine does not.
202 *
203 * The data variable is |mSSData|.
204 */
205 struct SSData
206 {
207 Utf8Str mStateFilePath;
208 };
209
210 /**
211 * User changeable machine data.
212 *
213 * This data is common for all machine snapshots, i.e. it is shared
214 * by all SnapshotMachine instances associated with the given machine
215 * using the util::Backupable template through the |mUserData| variable.
216 *
217 * SessionMachine instances can alter this data and discard changes.
218 *
219 * @note There is no need to lock anything inside init() or uninit()
220 * methods, because they are always serialized (see AutoCaller).
221 */
222 struct UserData
223 {
224 UserData();
225 ~UserData();
226
227 Bstr mName;
228 BOOL mNameSync;
229 Bstr mDescription;
230 Bstr mOSTypeId;
231 Bstr mSnapshotFolder;
232 Bstr mSnapshotFolderFull;
233 BOOL mTeleporterEnabled;
234 ULONG mTeleporterPort;
235 Bstr mTeleporterAddress;
236 Bstr mTeleporterPassword;
237 BOOL mRTCUseUTC;
238 };
239
240 /**
241 * Hardware data.
242 *
243 * This data is unique for a machine and for every machine snapshot.
244 * Stored using the util::Backupable template in the |mHWData| variable.
245 *
246 * SessionMachine instances can alter this data and discard changes.
247 */
248 struct HWData
249 {
250 /**
251 * Data structure to hold information about a guest property.
252 */
253 struct GuestProperty {
254 /** Property name */
255 Utf8Str strName;
256 /** Property value */
257 Utf8Str strValue;
258 /** Property timestamp */
259 ULONG64 mTimestamp;
260 /** Property flags */
261 ULONG mFlags;
262 };
263
264 HWData();
265 ~HWData();
266
267 Bstr mHWVersion;
268 Guid mHardwareUUID; /**< If Null, use mData.mUuid. */
269 ULONG mMemorySize;
270 ULONG mMemoryBalloonSize;
271 ULONG mStatisticsUpdateInterval;
272 ULONG mVRAMSize;
273 ULONG mMonitorCount;
274 BOOL mHWVirtExEnabled;
275 BOOL mHWVirtExExclusive;
276 BOOL mHWVirtExNestedPagingEnabled;
277 BOOL mHWVirtExLargePagesEnabled;
278 BOOL mHWVirtExVPIDEnabled;
279 BOOL mAccelerate2DVideoEnabled;
280 BOOL mPAEEnabled;
281 BOOL mSyntheticCpu;
282 ULONG mCPUCount;
283 BOOL mCPUHotPlugEnabled;
284 BOOL mAccelerate3DEnabled;
285 BOOL mHpetEnabled;
286
287 BOOL mCPUAttached[SchemaDefs::MaxCPUCount];
288
289 settings::CpuIdLeaf mCpuIdStdLeafs[10];
290 settings::CpuIdLeaf mCpuIdExtLeafs[10];
291
292 DeviceType_T mBootOrder[SchemaDefs::MaxBootPosition];
293
294 typedef std::list< ComObjPtr<SharedFolder> > SharedFolderList;
295 SharedFolderList mSharedFolders;
296
297 ClipboardMode_T mClipboardMode;
298
299 typedef std::list<GuestProperty> GuestPropertyList;
300 GuestPropertyList mGuestProperties;
301 BOOL mPropertyServiceActive;
302 Utf8Str mGuestPropertyNotificationPatterns;
303
304 FirmwareType_T mFirmwareType;
305 KeyboardHidType_T mKeyboardHidType;
306 PointingHidType_T mPointingHidType;
307 };
308
309 /**
310 * Hard disk and other media data.
311 *
312 * The usage policy is the same as for HWData, but a separate structure
313 * is necessary because hard disk data requires different procedures when
314 * taking or discarding snapshots, etc.
315 *
316 * The data variable is |mMediaData|.
317 */
318 struct MediaData
319 {
320 MediaData();
321 ~MediaData();
322
323 typedef std::list< ComObjPtr<MediumAttachment> > AttachmentList;
324 AttachmentList mAttachments;
325 };
326
327 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Machine)
328
329 DECLARE_NOT_AGGREGATABLE(Machine)
330
331 DECLARE_PROTECT_FINAL_CONSTRUCT()
332
333 BEGIN_COM_MAP(Machine)
334 COM_INTERFACE_ENTRY(ISupportErrorInfo)
335 COM_INTERFACE_ENTRY(IMachine)
336 COM_INTERFACE_ENTRY(IDispatch)
337 END_COM_MAP()
338
339 DECLARE_EMPTY_CTOR_DTOR(Machine)
340
341 HRESULT FinalConstruct();
342 void FinalRelease();
343
344 // public initializer/uninitializer for internal purposes only
345 HRESULT init(VirtualBox *aParent,
346 const Utf8Str &strConfigFile,
347 InitMode aMode,
348 CBSTR aName = NULL,
349 GuestOSType *aOsType = NULL,
350 BOOL aNameSync = TRUE,
351 const Guid *aId = NULL);
352 void uninit();
353
354protected:
355 HRESULT initDataAndChildObjects();
356 void uninitDataAndChildObjects();
357
358public:
359 // IMachine properties
360 STDMETHOD(COMGETTER(Parent))(IVirtualBox **aParent);
361 STDMETHOD(COMGETTER(Accessible))(BOOL *aAccessible);
362 STDMETHOD(COMGETTER(AccessError))(IVirtualBoxErrorInfo **aAccessError);
363 STDMETHOD(COMGETTER(Name))(BSTR *aName);
364 STDMETHOD(COMSETTER(Name))(IN_BSTR aName);
365 STDMETHOD(COMGETTER(Description))(BSTR *aDescription);
366 STDMETHOD(COMSETTER(Description))(IN_BSTR aDescription);
367 STDMETHOD(COMGETTER(Id))(BSTR *aId);
368 STDMETHOD(COMGETTER(OSTypeId))(BSTR *aOSTypeId);
369 STDMETHOD(COMSETTER(OSTypeId))(IN_BSTR aOSTypeId);
370 STDMETHOD(COMGETTER(HardwareVersion))(BSTR *aVersion);
371 STDMETHOD(COMSETTER(HardwareVersion))(IN_BSTR aVersion);
372 STDMETHOD(COMGETTER(HardwareUUID))(BSTR *aUUID);
373 STDMETHOD(COMSETTER(HardwareUUID))(IN_BSTR aUUID);
374 STDMETHOD(COMGETTER(MemorySize))(ULONG *memorySize);
375 STDMETHOD(COMSETTER(MemorySize))(ULONG memorySize);
376 STDMETHOD(COMGETTER(CPUCount))(ULONG *cpuCount);
377 STDMETHOD(COMSETTER(CPUCount))(ULONG cpuCount);
378 STDMETHOD(COMGETTER(CPUHotPlugEnabled))(BOOL *enabled);
379 STDMETHOD(COMSETTER(CPUHotPlugEnabled))(BOOL enabled);
380 STDMETHOD(COMGETTER(HpetEnabled))(BOOL *enabled);
381 STDMETHOD(COMSETTER(HpetEnabled))(BOOL enabled);
382 STDMETHOD(COMGETTER(MemoryBalloonSize))(ULONG *memoryBalloonSize);
383 STDMETHOD(COMSETTER(MemoryBalloonSize))(ULONG memoryBalloonSize);
384 STDMETHOD(COMGETTER(StatisticsUpdateInterval))(ULONG *statisticsUpdateInterval);
385 STDMETHOD(COMSETTER(StatisticsUpdateInterval))(ULONG statisticsUpdateInterval);
386 STDMETHOD(COMGETTER(VRAMSize))(ULONG *memorySize);
387 STDMETHOD(COMSETTER(VRAMSize))(ULONG memorySize);
388 STDMETHOD(COMGETTER(MonitorCount))(ULONG *monitorCount);
389 STDMETHOD(COMSETTER(MonitorCount))(ULONG monitorCount);
390 STDMETHOD(COMGETTER(Accelerate3DEnabled))(BOOL *enabled);
391 STDMETHOD(COMSETTER(Accelerate3DEnabled))(BOOL enabled);
392 STDMETHOD(COMGETTER(Accelerate2DVideoEnabled))(BOOL *enabled);
393 STDMETHOD(COMSETTER(Accelerate2DVideoEnabled))(BOOL enabled);
394 STDMETHOD(COMGETTER(BIOSSettings))(IBIOSSettings **biosSettings);
395 STDMETHOD(COMGETTER(SnapshotFolder))(BSTR *aSavedStateFolder);
396 STDMETHOD(COMSETTER(SnapshotFolder))(IN_BSTR aSavedStateFolder);
397 STDMETHOD(COMGETTER(MediumAttachments))(ComSafeArrayOut(IMediumAttachment *, aAttachments));
398 STDMETHOD(COMGETTER(VRDPServer))(IVRDPServer **vrdpServer);
399 STDMETHOD(COMGETTER(AudioAdapter))(IAudioAdapter **audioAdapter);
400 STDMETHOD(COMGETTER(USBController))(IUSBController * *aUSBController);
401 STDMETHOD(COMGETTER(SettingsFilePath))(BSTR *aFilePath);
402 STDMETHOD(COMGETTER(SettingsModified))(BOOL *aModified);
403 STDMETHOD(COMGETTER(SessionState))(SessionState_T *aSessionState);
404 STDMETHOD(COMGETTER(SessionType))(BSTR *aSessionType);
405 STDMETHOD(COMGETTER(SessionPid))(ULONG *aSessionPid);
406 STDMETHOD(COMGETTER(State))(MachineState_T *machineState);
407 STDMETHOD(COMGETTER(LastStateChange))(LONG64 *aLastStateChange);
408 STDMETHOD(COMGETTER(StateFilePath))(BSTR *aStateFilePath);
409 STDMETHOD(COMGETTER(LogFolder))(BSTR *aLogFolder);
410 STDMETHOD(COMGETTER(CurrentSnapshot))(ISnapshot **aCurrentSnapshot);
411 STDMETHOD(COMGETTER(SnapshotCount))(ULONG *aSnapshotCount);
412 STDMETHOD(COMGETTER(CurrentStateModified))(BOOL *aCurrentStateModified);
413 STDMETHOD(COMGETTER(SharedFolders))(ComSafeArrayOut(ISharedFolder *, aSharedFolders));
414 STDMETHOD(COMGETTER(ClipboardMode))(ClipboardMode_T *aClipboardMode);
415 STDMETHOD(COMSETTER(ClipboardMode))(ClipboardMode_T aClipboardMode);
416 STDMETHOD(COMGETTER(GuestPropertyNotificationPatterns))(BSTR *aPattern);
417 STDMETHOD(COMSETTER(GuestPropertyNotificationPatterns))(IN_BSTR aPattern);
418 STDMETHOD(COMGETTER(StorageControllers))(ComSafeArrayOut(IStorageController *, aStorageControllers));
419 STDMETHOD(COMGETTER(TeleporterEnabled))(BOOL *aEnabled);
420 STDMETHOD(COMSETTER(TeleporterEnabled))(BOOL aEnabled);
421 STDMETHOD(COMGETTER(TeleporterPort))(ULONG *aPort);
422 STDMETHOD(COMSETTER(TeleporterPort))(ULONG aPort);
423 STDMETHOD(COMGETTER(TeleporterAddress))(BSTR *aAddress);
424 STDMETHOD(COMSETTER(TeleporterAddress))(IN_BSTR aAddress);
425 STDMETHOD(COMGETTER(TeleporterPassword))(BSTR *aPassword);
426 STDMETHOD(COMSETTER(TeleporterPassword))(IN_BSTR aPassword);
427 STDMETHOD(COMGETTER(RTCUseUTC))(BOOL *aEnabled);
428 STDMETHOD(COMSETTER(RTCUseUTC))(BOOL aEnabled);
429 STDMETHOD(COMGETTER(FirmwareType)) (FirmwareType_T *aFirmware);
430 STDMETHOD(COMSETTER(FirmwareType)) (FirmwareType_T aFirmware);
431 STDMETHOD(COMGETTER(KeyboardHidType)) (KeyboardHidType_T *aKeyboardHidType);
432 STDMETHOD(COMSETTER(KeyboardHidType)) (KeyboardHidType_T aKeyboardHidType);
433 STDMETHOD(COMGETTER(PointingHidType)) (PointingHidType_T *aPointingHidType);
434 STDMETHOD(COMSETTER(PointingHidType)) (PointingHidType_T aPointingHidType);
435
436 // IMachine methods
437 STDMETHOD(SetBootOrder)(ULONG aPosition, DeviceType_T aDevice);
438 STDMETHOD(GetBootOrder)(ULONG aPosition, DeviceType_T *aDevice);
439 STDMETHOD(AttachDevice)(IN_BSTR aControllerName, LONG aControllerPort,
440 LONG aDevice, DeviceType_T aType, IN_BSTR aId);
441 STDMETHOD(DetachDevice)(IN_BSTR aControllerName, LONG aControllerPort, LONG aDevice);
442 STDMETHOD(PassthroughDevice)(IN_BSTR aControllerName, LONG aControllerPort, LONG aDevice, BOOL aPassthrough);
443 STDMETHOD(MountMedium)(IN_BSTR aControllerName, LONG aControllerPort,
444 LONG aDevice, IN_BSTR aId, BOOL aForce);
445 STDMETHOD(GetMedium)(IN_BSTR aControllerName, LONG aControllerPort, LONG aDevice,
446 IMedium **aMedium);
447 STDMETHOD(GetSerialPort)(ULONG slot, ISerialPort **port);
448 STDMETHOD(GetParallelPort)(ULONG slot, IParallelPort **port);
449 STDMETHOD(GetNetworkAdapter)(ULONG slot, INetworkAdapter **adapter);
450 STDMETHOD(GetExtraDataKeys)(ComSafeArrayOut(BSTR, aKeys));
451 STDMETHOD(GetExtraData)(IN_BSTR aKey, BSTR *aValue);
452 STDMETHOD(SetExtraData)(IN_BSTR aKey, IN_BSTR aValue);
453 STDMETHOD(GetCpuProperty)(CpuPropertyType_T property, BOOL *aVal);
454 STDMETHOD(SetCpuProperty)(CpuPropertyType_T property, BOOL aVal);
455 STDMETHOD(GetCpuIdLeaf)(ULONG id, ULONG *aValEax, ULONG *aValEbx, ULONG *aValEcx, ULONG *aValEdx);
456 STDMETHOD(SetCpuIdLeaf)(ULONG id, ULONG aValEax, ULONG aValEbx, ULONG aValEcx, ULONG aValEdx);
457 STDMETHOD(RemoveCpuIdLeaf)(ULONG id);
458 STDMETHOD(RemoveAllCpuIdLeafs)();
459 STDMETHOD(GetHWVirtExProperty)(HWVirtExPropertyType_T property, BOOL *aVal);
460 STDMETHOD(SetHWVirtExProperty)(HWVirtExPropertyType_T property, BOOL aVal);
461 STDMETHOD(SaveSettings)();
462 STDMETHOD(DiscardSettings)();
463 STDMETHOD(DeleteSettings)();
464 STDMETHOD(Export)(IAppliance *aAppliance, IVirtualSystemDescription **aDescription);
465 STDMETHOD(GetSnapshot)(IN_BSTR aId, ISnapshot **aSnapshot);
466 STDMETHOD(FindSnapshot)(IN_BSTR aName, ISnapshot **aSnapshot);
467 STDMETHOD(SetCurrentSnapshot)(IN_BSTR aId);
468 STDMETHOD(CreateSharedFolder)(IN_BSTR aName, IN_BSTR aHostPath, BOOL aWritable);
469 STDMETHOD(RemoveSharedFolder)(IN_BSTR aName);
470 STDMETHOD(CanShowConsoleWindow)(BOOL *aCanShow);
471 STDMETHOD(ShowConsoleWindow)(ULONG64 *aWinId);
472 STDMETHOD(GetGuestProperty)(IN_BSTR aName, BSTR *aValue, ULONG64 *aTimestamp, BSTR *aFlags);
473 STDMETHOD(GetGuestPropertyValue)(IN_BSTR aName, BSTR *aValue);
474 STDMETHOD(GetGuestPropertyTimestamp)(IN_BSTR aName, ULONG64 *aTimestamp);
475 STDMETHOD(SetGuestProperty)(IN_BSTR aName, IN_BSTR aValue, IN_BSTR aFlags);
476 STDMETHOD(SetGuestPropertyValue)(IN_BSTR aName, IN_BSTR aValue);
477 STDMETHOD(EnumerateGuestProperties)(IN_BSTR aPattern, ComSafeArrayOut(BSTR, aNames), ComSafeArrayOut(BSTR, aValues), ComSafeArrayOut(ULONG64, aTimestamps), ComSafeArrayOut(BSTR, aFlags));
478 STDMETHOD(GetMediumAttachmentsOfController)(IN_BSTR aName, ComSafeArrayOut(IMediumAttachment *, aAttachments));
479 STDMETHOD(GetMediumAttachment)(IN_BSTR aConstrollerName, LONG aControllerPort, LONG aDevice, IMediumAttachment **aAttachment);
480 STDMETHOD(AddStorageController)(IN_BSTR aName, StorageBus_T aConnectionType, IStorageController **controller);
481 STDMETHOD(RemoveStorageController(IN_BSTR aName));
482 STDMETHOD(GetStorageControllerByName(IN_BSTR aName, IStorageController **storageController));
483 STDMETHOD(GetStorageControllerByInstance(ULONG aInstance, IStorageController **storageController));
484 STDMETHOD(QuerySavedThumbnailSize)(ULONG *aSize, ULONG *aWidth, ULONG *aHeight);
485 STDMETHOD(ReadSavedThumbnailToArray)(BOOL aBGR, ULONG *aWidth, ULONG *aHeight, ComSafeArrayOut(BYTE, aData));
486 STDMETHOD(QuerySavedScreenshotPNGSize)(ULONG *aSize, ULONG *aWidth, ULONG *aHeight);
487 STDMETHOD(ReadSavedScreenshotPNGToArray)(ULONG *aWidth, ULONG *aHeight, ComSafeArrayOut(BYTE, aData));
488 STDMETHOD(HotPlugCPU(ULONG aCpu));
489 STDMETHOD(HotUnplugCPU(ULONG aCpu));
490 STDMETHOD(GetCPUStatus(ULONG aCpu, BOOL *aCpuAttached));
491
492 // public methods only for internal purposes
493
494 /**
495 * Simple run-time type identification without having to enable C++ RTTI.
496 * The class IDs are defined in VirtualBoxBase.h.
497 * @return
498 */
499 virtual VBoxClsID getClassID() const
500 {
501 return clsidMachine;
502 }
503
504 /**
505 * Override of the default locking class to be used for validating lock
506 * order with the standard member lock handle.
507 */
508 virtual VBoxLockingClass getLockingClass() const
509 {
510 return LOCKCLASS_MACHINEOBJECT;
511 }
512
513 /// @todo (dmik) add lock and make non-inlined after revising classes
514 // that use it. Note: they should enter Machine lock to keep the returned
515 // information valid!
516 bool isRegistered() { return !!mData->mRegistered; }
517
518 // unsafe inline public methods for internal purposes only (ensure there is
519 // a caller and a read lock before calling them!)
520
521 /**
522 * Returns the VirtualBox object this machine belongs to.
523 *
524 * @note This method doesn't check this object's readiness. Intended to be
525 * used by ready Machine children (whose readiness is bound to the parent's
526 * one) or after doing addCaller() manually.
527 */
528 const ComObjPtr<VirtualBox, ComWeakRef>& getVirtualBox() const { return mParent; }
529
530 /**
531 * Returns this machine ID.
532 *
533 * @note This method doesn't check this object's readiness. Intended to be
534 * used by ready Machine children (whose readiness is bound to the parent's
535 * one) or after adding a caller manually.
536 */
537 const Guid& getId() const { return mData->mUuid; }
538
539 /**
540 * Returns the snapshot ID this machine represents or an empty UUID if this
541 * instance is not SnapshotMachine.
542 *
543 * @note This method doesn't check this object's readiness. Intended to be
544 * used by ready Machine children (whose readiness is bound to the parent's
545 * one) or after adding a caller manually.
546 */
547 inline const Guid& getSnapshotId() const;
548
549 /**
550 * Returns this machine's full settings file path.
551 *
552 * @note This method doesn't lock this object or check its readiness.
553 * Intended to be used only after doing addCaller() manually and locking it
554 * for reading.
555 */
556 const Utf8Str& getSettingsFileFull() const { return mData->m_strConfigFileFull; }
557
558 /**
559 * Returns this machine name.
560 *
561 * @note This method doesn't lock this object or check its readiness.
562 * Intended to be used only after doing addCaller() manually and locking it
563 * for reading.
564 */
565 const Bstr& getName() const { return mUserData->mName; }
566
567 enum
568 {
569 IsModified_MachineData = 0x0001,
570 IsModified_Storage = 0x0002,
571 IsModified_NetworkAdapters = 0x0008,
572 IsModified_SerialPorts = 0x0010,
573 IsModified_ParallelPorts = 0x0020,
574 IsModified_VRDPServer = 0x0040,
575 IsModified_AudioAdapter = 0x0080,
576 IsModified_USB = 0x0100,
577 IsModified_BIOS = 0x0200,
578 IsModified_SharedFolders = 0x0400
579 };
580
581 void setModified(uint32_t fl);
582
583 // callback handlers
584 virtual HRESULT onNetworkAdapterChange(INetworkAdapter * /* networkAdapter */, BOOL /* changeAdapter */) { return S_OK; }
585 virtual HRESULT onSerialPortChange(ISerialPort * /* serialPort */) { return S_OK; }
586 virtual HRESULT onParallelPortChange(IParallelPort * /* parallelPort */) { return S_OK; }
587 virtual HRESULT onVRDPServerChange() { return S_OK; }
588 virtual HRESULT onUSBControllerChange() { return S_OK; }
589 virtual HRESULT onStorageControllerChange() { return S_OK; }
590 virtual HRESULT onCPUChange(ULONG /* aCPU */, BOOL /* aRemove */) { return S_OK; }
591 virtual HRESULT onMediumChange(IMediumAttachment * /* mediumAttachment */, BOOL /* force */) { return S_OK; }
592 virtual HRESULT onSharedFolderChange() { return S_OK; }
593
594 HRESULT saveRegistryEntry(settings::MachineRegistryEntry &data);
595
596 int calculateFullPath(const Utf8Str &strPath, Utf8Str &aResult);
597 void calculateRelativePath(const Utf8Str &strPath, Utf8Str &aResult);
598
599 void getLogFolder(Utf8Str &aLogFolder);
600
601 HRESULT openSession(IInternalSessionControl *aControl);
602 HRESULT openRemoteSession(IInternalSessionControl *aControl,
603 IN_BSTR aType, IN_BSTR aEnvironment,
604 Progress *aProgress);
605 HRESULT openExistingSession(IInternalSessionControl *aControl);
606
607#if defined(RT_OS_WINDOWS)
608
609 bool isSessionOpen(ComObjPtr<SessionMachine> &aMachine,
610 ComPtr<IInternalSessionControl> *aControl = NULL,
611 HANDLE *aIPCSem = NULL, bool aAllowClosing = false);
612 bool isSessionSpawning(RTPROCESS *aPID = NULL);
613
614 bool isSessionOpenOrClosing(ComObjPtr<SessionMachine> &aMachine,
615 ComPtr<IInternalSessionControl> *aControl = NULL,
616 HANDLE *aIPCSem = NULL)
617 { return isSessionOpen(aMachine, aControl, aIPCSem, true /* aAllowClosing */); }
618
619#elif defined(RT_OS_OS2)
620
621 bool isSessionOpen(ComObjPtr<SessionMachine> &aMachine,
622 ComPtr<IInternalSessionControl> *aControl = NULL,
623 HMTX *aIPCSem = NULL, bool aAllowClosing = false);
624
625 bool isSessionSpawning(RTPROCESS *aPID = NULL);
626
627 bool isSessionOpenOrClosing(ComObjPtr<SessionMachine> &aMachine,
628 ComPtr<IInternalSessionControl> *aControl = NULL,
629 HMTX *aIPCSem = NULL)
630 { return isSessionOpen(aMachine, aControl, aIPCSem, true /* aAllowClosing */); }
631
632#else
633
634 bool isSessionOpen(ComObjPtr<SessionMachine> &aMachine,
635 ComPtr<IInternalSessionControl> *aControl = NULL,
636 bool aAllowClosing = false);
637 bool isSessionSpawning();
638
639 bool isSessionOpenOrClosing(ComObjPtr<SessionMachine> &aMachine,
640 ComPtr<IInternalSessionControl> *aControl = NULL)
641 { return isSessionOpen(aMachine, aControl, true /* aAllowClosing */); }
642
643#endif
644
645 bool checkForSpawnFailure();
646
647 HRESULT trySetRegistered(BOOL aRegistered);
648
649 HRESULT getSharedFolder(CBSTR aName,
650 ComObjPtr<SharedFolder> &aSharedFolder,
651 bool aSetError = false)
652 {
653 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
654 return findSharedFolder(aName, aSharedFolder, aSetError);
655 }
656
657 HRESULT addStateDependency(StateDependency aDepType = AnyStateDep,
658 MachineState_T *aState = NULL,
659 BOOL *aRegistered = NULL);
660 void releaseStateDependency();
661
662 // for VirtualBoxSupportErrorInfoImpl
663 static const wchar_t *getComponentName() { return L"Machine"; }
664
665protected:
666
667 HRESULT registeredInit();
668
669 HRESULT checkStateDependency(StateDependency aDepType);
670
671 inline Machine *getMachine();
672
673 void ensureNoStateDependencies();
674
675 virtual HRESULT setMachineState(MachineState_T aMachineState);
676
677 HRESULT findSharedFolder(CBSTR aName,
678 ComObjPtr<SharedFolder> &aSharedFolder,
679 bool aSetError = false);
680
681 HRESULT loadSettings(bool aRegistered);
682 HRESULT loadSnapshot(const settings::Snapshot &data,
683 const Guid &aCurSnapshotId,
684 Snapshot *aParentSnapshot);
685 HRESULT loadHardware(const settings::Hardware &data);
686 HRESULT loadStorageControllers(const settings::Storage &data,
687 bool aRegistered,
688 const Guid *aSnapshotId = NULL);
689 HRESULT loadStorageDevices(StorageController *aStorageController,
690 const settings::StorageController &data,
691 bool aRegistered,
692 const Guid *aSnapshotId = NULL);
693
694 HRESULT findSnapshot(const Guid &aId, ComObjPtr<Snapshot> &aSnapshot,
695 bool aSetError = false);
696 HRESULT findSnapshot(IN_BSTR aName, ComObjPtr<Snapshot> &aSnapshot,
697 bool aSetError = false);
698
699 HRESULT getStorageControllerByName(const Utf8Str &aName,
700 ComObjPtr<StorageController> &aStorageController,
701 bool aSetError = false);
702
703 HRESULT getMediumAttachmentsOfController(CBSTR aName,
704 MediaData::AttachmentList &aAttachments);
705
706 enum
707 {
708 /* flags for #saveSettings() */
709 SaveS_ResetCurStateModified = 0x01,
710 SaveS_InformCallbacksAnyway = 0x02,
711 /* flags for #saveSnapshotSettings() */
712 SaveSS_CurStateModified = 0x40,
713 SaveSS_CurrentId = 0x80,
714 /* flags for #saveStateSettings() */
715 SaveSTS_CurStateModified = 0x20,
716 SaveSTS_StateFilePath = 0x40,
717 SaveSTS_StateTimeStamp = 0x80,
718 };
719
720 HRESULT prepareSaveSettings(bool &aRenamed, bool &aNew);
721 HRESULT saveSettings(int aFlags = 0);
722
723 HRESULT saveAllSnapshots();
724
725 HRESULT saveHardware(settings::Hardware &data);
726 HRESULT saveStorageControllers(settings::Storage &data);
727 HRESULT saveStorageDevices(ComObjPtr<StorageController> aStorageController,
728 settings::StorageController &data);
729
730 HRESULT saveStateSettings(int aFlags);
731
732 HRESULT createImplicitDiffs(const Bstr &aFolder,
733 IProgress *aProgress,
734 ULONG aWeight,
735 bool aOnline,
736 bool *pfNeedsSaveSettings);
737 HRESULT deleteImplicitDiffs(bool *pfNeedsSaveSettings);
738
739 MediumAttachment* findAttachment(const MediaData::AttachmentList &ll,
740 IN_BSTR aControllerName,
741 LONG aControllerPort,
742 LONG aDevice);
743 MediumAttachment* findAttachment(const MediaData::AttachmentList &ll,
744 ComObjPtr<Medium> pMedium);
745 MediumAttachment* findAttachment(const MediaData::AttachmentList &ll,
746 Guid &id);
747
748 void commitMedia(bool aOnline = false);
749 void rollbackMedia();
750
751 bool isInOwnDir(Utf8Str *aSettingsDir = NULL);
752
753 void rollback(bool aNotify);
754 void commit();
755 void copyFrom(Machine *aThat);
756
757#ifdef VBOX_WITH_RESOURCE_USAGE_API
758 void registerMetrics(PerformanceCollector *aCollector, Machine *aMachine, RTPROCESS pid);
759 void unregisterMetrics(PerformanceCollector *aCollector, Machine *aMachine);
760#endif /* VBOX_WITH_RESOURCE_USAGE_API */
761
762 const ComObjPtr<Machine, ComWeakRef> mPeer;
763
764 const ComObjPtr<VirtualBox, ComWeakRef> mParent;
765
766 uint32_t m_flModifications;
767
768 Shareable<Data> mData;
769 Shareable<SSData> mSSData;
770
771 Backupable<UserData> mUserData;
772 Backupable<HWData> mHWData;
773 Backupable<MediaData> mMediaData;
774
775 // the following fields need special backup/rollback/commit handling,
776 // so they cannot be a part of HWData
777
778 const ComObjPtr<VRDPServer> mVRDPServer;
779 const ComObjPtr<SerialPort> mSerialPorts[SchemaDefs::SerialPortCount];
780 const ComObjPtr<ParallelPort> mParallelPorts[SchemaDefs::ParallelPortCount];
781 const ComObjPtr<AudioAdapter> mAudioAdapter;
782 const ComObjPtr<USBController> mUSBController;
783 const ComObjPtr<BIOSSettings> mBIOSSettings;
784 const ComObjPtr<NetworkAdapter> mNetworkAdapters[SchemaDefs::NetworkAdapterCount];
785
786 typedef std::list< ComObjPtr<StorageController> > StorageControllerList;
787 Backupable<StorageControllerList> mStorageControllers;
788
789 friend class SessionMachine;
790 friend class SnapshotMachine;
791};
792
793// SessionMachine class
794////////////////////////////////////////////////////////////////////////////////
795
796/**
797 * @note Notes on locking objects of this class:
798 * SessionMachine shares some data with the primary Machine instance (pointed
799 * to by the |mPeer| member). In order to provide data consistency it also
800 * shares its lock handle. This means that whenever you lock a SessionMachine
801 * instance using Auto[Reader]Lock or AutoMultiLock, the corresponding Machine
802 * instance is also locked in the same lock mode. Keep it in mind.
803 */
804class ATL_NO_VTABLE SessionMachine :
805 public VirtualBoxSupportTranslation<SessionMachine>,
806 public Machine,
807 VBOX_SCRIPTABLE_IMPL(IInternalMachineControl)
808{
809public:
810
811 VIRTUALBOXSUPPORTTRANSLATION_OVERRIDE(SessionMachine)
812
813 DECLARE_NOT_AGGREGATABLE(SessionMachine)
814
815 DECLARE_PROTECT_FINAL_CONSTRUCT()
816
817 BEGIN_COM_MAP(SessionMachine)
818 COM_INTERFACE_ENTRY2(IDispatch, IMachine)
819 COM_INTERFACE_ENTRY(ISupportErrorInfo)
820 COM_INTERFACE_ENTRY(IMachine)
821 COM_INTERFACE_ENTRY(IInternalMachineControl)
822 END_COM_MAP()
823
824 DECLARE_EMPTY_CTOR_DTOR(SessionMachine)
825
826 HRESULT FinalConstruct();
827 void FinalRelease();
828
829 // public initializer/uninitializer for internal purposes only
830 HRESULT init(Machine *aMachine);
831 void uninit() { uninit(Uninit::Unexpected); }
832
833 // util::Lockable interface
834 RWLockHandle *lockHandle() const;
835
836 // IInternalMachineControl methods
837 STDMETHOD(SetRemoveSavedState)(BOOL aRemove);
838 STDMETHOD(UpdateState)(MachineState_T machineState);
839 STDMETHOD(GetIPCId)(BSTR *id);
840 STDMETHOD(SetPowerUpInfo)(IVirtualBoxErrorInfo *aError);
841 STDMETHOD(RunUSBDeviceFilters)(IUSBDevice *aUSBDevice, BOOL *aMatched, ULONG *aMaskedIfs);
842 STDMETHOD(CaptureUSBDevice)(IN_BSTR aId);
843 STDMETHOD(DetachUSBDevice)(IN_BSTR aId, BOOL aDone);
844 STDMETHOD(AutoCaptureUSBDevices)();
845 STDMETHOD(DetachAllUSBDevices)(BOOL aDone);
846 STDMETHOD(OnSessionEnd)(ISession *aSession, IProgress **aProgress);
847 STDMETHOD(BeginSavingState)(IProgress *aProgress, BSTR *aStateFilePath);
848 STDMETHOD(EndSavingState)(BOOL aSuccess);
849 STDMETHOD(AdoptSavedState)(IN_BSTR aSavedStateFile);
850 STDMETHOD(BeginTakingSnapshot)(IConsole *aInitiator,
851 IN_BSTR aName,
852 IN_BSTR aDescription,
853 IProgress *aConsoleProgress,
854 BOOL fTakingSnapshotOnline,
855 BSTR *aStateFilePath);
856 STDMETHOD(EndTakingSnapshot)(BOOL aSuccess);
857 STDMETHOD(DeleteSnapshot)(IConsole *aInitiator, IN_BSTR aId,
858 MachineState_T *aMachineState, IProgress **aProgress);
859 STDMETHOD(RestoreSnapshot)(IConsole *aInitiator,
860 ISnapshot *aSnapshot,
861 MachineState_T *aMachineState,
862 IProgress **aProgress);
863 STDMETHOD(PullGuestProperties)(ComSafeArrayOut(BSTR, aNames), ComSafeArrayOut(BSTR, aValues),
864 ComSafeArrayOut(ULONG64, aTimestamps), ComSafeArrayOut(BSTR, aFlags));
865 STDMETHOD(PushGuestProperties)(ComSafeArrayIn(IN_BSTR, aNames), ComSafeArrayIn(IN_BSTR, aValues),
866 ComSafeArrayIn(ULONG64, aTimestamps), ComSafeArrayIn(IN_BSTR, aFlags));
867 STDMETHOD(PushGuestProperty)(IN_BSTR aName, IN_BSTR aValue,
868 ULONG64 aTimestamp, IN_BSTR aFlags);
869 STDMETHOD(LockMedia)() { return lockMedia(); }
870 STDMETHOD(UnlockMedia)() { unlockMedia(); return S_OK; }
871
872 // public methods only for internal purposes
873
874 /**
875 * Simple run-time type identification without having to enable C++ RTTI.
876 * The class IDs are defined in VirtualBoxBase.h.
877 * @return
878 */
879 virtual VBoxClsID getClassID() const
880 {
881 return clsidSessionMachine;
882 }
883
884 bool checkForDeath();
885
886 HRESULT onNetworkAdapterChange(INetworkAdapter *networkAdapter, BOOL changeAdapter);
887 HRESULT onStorageControllerChange();
888 HRESULT onMediumChange(IMediumAttachment *aMediumAttachment, BOOL aForce);
889 HRESULT onSerialPortChange(ISerialPort *serialPort);
890 HRESULT onParallelPortChange(IParallelPort *parallelPort);
891 HRESULT onCPUChange(ULONG aCPU, BOOL aRemove);
892 HRESULT onVRDPServerChange();
893 HRESULT onUSBControllerChange();
894 HRESULT onUSBDeviceAttach(IUSBDevice *aDevice,
895 IVirtualBoxErrorInfo *aError,
896 ULONG aMaskedIfs);
897 HRESULT onUSBDeviceDetach(IN_BSTR aId,
898 IVirtualBoxErrorInfo *aError);
899 HRESULT onSharedFolderChange();
900
901 bool hasMatchingUSBFilter(const ComObjPtr<HostUSBDevice> &aDevice, ULONG *aMaskedIfs);
902
903private:
904
905 struct SnapshotData
906 {
907 SnapshotData() : mLastState(MachineState_Null) {}
908
909 MachineState_T mLastState;
910
911 // used when taking snapshot
912 ComObjPtr<Snapshot> mSnapshot;
913
914 // used when saving state
915 Guid mProgressId;
916 Utf8Str mStateFilePath;
917 };
918
919 struct Uninit
920 {
921 enum Reason { Unexpected, Abnormal, Normal };
922 };
923
924 struct SnapshotTask;
925 struct DeleteSnapshotTask;
926 struct RestoreSnapshotTask;
927
928 friend struct DeleteSnapshotTask;
929 friend struct RestoreSnapshotTask;
930
931 void uninit(Uninit::Reason aReason);
932
933 HRESULT endSavingState(BOOL aSuccess);
934
935 typedef std::map<ComObjPtr<Machine>, MachineState_T> AffectedMachines;
936
937 void deleteSnapshotHandler(DeleteSnapshotTask &aTask);
938 void restoreSnapshotHandler(RestoreSnapshotTask &aTask);
939
940 HRESULT lockMedia();
941 void unlockMedia();
942
943 HRESULT setMachineState(MachineState_T aMachineState);
944 HRESULT updateMachineStateOnClient();
945
946 HRESULT mRemoveSavedState;
947
948 SnapshotData mSnapshotData;
949
950 /** interprocess semaphore handle for this machine */
951#if defined(RT_OS_WINDOWS)
952 HANDLE mIPCSem;
953 Bstr mIPCSemName;
954 friend bool Machine::isSessionOpen(ComObjPtr<SessionMachine> &aMachine,
955 ComPtr<IInternalSessionControl> *aControl,
956 HANDLE *aIPCSem, bool aAllowClosing);
957#elif defined(RT_OS_OS2)
958 HMTX mIPCSem;
959 Bstr mIPCSemName;
960 friend bool Machine::isSessionOpen(ComObjPtr<SessionMachine> &aMachine,
961 ComPtr<IInternalSessionControl> *aControl,
962 HMTX *aIPCSem, bool aAllowClosing);
963#elif defined(VBOX_WITH_SYS_V_IPC_SESSION_WATCHER)
964 int mIPCSem;
965# ifdef VBOX_WITH_NEW_SYS_V_KEYGEN
966 Bstr mIPCKey;
967# endif /*VBOX_WITH_NEW_SYS_V_KEYGEN */
968#else
969# error "Port me!"
970#endif
971
972 static DECLCALLBACK(int) taskHandler(RTTHREAD thread, void *pvUser);
973};
974
975// SnapshotMachine class
976////////////////////////////////////////////////////////////////////////////////
977
978/**
979 * @note Notes on locking objects of this class:
980 * SnapshotMachine shares some data with the primary Machine instance (pointed
981 * to by the |mPeer| member). In order to provide data consistency it also
982 * shares its lock handle. This means that whenever you lock a SessionMachine
983 * instance using Auto[Reader]Lock or AutoMultiLock, the corresponding Machine
984 * instance is also locked in the same lock mode. Keep it in mind.
985 */
986class ATL_NO_VTABLE SnapshotMachine :
987 public VirtualBoxSupportTranslation<SnapshotMachine>,
988 public Machine
989{
990public:
991
992 VIRTUALBOXSUPPORTTRANSLATION_OVERRIDE(SnapshotMachine)
993
994 DECLARE_NOT_AGGREGATABLE(SnapshotMachine)
995
996 DECLARE_PROTECT_FINAL_CONSTRUCT()
997
998 BEGIN_COM_MAP(SnapshotMachine)
999 COM_INTERFACE_ENTRY2(IDispatch, IMachine)
1000 COM_INTERFACE_ENTRY(ISupportErrorInfo)
1001 COM_INTERFACE_ENTRY(IMachine)
1002 END_COM_MAP()
1003
1004 DECLARE_EMPTY_CTOR_DTOR(SnapshotMachine)
1005
1006 HRESULT FinalConstruct();
1007 void FinalRelease();
1008
1009 // public initializer/uninitializer for internal purposes only
1010 HRESULT init(SessionMachine *aSessionMachine,
1011 IN_GUID aSnapshotId,
1012 const Utf8Str &aStateFilePath);
1013 HRESULT init(Machine *aMachine,
1014 const settings::Hardware &hardware,
1015 const settings::Storage &storage,
1016 IN_GUID aSnapshotId,
1017 const Utf8Str &aStateFilePath);
1018 void uninit();
1019
1020 // util::Lockable interface
1021 RWLockHandle *lockHandle() const;
1022
1023 // public methods only for internal purposes
1024
1025 /**
1026 * Simple run-time type identification without having to enable C++ RTTI.
1027 * The class IDs are defined in VirtualBoxBase.h.
1028 * @return
1029 */
1030 virtual VBoxClsID getClassID() const
1031 {
1032 return clsidSnapshotMachine;
1033 }
1034
1035 HRESULT onSnapshotChange(Snapshot *aSnapshot);
1036
1037 // unsafe inline public methods for internal purposes only (ensure there is
1038 // a caller and a read lock before calling them!)
1039
1040 const Guid& getSnapshotId() const { return mSnapshotId; }
1041
1042private:
1043
1044 Guid mSnapshotId;
1045
1046 friend class Snapshot;
1047};
1048
1049// third party methods that depend on SnapshotMachine definiton
1050
1051inline const Guid &Machine::getSnapshotId() const
1052{
1053 return getClassID() != clsidSnapshotMachine
1054 ? Guid::Empty
1055 : static_cast<const SnapshotMachine*>(this)->getSnapshotId();
1056}
1057
1058////////////////////////////////////////////////////////////////////////////////
1059
1060/**
1061 * Returns a pointer to the Machine object for this machine that acts like a
1062 * parent for complex machine data objects such as shared folders, etc.
1063 *
1064 * For primary Machine objects and for SnapshotMachine objects, returns this
1065 * object's pointer itself. For SessoinMachine objects, returns the peer
1066 * (primary) machine pointer.
1067 */
1068inline Machine *Machine::getMachine()
1069{
1070 if (getClassID() == clsidSessionMachine)
1071 return mPeer;
1072 return this;
1073}
1074
1075
1076#endif // ____H_MACHINEIMPL
1077/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette