1 | /* $Id: VBoxManageInfo.cpp 57358 2015-08-14 15:16:38Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxManage - The 'showvminfo' command and helper routines.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2015 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef VBOX_ONLY_DOCS
|
---|
19 |
|
---|
20 |
|
---|
21 | /*********************************************************************************************************************************
|
---|
22 | * Header Files *
|
---|
23 | *********************************************************************************************************************************/
|
---|
24 | #include <VBox/com/com.h>
|
---|
25 | #include <VBox/com/string.h>
|
---|
26 | #include <VBox/com/Guid.h>
|
---|
27 | #include <VBox/com/array.h>
|
---|
28 | #include <VBox/com/ErrorInfo.h>
|
---|
29 | #include <VBox/com/errorprint.h>
|
---|
30 |
|
---|
31 | #include <VBox/com/VirtualBox.h>
|
---|
32 |
|
---|
33 | #ifdef VBOX_WITH_PCI_PASSTHROUGH
|
---|
34 | #include <VBox/pci.h>
|
---|
35 | #endif
|
---|
36 |
|
---|
37 | #include <VBox/log.h>
|
---|
38 | #include <iprt/stream.h>
|
---|
39 | #include <iprt/time.h>
|
---|
40 | #include <iprt/string.h>
|
---|
41 | #include <iprt/getopt.h>
|
---|
42 | #include <iprt/ctype.h>
|
---|
43 |
|
---|
44 | #include "VBoxManage.h"
|
---|
45 | using namespace com;
|
---|
46 |
|
---|
47 |
|
---|
48 | // funcs
|
---|
49 | ///////////////////////////////////////////////////////////////////////////////
|
---|
50 |
|
---|
51 | HRESULT showSnapshots(ComPtr<ISnapshot> &rootSnapshot,
|
---|
52 | ComPtr<ISnapshot> ¤tSnapshot,
|
---|
53 | VMINFO_DETAILS details,
|
---|
54 | const Utf8Str &prefix /* = ""*/,
|
---|
55 | int level /*= 0*/)
|
---|
56 | {
|
---|
57 | /* start with the root */
|
---|
58 | Bstr name;
|
---|
59 | Bstr uuid;
|
---|
60 | Bstr description;
|
---|
61 | CHECK_ERROR2I_RET(rootSnapshot, COMGETTER(Name)(name.asOutParam()), hrcCheck);
|
---|
62 | CHECK_ERROR2I_RET(rootSnapshot, COMGETTER(Id)(uuid.asOutParam()), hrcCheck);
|
---|
63 | CHECK_ERROR2I_RET(rootSnapshot, COMGETTER(Description)(description.asOutParam()), hrcCheck);
|
---|
64 | bool fCurrent = (rootSnapshot == currentSnapshot);
|
---|
65 | if (details == VMINFO_MACHINEREADABLE)
|
---|
66 | {
|
---|
67 | /* print with hierarchical numbering */
|
---|
68 | RTPrintf("SnapshotName%s=\"%ls\"\n", prefix.c_str(), name.raw());
|
---|
69 | RTPrintf("SnapshotUUID%s=\"%s\"\n", prefix.c_str(), Utf8Str(uuid).c_str());
|
---|
70 | if (!description.isEmpty())
|
---|
71 | RTPrintf("SnapshotDescription%s=\"%ls\"\n", prefix.c_str(), description.raw());
|
---|
72 | if (fCurrent)
|
---|
73 | {
|
---|
74 | RTPrintf("CurrentSnapshotName=\"%ls\"\n", name.raw());
|
---|
75 | RTPrintf("CurrentSnapshotUUID=\"%s\"\n", Utf8Str(uuid).c_str());
|
---|
76 | RTPrintf("CurrentSnapshotNode=\"SnapshotName%s\"\n", prefix.c_str());
|
---|
77 | }
|
---|
78 | }
|
---|
79 | else
|
---|
80 | {
|
---|
81 | /* print with indentation */
|
---|
82 | RTPrintf(" %sName: %ls (UUID: %s)%s\n",
|
---|
83 | prefix.c_str(),
|
---|
84 | name.raw(),
|
---|
85 | Utf8Str(uuid).c_str(),
|
---|
86 | (fCurrent) ? " *" : "");
|
---|
87 | if (!description.isEmpty())
|
---|
88 | RTPrintf(" %sDescription:\n%ls\n", prefix.c_str(), description.raw());
|
---|
89 | }
|
---|
90 |
|
---|
91 | /* get the children */
|
---|
92 | HRESULT hrc = S_OK;
|
---|
93 | SafeIfaceArray <ISnapshot> coll;
|
---|
94 | CHECK_ERROR2I_RET(rootSnapshot,COMGETTER(Children)(ComSafeArrayAsOutParam(coll)), hrcCheck);
|
---|
95 | if (!coll.isNull())
|
---|
96 | {
|
---|
97 | for (size_t index = 0; index < coll.size(); ++index)
|
---|
98 | {
|
---|
99 | ComPtr<ISnapshot> snapshot = coll[index];
|
---|
100 | if (snapshot)
|
---|
101 | {
|
---|
102 | Utf8Str newPrefix;
|
---|
103 | if (details == VMINFO_MACHINEREADABLE)
|
---|
104 | newPrefix = Utf8StrFmt("%s-%d", prefix.c_str(), index + 1);
|
---|
105 | else
|
---|
106 | {
|
---|
107 | newPrefix = Utf8StrFmt("%s ", prefix.c_str());
|
---|
108 | }
|
---|
109 |
|
---|
110 | /* recursive call */
|
---|
111 | HRESULT hrc2 = showSnapshots(snapshot, currentSnapshot, details, newPrefix, level + 1);
|
---|
112 | if (FAILED(hrc2))
|
---|
113 | hrc = hrc2;
|
---|
114 | }
|
---|
115 | }
|
---|
116 | }
|
---|
117 | return hrc;
|
---|
118 | }
|
---|
119 |
|
---|
120 | static void makeTimeStr(char *s, int cb, int64_t millies)
|
---|
121 | {
|
---|
122 | RTTIME t;
|
---|
123 | RTTIMESPEC ts;
|
---|
124 |
|
---|
125 | RTTimeSpecSetMilli(&ts, millies);
|
---|
126 |
|
---|
127 | RTTimeExplode(&t, &ts);
|
---|
128 |
|
---|
129 | RTStrPrintf(s, cb, "%04d/%02d/%02d %02d:%02d:%02d UTC",
|
---|
130 | t.i32Year, t.u8Month, t.u8MonthDay,
|
---|
131 | t.u8Hour, t.u8Minute, t.u8Second);
|
---|
132 | }
|
---|
133 |
|
---|
134 | const char *machineStateToName(MachineState_T machineState, bool fShort)
|
---|
135 | {
|
---|
136 | switch (machineState)
|
---|
137 | {
|
---|
138 | case MachineState_PoweredOff:
|
---|
139 | return fShort ? "poweroff" : "powered off";
|
---|
140 | case MachineState_Saved:
|
---|
141 | return "saved";
|
---|
142 | case MachineState_Teleported:
|
---|
143 | return "teleported";
|
---|
144 | case MachineState_Aborted:
|
---|
145 | return "aborted";
|
---|
146 | case MachineState_Running:
|
---|
147 | return "running";
|
---|
148 | case MachineState_Paused:
|
---|
149 | return "paused";
|
---|
150 | case MachineState_Stuck:
|
---|
151 | return fShort ? "gurumeditation" : "guru meditation";
|
---|
152 | case MachineState_Teleporting:
|
---|
153 | return "teleporting";
|
---|
154 | case MachineState_LiveSnapshotting:
|
---|
155 | return fShort ? "livesnapshotting" : "live snapshotting";
|
---|
156 | case MachineState_Starting:
|
---|
157 | return "starting";
|
---|
158 | case MachineState_Stopping:
|
---|
159 | return "stopping";
|
---|
160 | case MachineState_Saving:
|
---|
161 | return "saving";
|
---|
162 | case MachineState_Restoring:
|
---|
163 | return "restoring";
|
---|
164 | case MachineState_TeleportingPausedVM:
|
---|
165 | return fShort ? "teleportingpausedvm" : "teleporting paused vm";
|
---|
166 | case MachineState_TeleportingIn:
|
---|
167 | return fShort ? "teleportingin" : "teleporting (incoming)";
|
---|
168 | case MachineState_FaultTolerantSyncing:
|
---|
169 | return fShort ? "faulttolerantsyncing" : "fault tolerant syncing";
|
---|
170 | case MachineState_DeletingSnapshotOnline:
|
---|
171 | return fShort ? "deletingsnapshotlive" : "deleting snapshot live";
|
---|
172 | case MachineState_DeletingSnapshotPaused:
|
---|
173 | return fShort ? "deletingsnapshotlivepaused" : "deleting snapshot live paused";
|
---|
174 | case MachineState_OnlineSnapshotting:
|
---|
175 | return fShort ? "onlinesnapshotting" : "online snapshotting";
|
---|
176 | case MachineState_RestoringSnapshot:
|
---|
177 | return fShort ? "restoringsnapshot" : "restoring snapshot";
|
---|
178 | case MachineState_DeletingSnapshot:
|
---|
179 | return fShort ? "deletingsnapshot" : "deleting snapshot";
|
---|
180 | case MachineState_SettingUp:
|
---|
181 | return fShort ? "settingup" : "setting up";
|
---|
182 | case MachineState_Snapshotting:
|
---|
183 | return fShort ? "snapshotting" : "offline snapshotting";
|
---|
184 | default:
|
---|
185 | break;
|
---|
186 | }
|
---|
187 | return "unknown";
|
---|
188 | }
|
---|
189 |
|
---|
190 | const char *facilityStateToName(AdditionsFacilityStatus_T faStatus, bool fShort)
|
---|
191 | {
|
---|
192 | switch (faStatus)
|
---|
193 | {
|
---|
194 | case AdditionsFacilityStatus_Inactive:
|
---|
195 | return fShort ? "inactive" : "not active";
|
---|
196 | case AdditionsFacilityStatus_Paused:
|
---|
197 | return "paused";
|
---|
198 | case AdditionsFacilityStatus_PreInit:
|
---|
199 | return fShort ? "preinit" : "pre-initializing";
|
---|
200 | case AdditionsFacilityStatus_Init:
|
---|
201 | return fShort ? "init" : "initializing";
|
---|
202 | case AdditionsFacilityStatus_Active:
|
---|
203 | return fShort ? "active" : "active/running";
|
---|
204 | case AdditionsFacilityStatus_Terminating:
|
---|
205 | return "terminating";
|
---|
206 | case AdditionsFacilityStatus_Terminated:
|
---|
207 | return "terminated";
|
---|
208 | case AdditionsFacilityStatus_Failed:
|
---|
209 | return "failed";
|
---|
210 | case AdditionsFacilityStatus_Unknown:
|
---|
211 | default:
|
---|
212 | break;
|
---|
213 | }
|
---|
214 | return "unknown";
|
---|
215 | }
|
---|
216 |
|
---|
217 | /**
|
---|
218 | * This takes care of escaping double quotes and slashes that the string might
|
---|
219 | * contain.
|
---|
220 | *
|
---|
221 | * @param pszName The variable name.
|
---|
222 | * @param pbstrValue The value.
|
---|
223 | */
|
---|
224 | static void outputMachineReadableString(const char *pszName, Bstr const *pbstrValue)
|
---|
225 | {
|
---|
226 | Assert(strpbrk(pszName, "\"\\") == NULL);
|
---|
227 |
|
---|
228 | com::Utf8Str strValue(*pbstrValue);
|
---|
229 | if ( strValue.isEmpty()
|
---|
230 | || ( !strValue.count('"')
|
---|
231 | && !strValue.count('\\')))
|
---|
232 | RTPrintf("%s=\"%s\"\n", pszName, strValue.c_str());
|
---|
233 | else
|
---|
234 | {
|
---|
235 | /* The value needs escaping. */
|
---|
236 | RTPrintf("%s=\"", pszName);
|
---|
237 | const char *psz = strValue.c_str();
|
---|
238 | for (;;)
|
---|
239 | {
|
---|
240 | const char *pszNext = strpbrk(psz, "\"\\");
|
---|
241 | if (!pszNext)
|
---|
242 | {
|
---|
243 | RTPrintf("%s", psz);
|
---|
244 | break;
|
---|
245 | }
|
---|
246 | RTPrintf("%.*s\\%c", pszNext - psz, psz, *pszNext);
|
---|
247 | psz = pszNext + 1;
|
---|
248 | }
|
---|
249 | RTPrintf("\"\n");
|
---|
250 | }
|
---|
251 | }
|
---|
252 |
|
---|
253 | /**
|
---|
254 | * Converts bandwidth group type to a string.
|
---|
255 | * @returns String representation.
|
---|
256 | * @param enmType Bandwidth control group type.
|
---|
257 | */
|
---|
258 | inline const char * bwGroupTypeToString(BandwidthGroupType_T enmType)
|
---|
259 | {
|
---|
260 | switch (enmType)
|
---|
261 | {
|
---|
262 | case BandwidthGroupType_Disk: return "Disk";
|
---|
263 | case BandwidthGroupType_Network: return "Network";
|
---|
264 | }
|
---|
265 | return "unknown";
|
---|
266 | }
|
---|
267 |
|
---|
268 | HRESULT showBandwidthGroups(ComPtr<IBandwidthControl> &bwCtrl,
|
---|
269 | VMINFO_DETAILS details)
|
---|
270 | {
|
---|
271 | int rc = S_OK;
|
---|
272 | SafeIfaceArray<IBandwidthGroup> bwGroups;
|
---|
273 |
|
---|
274 | CHECK_ERROR_RET(bwCtrl, GetAllBandwidthGroups(ComSafeArrayAsOutParam(bwGroups)), rc);
|
---|
275 |
|
---|
276 | if (bwGroups.size() && details != VMINFO_MACHINEREADABLE)
|
---|
277 | RTPrintf("\n\n");
|
---|
278 | for (size_t i = 0; i < bwGroups.size(); i++)
|
---|
279 | {
|
---|
280 | Bstr strName;
|
---|
281 | LONG64 cMaxBytesPerSec;
|
---|
282 | BandwidthGroupType_T enmType;
|
---|
283 |
|
---|
284 | CHECK_ERROR_RET(bwGroups[i], COMGETTER(Name)(strName.asOutParam()), rc);
|
---|
285 | CHECK_ERROR_RET(bwGroups[i], COMGETTER(Type)(&enmType), rc);
|
---|
286 | CHECK_ERROR_RET(bwGroups[i], COMGETTER(MaxBytesPerSec)(&cMaxBytesPerSec), rc);
|
---|
287 |
|
---|
288 | const char *pszType = bwGroupTypeToString(enmType);
|
---|
289 | if (details == VMINFO_MACHINEREADABLE)
|
---|
290 | RTPrintf("BandwidthGroup%zu=%ls,%s,%lld\n", i, strName.raw(), pszType, cMaxBytesPerSec);
|
---|
291 | else
|
---|
292 | {
|
---|
293 | const char *pszUnits = "";
|
---|
294 | LONG64 cBytes = cMaxBytesPerSec;
|
---|
295 | if (cBytes == 0)
|
---|
296 | {
|
---|
297 | RTPrintf("Name: '%ls', Type: %s, Limit: none (disabled)\n", strName.raw(), pszType);
|
---|
298 | continue;
|
---|
299 | }
|
---|
300 | else if (!(cBytes % _1G))
|
---|
301 | {
|
---|
302 | pszUnits = "G";
|
---|
303 | cBytes /= _1G;
|
---|
304 | }
|
---|
305 | else if (!(cBytes % _1M))
|
---|
306 | {
|
---|
307 | pszUnits = "M";
|
---|
308 | cBytes /= _1M;
|
---|
309 | }
|
---|
310 | else if (!(cBytes % _1K))
|
---|
311 | {
|
---|
312 | pszUnits = "K";
|
---|
313 | cBytes /= _1K;
|
---|
314 | }
|
---|
315 | const char *pszNetUnits = NULL;
|
---|
316 | if (enmType == BandwidthGroupType_Network)
|
---|
317 | {
|
---|
318 | /*
|
---|
319 | * We want to report network rate limit in bits/s, not bytes.
|
---|
320 | * Only if it cannot be express it in kilobits we will fall
|
---|
321 | * back to reporting it in bytes.
|
---|
322 | */
|
---|
323 | LONG64 cBits = cMaxBytesPerSec;
|
---|
324 | if (!(cBits % 125))
|
---|
325 | {
|
---|
326 | cBits /= 125;
|
---|
327 | pszNetUnits = "k";
|
---|
328 | if (!(cBits % 1000000))
|
---|
329 | {
|
---|
330 | cBits /= 1000000;
|
---|
331 | pszNetUnits = "g";
|
---|
332 | }
|
---|
333 | else if (!(cBits % 1000))
|
---|
334 | {
|
---|
335 | cBits /= 1000;
|
---|
336 | pszNetUnits = "m";
|
---|
337 | }
|
---|
338 | RTPrintf("Name: '%ls', Type: %s, Limit: %lld %sbits/sec (%lld %sbytes/sec)\n", strName.raw(), pszType, cBits, pszNetUnits, cBytes, pszUnits);
|
---|
339 | }
|
---|
340 | }
|
---|
341 | if (!pszNetUnits)
|
---|
342 | RTPrintf("Name: '%ls', Type: %s, Limit: %lld %sbytes/sec\n", strName.raw(), pszType, cBytes, pszUnits);
|
---|
343 | }
|
---|
344 | }
|
---|
345 | if (details != VMINFO_MACHINEREADABLE)
|
---|
346 | RTPrintf(bwGroups.size() != 0 ? "\n" : "<none>\n\n");
|
---|
347 |
|
---|
348 | return rc;
|
---|
349 | }
|
---|
350 |
|
---|
351 |
|
---|
352 | /* Disable global optimizations for MSC 8.0/64 to make it compile in reasonable
|
---|
353 | time. MSC 7.1/32 doesn't have quite as much trouble with it, but still
|
---|
354 | sufficient to qualify for this hack as well since this code isn't performance
|
---|
355 | critical and probably won't gain much from the extra optimizing in real life. */
|
---|
356 | #if defined(_MSC_VER)
|
---|
357 | # pragma optimize("g", off)
|
---|
358 | #endif
|
---|
359 |
|
---|
360 | HRESULT showVMInfo(ComPtr<IVirtualBox> pVirtualBox,
|
---|
361 | ComPtr<IMachine> machine,
|
---|
362 | ComPtr<ISession> pSession,
|
---|
363 | VMINFO_DETAILS details /*= VMINFO_NONE*/)
|
---|
364 | {
|
---|
365 | HRESULT rc;
|
---|
366 | ComPtr<IConsole> pConsole;
|
---|
367 | if (pSession)
|
---|
368 | pSession->COMGETTER(Console)(pConsole.asOutParam());
|
---|
369 |
|
---|
370 | #define SHOW_BOOLEAN_PROP(a_pObj, a_Prop, a_szMachine, a_szHuman) \
|
---|
371 | SHOW_BOOLEAN_PROP_EX(a_pObj, a_Prop, a_szMachine, a_szHuman, "on", "off")
|
---|
372 |
|
---|
373 | #define SHOW_BOOLEAN_PROP_EX(a_pObj, a_Prop, a_szMachine, a_szHuman, a_szTrue, a_szFalse) \
|
---|
374 | do \
|
---|
375 | { \
|
---|
376 | BOOL f; \
|
---|
377 | CHECK_ERROR2I_RET(a_pObj, COMGETTER(a_Prop)(&f), hrcCheck); \
|
---|
378 | if (details == VMINFO_MACHINEREADABLE) \
|
---|
379 | RTPrintf( a_szMachine "=\"%s\"\n", f ? "on" : "off"); \
|
---|
380 | else \
|
---|
381 | RTPrintf("%-16s %s\n", a_szHuman ":", f ? a_szTrue : a_szFalse); \
|
---|
382 | } while (0)
|
---|
383 |
|
---|
384 | #define SHOW_BOOLEAN_METHOD(a_pObj, a_Invocation, a_szMachine, a_szHuman) \
|
---|
385 | do \
|
---|
386 | { \
|
---|
387 | BOOL f; \
|
---|
388 | CHECK_ERROR2I_RET(a_pObj, a_Invocation, hrcCheck); \
|
---|
389 | if (details == VMINFO_MACHINEREADABLE) \
|
---|
390 | RTPrintf( a_szMachine "=\"%s\"\n", f ? "on" : "off"); \
|
---|
391 | else \
|
---|
392 | RTPrintf("%-16s %s\n", a_szHuman ":", f ? "on" : "off"); \
|
---|
393 | } while (0)
|
---|
394 |
|
---|
395 | #define SHOW_STRING_PROP(a_pObj, a_Prop, a_szMachine, a_szHuman) \
|
---|
396 | do \
|
---|
397 | { \
|
---|
398 | Bstr bstr; \
|
---|
399 | CHECK_ERROR2I_RET(a_pObj, COMGETTER(a_Prop)(bstr.asOutParam()), hrcCheck); \
|
---|
400 | if (details == VMINFO_MACHINEREADABLE) \
|
---|
401 | outputMachineReadableString(a_szMachine, &bstr); \
|
---|
402 | else \
|
---|
403 | RTPrintf("%-16s %ls\n", a_szHuman ":", bstr.raw()); \
|
---|
404 | } while (0)
|
---|
405 |
|
---|
406 | #define SHOW_STRINGARRAY_PROP(a_pObj, a_Prop, a_szMachine, a_szHuman) \
|
---|
407 | do \
|
---|
408 | { \
|
---|
409 | SafeArray<BSTR> array; \
|
---|
410 | CHECK_ERROR2I_RET(a_pObj, COMGETTER(a_Prop)(ComSafeArrayAsOutParam(array)), hrcCheck); \
|
---|
411 | Utf8Str str; \
|
---|
412 | for (size_t i = 0; i < array.size(); i++) \
|
---|
413 | { \
|
---|
414 | if (i != 0) \
|
---|
415 | str.append(","); \
|
---|
416 | str.append(Utf8Str(array[i]).c_str()); \
|
---|
417 | } \
|
---|
418 | Bstr bstr(str); \
|
---|
419 | if (details == VMINFO_MACHINEREADABLE) \
|
---|
420 | outputMachineReadableString(a_szMachine, &bstr); \
|
---|
421 | else \
|
---|
422 | RTPrintf("%-16s %ls\n", a_szHuman ":", bstr.raw()); \
|
---|
423 | } while (0)
|
---|
424 |
|
---|
425 | #define SHOW_UUID_PROP(a_pObj, a_Prop, a_szMachine, a_szHuman) \
|
---|
426 | SHOW_STRING_PROP(a_pObj, a_Prop, a_szMachine, a_szHuman)
|
---|
427 |
|
---|
428 | #define SHOW_ULONG_PROP(a_pObj, a_Prop, a_szMachine, a_szHuman, a_szUnit) \
|
---|
429 | do \
|
---|
430 | { \
|
---|
431 | ULONG u32; \
|
---|
432 | CHECK_ERROR2I_RET(a_pObj, COMGETTER(a_Prop)(&u32), hrcCheck); \
|
---|
433 | if (details == VMINFO_MACHINEREADABLE) \
|
---|
434 | RTPrintf(a_szMachine "=%u\n", u32); \
|
---|
435 | else \
|
---|
436 | RTPrintf("%-16s %u" a_szUnit "\n", a_szHuman ":", u32); \
|
---|
437 | } while (0)
|
---|
438 |
|
---|
439 | #define SHOW_LONG64_PROP(a_pObj, a_Prop, a_szMachine, a_szHuman, a_szUnit) \
|
---|
440 | do \
|
---|
441 | { \
|
---|
442 | LONG64 i64; \
|
---|
443 | CHECK_ERROR2I_RET(a_pObj, COMGETTER(a_Prop)(&i64), hrcCheck); \
|
---|
444 | if (details == VMINFO_MACHINEREADABLE) \
|
---|
445 | RTPrintf(a_szMachine "=%lld\n", i64); \
|
---|
446 | else \
|
---|
447 | RTPrintf("%-16s %'lld" a_szUnit "\n", a_szHuman ":", i64); \
|
---|
448 | } while (0)
|
---|
449 |
|
---|
450 | /*
|
---|
451 | * The rules for output in -argdump format:
|
---|
452 | * 1) the key part (the [0-9a-zA-Z_\-]+ string before the '=' delimiter)
|
---|
453 | * is all lowercase for "VBoxManage modifyvm" parameters. Any
|
---|
454 | * other values printed are in CamelCase.
|
---|
455 | * 2) strings (anything non-decimal) are printed surrounded by
|
---|
456 | * double quotes '"'. If the strings themselves contain double
|
---|
457 | * quotes, these characters are escaped by '\'. Any '\' character
|
---|
458 | * in the original string is also escaped by '\'.
|
---|
459 | * 3) numbers (containing just [0-9\-]) are written out unchanged.
|
---|
460 | */
|
---|
461 |
|
---|
462 | BOOL fAccessible;
|
---|
463 | CHECK_ERROR2I_RET(machine, COMGETTER(Accessible)(&fAccessible), hrcCheck);
|
---|
464 | if (!fAccessible)
|
---|
465 | {
|
---|
466 | Bstr uuid;
|
---|
467 | machine->COMGETTER(Id)(uuid.asOutParam());
|
---|
468 | if (details == VMINFO_COMPACT)
|
---|
469 | RTPrintf("\"<inaccessible>\" {%s}\n", Utf8Str(uuid).c_str());
|
---|
470 | else
|
---|
471 | {
|
---|
472 | if (details == VMINFO_MACHINEREADABLE)
|
---|
473 | RTPrintf("name=\"<inaccessible>\"\n");
|
---|
474 | else
|
---|
475 | RTPrintf("Name: <inaccessible!>\n");
|
---|
476 | if (details == VMINFO_MACHINEREADABLE)
|
---|
477 | RTPrintf("UUID=\"%s\"\n", Utf8Str(uuid).c_str());
|
---|
478 | else
|
---|
479 | RTPrintf("UUID: %s\n", Utf8Str(uuid).c_str());
|
---|
480 | if (details != VMINFO_MACHINEREADABLE)
|
---|
481 | {
|
---|
482 | Bstr settingsFilePath;
|
---|
483 | rc = machine->COMGETTER(SettingsFilePath)(settingsFilePath.asOutParam());
|
---|
484 | RTPrintf("Config file: %ls\n", settingsFilePath.raw());
|
---|
485 | ComPtr<IVirtualBoxErrorInfo> accessError;
|
---|
486 | rc = machine->COMGETTER(AccessError)(accessError.asOutParam());
|
---|
487 | RTPrintf("Access error details:\n");
|
---|
488 | ErrorInfo ei(accessError);
|
---|
489 | GluePrintErrorInfo(ei);
|
---|
490 | RTPrintf("\n");
|
---|
491 | }
|
---|
492 | }
|
---|
493 | return S_OK;
|
---|
494 | }
|
---|
495 |
|
---|
496 | if (details == VMINFO_COMPACT)
|
---|
497 | {
|
---|
498 | Bstr machineName;
|
---|
499 | machine->COMGETTER(Name)(machineName.asOutParam());
|
---|
500 | Bstr uuid;
|
---|
501 | machine->COMGETTER(Id)(uuid.asOutParam());
|
---|
502 |
|
---|
503 | RTPrintf("\"%ls\" {%s}\n", machineName.raw(), Utf8Str(uuid).c_str());
|
---|
504 | return S_OK;
|
---|
505 | }
|
---|
506 |
|
---|
507 | SHOW_STRING_PROP( machine, Name, "name", "Name");
|
---|
508 |
|
---|
509 | Bstr osTypeId;
|
---|
510 | CHECK_ERROR2I_RET(machine, COMGETTER(OSTypeId)(osTypeId.asOutParam()), hrcCheck);
|
---|
511 | ComPtr<IGuestOSType> osType;
|
---|
512 | CHECK_ERROR2I_RET(pVirtualBox, GetGuestOSType(osTypeId.raw(), osType.asOutParam()), hrcCheck);
|
---|
513 | SHOW_STRINGARRAY_PROP( machine, Groups, "groups", "Groups");
|
---|
514 | SHOW_STRING_PROP( osType, Description, "ostype", "Guest OS");
|
---|
515 | SHOW_UUID_PROP( machine, Id, "UUID", "UUID");
|
---|
516 | SHOW_STRING_PROP( machine, SettingsFilePath, "CfgFile", "Config file");
|
---|
517 | SHOW_STRING_PROP( machine, SnapshotFolder, "SnapFldr", "Snapshot folder");
|
---|
518 | SHOW_STRING_PROP( machine, LogFolder, "LogFldr", "Log folder");
|
---|
519 | SHOW_UUID_PROP( machine, HardwareUUID, "hardwareuuid", "Hardware UUID");
|
---|
520 | SHOW_ULONG_PROP( machine, MemorySize, "memory", "Memory size", "MB");
|
---|
521 | SHOW_BOOLEAN_PROP( machine, PageFusionEnabled, "pagefusion", "Page Fusion");
|
---|
522 | SHOW_ULONG_PROP( machine, VRAMSize, "vram", "VRAM size", "MB");
|
---|
523 | SHOW_ULONG_PROP( machine, CPUExecutionCap, "cpuexecutioncap", "CPU exec cap", "%%");
|
---|
524 | SHOW_BOOLEAN_PROP( machine, HPETEnabled, "hpet", "HPET");
|
---|
525 |
|
---|
526 | ChipsetType_T chipsetType;
|
---|
527 | CHECK_ERROR2I_RET(machine, COMGETTER(ChipsetType)(&chipsetType), hrcCheck);
|
---|
528 | const char *pszChipsetType;
|
---|
529 | switch (chipsetType)
|
---|
530 | {
|
---|
531 | case ChipsetType_Null: pszChipsetType = "invalid"; break;
|
---|
532 | case ChipsetType_PIIX3: pszChipsetType = "piix3"; break;
|
---|
533 | case ChipsetType_ICH9: pszChipsetType = "ich9"; break;
|
---|
534 | default: AssertFailed(); pszChipsetType = "unknown"; break;
|
---|
535 | }
|
---|
536 | if (details == VMINFO_MACHINEREADABLE)
|
---|
537 | RTPrintf("chipset=\"%s\"\n", pszChipsetType);
|
---|
538 | else
|
---|
539 | RTPrintf("Chipset: %s\n", pszChipsetType);
|
---|
540 |
|
---|
541 | FirmwareType_T firmwareType;
|
---|
542 | CHECK_ERROR2I_RET(machine, COMGETTER(FirmwareType)(&firmwareType), hrcCheck);
|
---|
543 | const char *pszFirmwareType;
|
---|
544 | switch (firmwareType)
|
---|
545 | {
|
---|
546 | case FirmwareType_BIOS: pszFirmwareType = "BIOS"; break;
|
---|
547 | case FirmwareType_EFI: pszFirmwareType = "EFI"; break;
|
---|
548 | case FirmwareType_EFI32: pszFirmwareType = "EFI32"; break;
|
---|
549 | case FirmwareType_EFI64: pszFirmwareType = "EFI64"; break;
|
---|
550 | case FirmwareType_EFIDUAL: pszFirmwareType = "EFIDUAL"; break;
|
---|
551 | default: AssertFailed(); pszFirmwareType = "unknown"; break;
|
---|
552 | }
|
---|
553 | if (details == VMINFO_MACHINEREADABLE)
|
---|
554 | RTPrintf("firmware=\"%s\"\n", pszFirmwareType);
|
---|
555 | else
|
---|
556 | RTPrintf("Firmware: %s\n", pszFirmwareType);
|
---|
557 |
|
---|
558 | SHOW_ULONG_PROP( machine, CPUCount, "cpus", "Number of CPUs", "");
|
---|
559 | SHOW_BOOLEAN_METHOD( machine, GetCPUProperty(CPUPropertyType_PAE, &f), "pae", "PAE");
|
---|
560 | SHOW_BOOLEAN_METHOD( machine, GetCPUProperty(CPUPropertyType_LongMode, &f), "longmode", "Long Mode");
|
---|
561 | SHOW_ULONG_PROP( machine, CPUIDPortabilityLevel, "cpuid-portability-level", "CPUID Portability Level", "");
|
---|
562 |
|
---|
563 | if (details != VMINFO_MACHINEREADABLE)
|
---|
564 | RTPrintf("CPUID overrides: ");
|
---|
565 | ULONG cFound = 0;
|
---|
566 | static uint32_t const s_auCpuIdRanges[] =
|
---|
567 | {
|
---|
568 | UINT32_C(0x00000000), UINT32_C(0x0000000a),
|
---|
569 | UINT32_C(0x80000000), UINT32_C(0x8000000a)
|
---|
570 | };
|
---|
571 | for (unsigned i = 0; i < RT_ELEMENTS(s_auCpuIdRanges); i += 2)
|
---|
572 | for (uint32_t uLeaf = s_auCpuIdRanges[i]; uLeaf < s_auCpuIdRanges[i + 1]; uLeaf++)
|
---|
573 | {
|
---|
574 | ULONG uEAX, uEBX, uECX, uEDX;
|
---|
575 | rc = machine->GetCPUIDLeaf(uLeaf, &uEAX, &uEBX, &uECX, &uEDX);
|
---|
576 | if (SUCCEEDED(rc))
|
---|
577 | {
|
---|
578 | if (details == VMINFO_MACHINEREADABLE)
|
---|
579 | RTPrintf("cpuid=%08x,%08x,%08x,%08x,%08x", uLeaf, uEAX, uEBX, uECX, uEDX);
|
---|
580 | else
|
---|
581 | {
|
---|
582 | if (!cFound)
|
---|
583 | RTPrintf("Leaf no. EAX EBX ECX EDX\n");
|
---|
584 | RTPrintf(" %08x %08x %08x %08x %08x\n", uLeaf, uEAX, uEBX, uECX, uEDX);
|
---|
585 | }
|
---|
586 | cFound++;
|
---|
587 | }
|
---|
588 | }
|
---|
589 | if (!cFound && details != VMINFO_MACHINEREADABLE)
|
---|
590 | RTPrintf("None\n");
|
---|
591 |
|
---|
592 | ComPtr<IBIOSSettings> biosSettings;
|
---|
593 | CHECK_ERROR2I_RET(machine, COMGETTER(BIOSSettings)(biosSettings.asOutParam()), hrcCheck);
|
---|
594 |
|
---|
595 | BIOSBootMenuMode_T bootMenuMode;
|
---|
596 | CHECK_ERROR2I_RET(biosSettings, COMGETTER(BootMenuMode)(&bootMenuMode), hrcCheck);
|
---|
597 | const char *pszBootMenu;
|
---|
598 | switch (bootMenuMode)
|
---|
599 | {
|
---|
600 | case BIOSBootMenuMode_Disabled:
|
---|
601 | pszBootMenu = "disabled";
|
---|
602 | break;
|
---|
603 | case BIOSBootMenuMode_MenuOnly:
|
---|
604 | if (details == VMINFO_MACHINEREADABLE)
|
---|
605 | pszBootMenu = "menuonly";
|
---|
606 | else
|
---|
607 | pszBootMenu = "menu only";
|
---|
608 | break;
|
---|
609 | default:
|
---|
610 | if (details == VMINFO_MACHINEREADABLE)
|
---|
611 | pszBootMenu = "messageandmenu";
|
---|
612 | else
|
---|
613 | pszBootMenu = "message and menu";
|
---|
614 | }
|
---|
615 | if (details == VMINFO_MACHINEREADABLE)
|
---|
616 | RTPrintf("bootmenu=\"%s\"\n", pszBootMenu);
|
---|
617 | else
|
---|
618 | RTPrintf("Boot menu mode: %s\n", pszBootMenu);
|
---|
619 |
|
---|
620 | ComPtr<ISystemProperties> systemProperties;
|
---|
621 | CHECK_ERROR2I_RET(pVirtualBox, COMGETTER(SystemProperties)(systemProperties.asOutParam()), hrcCheck);
|
---|
622 | ULONG maxBootPosition = 0;
|
---|
623 | CHECK_ERROR2I_RET(systemProperties, COMGETTER(MaxBootPosition)(&maxBootPosition), hrcCheck);
|
---|
624 | for (ULONG i = 1; i <= maxBootPosition; i++)
|
---|
625 | {
|
---|
626 | DeviceType_T bootOrder;
|
---|
627 | CHECK_ERROR2I_RET(machine, GetBootOrder(i, &bootOrder), hrcCheck);
|
---|
628 | if (bootOrder == DeviceType_Floppy)
|
---|
629 | {
|
---|
630 | if (details == VMINFO_MACHINEREADABLE)
|
---|
631 | RTPrintf("boot%d=\"floppy\"\n", i);
|
---|
632 | else
|
---|
633 | RTPrintf("Boot Device (%d): Floppy\n", i);
|
---|
634 | }
|
---|
635 | else if (bootOrder == DeviceType_DVD)
|
---|
636 | {
|
---|
637 | if (details == VMINFO_MACHINEREADABLE)
|
---|
638 | RTPrintf("boot%d=\"dvd\"\n", i);
|
---|
639 | else
|
---|
640 | RTPrintf("Boot Device (%d): DVD\n", i);
|
---|
641 | }
|
---|
642 | else if (bootOrder == DeviceType_HardDisk)
|
---|
643 | {
|
---|
644 | if (details == VMINFO_MACHINEREADABLE)
|
---|
645 | RTPrintf("boot%d=\"disk\"\n", i);
|
---|
646 | else
|
---|
647 | RTPrintf("Boot Device (%d): HardDisk\n", i);
|
---|
648 | }
|
---|
649 | else if (bootOrder == DeviceType_Network)
|
---|
650 | {
|
---|
651 | if (details == VMINFO_MACHINEREADABLE)
|
---|
652 | RTPrintf("boot%d=\"net\"\n", i);
|
---|
653 | else
|
---|
654 | RTPrintf("Boot Device (%d): Network\n", i);
|
---|
655 | }
|
---|
656 | else if (bootOrder == DeviceType_USB)
|
---|
657 | {
|
---|
658 | if (details == VMINFO_MACHINEREADABLE)
|
---|
659 | RTPrintf("boot%d=\"usb\"\n", i);
|
---|
660 | else
|
---|
661 | RTPrintf("Boot Device (%d): USB\n", i);
|
---|
662 | }
|
---|
663 | else if (bootOrder == DeviceType_SharedFolder)
|
---|
664 | {
|
---|
665 | if (details == VMINFO_MACHINEREADABLE)
|
---|
666 | RTPrintf("boot%d=\"sharedfolder\"\n", i);
|
---|
667 | else
|
---|
668 | RTPrintf("Boot Device (%d): Shared Folder\n", i);
|
---|
669 | }
|
---|
670 | else
|
---|
671 | {
|
---|
672 | if (details == VMINFO_MACHINEREADABLE)
|
---|
673 | RTPrintf("boot%d=\"none\"\n", i);
|
---|
674 | else
|
---|
675 | RTPrintf("Boot Device (%d): Not Assigned\n", i);
|
---|
676 | }
|
---|
677 | }
|
---|
678 |
|
---|
679 | SHOW_BOOLEAN_PROP(biosSettings, ACPIEnabled, "acpi", "ACPI");
|
---|
680 | SHOW_BOOLEAN_PROP(biosSettings, IOAPICEnabled, "ioapic", "IOAPIC");
|
---|
681 | SHOW_LONG64_PROP(biosSettings, TimeOffset, "biossystemtimeoffset", "Time offset", "ms");
|
---|
682 | SHOW_BOOLEAN_PROP_EX(machine, RTCUseUTC, "rtcuseutc", "RTC", "UTC", "local time");
|
---|
683 | SHOW_BOOLEAN_METHOD(machine, GetHWVirtExProperty(HWVirtExPropertyType_Enabled, &f), "hwvirtex", "Hardw. virt.ext");
|
---|
684 | SHOW_BOOLEAN_METHOD(machine, GetHWVirtExProperty(HWVirtExPropertyType_NestedPaging, &f),"nestedpaging", "Nested Paging");
|
---|
685 | SHOW_BOOLEAN_METHOD(machine, GetHWVirtExProperty(HWVirtExPropertyType_LargePages, &f), "largepages", "Large Pages");
|
---|
686 | SHOW_BOOLEAN_METHOD(machine, GetHWVirtExProperty(HWVirtExPropertyType_VPID, &f), "vtxvpid", "VT-x VPID");
|
---|
687 | SHOW_BOOLEAN_METHOD(machine, GetHWVirtExProperty(HWVirtExPropertyType_UnrestrictedExecution, &f), "vtxux", "VT-x unr. exec.");
|
---|
688 |
|
---|
689 | ParavirtProvider_T paravirtProvider;
|
---|
690 | CHECK_ERROR2I_RET(machine, COMGETTER(ParavirtProvider)(¶virtProvider), hrcCheck);
|
---|
691 | const char *pszParavirtProvider;
|
---|
692 | switch (paravirtProvider)
|
---|
693 | {
|
---|
694 | case ParavirtProvider_None:
|
---|
695 | if (details == VMINFO_MACHINEREADABLE)
|
---|
696 | pszParavirtProvider = "none";
|
---|
697 | else
|
---|
698 | pszParavirtProvider = "None";
|
---|
699 | break;
|
---|
700 |
|
---|
701 | case ParavirtProvider_Default:
|
---|
702 | if (details == VMINFO_MACHINEREADABLE)
|
---|
703 | pszParavirtProvider = "default";
|
---|
704 | else
|
---|
705 | pszParavirtProvider = "Default";
|
---|
706 | break;
|
---|
707 |
|
---|
708 | case ParavirtProvider_Legacy:
|
---|
709 | if (details == VMINFO_MACHINEREADABLE)
|
---|
710 | pszParavirtProvider = "legacy";
|
---|
711 | else
|
---|
712 | pszParavirtProvider = "Legacy";
|
---|
713 | break;
|
---|
714 |
|
---|
715 | case ParavirtProvider_Minimal:
|
---|
716 | if (details == VMINFO_MACHINEREADABLE)
|
---|
717 | pszParavirtProvider = "minimal";
|
---|
718 | else
|
---|
719 | pszParavirtProvider = "Minimal";
|
---|
720 | break;
|
---|
721 |
|
---|
722 | case ParavirtProvider_HyperV:
|
---|
723 | if (details == VMINFO_MACHINEREADABLE)
|
---|
724 | pszParavirtProvider = "hyperv";
|
---|
725 | else
|
---|
726 | pszParavirtProvider = "HyperV";
|
---|
727 | break;
|
---|
728 |
|
---|
729 | case ParavirtProvider_KVM:
|
---|
730 | if (details == VMINFO_MACHINEREADABLE)
|
---|
731 | pszParavirtProvider = "kvm";
|
---|
732 | else
|
---|
733 | pszParavirtProvider = "KVM";
|
---|
734 | break;
|
---|
735 |
|
---|
736 | default:
|
---|
737 | if (details == VMINFO_MACHINEREADABLE)
|
---|
738 | pszParavirtProvider = "unknown";
|
---|
739 | else
|
---|
740 | pszParavirtProvider = "Unknown";
|
---|
741 | }
|
---|
742 | if (details == VMINFO_MACHINEREADABLE)
|
---|
743 | RTPrintf("paravirtprovider=\"%s\"\n", pszParavirtProvider);
|
---|
744 | else
|
---|
745 | RTPrintf("Paravirt. Provider: %s\n", pszParavirtProvider);
|
---|
746 |
|
---|
747 |
|
---|
748 | MachineState_T machineState;
|
---|
749 | CHECK_ERROR2I_RET(machine, COMGETTER(State)(&machineState), hrcCheck);
|
---|
750 | const char *pszState = machineStateToName(machineState, details == VMINFO_MACHINEREADABLE /*=fShort*/);
|
---|
751 |
|
---|
752 | LONG64 stateSince;
|
---|
753 | machine->COMGETTER(LastStateChange)(&stateSince);
|
---|
754 | RTTIMESPEC timeSpec;
|
---|
755 | RTTimeSpecSetMilli(&timeSpec, stateSince);
|
---|
756 | char pszTime[30] = {0};
|
---|
757 | RTTimeSpecToString(&timeSpec, pszTime, sizeof(pszTime));
|
---|
758 | if (details == VMINFO_MACHINEREADABLE)
|
---|
759 | {
|
---|
760 | RTPrintf("VMState=\"%s\"\n", pszState);
|
---|
761 | RTPrintf("VMStateChangeTime=\"%s\"\n", pszTime);
|
---|
762 |
|
---|
763 | Bstr stateFile;
|
---|
764 | machine->COMGETTER(StateFilePath)(stateFile.asOutParam());
|
---|
765 | if (!stateFile.isEmpty())
|
---|
766 | RTPrintf("VMStateFile=\"%ls\"\n", stateFile.raw());
|
---|
767 | }
|
---|
768 | else
|
---|
769 | RTPrintf("State: %s (since %s)\n", pszState, pszTime);
|
---|
770 |
|
---|
771 | SHOW_ULONG_PROP( machine, MonitorCount, "monitorcount", "Monitor count", "");
|
---|
772 | SHOW_BOOLEAN_PROP( machine, Accelerate3DEnabled, "accelerate3d", "3D Acceleration");
|
---|
773 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
774 | SHOW_BOOLEAN_PROP( machine, Accelerate2DVideoEnabled, "accelerate2dvideo", "2D Video Acceleration");
|
---|
775 | #endif
|
---|
776 | SHOW_BOOLEAN_PROP( machine, TeleporterEnabled, "teleporterenabled", "Teleporter Enabled");
|
---|
777 | SHOW_ULONG_PROP( machine, TeleporterPort, "teleporterport", "Teleporter Port", "");
|
---|
778 | SHOW_STRING_PROP( machine, TeleporterAddress, "teleporteraddress", "Teleporter Address");
|
---|
779 | SHOW_STRING_PROP( machine, TeleporterPassword, "teleporterpassword", "Teleporter Password");
|
---|
780 | SHOW_BOOLEAN_PROP( machine, TracingEnabled, "tracing-enabled", "Tracing Enabled");
|
---|
781 | SHOW_BOOLEAN_PROP( machine, AllowTracingToAccessVM, "tracing-allow-vm-access", "Allow Tracing to Access VM");
|
---|
782 | SHOW_STRING_PROP( machine, TracingConfig, "tracing-config", "Tracing Configuration");
|
---|
783 | SHOW_BOOLEAN_PROP( machine, AutostartEnabled, "autostart-enabled", "Autostart Enabled");
|
---|
784 | SHOW_ULONG_PROP( machine, AutostartDelay, "autostart-delay", "Autostart Delay", "");
|
---|
785 | SHOW_STRING_PROP( machine, DefaultFrontend, "defaultfrontend", "Default Frontend");
|
---|
786 |
|
---|
787 | /** @todo Convert the remainder of the function to SHOW_XXX macros and add error
|
---|
788 | * checking where missing. */
|
---|
789 | /*
|
---|
790 | * Storage Controllers and their attached Mediums.
|
---|
791 | */
|
---|
792 | com::SafeIfaceArray<IStorageController> storageCtls;
|
---|
793 | CHECK_ERROR(machine, COMGETTER(StorageControllers)(ComSafeArrayAsOutParam(storageCtls)));
|
---|
794 | for (size_t i = 0; i < storageCtls.size(); ++ i)
|
---|
795 | {
|
---|
796 | ComPtr<IStorageController> storageCtl = storageCtls[i];
|
---|
797 | StorageControllerType_T enmCtlType = StorageControllerType_Null;
|
---|
798 | const char *pszCtl = NULL;
|
---|
799 | ULONG ulValue = 0;
|
---|
800 | BOOL fBootable = FALSE;
|
---|
801 | Bstr storageCtlName;
|
---|
802 |
|
---|
803 | storageCtl->COMGETTER(Name)(storageCtlName.asOutParam());
|
---|
804 | if (details == VMINFO_MACHINEREADABLE)
|
---|
805 | RTPrintf("storagecontrollername%u=\"%ls\"\n", i, storageCtlName.raw());
|
---|
806 | else
|
---|
807 | RTPrintf("Storage Controller Name (%u): %ls\n", i, storageCtlName.raw());
|
---|
808 |
|
---|
809 | storageCtl->COMGETTER(ControllerType)(&enmCtlType);
|
---|
810 | switch (enmCtlType)
|
---|
811 | {
|
---|
812 | case StorageControllerType_LsiLogic:
|
---|
813 | pszCtl = "LsiLogic";
|
---|
814 | break;
|
---|
815 | case StorageControllerType_LsiLogicSas:
|
---|
816 | pszCtl = "LsiLogicSas";
|
---|
817 | break;
|
---|
818 | case StorageControllerType_BusLogic:
|
---|
819 | pszCtl = "BusLogic";
|
---|
820 | break;
|
---|
821 | case StorageControllerType_IntelAhci:
|
---|
822 | pszCtl = "IntelAhci";
|
---|
823 | break;
|
---|
824 | case StorageControllerType_PIIX3:
|
---|
825 | pszCtl = "PIIX3";
|
---|
826 | break;
|
---|
827 | case StorageControllerType_PIIX4:
|
---|
828 | pszCtl = "PIIX4";
|
---|
829 | break;
|
---|
830 | case StorageControllerType_ICH6:
|
---|
831 | pszCtl = "ICH6";
|
---|
832 | break;
|
---|
833 | case StorageControllerType_I82078:
|
---|
834 | pszCtl = "I82078";
|
---|
835 | break;
|
---|
836 | case StorageControllerType_USB:
|
---|
837 | pszCtl = "USB";
|
---|
838 | break;
|
---|
839 |
|
---|
840 | default:
|
---|
841 | pszCtl = "unknown";
|
---|
842 | }
|
---|
843 | if (details == VMINFO_MACHINEREADABLE)
|
---|
844 | RTPrintf("storagecontrollertype%u=\"%s\"\n", i, pszCtl);
|
---|
845 | else
|
---|
846 | RTPrintf("Storage Controller Type (%u): %s\n", i, pszCtl);
|
---|
847 |
|
---|
848 | storageCtl->COMGETTER(Instance)(&ulValue);
|
---|
849 | if (details == VMINFO_MACHINEREADABLE)
|
---|
850 | RTPrintf("storagecontrollerinstance%u=\"%lu\"\n", i, ulValue);
|
---|
851 | else
|
---|
852 | RTPrintf("Storage Controller Instance Number (%u): %lu\n", i, ulValue);
|
---|
853 |
|
---|
854 | storageCtl->COMGETTER(MaxPortCount)(&ulValue);
|
---|
855 | if (details == VMINFO_MACHINEREADABLE)
|
---|
856 | RTPrintf("storagecontrollermaxportcount%u=\"%lu\"\n", i, ulValue);
|
---|
857 | else
|
---|
858 | RTPrintf("Storage Controller Max Port Count (%u): %lu\n", i, ulValue);
|
---|
859 |
|
---|
860 | storageCtl->COMGETTER(PortCount)(&ulValue);
|
---|
861 | if (details == VMINFO_MACHINEREADABLE)
|
---|
862 | RTPrintf("storagecontrollerportcount%u=\"%lu\"\n", i, ulValue);
|
---|
863 | else
|
---|
864 | RTPrintf("Storage Controller Port Count (%u): %lu\n", i, ulValue);
|
---|
865 |
|
---|
866 | storageCtl->COMGETTER(Bootable)(&fBootable);
|
---|
867 | if (details == VMINFO_MACHINEREADABLE)
|
---|
868 | RTPrintf("storagecontrollerbootable%u=\"%s\"\n", i, fBootable ? "on" : "off");
|
---|
869 | else
|
---|
870 | RTPrintf("Storage Controller Bootable (%u): %s\n", i, fBootable ? "on" : "off");
|
---|
871 | }
|
---|
872 |
|
---|
873 | for (size_t j = 0; j < storageCtls.size(); ++ j)
|
---|
874 | {
|
---|
875 | ComPtr<IStorageController> storageCtl = storageCtls[j];
|
---|
876 | ComPtr<IMedium> medium;
|
---|
877 | Bstr storageCtlName;
|
---|
878 | Bstr filePath;
|
---|
879 | ULONG cDevices;
|
---|
880 | ULONG cPorts;
|
---|
881 |
|
---|
882 | storageCtl->COMGETTER(Name)(storageCtlName.asOutParam());
|
---|
883 | storageCtl->COMGETTER(MaxDevicesPerPortCount)(&cDevices);
|
---|
884 | storageCtl->COMGETTER(PortCount)(&cPorts);
|
---|
885 |
|
---|
886 | for (ULONG i = 0; i < cPorts; ++ i)
|
---|
887 | {
|
---|
888 | for (ULONG k = 0; k < cDevices; ++ k)
|
---|
889 | {
|
---|
890 | ComPtr<IMediumAttachment> mediumAttach;
|
---|
891 | machine->GetMediumAttachment(storageCtlName.raw(),
|
---|
892 | i, k,
|
---|
893 | mediumAttach.asOutParam());
|
---|
894 | BOOL fIsEjected = FALSE;
|
---|
895 | BOOL fTempEject = FALSE;
|
---|
896 | DeviceType_T devType = DeviceType_Null;
|
---|
897 | if (mediumAttach)
|
---|
898 | {
|
---|
899 | mediumAttach->COMGETTER(TemporaryEject)(&fTempEject);
|
---|
900 | mediumAttach->COMGETTER(IsEjected)(&fIsEjected);
|
---|
901 | mediumAttach->COMGETTER(Type)(&devType);
|
---|
902 | }
|
---|
903 | rc = machine->GetMedium(storageCtlName.raw(), i, k,
|
---|
904 | medium.asOutParam());
|
---|
905 | if (SUCCEEDED(rc) && medium)
|
---|
906 | {
|
---|
907 | BOOL fPassthrough = FALSE;
|
---|
908 |
|
---|
909 | if (mediumAttach)
|
---|
910 | mediumAttach->COMGETTER(Passthrough)(&fPassthrough);
|
---|
911 |
|
---|
912 | medium->COMGETTER(Location)(filePath.asOutParam());
|
---|
913 | Bstr uuid;
|
---|
914 | medium->COMGETTER(Id)(uuid.asOutParam());
|
---|
915 |
|
---|
916 | if (details == VMINFO_MACHINEREADABLE)
|
---|
917 | {
|
---|
918 | RTPrintf("\"%ls-%d-%d\"=\"%ls\"\n", storageCtlName.raw(),
|
---|
919 | i, k, filePath.raw());
|
---|
920 | RTPrintf("\"%ls-ImageUUID-%d-%d\"=\"%s\"\n",
|
---|
921 | storageCtlName.raw(), i, k, Utf8Str(uuid).c_str());
|
---|
922 | if (fPassthrough)
|
---|
923 | RTPrintf("\"%ls-dvdpassthrough\"=\"%s\"\n", storageCtlName.raw(),
|
---|
924 | fPassthrough ? "on" : "off");
|
---|
925 | if (devType == DeviceType_DVD)
|
---|
926 | {
|
---|
927 | RTPrintf("\"%ls-tempeject\"=\"%s\"\n", storageCtlName.raw(),
|
---|
928 | fTempEject ? "on" : "off");
|
---|
929 | RTPrintf("\"%ls-IsEjected\"=\"%s\"\n", storageCtlName.raw(),
|
---|
930 | fIsEjected ? "on" : "off");
|
---|
931 | }
|
---|
932 | }
|
---|
933 | else
|
---|
934 | {
|
---|
935 | RTPrintf("%ls (%d, %d): %ls (UUID: %s)",
|
---|
936 | storageCtlName.raw(), i, k, filePath.raw(),
|
---|
937 | Utf8Str(uuid).c_str());
|
---|
938 | if (fPassthrough)
|
---|
939 | RTPrintf(" (passthrough enabled)");
|
---|
940 | if (fTempEject)
|
---|
941 | RTPrintf(" (temp eject)");
|
---|
942 | if (fIsEjected)
|
---|
943 | RTPrintf(" (ejected)");
|
---|
944 | RTPrintf("\n");
|
---|
945 | }
|
---|
946 | }
|
---|
947 | else if (SUCCEEDED(rc))
|
---|
948 | {
|
---|
949 | if (details == VMINFO_MACHINEREADABLE)
|
---|
950 | {
|
---|
951 | RTPrintf("\"%ls-%d-%d\"=\"emptydrive\"\n", storageCtlName.raw(), i, k);
|
---|
952 | if (devType == DeviceType_DVD)
|
---|
953 | RTPrintf("\"%ls-IsEjected\"=\"%s\"\n", storageCtlName.raw(),
|
---|
954 | fIsEjected ? "on" : "off");
|
---|
955 | }
|
---|
956 | else
|
---|
957 | {
|
---|
958 | RTPrintf("%ls (%d, %d): Empty", storageCtlName.raw(), i, k);
|
---|
959 | if (fTempEject)
|
---|
960 | RTPrintf(" (temp eject)");
|
---|
961 | if (fIsEjected)
|
---|
962 | RTPrintf(" (ejected)");
|
---|
963 | RTPrintf("\n");
|
---|
964 | }
|
---|
965 | }
|
---|
966 | else
|
---|
967 | {
|
---|
968 | if (details == VMINFO_MACHINEREADABLE)
|
---|
969 | RTPrintf("\"%ls-%d-%d\"=\"none\"\n", storageCtlName.raw(), i, k);
|
---|
970 | }
|
---|
971 | }
|
---|
972 | }
|
---|
973 | }
|
---|
974 |
|
---|
975 | /* get the maximum amount of NICS */
|
---|
976 | ULONG maxNICs = getMaxNics(pVirtualBox, machine);
|
---|
977 |
|
---|
978 | for (ULONG currentNIC = 0; currentNIC < maxNICs; currentNIC++)
|
---|
979 | {
|
---|
980 | ComPtr<INetworkAdapter> nic;
|
---|
981 | rc = machine->GetNetworkAdapter(currentNIC, nic.asOutParam());
|
---|
982 | if (SUCCEEDED(rc) && nic)
|
---|
983 | {
|
---|
984 | BOOL fEnabled;
|
---|
985 | nic->COMGETTER(Enabled)(&fEnabled);
|
---|
986 | if (!fEnabled)
|
---|
987 | {
|
---|
988 | if (details == VMINFO_MACHINEREADABLE)
|
---|
989 | RTPrintf("nic%d=\"none\"\n", currentNIC + 1);
|
---|
990 | else
|
---|
991 | RTPrintf("NIC %d: disabled\n", currentNIC + 1);
|
---|
992 | }
|
---|
993 | else
|
---|
994 | {
|
---|
995 | Bstr strMACAddress;
|
---|
996 | nic->COMGETTER(MACAddress)(strMACAddress.asOutParam());
|
---|
997 | Utf8Str strAttachment;
|
---|
998 | Utf8Str strNatSettings = "";
|
---|
999 | Utf8Str strNatForwardings = "";
|
---|
1000 | NetworkAttachmentType_T attachment;
|
---|
1001 | nic->COMGETTER(AttachmentType)(&attachment);
|
---|
1002 | switch (attachment)
|
---|
1003 | {
|
---|
1004 | case NetworkAttachmentType_Null:
|
---|
1005 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1006 | strAttachment = "null";
|
---|
1007 | else
|
---|
1008 | strAttachment = "none";
|
---|
1009 | break;
|
---|
1010 |
|
---|
1011 | case NetworkAttachmentType_NAT:
|
---|
1012 | {
|
---|
1013 | Bstr strNetwork;
|
---|
1014 | ComPtr<INATEngine> engine;
|
---|
1015 | nic->COMGETTER(NATEngine)(engine.asOutParam());
|
---|
1016 | engine->COMGETTER(Network)(strNetwork.asOutParam());
|
---|
1017 | com::SafeArray<BSTR> forwardings;
|
---|
1018 | engine->COMGETTER(Redirects)(ComSafeArrayAsOutParam(forwardings));
|
---|
1019 | strNatForwardings = "";
|
---|
1020 | for (size_t i = 0; i < forwardings.size(); ++i)
|
---|
1021 | {
|
---|
1022 | bool fSkip = false;
|
---|
1023 | uint16_t port = 0;
|
---|
1024 | BSTR r = forwardings[i];
|
---|
1025 | Utf8Str utf = Utf8Str(r);
|
---|
1026 | Utf8Str strName;
|
---|
1027 | Utf8Str strProto;
|
---|
1028 | Utf8Str strHostPort;
|
---|
1029 | Utf8Str strHostIP;
|
---|
1030 | Utf8Str strGuestPort;
|
---|
1031 | Utf8Str strGuestIP;
|
---|
1032 | size_t pos, ppos;
|
---|
1033 | pos = ppos = 0;
|
---|
1034 | #define ITERATE_TO_NEXT_TERM(res, str, pos, ppos) \
|
---|
1035 | do { \
|
---|
1036 | pos = str.find(",", ppos); \
|
---|
1037 | if (pos == Utf8Str::npos) \
|
---|
1038 | { \
|
---|
1039 | Log(( #res " extracting from %s is failed\n", str.c_str())); \
|
---|
1040 | fSkip = true; \
|
---|
1041 | } \
|
---|
1042 | res = str.substr(ppos, pos - ppos); \
|
---|
1043 | Log2((#res " %s pos:%d, ppos:%d\n", res.c_str(), pos, ppos)); \
|
---|
1044 | ppos = pos + 1; \
|
---|
1045 | } while (0)
|
---|
1046 | ITERATE_TO_NEXT_TERM(strName, utf, pos, ppos);
|
---|
1047 | if (fSkip) continue;
|
---|
1048 | ITERATE_TO_NEXT_TERM(strProto, utf, pos, ppos);
|
---|
1049 | if (fSkip) continue;
|
---|
1050 | ITERATE_TO_NEXT_TERM(strHostIP, utf, pos, ppos);
|
---|
1051 | if (fSkip) continue;
|
---|
1052 | ITERATE_TO_NEXT_TERM(strHostPort, utf, pos, ppos);
|
---|
1053 | if (fSkip) continue;
|
---|
1054 | ITERATE_TO_NEXT_TERM(strGuestIP, utf, pos, ppos);
|
---|
1055 | if (fSkip) continue;
|
---|
1056 | strGuestPort = utf.substr(ppos, utf.length() - ppos);
|
---|
1057 | #undef ITERATE_TO_NEXT_TERM
|
---|
1058 | switch (strProto.toUInt32())
|
---|
1059 | {
|
---|
1060 | case NATProtocol_TCP:
|
---|
1061 | strProto = "tcp";
|
---|
1062 | break;
|
---|
1063 | case NATProtocol_UDP:
|
---|
1064 | strProto = "udp";
|
---|
1065 | break;
|
---|
1066 | default:
|
---|
1067 | strProto = "unk";
|
---|
1068 | break;
|
---|
1069 | }
|
---|
1070 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1071 | {
|
---|
1072 | strNatForwardings = Utf8StrFmt("%sForwarding(%d)=\"%s,%s,%s,%s,%s,%s\"\n",
|
---|
1073 | strNatForwardings.c_str(), i, strName.c_str(), strProto.c_str(),
|
---|
1074 | strHostIP.c_str(), strHostPort.c_str(),
|
---|
1075 | strGuestIP.c_str(), strGuestPort.c_str());
|
---|
1076 | }
|
---|
1077 | else
|
---|
1078 | {
|
---|
1079 | strNatForwardings = Utf8StrFmt("%sNIC %d Rule(%d): name = %s, protocol = %s,"
|
---|
1080 | " host ip = %s, host port = %s, guest ip = %s, guest port = %s\n",
|
---|
1081 | strNatForwardings.c_str(), currentNIC + 1, i, strName.c_str(), strProto.c_str(),
|
---|
1082 | strHostIP.c_str(), strHostPort.c_str(),
|
---|
1083 | strGuestIP.c_str(), strGuestPort.c_str());
|
---|
1084 | }
|
---|
1085 | }
|
---|
1086 | ULONG mtu = 0;
|
---|
1087 | ULONG sockSnd = 0;
|
---|
1088 | ULONG sockRcv = 0;
|
---|
1089 | ULONG tcpSnd = 0;
|
---|
1090 | ULONG tcpRcv = 0;
|
---|
1091 | engine->GetNetworkSettings(&mtu, &sockSnd, &sockRcv, &tcpSnd, &tcpRcv);
|
---|
1092 |
|
---|
1093 | /** @todo r=klaus dnsproxy etc needs to be dumped, too */
|
---|
1094 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1095 | {
|
---|
1096 | RTPrintf("natnet%d=\"%ls\"\n", currentNIC + 1, strNetwork.length() ? strNetwork.raw(): Bstr("nat").raw());
|
---|
1097 | strAttachment = "nat";
|
---|
1098 | strNatSettings = Utf8StrFmt("mtu=\"%d\"\nsockSnd=\"%d\"\nsockRcv=\"%d\"\ntcpWndSnd=\"%d\"\ntcpWndRcv=\"%d\"\n",
|
---|
1099 | mtu, sockSnd ? sockSnd : 64, sockRcv ? sockRcv : 64, tcpSnd ? tcpSnd : 64, tcpRcv ? tcpRcv : 64);
|
---|
1100 | }
|
---|
1101 | else
|
---|
1102 | {
|
---|
1103 | strAttachment = "NAT";
|
---|
1104 | strNatSettings = Utf8StrFmt("NIC %d Settings: MTU: %d, Socket (send: %d, receive: %d), TCP Window (send:%d, receive: %d)\n",
|
---|
1105 | currentNIC + 1, mtu, sockSnd ? sockSnd : 64, sockRcv ? sockRcv : 64, tcpSnd ? tcpSnd : 64, tcpRcv ? tcpRcv : 64);
|
---|
1106 | }
|
---|
1107 | break;
|
---|
1108 | }
|
---|
1109 |
|
---|
1110 | case NetworkAttachmentType_Bridged:
|
---|
1111 | {
|
---|
1112 | Bstr strBridgeAdp;
|
---|
1113 | nic->COMGETTER(BridgedInterface)(strBridgeAdp.asOutParam());
|
---|
1114 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1115 | {
|
---|
1116 | RTPrintf("bridgeadapter%d=\"%ls\"\n", currentNIC + 1, strBridgeAdp.raw());
|
---|
1117 | strAttachment = "bridged";
|
---|
1118 | }
|
---|
1119 | else
|
---|
1120 | strAttachment = Utf8StrFmt("Bridged Interface '%ls'", strBridgeAdp.raw());
|
---|
1121 | break;
|
---|
1122 | }
|
---|
1123 |
|
---|
1124 | case NetworkAttachmentType_Internal:
|
---|
1125 | {
|
---|
1126 | Bstr strNetwork;
|
---|
1127 | nic->COMGETTER(InternalNetwork)(strNetwork.asOutParam());
|
---|
1128 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1129 | {
|
---|
1130 | RTPrintf("intnet%d=\"%ls\"\n", currentNIC + 1, strNetwork.raw());
|
---|
1131 | strAttachment = "intnet";
|
---|
1132 | }
|
---|
1133 | else
|
---|
1134 | strAttachment = Utf8StrFmt("Internal Network '%s'", Utf8Str(strNetwork).c_str());
|
---|
1135 | break;
|
---|
1136 | }
|
---|
1137 |
|
---|
1138 | case NetworkAttachmentType_HostOnly:
|
---|
1139 | {
|
---|
1140 | Bstr strHostonlyAdp;
|
---|
1141 | nic->COMGETTER(HostOnlyInterface)(strHostonlyAdp.asOutParam());
|
---|
1142 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1143 | {
|
---|
1144 | RTPrintf("hostonlyadapter%d=\"%ls\"\n", currentNIC + 1, strHostonlyAdp.raw());
|
---|
1145 | strAttachment = "hostonly";
|
---|
1146 | }
|
---|
1147 | else
|
---|
1148 | strAttachment = Utf8StrFmt("Host-only Interface '%ls'", strHostonlyAdp.raw());
|
---|
1149 | break;
|
---|
1150 | }
|
---|
1151 |
|
---|
1152 | case NetworkAttachmentType_Generic:
|
---|
1153 | {
|
---|
1154 | Bstr strGenericDriver;
|
---|
1155 | nic->COMGETTER(GenericDriver)(strGenericDriver.asOutParam());
|
---|
1156 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1157 | {
|
---|
1158 | RTPrintf("generic%d=\"%ls\"\n", currentNIC + 1, strGenericDriver.raw());
|
---|
1159 | strAttachment = "Generic";
|
---|
1160 | }
|
---|
1161 | else
|
---|
1162 | {
|
---|
1163 | strAttachment = Utf8StrFmt("Generic '%ls'", strGenericDriver.raw());
|
---|
1164 |
|
---|
1165 | // show the generic properties
|
---|
1166 | com::SafeArray<BSTR> aProperties;
|
---|
1167 | com::SafeArray<BSTR> aValues;
|
---|
1168 | rc = nic->GetProperties(NULL,
|
---|
1169 | ComSafeArrayAsOutParam(aProperties),
|
---|
1170 | ComSafeArrayAsOutParam(aValues));
|
---|
1171 | if (SUCCEEDED(rc))
|
---|
1172 | {
|
---|
1173 | strAttachment += " { ";
|
---|
1174 | for (unsigned i = 0; i < aProperties.size(); ++i)
|
---|
1175 | strAttachment += Utf8StrFmt(!i ? "%ls='%ls'" : ", %ls='%ls'",
|
---|
1176 | aProperties[i], aValues[i]);
|
---|
1177 | strAttachment += " }";
|
---|
1178 | }
|
---|
1179 | }
|
---|
1180 | break;
|
---|
1181 | }
|
---|
1182 |
|
---|
1183 | case NetworkAttachmentType_NATNetwork:
|
---|
1184 | {
|
---|
1185 | Bstr strNetwork;
|
---|
1186 | nic->COMGETTER(NATNetwork)(strNetwork.asOutParam());
|
---|
1187 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1188 | {
|
---|
1189 | RTPrintf("nat-network%d=\"%ls\"\n", currentNIC + 1, strNetwork.raw());
|
---|
1190 | strAttachment = "natnetwork";
|
---|
1191 | }
|
---|
1192 | else
|
---|
1193 | strAttachment = Utf8StrFmt("NAT Network '%s'", Utf8Str(strNetwork).c_str());
|
---|
1194 | break;
|
---|
1195 | }
|
---|
1196 |
|
---|
1197 | default:
|
---|
1198 | strAttachment = "unknown";
|
---|
1199 | break;
|
---|
1200 | }
|
---|
1201 |
|
---|
1202 | /* cable connected */
|
---|
1203 | BOOL fConnected;
|
---|
1204 | nic->COMGETTER(CableConnected)(&fConnected);
|
---|
1205 |
|
---|
1206 | /* promisc policy */
|
---|
1207 | NetworkAdapterPromiscModePolicy_T enmPromiscModePolicy;
|
---|
1208 | CHECK_ERROR2I_RET(nic, COMGETTER(PromiscModePolicy)(&enmPromiscModePolicy), hrcCheck);
|
---|
1209 | const char *pszPromiscuousGuestPolicy;
|
---|
1210 | switch (enmPromiscModePolicy)
|
---|
1211 | {
|
---|
1212 | case NetworkAdapterPromiscModePolicy_Deny: pszPromiscuousGuestPolicy = "deny"; break;
|
---|
1213 | case NetworkAdapterPromiscModePolicy_AllowNetwork: pszPromiscuousGuestPolicy = "allow-vms"; break;
|
---|
1214 | case NetworkAdapterPromiscModePolicy_AllowAll: pszPromiscuousGuestPolicy = "allow-all"; break;
|
---|
1215 | default: AssertFailedReturn(E_INVALIDARG);
|
---|
1216 | }
|
---|
1217 |
|
---|
1218 | /* trace stuff */
|
---|
1219 | BOOL fTraceEnabled;
|
---|
1220 | nic->COMGETTER(TraceEnabled)(&fTraceEnabled);
|
---|
1221 | Bstr traceFile;
|
---|
1222 | nic->COMGETTER(TraceFile)(traceFile.asOutParam());
|
---|
1223 |
|
---|
1224 | /* NIC type */
|
---|
1225 | NetworkAdapterType_T NICType;
|
---|
1226 | nic->COMGETTER(AdapterType)(&NICType);
|
---|
1227 | const char *pszNICType;
|
---|
1228 | switch (NICType)
|
---|
1229 | {
|
---|
1230 | case NetworkAdapterType_Am79C970A: pszNICType = "Am79C970A"; break;
|
---|
1231 | case NetworkAdapterType_Am79C973: pszNICType = "Am79C973"; break;
|
---|
1232 | #ifdef VBOX_WITH_E1000
|
---|
1233 | case NetworkAdapterType_I82540EM: pszNICType = "82540EM"; break;
|
---|
1234 | case NetworkAdapterType_I82543GC: pszNICType = "82543GC"; break;
|
---|
1235 | case NetworkAdapterType_I82545EM: pszNICType = "82545EM"; break;
|
---|
1236 | #endif
|
---|
1237 | #ifdef VBOX_WITH_VIRTIO
|
---|
1238 | case NetworkAdapterType_Virtio: pszNICType = "virtio"; break;
|
---|
1239 | #endif
|
---|
1240 | default: AssertFailed(); pszNICType = "unknown"; break;
|
---|
1241 | }
|
---|
1242 |
|
---|
1243 | /* reported line speed */
|
---|
1244 | ULONG ulLineSpeed;
|
---|
1245 | nic->COMGETTER(LineSpeed)(&ulLineSpeed);
|
---|
1246 |
|
---|
1247 | /* boot priority of the adapter */
|
---|
1248 | ULONG ulBootPriority;
|
---|
1249 | nic->COMGETTER(BootPriority)(&ulBootPriority);
|
---|
1250 |
|
---|
1251 | /* bandwidth group */
|
---|
1252 | ComObjPtr<IBandwidthGroup> pBwGroup;
|
---|
1253 | Bstr strBwGroup;
|
---|
1254 | nic->COMGETTER(BandwidthGroup)(pBwGroup.asOutParam());
|
---|
1255 | if (!pBwGroup.isNull())
|
---|
1256 | pBwGroup->COMGETTER(Name)(strBwGroup.asOutParam());
|
---|
1257 |
|
---|
1258 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1259 | {
|
---|
1260 | RTPrintf("macaddress%d=\"%ls\"\n", currentNIC + 1, strMACAddress.raw());
|
---|
1261 | RTPrintf("cableconnected%d=\"%s\"\n", currentNIC + 1, fConnected ? "on" : "off");
|
---|
1262 | RTPrintf("nic%d=\"%s\"\n", currentNIC + 1, strAttachment.c_str());
|
---|
1263 | RTPrintf("nictype%d=\"%s\"\n", currentNIC + 1, pszNICType);
|
---|
1264 | RTPrintf("nicspeed%d=\"%d\"\n", currentNIC + 1, ulLineSpeed);
|
---|
1265 | }
|
---|
1266 | else
|
---|
1267 | RTPrintf("NIC %u: MAC: %ls, Attachment: %s, Cable connected: %s, Trace: %s (file: %ls), Type: %s, Reported speed: %d Mbps, Boot priority: %d, Promisc Policy: %s, Bandwidth group: %ls\n",
|
---|
1268 | currentNIC + 1, strMACAddress.raw(), strAttachment.c_str(),
|
---|
1269 | fConnected ? "on" : "off",
|
---|
1270 | fTraceEnabled ? "on" : "off",
|
---|
1271 | traceFile.isEmpty() ? Bstr("none").raw() : traceFile.raw(),
|
---|
1272 | pszNICType,
|
---|
1273 | ulLineSpeed / 1000,
|
---|
1274 | (int)ulBootPriority,
|
---|
1275 | pszPromiscuousGuestPolicy,
|
---|
1276 | strBwGroup.isEmpty() ? Bstr("none").raw() : strBwGroup.raw());
|
---|
1277 | if (strNatSettings.length())
|
---|
1278 | RTPrintf(strNatSettings.c_str());
|
---|
1279 | if (strNatForwardings.length())
|
---|
1280 | RTPrintf(strNatForwardings.c_str());
|
---|
1281 | }
|
---|
1282 | }
|
---|
1283 | }
|
---|
1284 |
|
---|
1285 | /* Pointing device information */
|
---|
1286 | PointingHIDType_T aPointingHID;
|
---|
1287 | const char *pszHID = "Unknown";
|
---|
1288 | const char *pszMrHID = "unknown";
|
---|
1289 | machine->COMGETTER(PointingHIDType)(&aPointingHID);
|
---|
1290 | switch (aPointingHID)
|
---|
1291 | {
|
---|
1292 | case PointingHIDType_None:
|
---|
1293 | pszHID = "None";
|
---|
1294 | pszMrHID = "none";
|
---|
1295 | break;
|
---|
1296 | case PointingHIDType_PS2Mouse:
|
---|
1297 | pszHID = "PS/2 Mouse";
|
---|
1298 | pszMrHID = "ps2mouse";
|
---|
1299 | break;
|
---|
1300 | case PointingHIDType_USBMouse:
|
---|
1301 | pszHID = "USB Mouse";
|
---|
1302 | pszMrHID = "usbmouse";
|
---|
1303 | break;
|
---|
1304 | case PointingHIDType_USBTablet:
|
---|
1305 | pszHID = "USB Tablet";
|
---|
1306 | pszMrHID = "usbtablet";
|
---|
1307 | break;
|
---|
1308 | case PointingHIDType_ComboMouse:
|
---|
1309 | pszHID = "USB Tablet and PS/2 Mouse";
|
---|
1310 | pszMrHID = "combomouse";
|
---|
1311 | break;
|
---|
1312 | case PointingHIDType_USBMultiTouch:
|
---|
1313 | pszHID = "USB Multi-Touch";
|
---|
1314 | pszMrHID = "usbmultitouch";
|
---|
1315 | break;
|
---|
1316 | default:
|
---|
1317 | break;
|
---|
1318 | }
|
---|
1319 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1320 | RTPrintf("hidpointing=\"%s\"\n", pszMrHID);
|
---|
1321 | else
|
---|
1322 | RTPrintf("Pointing Device: %s\n", pszHID);
|
---|
1323 |
|
---|
1324 | /* Keyboard device information */
|
---|
1325 | KeyboardHIDType_T aKeyboardHID;
|
---|
1326 | machine->COMGETTER(KeyboardHIDType)(&aKeyboardHID);
|
---|
1327 | pszHID = "Unknown";
|
---|
1328 | pszMrHID = "unknown";
|
---|
1329 | switch (aKeyboardHID)
|
---|
1330 | {
|
---|
1331 | case KeyboardHIDType_None:
|
---|
1332 | pszHID = "None";
|
---|
1333 | pszMrHID = "none";
|
---|
1334 | break;
|
---|
1335 | case KeyboardHIDType_PS2Keyboard:
|
---|
1336 | pszHID = "PS/2 Keyboard";
|
---|
1337 | pszMrHID = "ps2kbd";
|
---|
1338 | break;
|
---|
1339 | case KeyboardHIDType_USBKeyboard:
|
---|
1340 | pszHID = "USB Keyboard";
|
---|
1341 | pszMrHID = "usbkbd";
|
---|
1342 | break;
|
---|
1343 | case KeyboardHIDType_ComboKeyboard:
|
---|
1344 | pszHID = "USB and PS/2 Keyboard";
|
---|
1345 | pszMrHID = "combokbd";
|
---|
1346 | break;
|
---|
1347 | default:
|
---|
1348 | break;
|
---|
1349 | }
|
---|
1350 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1351 | RTPrintf("hidkeyboard=\"%s\"\n", pszMrHID);
|
---|
1352 | else
|
---|
1353 | RTPrintf("Keyboard Device: %s\n", pszHID);
|
---|
1354 |
|
---|
1355 | ComPtr<ISystemProperties> sysProps;
|
---|
1356 | pVirtualBox->COMGETTER(SystemProperties)(sysProps.asOutParam());
|
---|
1357 |
|
---|
1358 | /* get the maximum amount of UARTs */
|
---|
1359 | ULONG maxUARTs = 0;
|
---|
1360 | sysProps->COMGETTER(SerialPortCount)(&maxUARTs);
|
---|
1361 | for (ULONG currentUART = 0; currentUART < maxUARTs; currentUART++)
|
---|
1362 | {
|
---|
1363 | ComPtr<ISerialPort> uart;
|
---|
1364 | rc = machine->GetSerialPort(currentUART, uart.asOutParam());
|
---|
1365 | if (SUCCEEDED(rc) && uart)
|
---|
1366 | {
|
---|
1367 | /* show the config of this UART */
|
---|
1368 | BOOL fEnabled;
|
---|
1369 | uart->COMGETTER(Enabled)(&fEnabled);
|
---|
1370 | if (!fEnabled)
|
---|
1371 | {
|
---|
1372 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1373 | RTPrintf("uart%d=\"off\"\n", currentUART + 1);
|
---|
1374 | else
|
---|
1375 | RTPrintf("UART %d: disabled\n", currentUART + 1);
|
---|
1376 | }
|
---|
1377 | else
|
---|
1378 | {
|
---|
1379 | ULONG ulIRQ, ulIOBase;
|
---|
1380 | PortMode_T HostMode;
|
---|
1381 | Bstr path;
|
---|
1382 | BOOL fServer;
|
---|
1383 | uart->COMGETTER(IRQ)(&ulIRQ);
|
---|
1384 | uart->COMGETTER(IOBase)(&ulIOBase);
|
---|
1385 | uart->COMGETTER(Path)(path.asOutParam());
|
---|
1386 | uart->COMGETTER(Server)(&fServer);
|
---|
1387 | uart->COMGETTER(HostMode)(&HostMode);
|
---|
1388 |
|
---|
1389 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1390 | RTPrintf("uart%d=\"%#06x,%d\"\n", currentUART + 1,
|
---|
1391 | ulIOBase, ulIRQ);
|
---|
1392 | else
|
---|
1393 | RTPrintf("UART %d: I/O base: %#06x, IRQ: %d",
|
---|
1394 | currentUART + 1, ulIOBase, ulIRQ);
|
---|
1395 | switch (HostMode)
|
---|
1396 | {
|
---|
1397 | default:
|
---|
1398 | case PortMode_Disconnected:
|
---|
1399 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1400 | RTPrintf("uartmode%d=\"disconnected\"\n", currentUART + 1);
|
---|
1401 | else
|
---|
1402 | RTPrintf(", disconnected\n");
|
---|
1403 | break;
|
---|
1404 | case PortMode_RawFile:
|
---|
1405 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1406 | RTPrintf("uartmode%d=\"file,%ls\"\n", currentUART + 1,
|
---|
1407 | path.raw());
|
---|
1408 | else
|
---|
1409 | RTPrintf(", attached to raw file '%ls'\n",
|
---|
1410 | path.raw());
|
---|
1411 | break;
|
---|
1412 | case PortMode_TCP:
|
---|
1413 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1414 | RTPrintf("uartmode%d=\"%s,%ls\"\n", currentUART + 1,
|
---|
1415 | fServer ? "tcpserver" : "tcpclient", path.raw());
|
---|
1416 | else
|
---|
1417 | RTPrintf(", attached to tcp (%s) '%ls'\n",
|
---|
1418 | fServer ? "server" : "client", path.raw());
|
---|
1419 | break;
|
---|
1420 | case PortMode_HostPipe:
|
---|
1421 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1422 | RTPrintf("uartmode%d=\"%s,%ls\"\n", currentUART + 1,
|
---|
1423 | fServer ? "server" : "client", path.raw());
|
---|
1424 | else
|
---|
1425 | RTPrintf(", attached to pipe (%s) '%ls'\n",
|
---|
1426 | fServer ? "server" : "client", path.raw());
|
---|
1427 | break;
|
---|
1428 | case PortMode_HostDevice:
|
---|
1429 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1430 | RTPrintf("uartmode%d=\"%ls\"\n", currentUART + 1,
|
---|
1431 | path.raw());
|
---|
1432 | else
|
---|
1433 | RTPrintf(", attached to device '%ls'\n", path.raw());
|
---|
1434 | break;
|
---|
1435 | }
|
---|
1436 | }
|
---|
1437 | }
|
---|
1438 | }
|
---|
1439 |
|
---|
1440 | /* get the maximum amount of LPTs */
|
---|
1441 | ULONG maxLPTs = 0;
|
---|
1442 | sysProps->COMGETTER(ParallelPortCount)(&maxLPTs);
|
---|
1443 | for (ULONG currentLPT = 0; currentLPT < maxLPTs; currentLPT++)
|
---|
1444 | {
|
---|
1445 | ComPtr<IParallelPort> lpt;
|
---|
1446 | rc = machine->GetParallelPort(currentLPT, lpt.asOutParam());
|
---|
1447 | if (SUCCEEDED(rc) && lpt)
|
---|
1448 | {
|
---|
1449 | /* show the config of this LPT */
|
---|
1450 | BOOL fEnabled;
|
---|
1451 | lpt->COMGETTER(Enabled)(&fEnabled);
|
---|
1452 | if (!fEnabled)
|
---|
1453 | {
|
---|
1454 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1455 | RTPrintf("lpt%d=\"off\"\n", currentLPT + 1);
|
---|
1456 | else
|
---|
1457 | RTPrintf("LPT %d: disabled\n", currentLPT + 1);
|
---|
1458 | }
|
---|
1459 | else
|
---|
1460 | {
|
---|
1461 | ULONG ulIRQ, ulIOBase;
|
---|
1462 | Bstr path;
|
---|
1463 | lpt->COMGETTER(IRQ)(&ulIRQ);
|
---|
1464 | lpt->COMGETTER(IOBase)(&ulIOBase);
|
---|
1465 | lpt->COMGETTER(Path)(path.asOutParam());
|
---|
1466 |
|
---|
1467 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1468 | RTPrintf("lpt%d=\"%#06x,%d\"\n", currentLPT + 1,
|
---|
1469 | ulIOBase, ulIRQ);
|
---|
1470 | else
|
---|
1471 | RTPrintf("LPT %d: I/O base: %#06x, IRQ: %d",
|
---|
1472 | currentLPT + 1, ulIOBase, ulIRQ);
|
---|
1473 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1474 | RTPrintf("lptmode%d=\"%ls\"\n", currentLPT + 1,
|
---|
1475 | path.raw());
|
---|
1476 | else
|
---|
1477 | RTPrintf(", attached to device '%ls'\n", path.raw());
|
---|
1478 | }
|
---|
1479 | }
|
---|
1480 | }
|
---|
1481 |
|
---|
1482 | ComPtr<IAudioAdapter> AudioAdapter;
|
---|
1483 | rc = machine->COMGETTER(AudioAdapter)(AudioAdapter.asOutParam());
|
---|
1484 | if (SUCCEEDED(rc))
|
---|
1485 | {
|
---|
1486 | const char *pszDrv = "Unknown";
|
---|
1487 | const char *pszCtrl = "Unknown";
|
---|
1488 | const char *pszCodec = "Unknown";
|
---|
1489 | BOOL fEnabled;
|
---|
1490 | rc = AudioAdapter->COMGETTER(Enabled)(&fEnabled);
|
---|
1491 | if (SUCCEEDED(rc) && fEnabled)
|
---|
1492 | {
|
---|
1493 | AudioDriverType_T enmDrvType;
|
---|
1494 | rc = AudioAdapter->COMGETTER(AudioDriver)(&enmDrvType);
|
---|
1495 | switch (enmDrvType)
|
---|
1496 | {
|
---|
1497 | case AudioDriverType_Null:
|
---|
1498 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1499 | pszDrv = "null";
|
---|
1500 | else
|
---|
1501 | pszDrv = "Null";
|
---|
1502 | break;
|
---|
1503 | case AudioDriverType_WinMM:
|
---|
1504 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1505 | pszDrv = "winmm";
|
---|
1506 | else
|
---|
1507 | pszDrv = "WINMM";
|
---|
1508 | break;
|
---|
1509 | case AudioDriverType_DirectSound:
|
---|
1510 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1511 | pszDrv = "dsound";
|
---|
1512 | else
|
---|
1513 | pszDrv = "DSOUND";
|
---|
1514 | break;
|
---|
1515 | case AudioDriverType_OSS:
|
---|
1516 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1517 | pszDrv = "oss";
|
---|
1518 | else
|
---|
1519 | pszDrv = "OSS";
|
---|
1520 | break;
|
---|
1521 | case AudioDriverType_ALSA:
|
---|
1522 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1523 | pszDrv = "alsa";
|
---|
1524 | else
|
---|
1525 | pszDrv = "ALSA";
|
---|
1526 | break;
|
---|
1527 | case AudioDriverType_Pulse:
|
---|
1528 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1529 | pszDrv = "pulse";
|
---|
1530 | else
|
---|
1531 | pszDrv = "PulseAudio";
|
---|
1532 | break;
|
---|
1533 | case AudioDriverType_CoreAudio:
|
---|
1534 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1535 | pszDrv = "coreaudio";
|
---|
1536 | else
|
---|
1537 | pszDrv = "CoreAudio";
|
---|
1538 | break;
|
---|
1539 | case AudioDriverType_SolAudio:
|
---|
1540 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1541 | pszDrv = "solaudio";
|
---|
1542 | else
|
---|
1543 | pszDrv = "SolAudio";
|
---|
1544 | break;
|
---|
1545 | default:
|
---|
1546 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1547 | pszDrv = "unknown";
|
---|
1548 | break;
|
---|
1549 | }
|
---|
1550 | AudioControllerType_T enmCtrlType;
|
---|
1551 | rc = AudioAdapter->COMGETTER(AudioController)(&enmCtrlType);
|
---|
1552 | switch (enmCtrlType)
|
---|
1553 | {
|
---|
1554 | case AudioControllerType_AC97:
|
---|
1555 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1556 | pszCtrl = "ac97";
|
---|
1557 | else
|
---|
1558 | pszCtrl = "AC97";
|
---|
1559 | break;
|
---|
1560 | case AudioControllerType_SB16:
|
---|
1561 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1562 | pszCtrl = "sb16";
|
---|
1563 | else
|
---|
1564 | pszCtrl = "SB16";
|
---|
1565 | break;
|
---|
1566 | case AudioControllerType_HDA:
|
---|
1567 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1568 | pszCtrl = "hda";
|
---|
1569 | else
|
---|
1570 | pszCtrl = "HDA";
|
---|
1571 | break;
|
---|
1572 | }
|
---|
1573 | AudioCodecType_T enmCodecType;
|
---|
1574 | rc = AudioAdapter->COMGETTER(AudioCodec)(&enmCodecType);
|
---|
1575 | switch (enmCodecType)
|
---|
1576 | {
|
---|
1577 | case AudioCodecType_SB16:
|
---|
1578 | pszCodec = "SB16";
|
---|
1579 | break;
|
---|
1580 | case AudioCodecType_STAC9700:
|
---|
1581 | pszCodec = "STAC9700";
|
---|
1582 | break;
|
---|
1583 | case AudioCodecType_AD1980:
|
---|
1584 | pszCodec = "AD1980";
|
---|
1585 | break;
|
---|
1586 | case AudioCodecType_STAC9221:
|
---|
1587 | pszCodec = "STAC9221";
|
---|
1588 | break;
|
---|
1589 | }
|
---|
1590 | }
|
---|
1591 | else
|
---|
1592 | fEnabled = FALSE;
|
---|
1593 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1594 | {
|
---|
1595 | if (fEnabled)
|
---|
1596 | RTPrintf("audio=\"%s\"\n", pszDrv);
|
---|
1597 | else
|
---|
1598 | RTPrintf("audio=\"none\"\n");
|
---|
1599 | }
|
---|
1600 | else
|
---|
1601 | {
|
---|
1602 | RTPrintf("Audio: %s",
|
---|
1603 | fEnabled ? "enabled" : "disabled");
|
---|
1604 | if (fEnabled)
|
---|
1605 | RTPrintf(" (Driver: %s, Controller: %s, Codec: %s)",
|
---|
1606 | pszDrv, pszCtrl, pszCodec);
|
---|
1607 | RTPrintf("\n");
|
---|
1608 | }
|
---|
1609 | }
|
---|
1610 |
|
---|
1611 | /* Shared clipboard */
|
---|
1612 | {
|
---|
1613 | const char *psz = "Unknown";
|
---|
1614 | ClipboardMode_T enmMode;
|
---|
1615 | rc = machine->COMGETTER(ClipboardMode)(&enmMode);
|
---|
1616 | switch (enmMode)
|
---|
1617 | {
|
---|
1618 | case ClipboardMode_Disabled:
|
---|
1619 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1620 | psz = "disabled";
|
---|
1621 | else
|
---|
1622 | psz = "disabled";
|
---|
1623 | break;
|
---|
1624 | case ClipboardMode_HostToGuest:
|
---|
1625 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1626 | psz = "hosttoguest";
|
---|
1627 | else
|
---|
1628 | psz = "HostToGuest";
|
---|
1629 | break;
|
---|
1630 | case ClipboardMode_GuestToHost:
|
---|
1631 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1632 | psz = "guesttohost";
|
---|
1633 | else
|
---|
1634 | psz = "GuestToHost";
|
---|
1635 | break;
|
---|
1636 | case ClipboardMode_Bidirectional:
|
---|
1637 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1638 | psz = "bidirectional";
|
---|
1639 | else
|
---|
1640 | psz = "Bidirectional";
|
---|
1641 | break;
|
---|
1642 | default:
|
---|
1643 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1644 | psz = "unknown";
|
---|
1645 | break;
|
---|
1646 | }
|
---|
1647 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1648 | RTPrintf("clipboard=\"%s\"\n", psz);
|
---|
1649 | else
|
---|
1650 | RTPrintf("Clipboard Mode: %s\n", psz);
|
---|
1651 | }
|
---|
1652 |
|
---|
1653 | /* Drag and drop */
|
---|
1654 | {
|
---|
1655 | const char *psz = "Unknown";
|
---|
1656 | DnDMode_T enmMode;
|
---|
1657 | rc = machine->COMGETTER(DnDMode)(&enmMode);
|
---|
1658 | switch (enmMode)
|
---|
1659 | {
|
---|
1660 | case DnDMode_Disabled:
|
---|
1661 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1662 | psz = "disabled";
|
---|
1663 | else
|
---|
1664 | psz = "disabled";
|
---|
1665 | break;
|
---|
1666 | case DnDMode_HostToGuest:
|
---|
1667 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1668 | psz = "hosttoguest";
|
---|
1669 | else
|
---|
1670 | psz = "HostToGuest";
|
---|
1671 | break;
|
---|
1672 | case DnDMode_GuestToHost:
|
---|
1673 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1674 | psz = "guesttohost";
|
---|
1675 | else
|
---|
1676 | psz = "GuestToHost";
|
---|
1677 | break;
|
---|
1678 | case DnDMode_Bidirectional:
|
---|
1679 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1680 | psz = "bidirectional";
|
---|
1681 | else
|
---|
1682 | psz = "Bidirectional";
|
---|
1683 | break;
|
---|
1684 | default:
|
---|
1685 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1686 | psz = "unknown";
|
---|
1687 | break;
|
---|
1688 | }
|
---|
1689 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1690 | RTPrintf("draganddrop=\"%s\"\n", psz);
|
---|
1691 | else
|
---|
1692 | RTPrintf("Drag and drop Mode: %s\n", psz);
|
---|
1693 | }
|
---|
1694 |
|
---|
1695 | {
|
---|
1696 | SessionState_T sessState;
|
---|
1697 | rc = machine->COMGETTER(SessionState)(&sessState);
|
---|
1698 | if (SUCCEEDED(rc) && sessState != SessionState_Unlocked)
|
---|
1699 | {
|
---|
1700 | Bstr sessName;
|
---|
1701 | rc = machine->COMGETTER(SessionName)(sessName.asOutParam());
|
---|
1702 | if (SUCCEEDED(rc) && !sessName.isEmpty())
|
---|
1703 | {
|
---|
1704 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1705 | RTPrintf("SessionName=\"%ls\"\n", sessName.raw());
|
---|
1706 | else
|
---|
1707 | RTPrintf("Session name: %ls\n", sessName.raw());
|
---|
1708 | }
|
---|
1709 | }
|
---|
1710 | }
|
---|
1711 |
|
---|
1712 | if (pConsole)
|
---|
1713 | {
|
---|
1714 | do
|
---|
1715 | {
|
---|
1716 | ComPtr<IDisplay> display;
|
---|
1717 | rc = pConsole->COMGETTER(Display)(display.asOutParam());
|
---|
1718 | if (rc == E_ACCESSDENIED || display.isNull())
|
---|
1719 | break; /* VM not powered up */
|
---|
1720 | if (FAILED(rc))
|
---|
1721 | {
|
---|
1722 | com::GlueHandleComError(pConsole, "COMGETTER(Display)(display.asOutParam())", rc, __FILE__, __LINE__);
|
---|
1723 | return rc;
|
---|
1724 | }
|
---|
1725 | ULONG xRes, yRes, bpp;
|
---|
1726 | LONG xOrigin, yOrigin;
|
---|
1727 | GuestMonitorStatus_T monitorStatus;
|
---|
1728 | rc = display->GetScreenResolution(0, &xRes, &yRes, &bpp, &xOrigin, &yOrigin, &monitorStatus);
|
---|
1729 | if (rc == E_ACCESSDENIED)
|
---|
1730 | break; /* VM not powered up */
|
---|
1731 | if (FAILED(rc))
|
---|
1732 | {
|
---|
1733 | com::ErrorInfo info(display, COM_IIDOF(IDisplay));
|
---|
1734 | GluePrintErrorInfo(info);
|
---|
1735 | return rc;
|
---|
1736 | }
|
---|
1737 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1738 | RTPrintf("VideoMode=\"%d,%d,%d\"@%d,%d %d\n", xRes, yRes, bpp, xOrigin, yOrigin, monitorStatus);
|
---|
1739 | else
|
---|
1740 | {
|
---|
1741 | const char *pszMonitorStatus = "unknown status";
|
---|
1742 | switch (monitorStatus)
|
---|
1743 | {
|
---|
1744 | case GuestMonitorStatus_Enabled: pszMonitorStatus = "enabled"; break;
|
---|
1745 | case GuestMonitorStatus_Disabled: pszMonitorStatus = "disabled"; break;
|
---|
1746 | default: break;
|
---|
1747 | }
|
---|
1748 | RTPrintf("Video mode: %dx%dx%d at %d,%d %s\n", xRes, yRes, bpp, xOrigin, yOrigin, pszMonitorStatus);
|
---|
1749 | }
|
---|
1750 | }
|
---|
1751 | while (0);
|
---|
1752 | }
|
---|
1753 |
|
---|
1754 | /*
|
---|
1755 | * Remote Desktop
|
---|
1756 | */
|
---|
1757 | ComPtr<IVRDEServer> vrdeServer;
|
---|
1758 | rc = machine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
|
---|
1759 | if (SUCCEEDED(rc) && vrdeServer)
|
---|
1760 | {
|
---|
1761 | BOOL fEnabled = false;
|
---|
1762 | vrdeServer->COMGETTER(Enabled)(&fEnabled);
|
---|
1763 | if (fEnabled)
|
---|
1764 | {
|
---|
1765 | LONG currentPort = -1;
|
---|
1766 | Bstr ports;
|
---|
1767 | vrdeServer->GetVRDEProperty(Bstr("TCP/Ports").raw(), ports.asOutParam());
|
---|
1768 | Bstr address;
|
---|
1769 | vrdeServer->GetVRDEProperty(Bstr("TCP/Address").raw(), address.asOutParam());
|
---|
1770 | BOOL fMultiCon;
|
---|
1771 | vrdeServer->COMGETTER(AllowMultiConnection)(&fMultiCon);
|
---|
1772 | BOOL fReuseCon;
|
---|
1773 | vrdeServer->COMGETTER(ReuseSingleConnection)(&fReuseCon);
|
---|
1774 | Bstr videoChannel;
|
---|
1775 | vrdeServer->GetVRDEProperty(Bstr("VideoChannel/Enabled").raw(), videoChannel.asOutParam());
|
---|
1776 | BOOL fVideoChannel = (videoChannel.compare(Bstr("true"), Bstr::CaseInsensitive)== 0)
|
---|
1777 | || (videoChannel == "1");
|
---|
1778 | Bstr videoChannelQuality;
|
---|
1779 | vrdeServer->GetVRDEProperty(Bstr("VideoChannel/Quality").raw(), videoChannelQuality.asOutParam());
|
---|
1780 | AuthType_T authType;
|
---|
1781 | const char *strAuthType;
|
---|
1782 | vrdeServer->COMGETTER(AuthType)(&authType);
|
---|
1783 | switch (authType)
|
---|
1784 | {
|
---|
1785 | case AuthType_Null:
|
---|
1786 | strAuthType = "null";
|
---|
1787 | break;
|
---|
1788 | case AuthType_External:
|
---|
1789 | strAuthType = "external";
|
---|
1790 | break;
|
---|
1791 | case AuthType_Guest:
|
---|
1792 | strAuthType = "guest";
|
---|
1793 | break;
|
---|
1794 | default:
|
---|
1795 | strAuthType = "unknown";
|
---|
1796 | break;
|
---|
1797 | }
|
---|
1798 | if (pConsole)
|
---|
1799 | {
|
---|
1800 | ComPtr<IVRDEServerInfo> vrdeServerInfo;
|
---|
1801 | CHECK_ERROR_RET(pConsole, COMGETTER(VRDEServerInfo)(vrdeServerInfo.asOutParam()), rc);
|
---|
1802 | if (!vrdeServerInfo.isNull())
|
---|
1803 | {
|
---|
1804 | rc = vrdeServerInfo->COMGETTER(Port)(¤tPort);
|
---|
1805 | if (rc == E_ACCESSDENIED)
|
---|
1806 | {
|
---|
1807 | currentPort = -1; /* VM not powered up */
|
---|
1808 | }
|
---|
1809 | else if (FAILED(rc))
|
---|
1810 | {
|
---|
1811 | com::ErrorInfo info(vrdeServerInfo, COM_IIDOF(IVRDEServerInfo));
|
---|
1812 | GluePrintErrorInfo(info);
|
---|
1813 | return rc;
|
---|
1814 | }
|
---|
1815 | }
|
---|
1816 | }
|
---|
1817 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1818 | {
|
---|
1819 | RTPrintf("vrde=\"on\"\n");
|
---|
1820 | RTPrintf("vrdeport=%d\n", currentPort);
|
---|
1821 | RTPrintf("vrdeports=\"%ls\"\n", ports.raw());
|
---|
1822 | RTPrintf("vrdeaddress=\"%ls\"\n", address.raw());
|
---|
1823 | RTPrintf("vrdeauthtype=\"%s\"\n", strAuthType);
|
---|
1824 | RTPrintf("vrdemulticon=\"%s\"\n", fMultiCon ? "on" : "off");
|
---|
1825 | RTPrintf("vrdereusecon=\"%s\"\n", fReuseCon ? "on" : "off");
|
---|
1826 | RTPrintf("vrdevideochannel=\"%s\"\n", fVideoChannel ? "on" : "off");
|
---|
1827 | if (fVideoChannel)
|
---|
1828 | RTPrintf("vrdevideochannelquality=\"%ls\"\n", videoChannelQuality.raw());
|
---|
1829 | }
|
---|
1830 | else
|
---|
1831 | {
|
---|
1832 | if (address.isEmpty())
|
---|
1833 | address = "0.0.0.0";
|
---|
1834 | RTPrintf("VRDE: enabled (Address %ls, Ports %ls, MultiConn: %s, ReuseSingleConn: %s, Authentication type: %s)\n", address.raw(), ports.raw(), fMultiCon ? "on" : "off", fReuseCon ? "on" : "off", strAuthType);
|
---|
1835 | if (pConsole && currentPort != -1 && currentPort != 0)
|
---|
1836 | RTPrintf("VRDE port: %d\n", currentPort);
|
---|
1837 | if (fVideoChannel)
|
---|
1838 | RTPrintf("Video redirection: enabled (Quality %ls)\n", videoChannelQuality.raw());
|
---|
1839 | else
|
---|
1840 | RTPrintf("Video redirection: disabled\n");
|
---|
1841 | }
|
---|
1842 | com::SafeArray<BSTR> aProperties;
|
---|
1843 | if (SUCCEEDED(vrdeServer->COMGETTER(VRDEProperties)(ComSafeArrayAsOutParam(aProperties))))
|
---|
1844 | {
|
---|
1845 | unsigned i;
|
---|
1846 | for (i = 0; i < aProperties.size(); ++i)
|
---|
1847 | {
|
---|
1848 | Bstr value;
|
---|
1849 | vrdeServer->GetVRDEProperty(aProperties[i], value.asOutParam());
|
---|
1850 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1851 | {
|
---|
1852 | if (value.isEmpty())
|
---|
1853 | RTPrintf("vrdeproperty[%ls]=<not set>\n", aProperties[i]);
|
---|
1854 | else
|
---|
1855 | RTPrintf("vrdeproperty[%ls]=\"%ls\"\n", aProperties[i], value.raw());
|
---|
1856 | }
|
---|
1857 | else
|
---|
1858 | {
|
---|
1859 | if (value.isEmpty())
|
---|
1860 | RTPrintf("VRDE property: %-10lS = <not set>\n", aProperties[i]);
|
---|
1861 | else
|
---|
1862 | RTPrintf("VRDE property: %-10lS = \"%ls\"\n", aProperties[i], value.raw());
|
---|
1863 | }
|
---|
1864 | }
|
---|
1865 | }
|
---|
1866 | }
|
---|
1867 | else
|
---|
1868 | {
|
---|
1869 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1870 | RTPrintf("vrde=\"off\"\n");
|
---|
1871 | else
|
---|
1872 | RTPrintf("VRDE: disabled\n");
|
---|
1873 | }
|
---|
1874 | }
|
---|
1875 |
|
---|
1876 | /*
|
---|
1877 | * USB.
|
---|
1878 | */
|
---|
1879 | SafeIfaceArray<IUSBController> USBCtlColl;
|
---|
1880 | rc = machine->COMGETTER(USBControllers)(ComSafeArrayAsOutParam(USBCtlColl));
|
---|
1881 | if (SUCCEEDED(rc))
|
---|
1882 | {
|
---|
1883 | bool fOhciEnabled = false;
|
---|
1884 | bool fEhciEnabled = false;
|
---|
1885 | bool fXhciEnabled = false;
|
---|
1886 |
|
---|
1887 | for (unsigned i = 0; i < USBCtlColl.size(); i++)
|
---|
1888 | {
|
---|
1889 | USBControllerType_T enmType;
|
---|
1890 |
|
---|
1891 | rc = USBCtlColl[i]->COMGETTER(Type)(&enmType);
|
---|
1892 | if (SUCCEEDED(rc))
|
---|
1893 | {
|
---|
1894 | switch (enmType)
|
---|
1895 | {
|
---|
1896 | case USBControllerType_OHCI:
|
---|
1897 | fOhciEnabled = true;
|
---|
1898 | break;
|
---|
1899 | case USBControllerType_EHCI:
|
---|
1900 | fEhciEnabled = true;
|
---|
1901 | break;
|
---|
1902 | case USBControllerType_XHCI:
|
---|
1903 | fXhciEnabled = true;
|
---|
1904 | break;
|
---|
1905 | default:
|
---|
1906 | break;
|
---|
1907 | }
|
---|
1908 | }
|
---|
1909 | }
|
---|
1910 |
|
---|
1911 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1912 | RTPrintf("usb=\"%s\"\n", fOhciEnabled ? "on" : "off");
|
---|
1913 | else
|
---|
1914 | RTPrintf("USB: %s\n", fOhciEnabled ? "enabled" : "disabled");
|
---|
1915 |
|
---|
1916 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1917 | RTPrintf("ehci=\"%s\"\n", fEhciEnabled ? "on" : "off");
|
---|
1918 | else
|
---|
1919 | RTPrintf("EHCI: %s\n", fEhciEnabled ? "enabled" : "disabled");
|
---|
1920 |
|
---|
1921 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1922 | RTPrintf("xhci=\"%s\"\n", fXhciEnabled ? "on" : "off");
|
---|
1923 | else
|
---|
1924 | RTPrintf("XHCI: %s\n", fXhciEnabled ? "enabled" : "disabled");
|
---|
1925 | }
|
---|
1926 |
|
---|
1927 | ComPtr<IUSBDeviceFilters> USBFlts;
|
---|
1928 | rc = machine->COMGETTER(USBDeviceFilters)(USBFlts.asOutParam());
|
---|
1929 | if (SUCCEEDED(rc))
|
---|
1930 | {
|
---|
1931 | SafeIfaceArray <IUSBDeviceFilter> Coll;
|
---|
1932 | rc = USBFlts->COMGETTER(DeviceFilters)(ComSafeArrayAsOutParam(Coll));
|
---|
1933 | if (SUCCEEDED(rc))
|
---|
1934 | {
|
---|
1935 | if (details != VMINFO_MACHINEREADABLE)
|
---|
1936 | RTPrintf("\nUSB Device Filters:\n\n");
|
---|
1937 |
|
---|
1938 | if (Coll.size() == 0)
|
---|
1939 | {
|
---|
1940 | if (details != VMINFO_MACHINEREADABLE)
|
---|
1941 | RTPrintf("<none>\n\n");
|
---|
1942 | }
|
---|
1943 | else
|
---|
1944 | {
|
---|
1945 | for (size_t index = 0; index < Coll.size(); ++index)
|
---|
1946 | {
|
---|
1947 | ComPtr<IUSBDeviceFilter> DevPtr = Coll[index];
|
---|
1948 |
|
---|
1949 | /* Query info. */
|
---|
1950 |
|
---|
1951 | if (details != VMINFO_MACHINEREADABLE)
|
---|
1952 | RTPrintf("Index: %zu\n", index);
|
---|
1953 |
|
---|
1954 | BOOL bActive = FALSE;
|
---|
1955 | CHECK_ERROR_RET(DevPtr, COMGETTER(Active)(&bActive), rc);
|
---|
1956 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1957 | RTPrintf("USBFilterActive%zu=\"%s\"\n", index + 1, bActive ? "on" : "off");
|
---|
1958 | else
|
---|
1959 | RTPrintf("Active: %s\n", bActive ? "yes" : "no");
|
---|
1960 |
|
---|
1961 | Bstr bstr;
|
---|
1962 | CHECK_ERROR_RET(DevPtr, COMGETTER(Name)(bstr.asOutParam()), rc);
|
---|
1963 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1964 | RTPrintf("USBFilterName%zu=\"%ls\"\n", index + 1, bstr.raw());
|
---|
1965 | else
|
---|
1966 | RTPrintf("Name: %ls\n", bstr.raw());
|
---|
1967 | CHECK_ERROR_RET(DevPtr, COMGETTER(VendorId)(bstr.asOutParam()), rc);
|
---|
1968 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1969 | RTPrintf("USBFilterVendorId%zu=\"%ls\"\n", index + 1, bstr.raw());
|
---|
1970 | else
|
---|
1971 | RTPrintf("VendorId: %ls\n", bstr.raw());
|
---|
1972 | CHECK_ERROR_RET(DevPtr, COMGETTER(ProductId)(bstr.asOutParam()), rc);
|
---|
1973 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1974 | RTPrintf("USBFilterProductId%zu=\"%ls\"\n", index + 1, bstr.raw());
|
---|
1975 | else
|
---|
1976 | RTPrintf("ProductId: %ls\n", bstr.raw());
|
---|
1977 | CHECK_ERROR_RET(DevPtr, COMGETTER(Revision)(bstr.asOutParam()), rc);
|
---|
1978 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1979 | RTPrintf("USBFilterRevision%zu=\"%ls\"\n", index + 1, bstr.raw());
|
---|
1980 | else
|
---|
1981 | RTPrintf("Revision: %ls\n", bstr.raw());
|
---|
1982 | CHECK_ERROR_RET(DevPtr, COMGETTER(Manufacturer)(bstr.asOutParam()), rc);
|
---|
1983 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1984 | RTPrintf("USBFilterManufacturer%zu=\"%ls\"\n", index + 1, bstr.raw());
|
---|
1985 | else
|
---|
1986 | RTPrintf("Manufacturer: %ls\n", bstr.raw());
|
---|
1987 | CHECK_ERROR_RET(DevPtr, COMGETTER(Product)(bstr.asOutParam()), rc);
|
---|
1988 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1989 | RTPrintf("USBFilterProduct%zu=\"%ls\"\n", index + 1, bstr.raw());
|
---|
1990 | else
|
---|
1991 | RTPrintf("Product: %ls\n", bstr.raw());
|
---|
1992 | CHECK_ERROR_RET(DevPtr, COMGETTER(Remote)(bstr.asOutParam()), rc);
|
---|
1993 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1994 | RTPrintf("USBFilterRemote%zu=\"%ls\"\n", index + 1, bstr.raw());
|
---|
1995 | else
|
---|
1996 | RTPrintf("Remote: %ls\n", bstr.raw());
|
---|
1997 | CHECK_ERROR_RET(DevPtr, COMGETTER(SerialNumber)(bstr.asOutParam()), rc);
|
---|
1998 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1999 | RTPrintf("USBFilterSerialNumber%zu=\"%ls\"\n", index + 1, bstr.raw());
|
---|
2000 | else
|
---|
2001 | RTPrintf("Serial Number: %ls\n", bstr.raw());
|
---|
2002 | if (details != VMINFO_MACHINEREADABLE)
|
---|
2003 | {
|
---|
2004 | ULONG fMaskedIfs;
|
---|
2005 | CHECK_ERROR_RET(DevPtr, COMGETTER(MaskedInterfaces)(&fMaskedIfs), rc);
|
---|
2006 | if (fMaskedIfs)
|
---|
2007 | RTPrintf("Masked Interfaces: %#010x\n", fMaskedIfs);
|
---|
2008 | RTPrintf("\n");
|
---|
2009 | }
|
---|
2010 | }
|
---|
2011 | }
|
---|
2012 | }
|
---|
2013 |
|
---|
2014 | if (pConsole)
|
---|
2015 | {
|
---|
2016 | /* scope */
|
---|
2017 | {
|
---|
2018 | if (details != VMINFO_MACHINEREADABLE)
|
---|
2019 | RTPrintf("Available remote USB devices:\n\n");
|
---|
2020 |
|
---|
2021 | SafeIfaceArray <IHostUSBDevice> coll;
|
---|
2022 | CHECK_ERROR_RET(pConsole, COMGETTER(RemoteUSBDevices)(ComSafeArrayAsOutParam(coll)), rc);
|
---|
2023 |
|
---|
2024 | if (coll.size() == 0)
|
---|
2025 | {
|
---|
2026 | if (details != VMINFO_MACHINEREADABLE)
|
---|
2027 | RTPrintf("<none>\n\n");
|
---|
2028 | }
|
---|
2029 | else
|
---|
2030 | {
|
---|
2031 | for (size_t index = 0; index < coll.size(); ++index)
|
---|
2032 | {
|
---|
2033 | ComPtr<IHostUSBDevice> dev = coll[index];
|
---|
2034 |
|
---|
2035 | /* Query info. */
|
---|
2036 | Bstr id;
|
---|
2037 | CHECK_ERROR_RET(dev, COMGETTER(Id)(id.asOutParam()), rc);
|
---|
2038 | USHORT usVendorId;
|
---|
2039 | CHECK_ERROR_RET(dev, COMGETTER(VendorId)(&usVendorId), rc);
|
---|
2040 | USHORT usProductId;
|
---|
2041 | CHECK_ERROR_RET(dev, COMGETTER(ProductId)(&usProductId), rc);
|
---|
2042 | USHORT bcdRevision;
|
---|
2043 | CHECK_ERROR_RET(dev, COMGETTER(Revision)(&bcdRevision), rc);
|
---|
2044 |
|
---|
2045 | if (details == VMINFO_MACHINEREADABLE)
|
---|
2046 | RTPrintf("USBRemoteUUID%zu=\"%s\"\n"
|
---|
2047 | "USBRemoteVendorId%zu=\"%#06x\"\n"
|
---|
2048 | "USBRemoteProductId%zu=\"%#06x\"\n"
|
---|
2049 | "USBRemoteRevision%zu=\"%#04x%02x\"\n",
|
---|
2050 | index + 1, Utf8Str(id).c_str(),
|
---|
2051 | index + 1, usVendorId,
|
---|
2052 | index + 1, usProductId,
|
---|
2053 | index + 1, bcdRevision >> 8, bcdRevision & 0xff);
|
---|
2054 | else
|
---|
2055 | RTPrintf("UUID: %s\n"
|
---|
2056 | "VendorId: %#06x (%04X)\n"
|
---|
2057 | "ProductId: %#06x (%04X)\n"
|
---|
2058 | "Revision: %u.%u (%02u%02u)\n",
|
---|
2059 | Utf8Str(id).c_str(),
|
---|
2060 | usVendorId, usVendorId, usProductId, usProductId,
|
---|
2061 | bcdRevision >> 8, bcdRevision & 0xff,
|
---|
2062 | bcdRevision >> 8, bcdRevision & 0xff);
|
---|
2063 |
|
---|
2064 | /* optional stuff. */
|
---|
2065 | Bstr bstr;
|
---|
2066 | CHECK_ERROR_RET(dev, COMGETTER(Manufacturer)(bstr.asOutParam()), rc);
|
---|
2067 | if (!bstr.isEmpty())
|
---|
2068 | {
|
---|
2069 | if (details == VMINFO_MACHINEREADABLE)
|
---|
2070 | RTPrintf("USBRemoteManufacturer%zu=\"%ls\"\n", index + 1, bstr.raw());
|
---|
2071 | else
|
---|
2072 | RTPrintf("Manufacturer: %ls\n", bstr.raw());
|
---|
2073 | }
|
---|
2074 | CHECK_ERROR_RET(dev, COMGETTER(Product)(bstr.asOutParam()), rc);
|
---|
2075 | if (!bstr.isEmpty())
|
---|
2076 | {
|
---|
2077 | if (details == VMINFO_MACHINEREADABLE)
|
---|
2078 | RTPrintf("USBRemoteProduct%zu=\"%ls\"\n", index + 1, bstr.raw());
|
---|
2079 | else
|
---|
2080 | RTPrintf("Product: %ls\n", bstr.raw());
|
---|
2081 | }
|
---|
2082 | CHECK_ERROR_RET(dev, COMGETTER(SerialNumber)(bstr.asOutParam()), rc);
|
---|
2083 | if (!bstr.isEmpty())
|
---|
2084 | {
|
---|
2085 | if (details == VMINFO_MACHINEREADABLE)
|
---|
2086 | RTPrintf("USBRemoteSerialNumber%zu=\"%ls\"\n", index + 1, bstr.raw());
|
---|
2087 | else
|
---|
2088 | RTPrintf("SerialNumber: %ls\n", bstr.raw());
|
---|
2089 | }
|
---|
2090 | CHECK_ERROR_RET(dev, COMGETTER(Address)(bstr.asOutParam()), rc);
|
---|
2091 | if (!bstr.isEmpty())
|
---|
2092 | {
|
---|
2093 | if (details == VMINFO_MACHINEREADABLE)
|
---|
2094 | RTPrintf("USBRemoteAddress%zu=\"%ls\"\n", index + 1, bstr.raw());
|
---|
2095 | else
|
---|
2096 | RTPrintf("Address: %ls\n", bstr.raw());
|
---|
2097 | }
|
---|
2098 |
|
---|
2099 | if (details != VMINFO_MACHINEREADABLE)
|
---|
2100 | RTPrintf("\n");
|
---|
2101 | }
|
---|
2102 | }
|
---|
2103 | }
|
---|
2104 |
|
---|
2105 | /* scope */
|
---|
2106 | {
|
---|
2107 | if (details != VMINFO_MACHINEREADABLE)
|
---|
2108 | RTPrintf("Currently Attached USB Devices:\n\n");
|
---|
2109 |
|
---|
2110 | SafeIfaceArray <IUSBDevice> coll;
|
---|
2111 | CHECK_ERROR_RET(pConsole, COMGETTER(USBDevices)(ComSafeArrayAsOutParam(coll)), rc);
|
---|
2112 |
|
---|
2113 | if (coll.size() == 0)
|
---|
2114 | {
|
---|
2115 | if (details != VMINFO_MACHINEREADABLE)
|
---|
2116 | RTPrintf("<none>\n\n");
|
---|
2117 | }
|
---|
2118 | else
|
---|
2119 | {
|
---|
2120 | for (size_t index = 0; index < coll.size(); ++index)
|
---|
2121 | {
|
---|
2122 | ComPtr<IUSBDevice> dev = coll[index];
|
---|
2123 |
|
---|
2124 | /* Query info. */
|
---|
2125 | Bstr id;
|
---|
2126 | CHECK_ERROR_RET(dev, COMGETTER(Id)(id.asOutParam()), rc);
|
---|
2127 | USHORT usVendorId;
|
---|
2128 | CHECK_ERROR_RET(dev, COMGETTER(VendorId)(&usVendorId), rc);
|
---|
2129 | USHORT usProductId;
|
---|
2130 | CHECK_ERROR_RET(dev, COMGETTER(ProductId)(&usProductId), rc);
|
---|
2131 | USHORT bcdRevision;
|
---|
2132 | CHECK_ERROR_RET(dev, COMGETTER(Revision)(&bcdRevision), rc);
|
---|
2133 |
|
---|
2134 | if (details == VMINFO_MACHINEREADABLE)
|
---|
2135 | RTPrintf("USBAttachedUUID%zu=\"%s\"\n"
|
---|
2136 | "USBAttachedVendorId%zu=\"%#06x\"\n"
|
---|
2137 | "USBAttachedProductId%zu=\"%#06x\"\n"
|
---|
2138 | "USBAttachedRevision%zu=\"%#04x%02x\"\n",
|
---|
2139 | index + 1, Utf8Str(id).c_str(),
|
---|
2140 | index + 1, usVendorId,
|
---|
2141 | index + 1, usProductId,
|
---|
2142 | index + 1, bcdRevision >> 8, bcdRevision & 0xff);
|
---|
2143 | else
|
---|
2144 | RTPrintf("UUID: %s\n"
|
---|
2145 | "VendorId: %#06x (%04X)\n"
|
---|
2146 | "ProductId: %#06x (%04X)\n"
|
---|
2147 | "Revision: %u.%u (%02u%02u)\n",
|
---|
2148 | Utf8Str(id).c_str(),
|
---|
2149 | usVendorId, usVendorId, usProductId, usProductId,
|
---|
2150 | bcdRevision >> 8, bcdRevision & 0xff,
|
---|
2151 | bcdRevision >> 8, bcdRevision & 0xff);
|
---|
2152 |
|
---|
2153 | /* optional stuff. */
|
---|
2154 | Bstr bstr;
|
---|
2155 | CHECK_ERROR_RET(dev, COMGETTER(Manufacturer)(bstr.asOutParam()), rc);
|
---|
2156 | if (!bstr.isEmpty())
|
---|
2157 | {
|
---|
2158 | if (details == VMINFO_MACHINEREADABLE)
|
---|
2159 | RTPrintf("USBAttachedManufacturer%zu=\"%ls\"\n", index + 1, bstr.raw());
|
---|
2160 | else
|
---|
2161 | RTPrintf("Manufacturer: %ls\n", bstr.raw());
|
---|
2162 | }
|
---|
2163 | CHECK_ERROR_RET(dev, COMGETTER(Product)(bstr.asOutParam()), rc);
|
---|
2164 | if (!bstr.isEmpty())
|
---|
2165 | {
|
---|
2166 | if (details == VMINFO_MACHINEREADABLE)
|
---|
2167 | RTPrintf("USBAttachedProduct%zu=\"%ls\"\n", index + 1, bstr.raw());
|
---|
2168 | else
|
---|
2169 | RTPrintf("Product: %ls\n", bstr.raw());
|
---|
2170 | }
|
---|
2171 | CHECK_ERROR_RET(dev, COMGETTER(SerialNumber)(bstr.asOutParam()), rc);
|
---|
2172 | if (!bstr.isEmpty())
|
---|
2173 | {
|
---|
2174 | if (details == VMINFO_MACHINEREADABLE)
|
---|
2175 | RTPrintf("USBAttachedSerialNumber%zu=\"%ls\"\n", index + 1, bstr.raw());
|
---|
2176 | else
|
---|
2177 | RTPrintf("SerialNumber: %ls\n", bstr.raw());
|
---|
2178 | }
|
---|
2179 | CHECK_ERROR_RET(dev, COMGETTER(Address)(bstr.asOutParam()), rc);
|
---|
2180 | if (!bstr.isEmpty())
|
---|
2181 | {
|
---|
2182 | if (details == VMINFO_MACHINEREADABLE)
|
---|
2183 | RTPrintf("USBAttachedAddress%zu=\"%ls\"\n", index + 1, bstr.raw());
|
---|
2184 | else
|
---|
2185 | RTPrintf("Address: %ls\n", bstr.raw());
|
---|
2186 | }
|
---|
2187 |
|
---|
2188 | if (details != VMINFO_MACHINEREADABLE)
|
---|
2189 | RTPrintf("\n");
|
---|
2190 | }
|
---|
2191 | }
|
---|
2192 | }
|
---|
2193 | }
|
---|
2194 | } /* USB */
|
---|
2195 |
|
---|
2196 | #ifdef VBOX_WITH_PCI_PASSTHROUGH
|
---|
2197 | /* Host PCI passthrough devices */
|
---|
2198 | {
|
---|
2199 | SafeIfaceArray <IPCIDeviceAttachment> assignments;
|
---|
2200 | rc = machine->COMGETTER(PCIDeviceAssignments)(ComSafeArrayAsOutParam(assignments));
|
---|
2201 | if (SUCCEEDED(rc))
|
---|
2202 | {
|
---|
2203 | if (assignments.size() > 0 && (details != VMINFO_MACHINEREADABLE))
|
---|
2204 | {
|
---|
2205 | RTPrintf("\nAttached physical PCI devices:\n\n");
|
---|
2206 | }
|
---|
2207 |
|
---|
2208 | for (size_t index = 0; index < assignments.size(); ++index)
|
---|
2209 | {
|
---|
2210 | ComPtr<IPCIDeviceAttachment> Assignment = assignments[index];
|
---|
2211 | char szHostPCIAddress[32], szGuestPCIAddress[32];
|
---|
2212 | LONG iHostPCIAddress = -1, iGuestPCIAddress = -1;
|
---|
2213 | Bstr DevName;
|
---|
2214 |
|
---|
2215 | Assignment->COMGETTER(Name)(DevName.asOutParam());
|
---|
2216 | Assignment->COMGETTER(HostAddress)(&iHostPCIAddress);
|
---|
2217 | Assignment->COMGETTER(GuestAddress)(&iGuestPCIAddress);
|
---|
2218 | PCIBusAddress().fromLong(iHostPCIAddress).format(szHostPCIAddress, sizeof(szHostPCIAddress));
|
---|
2219 | PCIBusAddress().fromLong(iGuestPCIAddress).format(szGuestPCIAddress, sizeof(szGuestPCIAddress));
|
---|
2220 |
|
---|
2221 | if (details == VMINFO_MACHINEREADABLE)
|
---|
2222 | RTPrintf("AttachedHostPCI=%s,%s\n", szHostPCIAddress, szGuestPCIAddress);
|
---|
2223 | else
|
---|
2224 | RTPrintf(" Host device %ls at %s attached as %s\n", DevName.raw(), szHostPCIAddress, szGuestPCIAddress);
|
---|
2225 | }
|
---|
2226 |
|
---|
2227 | if (assignments.size() > 0 && (details != VMINFO_MACHINEREADABLE))
|
---|
2228 | {
|
---|
2229 | RTPrintf("\n");
|
---|
2230 | }
|
---|
2231 | }
|
---|
2232 | }
|
---|
2233 | /* Host PCI passthrough devices */
|
---|
2234 | #endif
|
---|
2235 |
|
---|
2236 | /*
|
---|
2237 | * Bandwidth groups
|
---|
2238 | */
|
---|
2239 | if (details != VMINFO_MACHINEREADABLE)
|
---|
2240 | RTPrintf("Bandwidth groups: ");
|
---|
2241 | {
|
---|
2242 | ComPtr<IBandwidthControl> bwCtrl;
|
---|
2243 | CHECK_ERROR_RET(machine, COMGETTER(BandwidthControl)(bwCtrl.asOutParam()), rc);
|
---|
2244 |
|
---|
2245 | rc = showBandwidthGroups(bwCtrl, details);
|
---|
2246 | }
|
---|
2247 |
|
---|
2248 |
|
---|
2249 | /*
|
---|
2250 | * Shared folders
|
---|
2251 | */
|
---|
2252 | if (details != VMINFO_MACHINEREADABLE)
|
---|
2253 | RTPrintf("Shared folders: ");
|
---|
2254 | uint32_t numSharedFolders = 0;
|
---|
2255 | #if 0 // not yet implemented
|
---|
2256 | /* globally shared folders first */
|
---|
2257 | {
|
---|
2258 | SafeIfaceArray <ISharedFolder> sfColl;
|
---|
2259 | CHECK_ERROR_RET(pVirtualBox, COMGETTER(SharedFolders)(ComSafeArrayAsOutParam(sfColl)), rc);
|
---|
2260 | for (size_t i = 0; i < sfColl.size(); ++i)
|
---|
2261 | {
|
---|
2262 | ComPtr<ISharedFolder> sf = sfColl[i];
|
---|
2263 | Bstr name, hostPath;
|
---|
2264 | sf->COMGETTER(Name)(name.asOutParam());
|
---|
2265 | sf->COMGETTER(HostPath)(hostPath.asOutParam());
|
---|
2266 | RTPrintf("Name: '%ls', Host path: '%ls' (global mapping)\n", name.raw(), hostPath.raw());
|
---|
2267 | ++numSharedFolders;
|
---|
2268 | }
|
---|
2269 | }
|
---|
2270 | #endif
|
---|
2271 | /* now VM mappings */
|
---|
2272 | {
|
---|
2273 | com::SafeIfaceArray <ISharedFolder> folders;
|
---|
2274 |
|
---|
2275 | CHECK_ERROR_RET(machine, COMGETTER(SharedFolders)(ComSafeArrayAsOutParam(folders)), rc);
|
---|
2276 |
|
---|
2277 | for (size_t i = 0; i < folders.size(); ++i)
|
---|
2278 | {
|
---|
2279 | ComPtr<ISharedFolder> sf = folders[i];
|
---|
2280 |
|
---|
2281 | Bstr name, hostPath;
|
---|
2282 | BOOL writable;
|
---|
2283 | sf->COMGETTER(Name)(name.asOutParam());
|
---|
2284 | sf->COMGETTER(HostPath)(hostPath.asOutParam());
|
---|
2285 | sf->COMGETTER(Writable)(&writable);
|
---|
2286 | if (!numSharedFolders && details != VMINFO_MACHINEREADABLE)
|
---|
2287 | RTPrintf("\n\n");
|
---|
2288 | if (details == VMINFO_MACHINEREADABLE)
|
---|
2289 | {
|
---|
2290 | RTPrintf("SharedFolderNameMachineMapping%zu=\"%ls\"\n", i + 1,
|
---|
2291 | name.raw());
|
---|
2292 | RTPrintf("SharedFolderPathMachineMapping%zu=\"%ls\"\n", i + 1,
|
---|
2293 | hostPath.raw());
|
---|
2294 | }
|
---|
2295 | else
|
---|
2296 | RTPrintf("Name: '%ls', Host path: '%ls' (machine mapping), %s\n",
|
---|
2297 | name.raw(), hostPath.raw(), writable ? "writable" : "readonly");
|
---|
2298 | ++numSharedFolders;
|
---|
2299 | }
|
---|
2300 | }
|
---|
2301 | /* transient mappings */
|
---|
2302 | if (pConsole)
|
---|
2303 | {
|
---|
2304 | com::SafeIfaceArray <ISharedFolder> folders;
|
---|
2305 |
|
---|
2306 | CHECK_ERROR_RET(pConsole, COMGETTER(SharedFolders)(ComSafeArrayAsOutParam(folders)), rc);
|
---|
2307 |
|
---|
2308 | for (size_t i = 0; i < folders.size(); ++i)
|
---|
2309 | {
|
---|
2310 | ComPtr<ISharedFolder> sf = folders[i];
|
---|
2311 |
|
---|
2312 | Bstr name, hostPath;
|
---|
2313 | sf->COMGETTER(Name)(name.asOutParam());
|
---|
2314 | sf->COMGETTER(HostPath)(hostPath.asOutParam());
|
---|
2315 | if (!numSharedFolders && details != VMINFO_MACHINEREADABLE)
|
---|
2316 | RTPrintf("\n\n");
|
---|
2317 | if (details == VMINFO_MACHINEREADABLE)
|
---|
2318 | {
|
---|
2319 | RTPrintf("SharedFolderNameTransientMapping%zu=\"%ls\"\n", i + 1,
|
---|
2320 | name.raw());
|
---|
2321 | RTPrintf("SharedFolderPathTransientMapping%zu=\"%ls\"\n", i + 1,
|
---|
2322 | hostPath.raw());
|
---|
2323 | }
|
---|
2324 | else
|
---|
2325 | RTPrintf("Name: '%ls', Host path: '%ls' (transient mapping)\n", name.raw(), hostPath.raw());
|
---|
2326 | ++numSharedFolders;
|
---|
2327 | }
|
---|
2328 | }
|
---|
2329 | if (!numSharedFolders && details != VMINFO_MACHINEREADABLE)
|
---|
2330 | RTPrintf("<none>\n");
|
---|
2331 | if (details != VMINFO_MACHINEREADABLE)
|
---|
2332 | RTPrintf("\n");
|
---|
2333 |
|
---|
2334 | if (pConsole)
|
---|
2335 | {
|
---|
2336 | /*
|
---|
2337 | * Live VRDE info.
|
---|
2338 | */
|
---|
2339 | ComPtr<IVRDEServerInfo> vrdeServerInfo;
|
---|
2340 | CHECK_ERROR_RET(pConsole, COMGETTER(VRDEServerInfo)(vrdeServerInfo.asOutParam()), rc);
|
---|
2341 | BOOL Active = FALSE;
|
---|
2342 | ULONG NumberOfClients = 0;
|
---|
2343 | LONG64 BeginTime = 0;
|
---|
2344 | LONG64 EndTime = 0;
|
---|
2345 | LONG64 BytesSent = 0;
|
---|
2346 | LONG64 BytesSentTotal = 0;
|
---|
2347 | LONG64 BytesReceived = 0;
|
---|
2348 | LONG64 BytesReceivedTotal = 0;
|
---|
2349 | Bstr User;
|
---|
2350 | Bstr Domain;
|
---|
2351 | Bstr ClientName;
|
---|
2352 | Bstr ClientIP;
|
---|
2353 | ULONG ClientVersion = 0;
|
---|
2354 | ULONG EncryptionStyle = 0;
|
---|
2355 |
|
---|
2356 | if (!vrdeServerInfo.isNull())
|
---|
2357 | {
|
---|
2358 | CHECK_ERROR_RET(vrdeServerInfo, COMGETTER(Active)(&Active), rc);
|
---|
2359 | CHECK_ERROR_RET(vrdeServerInfo, COMGETTER(NumberOfClients)(&NumberOfClients), rc);
|
---|
2360 | CHECK_ERROR_RET(vrdeServerInfo, COMGETTER(BeginTime)(&BeginTime), rc);
|
---|
2361 | CHECK_ERROR_RET(vrdeServerInfo, COMGETTER(EndTime)(&EndTime), rc);
|
---|
2362 | CHECK_ERROR_RET(vrdeServerInfo, COMGETTER(BytesSent)(&BytesSent), rc);
|
---|
2363 | CHECK_ERROR_RET(vrdeServerInfo, COMGETTER(BytesSentTotal)(&BytesSentTotal), rc);
|
---|
2364 | CHECK_ERROR_RET(vrdeServerInfo, COMGETTER(BytesReceived)(&BytesReceived), rc);
|
---|
2365 | CHECK_ERROR_RET(vrdeServerInfo, COMGETTER(BytesReceivedTotal)(&BytesReceivedTotal), rc);
|
---|
2366 | CHECK_ERROR_RET(vrdeServerInfo, COMGETTER(User)(User.asOutParam()), rc);
|
---|
2367 | CHECK_ERROR_RET(vrdeServerInfo, COMGETTER(Domain)(Domain.asOutParam()), rc);
|
---|
2368 | CHECK_ERROR_RET(vrdeServerInfo, COMGETTER(ClientName)(ClientName.asOutParam()), rc);
|
---|
2369 | CHECK_ERROR_RET(vrdeServerInfo, COMGETTER(ClientIP)(ClientIP.asOutParam()), rc);
|
---|
2370 | CHECK_ERROR_RET(vrdeServerInfo, COMGETTER(ClientVersion)(&ClientVersion), rc);
|
---|
2371 | CHECK_ERROR_RET(vrdeServerInfo, COMGETTER(EncryptionStyle)(&EncryptionStyle), rc);
|
---|
2372 | }
|
---|
2373 |
|
---|
2374 | if (details == VMINFO_MACHINEREADABLE)
|
---|
2375 | RTPrintf("VRDEActiveConnection=\"%s\"\n", Active ? "on": "off");
|
---|
2376 | else
|
---|
2377 | RTPrintf("VRDE Connection: %s\n", Active? "active": "not active");
|
---|
2378 |
|
---|
2379 | if (details == VMINFO_MACHINEREADABLE)
|
---|
2380 | RTPrintf("VRDEClients=%d\n", NumberOfClients);
|
---|
2381 | else
|
---|
2382 | RTPrintf("Clients so far: %d\n", NumberOfClients);
|
---|
2383 |
|
---|
2384 | if (NumberOfClients > 0)
|
---|
2385 | {
|
---|
2386 | char timestr[128];
|
---|
2387 |
|
---|
2388 | if (Active)
|
---|
2389 | {
|
---|
2390 | makeTimeStr(timestr, sizeof(timestr), BeginTime);
|
---|
2391 | if (details == VMINFO_MACHINEREADABLE)
|
---|
2392 | RTPrintf("VRDEStartTime=\"%s\"\n", timestr);
|
---|
2393 | else
|
---|
2394 | RTPrintf("Start time: %s\n", timestr);
|
---|
2395 | }
|
---|
2396 | else
|
---|
2397 | {
|
---|
2398 | makeTimeStr(timestr, sizeof(timestr), BeginTime);
|
---|
2399 | if (details == VMINFO_MACHINEREADABLE)
|
---|
2400 | RTPrintf("VRDELastStartTime=\"%s\"\n", timestr);
|
---|
2401 | else
|
---|
2402 | RTPrintf("Last started: %s\n", timestr);
|
---|
2403 | makeTimeStr(timestr, sizeof(timestr), EndTime);
|
---|
2404 | if (details == VMINFO_MACHINEREADABLE)
|
---|
2405 | RTPrintf("VRDELastEndTime=\"%s\"\n", timestr);
|
---|
2406 | else
|
---|
2407 | RTPrintf("Last ended: %s\n", timestr);
|
---|
2408 | }
|
---|
2409 |
|
---|
2410 | int64_t ThroughputSend = 0;
|
---|
2411 | int64_t ThroughputReceive = 0;
|
---|
2412 | if (EndTime != BeginTime)
|
---|
2413 | {
|
---|
2414 | ThroughputSend = (BytesSent * 1000) / (EndTime - BeginTime);
|
---|
2415 | ThroughputReceive = (BytesReceived * 1000) / (EndTime - BeginTime);
|
---|
2416 | }
|
---|
2417 |
|
---|
2418 | if (details == VMINFO_MACHINEREADABLE)
|
---|
2419 | {
|
---|
2420 | RTPrintf("VRDEBytesSent=%lld\n", BytesSent);
|
---|
2421 | RTPrintf("VRDEThroughputSend=%lld\n", ThroughputSend);
|
---|
2422 | RTPrintf("VRDEBytesSentTotal=%lld\n", BytesSentTotal);
|
---|
2423 |
|
---|
2424 | RTPrintf("VRDEBytesReceived=%lld\n", BytesReceived);
|
---|
2425 | RTPrintf("VRDEThroughputReceive=%lld\n", ThroughputReceive);
|
---|
2426 | RTPrintf("VRDEBytesReceivedTotal=%lld\n", BytesReceivedTotal);
|
---|
2427 | }
|
---|
2428 | else
|
---|
2429 | {
|
---|
2430 | RTPrintf("Sent: %lld Bytes\n", BytesSent);
|
---|
2431 | RTPrintf("Average speed: %lld B/s\n", ThroughputSend);
|
---|
2432 | RTPrintf("Sent total: %lld Bytes\n", BytesSentTotal);
|
---|
2433 |
|
---|
2434 | RTPrintf("Received: %lld Bytes\n", BytesReceived);
|
---|
2435 | RTPrintf("Speed: %lld B/s\n", ThroughputReceive);
|
---|
2436 | RTPrintf("Received total: %lld Bytes\n", BytesReceivedTotal);
|
---|
2437 | }
|
---|
2438 |
|
---|
2439 | if (Active)
|
---|
2440 | {
|
---|
2441 | if (details == VMINFO_MACHINEREADABLE)
|
---|
2442 | {
|
---|
2443 | RTPrintf("VRDEUserName=\"%ls\"\n", User.raw());
|
---|
2444 | RTPrintf("VRDEDomain=\"%ls\"\n", Domain.raw());
|
---|
2445 | RTPrintf("VRDEClientName=\"%ls\"\n", ClientName.raw());
|
---|
2446 | RTPrintf("VRDEClientIP=\"%ls\"\n", ClientIP.raw());
|
---|
2447 | RTPrintf("VRDEClientVersion=%d\n", ClientVersion);
|
---|
2448 | RTPrintf("VRDEEncryption=\"%s\"\n", EncryptionStyle == 0? "RDP4": "RDP5 (X.509)");
|
---|
2449 | }
|
---|
2450 | else
|
---|
2451 | {
|
---|
2452 | RTPrintf("User name: %ls\n", User.raw());
|
---|
2453 | RTPrintf("Domain: %ls\n", Domain.raw());
|
---|
2454 | RTPrintf("Client name: %ls\n", ClientName.raw());
|
---|
2455 | RTPrintf("Client IP: %ls\n", ClientIP.raw());
|
---|
2456 | RTPrintf("Client version: %d\n", ClientVersion);
|
---|
2457 | RTPrintf("Encryption: %s\n", EncryptionStyle == 0? "RDP4": "RDP5 (X.509)");
|
---|
2458 | }
|
---|
2459 | }
|
---|
2460 | }
|
---|
2461 |
|
---|
2462 | if (details != VMINFO_MACHINEREADABLE)
|
---|
2463 | RTPrintf("\n");
|
---|
2464 | }
|
---|
2465 |
|
---|
2466 | {
|
---|
2467 | /* Video capture */
|
---|
2468 | BOOL bActive = FALSE;
|
---|
2469 | CHECK_ERROR_RET(machine, COMGETTER(VideoCaptureEnabled)(&bActive), rc);
|
---|
2470 | com::SafeArray<BOOL> screens;
|
---|
2471 | CHECK_ERROR_RET(machine, COMGETTER(VideoCaptureScreens)(ComSafeArrayAsOutParam(screens)), rc);
|
---|
2472 | ULONG Width;
|
---|
2473 | CHECK_ERROR_RET(machine, COMGETTER(VideoCaptureWidth)(&Width), rc);
|
---|
2474 | ULONG Height;
|
---|
2475 | CHECK_ERROR_RET(machine, COMGETTER(VideoCaptureHeight)(&Height), rc);
|
---|
2476 | ULONG Rate;
|
---|
2477 | CHECK_ERROR_RET(machine, COMGETTER(VideoCaptureRate)(&Rate), rc);
|
---|
2478 | ULONG Fps;
|
---|
2479 | CHECK_ERROR_RET(machine, COMGETTER(VideoCaptureFPS)(&Fps), rc);
|
---|
2480 | Bstr File;
|
---|
2481 | CHECK_ERROR_RET(machine, COMGETTER(VideoCaptureFile)(File.asOutParam()), rc);
|
---|
2482 | if (details == VMINFO_MACHINEREADABLE)
|
---|
2483 | {
|
---|
2484 | RTPrintf("vcpenabled=\"%s\"\n", bActive ? "on" : "off");
|
---|
2485 | RTPrintf("vcpscreens=");
|
---|
2486 | bool fComma = false;
|
---|
2487 | for (unsigned i = 0; i < screens.size(); i++)
|
---|
2488 | if (screens[i])
|
---|
2489 | {
|
---|
2490 | RTPrintf("%s%u", fComma ? "," : "", i);
|
---|
2491 | fComma = true;
|
---|
2492 | }
|
---|
2493 | RTPrintf("\n");
|
---|
2494 | RTPrintf("vcpfile=\"%ls\"\n", File.raw());
|
---|
2495 | RTPrintf("vcpwidth=%u\n", (unsigned)Width);
|
---|
2496 | RTPrintf("vcpheight=%u\n", (unsigned)Height);
|
---|
2497 | RTPrintf("vcprate=%u\n", (unsigned)Rate);
|
---|
2498 | RTPrintf("vcpfps=%u\n", (unsigned)Fps);
|
---|
2499 | }
|
---|
2500 | else
|
---|
2501 | {
|
---|
2502 | RTPrintf("Video capturing: %s\n", bActive ? "active" : "not active");
|
---|
2503 | RTPrintf("Capture screens: ");
|
---|
2504 | bool fComma = false;
|
---|
2505 | for (unsigned i = 0; i < screens.size(); i++)
|
---|
2506 | if (screens[i])
|
---|
2507 | {
|
---|
2508 | RTPrintf("%s%u", fComma ? "," : "", i);
|
---|
2509 | fComma = true;
|
---|
2510 | }
|
---|
2511 | RTPrintf("\n");
|
---|
2512 | RTPrintf("Capture file: %ls\n", File.raw());
|
---|
2513 | RTPrintf("Capture dimensions: %ux%u\n", Width, Height);
|
---|
2514 | RTPrintf("Capture rate: %u kbps\n", Rate);
|
---|
2515 | RTPrintf("Capture FPS: %u\n", Fps);
|
---|
2516 | RTPrintf("\n");
|
---|
2517 | }
|
---|
2518 | }
|
---|
2519 |
|
---|
2520 | if ( details == VMINFO_STANDARD
|
---|
2521 | || details == VMINFO_FULL
|
---|
2522 | || details == VMINFO_MACHINEREADABLE)
|
---|
2523 | {
|
---|
2524 | Bstr description;
|
---|
2525 | machine->COMGETTER(Description)(description.asOutParam());
|
---|
2526 | if (!description.isEmpty())
|
---|
2527 | {
|
---|
2528 | if (details == VMINFO_MACHINEREADABLE)
|
---|
2529 | RTPrintf("description=\"%ls\"\n", description.raw());
|
---|
2530 | else
|
---|
2531 | RTPrintf("Description:\n%ls\n", description.raw());
|
---|
2532 | }
|
---|
2533 | }
|
---|
2534 |
|
---|
2535 | if (details != VMINFO_MACHINEREADABLE)
|
---|
2536 | RTPrintf("Guest:\n\n");
|
---|
2537 |
|
---|
2538 | ULONG guestVal;
|
---|
2539 | rc = machine->COMGETTER(MemoryBalloonSize)(&guestVal);
|
---|
2540 | if (SUCCEEDED(rc))
|
---|
2541 | {
|
---|
2542 | if (details == VMINFO_MACHINEREADABLE)
|
---|
2543 | RTPrintf("GuestMemoryBalloon=%d\n", guestVal);
|
---|
2544 | else
|
---|
2545 | RTPrintf("Configured memory balloon size: %d MB\n", guestVal);
|
---|
2546 | }
|
---|
2547 |
|
---|
2548 | if (pConsole)
|
---|
2549 | {
|
---|
2550 | ComPtr<IGuest> guest;
|
---|
2551 | rc = pConsole->COMGETTER(Guest)(guest.asOutParam());
|
---|
2552 | if (SUCCEEDED(rc) && !guest.isNull())
|
---|
2553 | {
|
---|
2554 | Bstr guestString;
|
---|
2555 | rc = guest->COMGETTER(OSTypeId)(guestString.asOutParam());
|
---|
2556 | if ( SUCCEEDED(rc)
|
---|
2557 | && !guestString.isEmpty())
|
---|
2558 | {
|
---|
2559 | if (details == VMINFO_MACHINEREADABLE)
|
---|
2560 | RTPrintf("GuestOSType=\"%ls\"\n", guestString.raw());
|
---|
2561 | else
|
---|
2562 | RTPrintf("OS type: %ls\n", guestString.raw());
|
---|
2563 | }
|
---|
2564 |
|
---|
2565 | AdditionsRunLevelType_T guestRunLevel; /** @todo Add a runlevel-to-string (e.g. 0 = "None") method? */
|
---|
2566 | rc = guest->COMGETTER(AdditionsRunLevel)(&guestRunLevel);
|
---|
2567 | if (SUCCEEDED(rc))
|
---|
2568 | {
|
---|
2569 | if (details == VMINFO_MACHINEREADABLE)
|
---|
2570 | RTPrintf("GuestAdditionsRunLevel=%u\n", guestRunLevel);
|
---|
2571 | else
|
---|
2572 | RTPrintf("Additions run level: %u\n", guestRunLevel);
|
---|
2573 | }
|
---|
2574 |
|
---|
2575 | rc = guest->COMGETTER(AdditionsVersion)(guestString.asOutParam());
|
---|
2576 | if ( SUCCEEDED(rc)
|
---|
2577 | && !guestString.isEmpty())
|
---|
2578 | {
|
---|
2579 | ULONG uRevision;
|
---|
2580 | rc = guest->COMGETTER(AdditionsRevision)(&uRevision);
|
---|
2581 | if (FAILED(rc))
|
---|
2582 | uRevision = 0;
|
---|
2583 |
|
---|
2584 | if (details == VMINFO_MACHINEREADABLE)
|
---|
2585 | RTPrintf("GuestAdditionsVersion=\"%ls r%u\"\n", guestString.raw(), uRevision);
|
---|
2586 | else
|
---|
2587 | RTPrintf("Additions version: %ls r%u\n\n", guestString.raw(), uRevision);
|
---|
2588 | }
|
---|
2589 |
|
---|
2590 | if (details != VMINFO_MACHINEREADABLE)
|
---|
2591 | RTPrintf("\nGuest Facilities:\n\n");
|
---|
2592 |
|
---|
2593 | /* Print information about known Guest Additions facilities: */
|
---|
2594 | SafeIfaceArray <IAdditionsFacility> collFac;
|
---|
2595 | CHECK_ERROR_RET(guest, COMGETTER(Facilities)(ComSafeArrayAsOutParam(collFac)), rc);
|
---|
2596 | LONG64 lLastUpdatedMS;
|
---|
2597 | char szLastUpdated[32];
|
---|
2598 | AdditionsFacilityStatus_T curStatus;
|
---|
2599 | for (size_t index = 0; index < collFac.size(); ++index)
|
---|
2600 | {
|
---|
2601 | ComPtr<IAdditionsFacility> fac = collFac[index];
|
---|
2602 | if (fac)
|
---|
2603 | {
|
---|
2604 | CHECK_ERROR_RET(fac, COMGETTER(Name)(guestString.asOutParam()), rc);
|
---|
2605 | if (!guestString.isEmpty())
|
---|
2606 | {
|
---|
2607 | CHECK_ERROR_RET(fac, COMGETTER(Status)(&curStatus), rc);
|
---|
2608 | CHECK_ERROR_RET(fac, COMGETTER(LastUpdated)(&lLastUpdatedMS), rc);
|
---|
2609 | if (details == VMINFO_MACHINEREADABLE)
|
---|
2610 | RTPrintf("GuestAdditionsFacility_%ls=%u,%lld\n",
|
---|
2611 | guestString.raw(), curStatus, lLastUpdatedMS);
|
---|
2612 | else
|
---|
2613 | {
|
---|
2614 | makeTimeStr(szLastUpdated, sizeof(szLastUpdated), lLastUpdatedMS);
|
---|
2615 | RTPrintf("Facility \"%ls\": %s (last update: %s)\n",
|
---|
2616 | guestString.raw(), facilityStateToName(curStatus, false /* No short naming */), szLastUpdated);
|
---|
2617 | }
|
---|
2618 | }
|
---|
2619 | else
|
---|
2620 | AssertMsgFailed(("Facility with undefined name retrieved!\n"));
|
---|
2621 | }
|
---|
2622 | else
|
---|
2623 | AssertMsgFailed(("Invalid facility returned!\n"));
|
---|
2624 | }
|
---|
2625 | if (!collFac.size() && details != VMINFO_MACHINEREADABLE)
|
---|
2626 | RTPrintf("No active facilities.\n");
|
---|
2627 | }
|
---|
2628 | }
|
---|
2629 |
|
---|
2630 | if (details != VMINFO_MACHINEREADABLE)
|
---|
2631 | RTPrintf("\n");
|
---|
2632 |
|
---|
2633 | /*
|
---|
2634 | * snapshots
|
---|
2635 | */
|
---|
2636 | ComPtr<ISnapshot> snapshot;
|
---|
2637 | rc = machine->FindSnapshot(Bstr().raw(), snapshot.asOutParam());
|
---|
2638 | if (SUCCEEDED(rc) && snapshot)
|
---|
2639 | {
|
---|
2640 | ComPtr<ISnapshot> currentSnapshot;
|
---|
2641 | rc = machine->COMGETTER(CurrentSnapshot)(currentSnapshot.asOutParam());
|
---|
2642 | if (SUCCEEDED(rc))
|
---|
2643 | {
|
---|
2644 | if (details != VMINFO_MACHINEREADABLE)
|
---|
2645 | RTPrintf("Snapshots:\n\n");
|
---|
2646 | showSnapshots(snapshot, currentSnapshot, details);
|
---|
2647 | }
|
---|
2648 | }
|
---|
2649 |
|
---|
2650 | if (details != VMINFO_MACHINEREADABLE)
|
---|
2651 | RTPrintf("\n");
|
---|
2652 | return S_OK;
|
---|
2653 | }
|
---|
2654 |
|
---|
2655 | #if defined(_MSC_VER)
|
---|
2656 | # pragma optimize("", on)
|
---|
2657 | #endif
|
---|
2658 |
|
---|
2659 | static const RTGETOPTDEF g_aShowVMInfoOptions[] =
|
---|
2660 | {
|
---|
2661 | { "--details", 'D', RTGETOPT_REQ_NOTHING },
|
---|
2662 | { "-details", 'D', RTGETOPT_REQ_NOTHING }, // deprecated
|
---|
2663 | { "--machinereadable", 'M', RTGETOPT_REQ_NOTHING },
|
---|
2664 | { "-machinereadable", 'M', RTGETOPT_REQ_NOTHING }, // deprecated
|
---|
2665 | { "--log", 'l', RTGETOPT_REQ_UINT32 },
|
---|
2666 | };
|
---|
2667 |
|
---|
2668 | RTEXITCODE handleShowVMInfo(HandlerArg *a)
|
---|
2669 | {
|
---|
2670 | HRESULT rc;
|
---|
2671 | const char *VMNameOrUuid = NULL;
|
---|
2672 | bool fLog = false;
|
---|
2673 | uint32_t uLogIdx = 0;
|
---|
2674 | bool fDetails = false;
|
---|
2675 | bool fMachinereadable = false;
|
---|
2676 |
|
---|
2677 | int c;
|
---|
2678 | RTGETOPTUNION ValueUnion;
|
---|
2679 | RTGETOPTSTATE GetState;
|
---|
2680 | // start at 0 because main() has hacked both the argc and argv given to us
|
---|
2681 | RTGetOptInit(&GetState, a->argc, a->argv, g_aShowVMInfoOptions, RT_ELEMENTS(g_aShowVMInfoOptions),
|
---|
2682 | 0, RTGETOPTINIT_FLAGS_NO_STD_OPTS);
|
---|
2683 | while ((c = RTGetOpt(&GetState, &ValueUnion)))
|
---|
2684 | {
|
---|
2685 | switch (c)
|
---|
2686 | {
|
---|
2687 | case 'D': // --details
|
---|
2688 | fDetails = true;
|
---|
2689 | break;
|
---|
2690 |
|
---|
2691 | case 'M': // --machinereadable
|
---|
2692 | fMachinereadable = true;
|
---|
2693 | break;
|
---|
2694 |
|
---|
2695 | case 'l': // --log
|
---|
2696 | fLog = true;
|
---|
2697 | uLogIdx = ValueUnion.u32;
|
---|
2698 | break;
|
---|
2699 |
|
---|
2700 | case VINF_GETOPT_NOT_OPTION:
|
---|
2701 | if (!VMNameOrUuid)
|
---|
2702 | VMNameOrUuid = ValueUnion.psz;
|
---|
2703 | else
|
---|
2704 | return errorSyntax(USAGE_SHOWVMINFO, "Invalid parameter '%s'", ValueUnion.psz);
|
---|
2705 | break;
|
---|
2706 |
|
---|
2707 | default:
|
---|
2708 | return errorGetOpt(USAGE_SHOWVMINFO, c, &ValueUnion);
|
---|
2709 | }
|
---|
2710 | }
|
---|
2711 |
|
---|
2712 | /* check for required options */
|
---|
2713 | if (!VMNameOrUuid)
|
---|
2714 | return errorSyntax(USAGE_SHOWVMINFO, "VM name or UUID required");
|
---|
2715 |
|
---|
2716 | /* try to find the given machine */
|
---|
2717 | ComPtr<IMachine> machine;
|
---|
2718 | CHECK_ERROR(a->virtualBox, FindMachine(Bstr(VMNameOrUuid).raw(),
|
---|
2719 | machine.asOutParam()));
|
---|
2720 | if (FAILED(rc))
|
---|
2721 | return RTEXITCODE_FAILURE;
|
---|
2722 |
|
---|
2723 | /* Printing the log is exclusive. */
|
---|
2724 | if (fLog && (fMachinereadable || fDetails))
|
---|
2725 | return errorSyntax(USAGE_SHOWVMINFO, "Option --log is exclusive");
|
---|
2726 |
|
---|
2727 | if (fLog)
|
---|
2728 | {
|
---|
2729 | ULONG64 uOffset = 0;
|
---|
2730 | SafeArray<BYTE> aLogData;
|
---|
2731 | size_t cbLogData;
|
---|
2732 | while (true)
|
---|
2733 | {
|
---|
2734 | /* Reset the array */
|
---|
2735 | aLogData.setNull();
|
---|
2736 | /* Fetch a chunk of the log file */
|
---|
2737 | CHECK_ERROR_BREAK(machine, ReadLog(uLogIdx, uOffset, _1M,
|
---|
2738 | ComSafeArrayAsOutParam(aLogData)));
|
---|
2739 | cbLogData = aLogData.size();
|
---|
2740 | if (cbLogData == 0)
|
---|
2741 | break;
|
---|
2742 | /* aLogData has a platform dependent line ending, standardize on
|
---|
2743 | * Unix style, as RTStrmWrite does the LF -> CR/LF replacement on
|
---|
2744 | * Windows. Otherwise we end up with CR/CR/LF on Windows. */
|
---|
2745 | size_t cbLogDataPrint = cbLogData;
|
---|
2746 | for (BYTE *s = aLogData.raw(), *d = s;
|
---|
2747 | s - aLogData.raw() < (ssize_t)cbLogData;
|
---|
2748 | s++, d++)
|
---|
2749 | {
|
---|
2750 | if (*s == '\r')
|
---|
2751 | {
|
---|
2752 | /* skip over CR, adjust destination */
|
---|
2753 | d--;
|
---|
2754 | cbLogDataPrint--;
|
---|
2755 | }
|
---|
2756 | else if (s != d)
|
---|
2757 | *d = *s;
|
---|
2758 | }
|
---|
2759 | RTStrmWrite(g_pStdOut, aLogData.raw(), cbLogDataPrint);
|
---|
2760 | uOffset += cbLogData;
|
---|
2761 | }
|
---|
2762 | }
|
---|
2763 | else
|
---|
2764 | {
|
---|
2765 | /* 2nd option can be -details or -argdump */
|
---|
2766 | VMINFO_DETAILS details = VMINFO_NONE;
|
---|
2767 | if (fMachinereadable)
|
---|
2768 | details = VMINFO_MACHINEREADABLE;
|
---|
2769 | else if (fDetails)
|
---|
2770 | details = VMINFO_FULL;
|
---|
2771 | else
|
---|
2772 | details = VMINFO_STANDARD;
|
---|
2773 |
|
---|
2774 | /* open an existing session for the VM */
|
---|
2775 | rc = machine->LockMachine(a->session, LockType_Shared);
|
---|
2776 | if (SUCCEEDED(rc))
|
---|
2777 | /* get the session machine */
|
---|
2778 | rc = a->session->COMGETTER(Machine)(machine.asOutParam());
|
---|
2779 |
|
---|
2780 | rc = showVMInfo(a->virtualBox, machine, a->session, details);
|
---|
2781 |
|
---|
2782 | a->session->UnlockMachine();
|
---|
2783 | }
|
---|
2784 |
|
---|
2785 | return SUCCEEDED(rc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE;
|
---|
2786 | }
|
---|
2787 |
|
---|
2788 | #endif /* !VBOX_ONLY_DOCS */
|
---|
2789 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|