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