1 | /* $Id: Global.h 26333 2010-02-08 18:48:39Z vboxsync $ */
|
---|
2 |
|
---|
3 | /** @file
|
---|
4 | *
|
---|
5 | * VirtualBox COM global declarations
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * Copyright (C) 2008 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_GLOBAL
|
---|
25 | #define ____H_GLOBAL
|
---|
26 |
|
---|
27 | /* generated header */
|
---|
28 | #include "SchemaDefs.h"
|
---|
29 |
|
---|
30 | /* interface definitions */
|
---|
31 | #include "VBox/com/VirtualBox.h"
|
---|
32 |
|
---|
33 | #include <VBox/ostypes.h>
|
---|
34 |
|
---|
35 | #include <iprt/types.h>
|
---|
36 |
|
---|
37 | #define VBOXOSHINT_NONE 0
|
---|
38 | #define VBOXOSHINT_64BIT RT_BIT(0)
|
---|
39 | #define VBOXOSHINT_HWVIRTEX RT_BIT(1)
|
---|
40 | #define VBOXOSHINT_IOAPIC RT_BIT(2)
|
---|
41 | #define VBOXOSHINT_EFI RT_BIT(3)
|
---|
42 | #define VBOXOSHINT_EXTHW RT_BIT(4)
|
---|
43 |
|
---|
44 | /**
|
---|
45 | * Contains global static definitions that can be referenced by all COM classes
|
---|
46 | * regardless of the apartment.
|
---|
47 | */
|
---|
48 | class Global
|
---|
49 | {
|
---|
50 | public:
|
---|
51 |
|
---|
52 | /** Represents OS Type <-> string mappings. */
|
---|
53 | struct OSType
|
---|
54 | {
|
---|
55 | const char *familyId; /* utf-8 */
|
---|
56 | const char *familyDescription; /* utf-8 */
|
---|
57 | const char *id; /* utf-8 */
|
---|
58 | const char *description; /* utf-8 */
|
---|
59 | const VBOXOSTYPE osType;
|
---|
60 | const uint32_t osHint;
|
---|
61 | const uint32_t recommendedRAM;
|
---|
62 | const uint32_t recommendedVRAM;
|
---|
63 | const uint32_t recommendedHDD;
|
---|
64 | const NetworkAdapterType_T networkAdapterType;
|
---|
65 | const uint32_t numSerialEnabled;
|
---|
66 | };
|
---|
67 |
|
---|
68 | static const OSType sOSTypes[SchemaDefs::OSTypeId_COUNT];
|
---|
69 |
|
---|
70 | static const char *OSTypeId(VBOXOSTYPE aOSType);
|
---|
71 |
|
---|
72 | /**
|
---|
73 | * Returns @c true if the given machine state is an online state. This is a
|
---|
74 | * recommended way to detect if the VM is online (being executed in a
|
---|
75 | * dedicated process) or not. Note that some online states are also
|
---|
76 | * transitional states (see #IsTransitional()).
|
---|
77 | *
|
---|
78 | * @remarks Saving may actually be an offline state according to the
|
---|
79 | * documentation (offline snapshot).
|
---|
80 | */
|
---|
81 | static bool IsOnline(MachineState_T aState)
|
---|
82 | {
|
---|
83 | #if 0
|
---|
84 | return aState >= MachineState_FirstOnline &&
|
---|
85 | aState <= MachineState_LastOnline;
|
---|
86 | #else
|
---|
87 | switch (aState)
|
---|
88 | {
|
---|
89 | case MachineState_Running:
|
---|
90 | case MachineState_Paused:
|
---|
91 | case MachineState_Teleporting:
|
---|
92 | case MachineState_LiveSnapshotting:
|
---|
93 | case MachineState_Stuck:
|
---|
94 | case MachineState_Starting:
|
---|
95 | case MachineState_Stopping:
|
---|
96 | case MachineState_Saving:
|
---|
97 | case MachineState_Restoring:
|
---|
98 | case MachineState_TeleportingPausedVM:
|
---|
99 | case MachineState_TeleportingIn:
|
---|
100 | return true;
|
---|
101 | default:
|
---|
102 | return false;
|
---|
103 | }
|
---|
104 | #endif
|
---|
105 | }
|
---|
106 |
|
---|
107 | /**
|
---|
108 | * Returns @c true if the given machine state is a transient state. This is
|
---|
109 | * a recommended way to detect if the VM is performing some potentially
|
---|
110 | * lengthy operation (such as starting, stopping, saving, discarding
|
---|
111 | * snapshot, etc.). Note some (but not all) transitional states are also
|
---|
112 | * online states (see #IsOnline()).
|
---|
113 | */
|
---|
114 | static bool IsTransient(MachineState_T aState)
|
---|
115 | {
|
---|
116 | #if 0
|
---|
117 | return aState >= MachineState_FirstTransient &&
|
---|
118 | aState <= MachineState_LastTransient;
|
---|
119 | #else
|
---|
120 | switch (aState)
|
---|
121 | {
|
---|
122 | case MachineState_Teleporting:
|
---|
123 | case MachineState_LiveSnapshotting:
|
---|
124 | case MachineState_Starting:
|
---|
125 | case MachineState_Stopping:
|
---|
126 | case MachineState_Saving:
|
---|
127 | case MachineState_Restoring:
|
---|
128 | case MachineState_TeleportingPausedVM:
|
---|
129 | case MachineState_TeleportingIn:
|
---|
130 | case MachineState_RestoringSnapshot:
|
---|
131 | case MachineState_DeletingSnapshot:
|
---|
132 | case MachineState_SettingUp:
|
---|
133 | return true;
|
---|
134 | default:
|
---|
135 | return false;
|
---|
136 | }
|
---|
137 | #endif
|
---|
138 | }
|
---|
139 |
|
---|
140 | /**
|
---|
141 | * Shortcut to <tt>IsOnline(aState) || IsTransient(aState)</tt>. When it returns
|
---|
142 | * @false, the VM is turned off (no VM process) and not busy with
|
---|
143 | * another exclusive operation.
|
---|
144 | */
|
---|
145 | static bool IsOnlineOrTransient(MachineState_T aState)
|
---|
146 | {
|
---|
147 | return IsOnline(aState) || IsTransient(aState);
|
---|
148 | }
|
---|
149 |
|
---|
150 | /**
|
---|
151 | * Stringify a machine state.
|
---|
152 | *
|
---|
153 | * @returns Pointer to a read only string.
|
---|
154 | * @param aState Valid machine state.
|
---|
155 | */
|
---|
156 | static const char *stringifyMachineState(MachineState_T aState);
|
---|
157 |
|
---|
158 | /**
|
---|
159 | * Stringify a session state.
|
---|
160 | *
|
---|
161 | * @returns Pointer to a read only string.
|
---|
162 | * @param aState Valid session state.
|
---|
163 | */
|
---|
164 | static const char *stringifySessionState(SessionState_T aState);
|
---|
165 |
|
---|
166 | /**
|
---|
167 | * Stringify a device type.
|
---|
168 | *
|
---|
169 | * @returns Pointer to a read only string.
|
---|
170 | * @param aType The device type.
|
---|
171 | */
|
---|
172 | static const char *stringifyDeviceType(DeviceType_T aType);
|
---|
173 |
|
---|
174 | /**
|
---|
175 | * Try convert a COM status code to a VirtualBox status code (VBox/err.h).
|
---|
176 | *
|
---|
177 | * @returns VBox status code.
|
---|
178 | * @param aComStatus COM status code.
|
---|
179 | */
|
---|
180 | static int vboxStatusCodeFromCOM(HRESULT aComStatus);
|
---|
181 |
|
---|
182 | /**
|
---|
183 | * Try convert a VirtualBox status code (VBox/err.h) to a COM status code.
|
---|
184 | *
|
---|
185 | * This is mainly inteded for dealing with vboxStatusCodeFromCOM() return
|
---|
186 | * values. If used on anything else, it won't be able to cope with most of the
|
---|
187 | * input!
|
---|
188 | *
|
---|
189 | * @returns COM status code.
|
---|
190 | * @param aVBoxStatus VBox status code.
|
---|
191 | */
|
---|
192 | static HRESULT vboxStatusCodeToCOM(int aVBoxStatus);
|
---|
193 | };
|
---|
194 |
|
---|
195 | #endif /* !____H_GLOBAL */
|
---|
196 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|