1 | /* $Id: VBoxManageInfo.cpp 16530 2009-02-05 16:08:49Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxManage - The 'showvminfo' command and helper routines.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2008 Sun Microsystems, Inc.
|
---|
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 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
18 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
19 | * additional information or have any questions.
|
---|
20 | */
|
---|
21 |
|
---|
22 | #ifndef VBOX_ONLY_DOCS
|
---|
23 |
|
---|
24 | /*******************************************************************************
|
---|
25 | * Header Files *
|
---|
26 | *******************************************************************************/
|
---|
27 | #include <VBox/com/com.h>
|
---|
28 | #include <VBox/com/string.h>
|
---|
29 | #include <VBox/com/Guid.h>
|
---|
30 | #include <VBox/com/array.h>
|
---|
31 | #include <VBox/com/ErrorInfo.h>
|
---|
32 | #include <VBox/com/errorprint2.h>
|
---|
33 |
|
---|
34 | #include <VBox/com/VirtualBox.h>
|
---|
35 |
|
---|
36 | #include <VBox/log.h>
|
---|
37 | #include <iprt/stream.h>
|
---|
38 | #include <iprt/time.h>
|
---|
39 | #include <iprt/string.h>
|
---|
40 |
|
---|
41 | #include "VBoxManage.h"
|
---|
42 | using namespace com;
|
---|
43 |
|
---|
44 |
|
---|
45 | // funcs
|
---|
46 | ///////////////////////////////////////////////////////////////////////////////
|
---|
47 |
|
---|
48 | void showSnapshots(ComPtr<ISnapshot> rootSnapshot, VMINFO_DETAILS details, const Bstr &prefix /* = ""*/, int level /*= 0*/)
|
---|
49 | {
|
---|
50 | /* start with the root */
|
---|
51 | Bstr name;
|
---|
52 | Guid uuid;
|
---|
53 | rootSnapshot->COMGETTER(Name)(name.asOutParam());
|
---|
54 | rootSnapshot->COMGETTER(Id)(uuid.asOutParam());
|
---|
55 | if (details == VMINFO_MACHINEREADABLE)
|
---|
56 | {
|
---|
57 | /* print with hierarchical numbering */
|
---|
58 | RTPrintf("SnapshotName%lS=\"%lS\"\n", prefix.raw(), name.raw());
|
---|
59 | RTPrintf("SnapshotUUID%lS=\"%s\"\n", prefix.raw(), uuid.toString().raw());
|
---|
60 | }
|
---|
61 | else
|
---|
62 | {
|
---|
63 | /* print with indentation */
|
---|
64 | RTPrintf(" %lSName: %lS (UUID: %s)\n", prefix.raw(), name.raw(), uuid.toString().raw());
|
---|
65 | }
|
---|
66 |
|
---|
67 | /* get the children */
|
---|
68 | ComPtr<ISnapshotCollection> coll;
|
---|
69 | rootSnapshot->COMGETTER(Children)(coll.asOutParam());
|
---|
70 | if (coll)
|
---|
71 | {
|
---|
72 | ComPtr<ISnapshotEnumerator> enumerator;
|
---|
73 | coll->Enumerate(enumerator.asOutParam());
|
---|
74 | ULONG index = 0;
|
---|
75 | BOOL hasMore = FALSE;
|
---|
76 | while (enumerator->HasMore(&hasMore), hasMore)
|
---|
77 | {
|
---|
78 | ComPtr<ISnapshot> snapshot;
|
---|
79 | enumerator->GetNext(snapshot.asOutParam());
|
---|
80 | if (snapshot)
|
---|
81 | {
|
---|
82 | Bstr newPrefix;
|
---|
83 | if (details == VMINFO_MACHINEREADABLE)
|
---|
84 | newPrefix = Utf8StrFmt("%lS-%d", prefix.raw(), index + 1);
|
---|
85 | else
|
---|
86 | newPrefix = Utf8StrFmt("%lS ", prefix.raw());
|
---|
87 | /* recursive call */
|
---|
88 | showSnapshots(snapshot, details, newPrefix, level + 1);
|
---|
89 | }
|
---|
90 | index++;
|
---|
91 | }
|
---|
92 | }
|
---|
93 | }
|
---|
94 |
|
---|
95 | static void makeTimeStr (char *s, int cb, int64_t millies)
|
---|
96 | {
|
---|
97 | RTTIME t;
|
---|
98 | RTTIMESPEC ts;
|
---|
99 |
|
---|
100 | RTTimeSpecSetMilli(&ts, millies);
|
---|
101 |
|
---|
102 | RTTimeExplode (&t, &ts);
|
---|
103 |
|
---|
104 | RTStrPrintf(s, cb, "%04d/%02d/%02d %02d:%02d:%02d UTC",
|
---|
105 | t.i32Year, t.u8Month, t.u8MonthDay,
|
---|
106 | t.u8Hour, t.u8Minute, t.u8Second);
|
---|
107 | }
|
---|
108 |
|
---|
109 | /* Disable global optimizations for MSC 8.0/64 to make it compile in reasonable
|
---|
110 | time. MSC 7.1/32 doesn't have quite as much trouble with it, but still
|
---|
111 | sufficient to qualify for this hack as well since this code isn't performance
|
---|
112 | critical and probably won't gain much from the extra optimizing in real life. */
|
---|
113 | #if defined(_MSC_VER)
|
---|
114 | # pragma optimize("g", off)
|
---|
115 | #endif
|
---|
116 |
|
---|
117 | HRESULT showVMInfo (ComPtr <IVirtualBox> virtualBox, ComPtr<IMachine> machine,
|
---|
118 | ComPtr <IConsole> console /*= ComPtr <IConsole> ()*/,
|
---|
119 | VMINFO_DETAILS details /*= VMINFO_NONE*/)
|
---|
120 | {
|
---|
121 | HRESULT rc;
|
---|
122 |
|
---|
123 | /*
|
---|
124 | * The rules for output in -argdump format:
|
---|
125 | * 1) the key part (the [0-9a-zA-Z_]+ string before the '=' delimiter)
|
---|
126 | * is all lowercase for "VBoxManage modifyvm" parameters. Any
|
---|
127 | * other values printed are in CamelCase.
|
---|
128 | * 2) strings (anything non-decimal) are printed surrounded by
|
---|
129 | * double quotes '"'. If the strings themselves contain double
|
---|
130 | * quotes, these characters are escaped by '\'. Any '\' character
|
---|
131 | * in the original string is also escaped by '\'.
|
---|
132 | * 3) numbers (containing just [0-9\-]) are written out unchanged.
|
---|
133 | */
|
---|
134 |
|
---|
135 | /** @todo the quoting is not yet implemented! */
|
---|
136 |
|
---|
137 | BOOL accessible = FALSE;
|
---|
138 | CHECK_ERROR (machine, COMGETTER(Accessible) (&accessible));
|
---|
139 | CheckComRCReturnRC (rc);
|
---|
140 |
|
---|
141 | if (!accessible)
|
---|
142 | {
|
---|
143 | if (details == VMINFO_MACHINEREADABLE)
|
---|
144 | RTPrintf("name=\"<inaccessible>\"\n");
|
---|
145 | else
|
---|
146 | RTPrintf ("Name: <inaccessible!>\n");
|
---|
147 | Guid uuid;
|
---|
148 | rc = machine->COMGETTER(Id) (uuid.asOutParam());
|
---|
149 | if (details == VMINFO_MACHINEREADABLE)
|
---|
150 | RTPrintf ("UUID=\"%s\"\n", uuid.toString().raw());
|
---|
151 | else
|
---|
152 | RTPrintf ("UUID: %s\n", uuid.toString().raw());
|
---|
153 | if (details != VMINFO_MACHINEREADABLE)
|
---|
154 | {
|
---|
155 | Bstr settingsFilePath;
|
---|
156 | rc = machine->COMGETTER(SettingsFilePath) (settingsFilePath.asOutParam());
|
---|
157 | RTPrintf ("Config file: %lS\n", settingsFilePath.raw());
|
---|
158 | ComPtr<IVirtualBoxErrorInfo> accessError;
|
---|
159 | rc = machine->COMGETTER(AccessError) (accessError.asOutParam());
|
---|
160 | RTPrintf ("Access error details:\n");
|
---|
161 | ErrorInfo ei (accessError);
|
---|
162 | GluePrintErrorInfo(ei);
|
---|
163 | RTPrintf ("\n");
|
---|
164 | }
|
---|
165 | return S_OK;
|
---|
166 | }
|
---|
167 |
|
---|
168 | Bstr machineName;
|
---|
169 | rc = machine->COMGETTER(Name)(machineName.asOutParam());
|
---|
170 | if (details == VMINFO_MACHINEREADABLE)
|
---|
171 | RTPrintf("name=\"%lS\"\n", machineName.raw());
|
---|
172 | else
|
---|
173 | RTPrintf("Name: %lS\n", machineName.raw());
|
---|
174 |
|
---|
175 | Bstr osTypeId;
|
---|
176 | rc = machine->COMGETTER(OSTypeId)(osTypeId.asOutParam());
|
---|
177 | ComPtr<IGuestOSType> osType;
|
---|
178 | rc = virtualBox->GetGuestOSType (osTypeId, osType.asOutParam());
|
---|
179 | Bstr osName;
|
---|
180 | rc = osType->COMGETTER(Description)(osName.asOutParam());
|
---|
181 | if (details == VMINFO_MACHINEREADABLE)
|
---|
182 | RTPrintf("ostype=\"%lS\"\n", osTypeId.raw());
|
---|
183 | else
|
---|
184 | RTPrintf("Guest OS: %lS\n", osName.raw());
|
---|
185 |
|
---|
186 | Guid uuid;
|
---|
187 | rc = machine->COMGETTER(Id)(uuid.asOutParam());
|
---|
188 | if (details == VMINFO_MACHINEREADABLE)
|
---|
189 | RTPrintf("UUID=\"%s\"\n", uuid.toString().raw());
|
---|
190 | else
|
---|
191 | RTPrintf("UUID: %s\n", uuid.toString().raw());
|
---|
192 |
|
---|
193 | Bstr settingsFilePath;
|
---|
194 | rc = machine->COMGETTER(SettingsFilePath)(settingsFilePath.asOutParam());
|
---|
195 | if (details == VMINFO_MACHINEREADABLE)
|
---|
196 | RTPrintf("CfgFile=\"%lS\"\n", settingsFilePath.raw());
|
---|
197 | else
|
---|
198 | RTPrintf("Config file: %lS\n", settingsFilePath.raw());
|
---|
199 |
|
---|
200 | ULONG memorySize;
|
---|
201 | rc = machine->COMGETTER(MemorySize)(&memorySize);
|
---|
202 | if (details == VMINFO_MACHINEREADABLE)
|
---|
203 | RTPrintf("memory=%u\n", memorySize);
|
---|
204 | else
|
---|
205 | RTPrintf("Memory size: %uMB\n", memorySize);
|
---|
206 |
|
---|
207 | ULONG vramSize;
|
---|
208 | rc = machine->COMGETTER(VRAMSize)(&vramSize);
|
---|
209 | if (details == VMINFO_MACHINEREADABLE)
|
---|
210 | RTPrintf("vram=%u\n", vramSize);
|
---|
211 | else
|
---|
212 | RTPrintf("VRAM size: %uMB\n", vramSize);
|
---|
213 |
|
---|
214 | ComPtr <IBIOSSettings> biosSettings;
|
---|
215 | machine->COMGETTER(BIOSSettings)(biosSettings.asOutParam());
|
---|
216 |
|
---|
217 | BIOSBootMenuMode_T bootMenuMode;
|
---|
218 | biosSettings->COMGETTER(BootMenuMode)(&bootMenuMode);
|
---|
219 | const char *pszBootMenu = NULL;
|
---|
220 | switch (bootMenuMode)
|
---|
221 | {
|
---|
222 | case BIOSBootMenuMode_Disabled:
|
---|
223 | pszBootMenu = "disabled";
|
---|
224 | break;
|
---|
225 | case BIOSBootMenuMode_MenuOnly:
|
---|
226 | if (details == VMINFO_MACHINEREADABLE)
|
---|
227 | pszBootMenu = "menuonly";
|
---|
228 | else
|
---|
229 | pszBootMenu = "menu only";
|
---|
230 | break;
|
---|
231 | default:
|
---|
232 | if (details == VMINFO_MACHINEREADABLE)
|
---|
233 | pszBootMenu = "messageandmenu";
|
---|
234 | else
|
---|
235 | pszBootMenu = "message and menu";
|
---|
236 | }
|
---|
237 | if (details == VMINFO_MACHINEREADABLE)
|
---|
238 | RTPrintf("bootmenu=\"%s\"\n", pszBootMenu);
|
---|
239 | else
|
---|
240 | RTPrintf("Boot menu mode: %s\n", pszBootMenu);
|
---|
241 |
|
---|
242 | BOOL acpiEnabled;
|
---|
243 | biosSettings->COMGETTER(ACPIEnabled)(&acpiEnabled);
|
---|
244 | if (details == VMINFO_MACHINEREADABLE)
|
---|
245 | RTPrintf("acpi=\"%s\"\n", acpiEnabled ? "on" : "off");
|
---|
246 | else
|
---|
247 | RTPrintf("ACPI: %s\n", acpiEnabled ? "on" : "off");
|
---|
248 |
|
---|
249 | BOOL ioapicEnabled;
|
---|
250 | biosSettings->COMGETTER(IOAPICEnabled)(&ioapicEnabled);
|
---|
251 | if (details == VMINFO_MACHINEREADABLE)
|
---|
252 | RTPrintf("ioapic=\"%s\"\n", ioapicEnabled ? "on" : "off");
|
---|
253 | else
|
---|
254 | RTPrintf("IOAPIC: %s\n", ioapicEnabled ? "on" : "off");
|
---|
255 |
|
---|
256 | BOOL PAEEnabled;
|
---|
257 | machine->COMGETTER(PAEEnabled)(&PAEEnabled);
|
---|
258 | if (details == VMINFO_MACHINEREADABLE)
|
---|
259 | RTPrintf("pae=\"%s\"\n", PAEEnabled ? "on" : "off");
|
---|
260 | else
|
---|
261 | RTPrintf("PAE: %s\n", PAEEnabled ? "on" : "off");
|
---|
262 |
|
---|
263 | LONG64 timeOffset;
|
---|
264 | biosSettings->COMGETTER(TimeOffset)(&timeOffset);
|
---|
265 | if (details == VMINFO_MACHINEREADABLE)
|
---|
266 | RTPrintf("biossystemtimeoffset=%lld\n", timeOffset);
|
---|
267 | else
|
---|
268 | RTPrintf("Time offset: %lld ms\n", timeOffset);
|
---|
269 |
|
---|
270 | TSBool_T hwVirtExEnabled;
|
---|
271 | machine->COMGETTER(HWVirtExEnabled)(&hwVirtExEnabled);
|
---|
272 | if (hwVirtExEnabled == TSBool_Default)
|
---|
273 | {
|
---|
274 | BOOL fHWVirtExEnabled;
|
---|
275 | ComPtr<ISystemProperties> systemProperties;
|
---|
276 | virtualBox->COMGETTER(SystemProperties)(systemProperties.asOutParam());
|
---|
277 | systemProperties->COMGETTER(HWVirtExEnabled)(&fHWVirtExEnabled);
|
---|
278 | if (details == VMINFO_MACHINEREADABLE)
|
---|
279 | RTPrintf("hwvirtex=\"default\"\n");
|
---|
280 | else
|
---|
281 | RTPrintf("Hardw. virt.ext: Default (%s)\n", fHWVirtExEnabled ? "on" : "off");
|
---|
282 | }
|
---|
283 | else
|
---|
284 | {
|
---|
285 | if (details == VMINFO_MACHINEREADABLE)
|
---|
286 | RTPrintf("hwvirtex=\"%s\"\n", hwVirtExEnabled == TSBool_True ? "on" : "off");
|
---|
287 | else
|
---|
288 | RTPrintf("Hardw. virt.ext: %s\n", hwVirtExEnabled == TSBool_True ? "on" : "off");
|
---|
289 | }
|
---|
290 | BOOL HWVirtExNestedPagingEnabled;
|
---|
291 | machine->COMGETTER(HWVirtExNestedPagingEnabled)(&HWVirtExNestedPagingEnabled);
|
---|
292 | if (details == VMINFO_MACHINEREADABLE)
|
---|
293 | RTPrintf("nestedpaging=\"%s\"\n", HWVirtExNestedPagingEnabled ? "on" : "off");
|
---|
294 | else
|
---|
295 | RTPrintf("Nested Paging: %s\n", HWVirtExNestedPagingEnabled ? "on" : "off");
|
---|
296 |
|
---|
297 | BOOL HWVirtExVPIDEnabled;
|
---|
298 | machine->COMGETTER(HWVirtExVPIDEnabled)(&HWVirtExVPIDEnabled);
|
---|
299 | if (details == VMINFO_MACHINEREADABLE)
|
---|
300 | RTPrintf("vtxvpid=\"%s\"\n", HWVirtExVPIDEnabled ? "on" : "off");
|
---|
301 | else
|
---|
302 | RTPrintf("VT-x VPID: %s\n", HWVirtExVPIDEnabled ? "on" : "off");
|
---|
303 |
|
---|
304 | MachineState_T machineState;
|
---|
305 | const char *pszState = NULL;
|
---|
306 | rc = machine->COMGETTER(State)(&machineState);
|
---|
307 | switch (machineState)
|
---|
308 | {
|
---|
309 | case MachineState_PoweredOff:
|
---|
310 | if (details == VMINFO_MACHINEREADABLE)
|
---|
311 | pszState = "poweroff";
|
---|
312 | else
|
---|
313 | pszState = "powered off";
|
---|
314 | break;
|
---|
315 | case MachineState_Saved:
|
---|
316 | pszState = "saved";
|
---|
317 | break;
|
---|
318 | case MachineState_Aborted:
|
---|
319 | pszState = "aborted";
|
---|
320 | break;
|
---|
321 | case MachineState_Running:
|
---|
322 | pszState = "running";
|
---|
323 | break;
|
---|
324 | case MachineState_Paused:
|
---|
325 | pszState = "paused";
|
---|
326 | break;
|
---|
327 | case MachineState_Starting:
|
---|
328 | pszState = "starting";
|
---|
329 | break;
|
---|
330 | case MachineState_Stopping:
|
---|
331 | pszState = "stopping";
|
---|
332 | break;
|
---|
333 | case MachineState_Saving:
|
---|
334 | pszState = "saving";
|
---|
335 | break;
|
---|
336 | case MachineState_Restoring:
|
---|
337 | pszState = "restoring";
|
---|
338 | break;
|
---|
339 | default:
|
---|
340 | pszState = "unknown";
|
---|
341 | break;
|
---|
342 | }
|
---|
343 | LONG64 stateSince;
|
---|
344 | machine->COMGETTER(LastStateChange)(&stateSince);
|
---|
345 | RTTIMESPEC timeSpec;
|
---|
346 | RTTimeSpecSetMilli(&timeSpec, stateSince);
|
---|
347 | char pszTime[30] = {0};
|
---|
348 | RTTimeSpecToString(&timeSpec, pszTime, sizeof(pszTime));
|
---|
349 | if (details == VMINFO_MACHINEREADABLE)
|
---|
350 | {
|
---|
351 | RTPrintf("VMState=\"%s\"\n", pszState);
|
---|
352 | RTPrintf("VMStateChangeTime=\"%s\"\n", pszTime);
|
---|
353 | }
|
---|
354 | else
|
---|
355 | RTPrintf("State: %s (since %s)\n", pszState, pszTime);
|
---|
356 |
|
---|
357 | ULONG numMonitors;
|
---|
358 | machine->COMGETTER(MonitorCount)(&numMonitors);
|
---|
359 | if (details == VMINFO_MACHINEREADABLE)
|
---|
360 | RTPrintf("monitorcount=%d\n", numMonitors);
|
---|
361 | else
|
---|
362 | RTPrintf("Monitor count: %d\n", numMonitors);
|
---|
363 |
|
---|
364 | BOOL accelerate3d;
|
---|
365 | machine->COMGETTER(Accelerate3DEnabled)(&accelerate3d);
|
---|
366 | if (details == VMINFO_MACHINEREADABLE)
|
---|
367 | RTPrintf("accelerate3d=\"%s\"\n", accelerate3d ? "on" : "off");
|
---|
368 | else
|
---|
369 | RTPrintf("3D Acceleration: %s\n", accelerate3d ? "on" : "off");
|
---|
370 |
|
---|
371 | ComPtr<IFloppyDrive> floppyDrive;
|
---|
372 | rc = machine->COMGETTER(FloppyDrive)(floppyDrive.asOutParam());
|
---|
373 | if (SUCCEEDED(rc) && floppyDrive)
|
---|
374 | {
|
---|
375 | BOOL fFloppyEnabled;
|
---|
376 | floppyDrive->COMGETTER(Enabled)(&fFloppyEnabled);
|
---|
377 | Utf8Str pszFloppy = "invalid";
|
---|
378 | if (fFloppyEnabled)
|
---|
379 | {
|
---|
380 | DriveState_T floppyState;
|
---|
381 | floppyDrive->COMGETTER(State)(&floppyState);
|
---|
382 | switch (floppyState)
|
---|
383 | {
|
---|
384 | case DriveState_ImageMounted:
|
---|
385 | {
|
---|
386 | ComPtr<IFloppyImage2> floppyImage;
|
---|
387 | rc = floppyDrive->GetImage(floppyImage.asOutParam());
|
---|
388 | if (SUCCEEDED(rc) && floppyImage)
|
---|
389 | {
|
---|
390 | Bstr imagePath;
|
---|
391 | floppyImage->COMGETTER(Location)(imagePath.asOutParam());
|
---|
392 | Guid imageGuid;
|
---|
393 | floppyImage->COMGETTER(Id)(imageGuid.asOutParam());
|
---|
394 | if (details == VMINFO_MACHINEREADABLE)
|
---|
395 | {
|
---|
396 | RTPrintf("FloppyImageUUID=\"%s\"\n", imageGuid.toString().raw());
|
---|
397 | pszFloppy = Utf8StrFmt("%lS", imagePath.raw());
|
---|
398 | }
|
---|
399 | else
|
---|
400 | pszFloppy = Utf8StrFmt("%lS (UUID: %s)", imagePath.raw(), imageGuid.toString().raw());
|
---|
401 | }
|
---|
402 | break;
|
---|
403 | }
|
---|
404 |
|
---|
405 | case DriveState_HostDriveCaptured:
|
---|
406 | {
|
---|
407 | ComPtr<IHostFloppyDrive> hostFloppyDrive;
|
---|
408 | rc = floppyDrive->GetHostDrive(hostFloppyDrive.asOutParam());
|
---|
409 | if (SUCCEEDED(rc) && floppyDrive)
|
---|
410 | {
|
---|
411 | Bstr driveName;
|
---|
412 | hostFloppyDrive->COMGETTER(Name)(driveName.asOutParam());
|
---|
413 | if (details == VMINFO_MACHINEREADABLE)
|
---|
414 | pszFloppy = Utf8StrFmt("host:%lS", driveName.raw());
|
---|
415 | else
|
---|
416 | pszFloppy = Utf8StrFmt("Host drive %lS", driveName.raw());
|
---|
417 | }
|
---|
418 | break;
|
---|
419 | }
|
---|
420 |
|
---|
421 | case DriveState_NotMounted:
|
---|
422 | {
|
---|
423 | pszFloppy = "empty";
|
---|
424 | break;
|
---|
425 | }
|
---|
426 | }
|
---|
427 | }
|
---|
428 | else
|
---|
429 | {
|
---|
430 | pszFloppy = "disabled";
|
---|
431 | }
|
---|
432 | if (details == VMINFO_MACHINEREADABLE)
|
---|
433 | RTPrintf("floppy=\"%s\"\n", pszFloppy.raw());
|
---|
434 | else
|
---|
435 | RTPrintf("Floppy: %s\n", pszFloppy.raw());
|
---|
436 | }
|
---|
437 |
|
---|
438 | /*
|
---|
439 | * SATA.
|
---|
440 | *
|
---|
441 | * Contributed by: James Lucas
|
---|
442 | */
|
---|
443 | #ifdef VBOX_WITH_AHCI
|
---|
444 | ComPtr<ISATAController> SATACtl;
|
---|
445 | BOOL fSataEnabled;
|
---|
446 | rc = machine->COMGETTER(SATAController)(SATACtl.asOutParam());
|
---|
447 | if (SUCCEEDED(rc))
|
---|
448 | {
|
---|
449 | rc = SATACtl->COMGETTER(Enabled)(&fSataEnabled);
|
---|
450 | if (FAILED(rc))
|
---|
451 | fSataEnabled = false;
|
---|
452 | if (details == VMINFO_MACHINEREADABLE)
|
---|
453 | RTPrintf("sata=\"%s\"\n", fSataEnabled ? "on" : "off");
|
---|
454 | else
|
---|
455 | RTPrintf("SATA: %s\n", fSataEnabled ? "enabled" : "disabled");
|
---|
456 | }
|
---|
457 |
|
---|
458 | /*
|
---|
459 | * SATA Hard disks
|
---|
460 | */
|
---|
461 | if (fSataEnabled)
|
---|
462 | {
|
---|
463 | ComPtr<IHardDisk2> hardDisk;
|
---|
464 | Bstr filePath;
|
---|
465 | ULONG cSataPorts;
|
---|
466 |
|
---|
467 | SATACtl->COMGETTER(PortCount)(&cSataPorts);
|
---|
468 | for (ULONG i = 0; i < cSataPorts; ++ i)
|
---|
469 | {
|
---|
470 | rc = machine->GetHardDisk2(StorageBus_SATA, i, 0, hardDisk.asOutParam());
|
---|
471 | if (SUCCEEDED(rc) && hardDisk)
|
---|
472 | {
|
---|
473 | hardDisk->COMGETTER(Location)(filePath.asOutParam());
|
---|
474 | hardDisk->COMGETTER(Id)(uuid.asOutParam());
|
---|
475 | if (details == VMINFO_MACHINEREADABLE)
|
---|
476 | {
|
---|
477 | RTPrintf("sataport%d=\"%lS\"\n", i, filePath.raw());
|
---|
478 | RTPrintf("SataPortImageUUID%d=\"%s\"\n", i, uuid.toString().raw());
|
---|
479 | }
|
---|
480 | else
|
---|
481 | RTPrintf("SATA %d: %lS (UUID: %s)\n", i, filePath.raw(), uuid.toString().raw());
|
---|
482 | }
|
---|
483 | else
|
---|
484 | {
|
---|
485 | if (details == VMINFO_MACHINEREADABLE)
|
---|
486 | RTPrintf("sata%d=\"none\"\n",i);
|
---|
487 | }
|
---|
488 | }
|
---|
489 | }
|
---|
490 | #endif
|
---|
491 |
|
---|
492 | /*
|
---|
493 | * IDE Hard disks
|
---|
494 | */
|
---|
495 | IDEControllerType_T ideController;
|
---|
496 | const char *pszIdeController = NULL;
|
---|
497 | biosSettings->COMGETTER(IDEControllerType)(&ideController);
|
---|
498 | switch (ideController)
|
---|
499 | {
|
---|
500 | case IDEControllerType_PIIX3:
|
---|
501 | pszIdeController = "PIIX3";
|
---|
502 | break;
|
---|
503 | case IDEControllerType_PIIX4:
|
---|
504 | pszIdeController = "PIIX4";
|
---|
505 | break;
|
---|
506 | default:
|
---|
507 | pszIdeController = "unknown";
|
---|
508 | }
|
---|
509 | if (details == VMINFO_MACHINEREADABLE)
|
---|
510 | RTPrintf("idecontroller=\"%s\"\n", pszIdeController);
|
---|
511 | else
|
---|
512 | RTPrintf("IDE Controller: %s\n", pszIdeController);
|
---|
513 |
|
---|
514 | ComPtr<IHardDisk2> hardDisk;
|
---|
515 | Bstr filePath;
|
---|
516 | rc = machine->GetHardDisk2(StorageBus_IDE, 0, 0, hardDisk.asOutParam());
|
---|
517 | if (SUCCEEDED(rc) && hardDisk)
|
---|
518 | {
|
---|
519 | hardDisk->COMGETTER(Location)(filePath.asOutParam());
|
---|
520 | hardDisk->COMGETTER(Id)(uuid.asOutParam());
|
---|
521 | if (details == VMINFO_MACHINEREADABLE)
|
---|
522 | {
|
---|
523 | RTPrintf("hda=\"%lS\"\n", filePath.raw());
|
---|
524 | RTPrintf("HdaImageUUID=\"%s\"\n", uuid.toString().raw());
|
---|
525 | }
|
---|
526 | else
|
---|
527 | RTPrintf("Primary master: %lS (UUID: %s)\n", filePath.raw(), uuid.toString().raw());
|
---|
528 | }
|
---|
529 | else
|
---|
530 | {
|
---|
531 | if (details == VMINFO_MACHINEREADABLE)
|
---|
532 | RTPrintf("hda=\"none\"\n");
|
---|
533 | }
|
---|
534 | rc = machine->GetHardDisk2(StorageBus_IDE, 0, 1, hardDisk.asOutParam());
|
---|
535 | if (SUCCEEDED(rc) && hardDisk)
|
---|
536 | {
|
---|
537 | hardDisk->COMGETTER(Location)(filePath.asOutParam());
|
---|
538 | hardDisk->COMGETTER(Id)(uuid.asOutParam());
|
---|
539 | if (details == VMINFO_MACHINEREADABLE)
|
---|
540 | {
|
---|
541 | RTPrintf("hdb=\"%lS\"\n", filePath.raw());
|
---|
542 | RTPrintf("HdbImageUUID=\"%s\"\n", uuid.toString().raw());
|
---|
543 | }
|
---|
544 | else
|
---|
545 | RTPrintf("Primary slave: %lS (UUID: %s)\n", filePath.raw(), uuid.toString().raw());
|
---|
546 | }
|
---|
547 | else
|
---|
548 | {
|
---|
549 | if (details == VMINFO_MACHINEREADABLE)
|
---|
550 | RTPrintf("hdb=\"none\"\n");
|
---|
551 | }
|
---|
552 | rc = machine->GetHardDisk2(StorageBus_IDE, 1, 1, hardDisk.asOutParam());
|
---|
553 | if (SUCCEEDED(rc) && hardDisk)
|
---|
554 | {
|
---|
555 | hardDisk->COMGETTER(Location)(filePath.asOutParam());
|
---|
556 | hardDisk->COMGETTER(Id)(uuid.asOutParam());
|
---|
557 | if (details == VMINFO_MACHINEREADABLE)
|
---|
558 | {
|
---|
559 | RTPrintf("hdd=\"%lS\"\n", filePath.raw());
|
---|
560 | RTPrintf("HddImageUUID=\"%s\"\n", uuid.toString().raw());
|
---|
561 | }
|
---|
562 | else
|
---|
563 | RTPrintf("Secondary slave: %lS (UUID: %s)\n", filePath.raw(), uuid.toString().raw());
|
---|
564 | }
|
---|
565 | else
|
---|
566 | {
|
---|
567 | if (details == VMINFO_MACHINEREADABLE)
|
---|
568 | RTPrintf("hdd=\"none\"\n");
|
---|
569 | }
|
---|
570 | ComPtr<IDVDDrive> dvdDrive;
|
---|
571 | rc = machine->COMGETTER(DVDDrive)(dvdDrive.asOutParam());
|
---|
572 | if (SUCCEEDED(rc) && dvdDrive)
|
---|
573 | {
|
---|
574 | ComPtr<IDVDImage2> dvdImage;
|
---|
575 | rc = dvdDrive->GetImage(dvdImage.asOutParam());
|
---|
576 | if (SUCCEEDED(rc) && dvdImage)
|
---|
577 | {
|
---|
578 | rc = dvdImage->COMGETTER(Location)(filePath.asOutParam());
|
---|
579 | if (SUCCEEDED(rc) && filePath)
|
---|
580 | {
|
---|
581 | rc = dvdImage->COMGETTER(Id)(uuid.asOutParam());
|
---|
582 | if (details == VMINFO_MACHINEREADABLE)
|
---|
583 | {
|
---|
584 | RTPrintf("dvd=\"%lS\"\n", filePath.raw());
|
---|
585 | RTPrintf("DvdImageUUID=\"%s\"\n", uuid.toString().raw());
|
---|
586 | }
|
---|
587 | else
|
---|
588 | RTPrintf("DVD: %lS (UUID: %s)\n", filePath.raw(), uuid.toString().raw());
|
---|
589 | }
|
---|
590 | }
|
---|
591 | else
|
---|
592 | {
|
---|
593 | ComPtr<IHostDVDDrive> hostDVDDrive;
|
---|
594 | rc = dvdDrive->GetHostDrive(hostDVDDrive.asOutParam());
|
---|
595 | if (SUCCEEDED(rc) && hostDVDDrive)
|
---|
596 | {
|
---|
597 | Bstr name;
|
---|
598 | hostDVDDrive->COMGETTER(Name)(name.asOutParam());
|
---|
599 | if (details == VMINFO_MACHINEREADABLE)
|
---|
600 | RTPrintf("dvd=\"host:%lS\"\n", name.raw());
|
---|
601 | else
|
---|
602 | RTPrintf("DVD: Host drive %lS", name.raw());
|
---|
603 | }
|
---|
604 | else
|
---|
605 | {
|
---|
606 | if (details == VMINFO_MACHINEREADABLE)
|
---|
607 | RTPrintf("dvd=\"none\"\n");
|
---|
608 | else
|
---|
609 | RTPrintf("DVD: empty");
|
---|
610 | }
|
---|
611 | BOOL fPassthrough;
|
---|
612 | dvdDrive->COMGETTER(Passthrough)(&fPassthrough);
|
---|
613 | if (details == VMINFO_MACHINEREADABLE)
|
---|
614 | {
|
---|
615 | RTPrintf("dvdpassthrough=\"%s\"\n", fPassthrough ? "on" : "off");
|
---|
616 | }
|
---|
617 | else
|
---|
618 | {
|
---|
619 | if (fPassthrough)
|
---|
620 | RTPrintf(" (passthrough enabled)");
|
---|
621 | RTPrintf("\n");
|
---|
622 | }
|
---|
623 | }
|
---|
624 | }
|
---|
625 |
|
---|
626 | /* get the maximum amount of NICS */
|
---|
627 | ComPtr<ISystemProperties> sysProps;
|
---|
628 | virtualBox->COMGETTER(SystemProperties)(sysProps.asOutParam());
|
---|
629 | ULONG maxNICs = 0;
|
---|
630 | sysProps->COMGETTER(NetworkAdapterCount)(&maxNICs);
|
---|
631 | for (ULONG currentNIC = 0; currentNIC < maxNICs; currentNIC++)
|
---|
632 | {
|
---|
633 | ComPtr<INetworkAdapter> nic;
|
---|
634 | rc = machine->GetNetworkAdapter(currentNIC, nic.asOutParam());
|
---|
635 | if (SUCCEEDED(rc) && nic)
|
---|
636 | {
|
---|
637 | BOOL fEnabled;
|
---|
638 | nic->COMGETTER(Enabled)(&fEnabled);
|
---|
639 | if (!fEnabled)
|
---|
640 | {
|
---|
641 | if (details == VMINFO_MACHINEREADABLE)
|
---|
642 | RTPrintf("nic%d=\"none\"\n", currentNIC + 1);
|
---|
643 | else
|
---|
644 | RTPrintf("NIC %d: disabled\n", currentNIC + 1);
|
---|
645 | }
|
---|
646 | else
|
---|
647 | {
|
---|
648 | Bstr strMACAddress;
|
---|
649 | nic->COMGETTER(MACAddress)(strMACAddress.asOutParam());
|
---|
650 | Utf8Str strAttachment;
|
---|
651 | NetworkAttachmentType_T attachment;
|
---|
652 | nic->COMGETTER(AttachmentType)(&attachment);
|
---|
653 | switch (attachment)
|
---|
654 | {
|
---|
655 | case NetworkAttachmentType_Null:
|
---|
656 | if (details == VMINFO_MACHINEREADABLE)
|
---|
657 | strAttachment = "null";
|
---|
658 | else
|
---|
659 | strAttachment = "none";
|
---|
660 | break;
|
---|
661 | case NetworkAttachmentType_NAT:
|
---|
662 | {
|
---|
663 | Bstr strNetwork;
|
---|
664 | nic->COMGETTER(NATNetwork)(strNetwork.asOutParam());
|
---|
665 | if (details == VMINFO_MACHINEREADABLE)
|
---|
666 | {
|
---|
667 | RTPrintf("natnet%d=\"%lS\"\n", currentNIC + 1, strNetwork.raw());
|
---|
668 | strAttachment = "nat";
|
---|
669 | }
|
---|
670 | else if (!strNetwork.isEmpty())
|
---|
671 | strAttachment = Utf8StrFmt("NAT (%lS)", strNetwork.raw());
|
---|
672 | else
|
---|
673 | strAttachment = "NAT";
|
---|
674 | break;
|
---|
675 | }
|
---|
676 | case NetworkAttachmentType_HostInterface:
|
---|
677 | {
|
---|
678 | Bstr strHostIfDev;
|
---|
679 | nic->COMGETTER(HostInterface)(strHostIfDev.asOutParam());
|
---|
680 | if (details == VMINFO_MACHINEREADABLE)
|
---|
681 | {
|
---|
682 | RTPrintf("hostifdev%d=\"%lS\"\n", currentNIC + 1, strHostIfDev.raw());
|
---|
683 | strAttachment = "hostif";
|
---|
684 | }
|
---|
685 | else
|
---|
686 | strAttachment = Utf8StrFmt("Host Interface '%lS'", strHostIfDev.raw());
|
---|
687 | break;
|
---|
688 | }
|
---|
689 | case NetworkAttachmentType_Internal:
|
---|
690 | {
|
---|
691 | Bstr strNetwork;
|
---|
692 | nic->COMGETTER(InternalNetwork)(strNetwork.asOutParam());
|
---|
693 | if (details == VMINFO_MACHINEREADABLE)
|
---|
694 | {
|
---|
695 | RTPrintf("intnet%d=\"%lS\"\n", currentNIC + 1, strNetwork.raw());
|
---|
696 | strAttachment = "intnet";
|
---|
697 | }
|
---|
698 | else
|
---|
699 | strAttachment = Utf8StrFmt("Internal Network '%s'", Utf8Str(strNetwork).raw());
|
---|
700 | break;
|
---|
701 | }
|
---|
702 | case NetworkAttachmentType_HostOnly:
|
---|
703 | {
|
---|
704 | if (details == VMINFO_MACHINEREADABLE)
|
---|
705 | {
|
---|
706 | strAttachment = "hostonly";
|
---|
707 | }
|
---|
708 | else
|
---|
709 | strAttachment = "Host-only Network";
|
---|
710 | break;
|
---|
711 | }
|
---|
712 | default:
|
---|
713 | strAttachment = "unknown";
|
---|
714 | break;
|
---|
715 | }
|
---|
716 |
|
---|
717 | /* cable connected */
|
---|
718 | BOOL fConnected;
|
---|
719 | nic->COMGETTER(CableConnected)(&fConnected);
|
---|
720 |
|
---|
721 | /* trace stuff */
|
---|
722 | BOOL fTraceEnabled;
|
---|
723 | nic->COMGETTER(TraceEnabled)(&fTraceEnabled);
|
---|
724 | Bstr traceFile;
|
---|
725 | nic->COMGETTER(TraceFile)(traceFile.asOutParam());
|
---|
726 |
|
---|
727 | /* NIC type */
|
---|
728 | Utf8Str strNICType;
|
---|
729 | NetworkAdapterType_T NICType;
|
---|
730 | nic->COMGETTER(AdapterType)(&NICType);
|
---|
731 | switch (NICType) {
|
---|
732 | case NetworkAdapterType_Am79C970A:
|
---|
733 | strNICType = "Am79C970A";
|
---|
734 | break;
|
---|
735 | case NetworkAdapterType_Am79C973:
|
---|
736 | strNICType = "Am79C973";
|
---|
737 | break;
|
---|
738 | #ifdef VBOX_WITH_E1000
|
---|
739 | case NetworkAdapterType_I82540EM:
|
---|
740 | strNICType = "82540EM";
|
---|
741 | break;
|
---|
742 | case NetworkAdapterType_I82543GC:
|
---|
743 | strNICType = "82543GC";
|
---|
744 | break;
|
---|
745 | #endif
|
---|
746 | default:
|
---|
747 | strNICType = "unknown";
|
---|
748 | break;
|
---|
749 | }
|
---|
750 |
|
---|
751 | /* reported line speed */
|
---|
752 | ULONG ulLineSpeed;
|
---|
753 | nic->COMGETTER(LineSpeed)(&ulLineSpeed);
|
---|
754 |
|
---|
755 | if (details == VMINFO_MACHINEREADABLE)
|
---|
756 | {
|
---|
757 | RTPrintf("macaddress%d=\"%lS\"\n", currentNIC + 1, strMACAddress.raw());
|
---|
758 | RTPrintf("cableconnected%d=\"%s\"\n", currentNIC + 1, fConnected ? "on" : "off");
|
---|
759 | RTPrintf("nic%d=\"%s\"\n", currentNIC + 1, strAttachment.raw());
|
---|
760 | }
|
---|
761 | else
|
---|
762 | RTPrintf("NIC %d: MAC: %lS, Attachment: %s, Cable connected: %s, Trace: %s (file: %lS), Type: %s, Reported speed: %d Mbps\n",
|
---|
763 | currentNIC + 1, strMACAddress.raw(), strAttachment.raw(),
|
---|
764 | fConnected ? "on" : "off",
|
---|
765 | fTraceEnabled ? "on" : "off",
|
---|
766 | traceFile.isEmpty() ? Bstr("none").raw() : traceFile.raw(),
|
---|
767 | strNICType.raw(),
|
---|
768 | ulLineSpeed / 1000);
|
---|
769 | }
|
---|
770 | }
|
---|
771 | }
|
---|
772 |
|
---|
773 | /* get the maximum amount of UARTs */
|
---|
774 | ULONG maxUARTs = 0;
|
---|
775 | sysProps->COMGETTER(SerialPortCount)(&maxUARTs);
|
---|
776 | for (ULONG currentUART = 0; currentUART < maxUARTs; currentUART++)
|
---|
777 | {
|
---|
778 | ComPtr<ISerialPort> uart;
|
---|
779 | rc = machine->GetSerialPort(currentUART, uart.asOutParam());
|
---|
780 | if (SUCCEEDED(rc) && uart)
|
---|
781 | {
|
---|
782 | BOOL fEnabled;
|
---|
783 | uart->COMGETTER(Enabled)(&fEnabled);
|
---|
784 | if (!fEnabled)
|
---|
785 | {
|
---|
786 | if (details == VMINFO_MACHINEREADABLE)
|
---|
787 | RTPrintf("uart%d=\"off\"\n", currentUART + 1);
|
---|
788 | else
|
---|
789 | RTPrintf("UART %d: disabled\n", currentUART + 1);
|
---|
790 | }
|
---|
791 | else
|
---|
792 | {
|
---|
793 | ULONG ulIRQ, ulIOBase;
|
---|
794 | PortMode_T HostMode;
|
---|
795 | Bstr path;
|
---|
796 | BOOL fServer;
|
---|
797 | uart->COMGETTER(IRQ)(&ulIRQ);
|
---|
798 | uart->COMGETTER(IOBase)(&ulIOBase);
|
---|
799 | uart->COMGETTER(Path)(path.asOutParam());
|
---|
800 | uart->COMGETTER(Server)(&fServer);
|
---|
801 | uart->COMGETTER(HostMode)(&HostMode);
|
---|
802 |
|
---|
803 | if (details == VMINFO_MACHINEREADABLE)
|
---|
804 | RTPrintf("uart%d=\"%#06x,%d\"\n", currentUART + 1,
|
---|
805 | ulIOBase, ulIRQ);
|
---|
806 | else
|
---|
807 | RTPrintf("UART %d: I/O base: 0x%04x, IRQ: %d",
|
---|
808 | currentUART + 1, ulIOBase, ulIRQ);
|
---|
809 | switch (HostMode)
|
---|
810 | {
|
---|
811 | default:
|
---|
812 | case PortMode_Disconnected:
|
---|
813 | if (details == VMINFO_MACHINEREADABLE)
|
---|
814 | RTPrintf("uartmode%d=\"disconnected\"\n", currentUART + 1);
|
---|
815 | else
|
---|
816 | RTPrintf(", disconnected\n");
|
---|
817 | break;
|
---|
818 | case PortMode_HostPipe:
|
---|
819 | if (details == VMINFO_MACHINEREADABLE)
|
---|
820 | RTPrintf("uartmode%d=\"%s,%lS\"\n", currentUART + 1,
|
---|
821 | fServer ? "server" : "client", path.raw());
|
---|
822 | else
|
---|
823 | RTPrintf(", attached to pipe (%s) '%lS'\n",
|
---|
824 | fServer ? "server" : "client", path.raw());
|
---|
825 | break;
|
---|
826 | case PortMode_HostDevice:
|
---|
827 | if (details == VMINFO_MACHINEREADABLE)
|
---|
828 | RTPrintf("uartmode%d=\"%lS\"\n", currentUART + 1,
|
---|
829 | path.raw());
|
---|
830 | else
|
---|
831 | RTPrintf(", attached to device '%lS'\n", path.raw());
|
---|
832 | break;
|
---|
833 | }
|
---|
834 | }
|
---|
835 | }
|
---|
836 | }
|
---|
837 |
|
---|
838 | ComPtr<IAudioAdapter> AudioAdapter;
|
---|
839 | rc = machine->COMGETTER(AudioAdapter)(AudioAdapter.asOutParam());
|
---|
840 | if (SUCCEEDED(rc))
|
---|
841 | {
|
---|
842 | const char *pszDrv = "Unknown";
|
---|
843 | const char *pszCtrl = "Unknown";
|
---|
844 | BOOL fEnabled;
|
---|
845 | rc = AudioAdapter->COMGETTER(Enabled)(&fEnabled);
|
---|
846 | if (SUCCEEDED(rc) && fEnabled)
|
---|
847 | {
|
---|
848 | AudioDriverType_T enmDrvType;
|
---|
849 | rc = AudioAdapter->COMGETTER(AudioDriver)(&enmDrvType);
|
---|
850 | switch (enmDrvType)
|
---|
851 | {
|
---|
852 | case AudioDriverType_Null:
|
---|
853 | if (details == VMINFO_MACHINEREADABLE)
|
---|
854 | pszDrv = "null";
|
---|
855 | else
|
---|
856 | pszDrv = "Null";
|
---|
857 | break;
|
---|
858 | case AudioDriverType_WinMM:
|
---|
859 | if (details == VMINFO_MACHINEREADABLE)
|
---|
860 | pszDrv = "winmm";
|
---|
861 | else
|
---|
862 | pszDrv = "WINMM";
|
---|
863 | break;
|
---|
864 | case AudioDriverType_DirectSound:
|
---|
865 | if (details == VMINFO_MACHINEREADABLE)
|
---|
866 | pszDrv = "dsound";
|
---|
867 | else
|
---|
868 | pszDrv = "DSOUND";
|
---|
869 | break;
|
---|
870 | case AudioDriverType_OSS:
|
---|
871 | if (details == VMINFO_MACHINEREADABLE)
|
---|
872 | pszDrv = "oss";
|
---|
873 | else
|
---|
874 | pszDrv = "OSS";
|
---|
875 | break;
|
---|
876 | case AudioDriverType_ALSA:
|
---|
877 | if (details == VMINFO_MACHINEREADABLE)
|
---|
878 | pszDrv = "alsa";
|
---|
879 | else
|
---|
880 | pszDrv = "ALSA";
|
---|
881 | break;
|
---|
882 | case AudioDriverType_Pulse:
|
---|
883 | if (details == VMINFO_MACHINEREADABLE)
|
---|
884 | pszDrv = "pulse";
|
---|
885 | else
|
---|
886 | pszDrv = "PulseAudio";
|
---|
887 | break;
|
---|
888 | case AudioDriverType_CoreAudio:
|
---|
889 | if (details == VMINFO_MACHINEREADABLE)
|
---|
890 | pszDrv = "coreaudio";
|
---|
891 | else
|
---|
892 | pszDrv = "CoreAudio";
|
---|
893 | break;
|
---|
894 | case AudioDriverType_SolAudio:
|
---|
895 | if (details == VMINFO_MACHINEREADABLE)
|
---|
896 | pszDrv = "solaudio";
|
---|
897 | else
|
---|
898 | pszDrv = "SolAudio";
|
---|
899 | break;
|
---|
900 | default:
|
---|
901 | if (details == VMINFO_MACHINEREADABLE)
|
---|
902 | pszDrv = "unknown";
|
---|
903 | break;
|
---|
904 | }
|
---|
905 | AudioControllerType_T enmCtrlType;
|
---|
906 | rc = AudioAdapter->COMGETTER(AudioController)(&enmCtrlType);
|
---|
907 | switch (enmCtrlType)
|
---|
908 | {
|
---|
909 | case AudioControllerType_AC97:
|
---|
910 | if (details == VMINFO_MACHINEREADABLE)
|
---|
911 | pszCtrl = "ac97";
|
---|
912 | else
|
---|
913 | pszCtrl = "AC97";
|
---|
914 | break;
|
---|
915 | case AudioControllerType_SB16:
|
---|
916 | if (details == VMINFO_MACHINEREADABLE)
|
---|
917 | pszCtrl = "sb16";
|
---|
918 | else
|
---|
919 | pszCtrl = "SB16";
|
---|
920 | break;
|
---|
921 | }
|
---|
922 | }
|
---|
923 | else
|
---|
924 | fEnabled = FALSE;
|
---|
925 | if (details == VMINFO_MACHINEREADABLE)
|
---|
926 | {
|
---|
927 | if (fEnabled)
|
---|
928 | RTPrintf("audio=\"%s\"\n", pszDrv);
|
---|
929 | else
|
---|
930 | RTPrintf("audio=\"none\"\n");
|
---|
931 | }
|
---|
932 | else
|
---|
933 | RTPrintf("Audio: %s (Driver: %s, Controller: %s)\n",
|
---|
934 | fEnabled ? "enabled" : "disabled", pszDrv, pszCtrl);
|
---|
935 | }
|
---|
936 |
|
---|
937 | /* Shared clipboard */
|
---|
938 | {
|
---|
939 | const char *psz = "Unknown";
|
---|
940 | ClipboardMode_T enmMode;
|
---|
941 | rc = machine->COMGETTER(ClipboardMode)(&enmMode);
|
---|
942 | switch (enmMode)
|
---|
943 | {
|
---|
944 | case ClipboardMode_Disabled:
|
---|
945 | if (details == VMINFO_MACHINEREADABLE)
|
---|
946 | psz = "disabled";
|
---|
947 | else
|
---|
948 | psz = "disabled";
|
---|
949 | break;
|
---|
950 | case ClipboardMode_HostToGuest:
|
---|
951 | if (details == VMINFO_MACHINEREADABLE)
|
---|
952 | psz = "hosttoguest";
|
---|
953 | else
|
---|
954 | psz = "HostToGuest";
|
---|
955 | break;
|
---|
956 | case ClipboardMode_GuestToHost:
|
---|
957 | if (details == VMINFO_MACHINEREADABLE)
|
---|
958 | psz = "guesttohost";
|
---|
959 | else
|
---|
960 | psz = "GuestToHost";
|
---|
961 | break;
|
---|
962 | case ClipboardMode_Bidirectional:
|
---|
963 | if (details == VMINFO_MACHINEREADABLE)
|
---|
964 | psz = "bidirectional";
|
---|
965 | else
|
---|
966 | psz = "Bidirectional";
|
---|
967 | break;
|
---|
968 | default:
|
---|
969 | if (details == VMINFO_MACHINEREADABLE)
|
---|
970 | psz = "unknown";
|
---|
971 | break;
|
---|
972 | }
|
---|
973 | if (details == VMINFO_MACHINEREADABLE)
|
---|
974 | RTPrintf("clipboard=\"%s\"\n", psz);
|
---|
975 | else
|
---|
976 | RTPrintf("Clipboard Mode: %s\n", psz);
|
---|
977 | }
|
---|
978 |
|
---|
979 | if (console)
|
---|
980 | {
|
---|
981 | ComPtr<IDisplay> display;
|
---|
982 | CHECK_ERROR_RET(console, COMGETTER(Display)(display.asOutParam()), rc);
|
---|
983 | do
|
---|
984 | {
|
---|
985 | ULONG xRes, yRes, bpp;
|
---|
986 | rc = display->COMGETTER(Width)(&xRes);
|
---|
987 | if (rc == E_ACCESSDENIED)
|
---|
988 | break; /* VM not powered up */
|
---|
989 | if (FAILED(rc))
|
---|
990 | {
|
---|
991 | com::ErrorInfo info (display);
|
---|
992 | GluePrintErrorInfo(info);
|
---|
993 | return rc;
|
---|
994 | }
|
---|
995 | rc = display->COMGETTER(Height)(&yRes);
|
---|
996 | if (rc == E_ACCESSDENIED)
|
---|
997 | break; /* VM not powered up */
|
---|
998 | if (FAILED(rc))
|
---|
999 | {
|
---|
1000 | com::ErrorInfo info (display);
|
---|
1001 | GluePrintErrorInfo(info);
|
---|
1002 | return rc;
|
---|
1003 | }
|
---|
1004 | rc = display->COMGETTER(BitsPerPixel)(&bpp);
|
---|
1005 | if (rc == E_ACCESSDENIED)
|
---|
1006 | break; /* VM not powered up */
|
---|
1007 | if (FAILED(rc))
|
---|
1008 | {
|
---|
1009 | com::ErrorInfo info (display);
|
---|
1010 | GluePrintErrorInfo(info);
|
---|
1011 | return rc;
|
---|
1012 | }
|
---|
1013 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1014 | RTPrintf("VideoMode=\"%d,%d,%d\"\n", xRes, yRes, bpp);
|
---|
1015 | else
|
---|
1016 | RTPrintf("Video mode: %dx%dx%d\n", xRes, yRes, bpp);
|
---|
1017 | }
|
---|
1018 | while (0);
|
---|
1019 | }
|
---|
1020 |
|
---|
1021 | /*
|
---|
1022 | * VRDP
|
---|
1023 | */
|
---|
1024 | ComPtr<IVRDPServer> vrdpServer;
|
---|
1025 | rc = machine->COMGETTER(VRDPServer)(vrdpServer.asOutParam());
|
---|
1026 | if (SUCCEEDED(rc) && vrdpServer)
|
---|
1027 | {
|
---|
1028 | BOOL fEnabled = false;
|
---|
1029 | vrdpServer->COMGETTER(Enabled)(&fEnabled);
|
---|
1030 | if (fEnabled)
|
---|
1031 | {
|
---|
1032 | ULONG port;
|
---|
1033 | vrdpServer->COMGETTER(Port)(&port);
|
---|
1034 | Bstr address;
|
---|
1035 | vrdpServer->COMGETTER(NetAddress)(address.asOutParam());
|
---|
1036 | BOOL fMultiCon;
|
---|
1037 | vrdpServer->COMGETTER(AllowMultiConnection)(&fMultiCon);
|
---|
1038 | BOOL fReuseCon;
|
---|
1039 | vrdpServer->COMGETTER(ReuseSingleConnection)(&fReuseCon);
|
---|
1040 | VRDPAuthType_T vrdpAuthType;
|
---|
1041 | const char *strAuthType;
|
---|
1042 | vrdpServer->COMGETTER(AuthType)(&vrdpAuthType);
|
---|
1043 | switch (vrdpAuthType)
|
---|
1044 | {
|
---|
1045 | case VRDPAuthType_Null:
|
---|
1046 | strAuthType = "null";
|
---|
1047 | break;
|
---|
1048 | case VRDPAuthType_External:
|
---|
1049 | strAuthType = "external";
|
---|
1050 | break;
|
---|
1051 | case VRDPAuthType_Guest:
|
---|
1052 | strAuthType = "guest";
|
---|
1053 | break;
|
---|
1054 | default:
|
---|
1055 | strAuthType = "unknown";
|
---|
1056 | break;
|
---|
1057 | }
|
---|
1058 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1059 | {
|
---|
1060 | RTPrintf("vrdp=\"on\"\n");
|
---|
1061 | RTPrintf("vrdpport=%d\n", port);
|
---|
1062 | RTPrintf("vrdpaddress=\"%lS\"\n", address.raw());
|
---|
1063 | RTPrintf("vrdpauthtype=\"%s\"\n", strAuthType);
|
---|
1064 | RTPrintf("vrdpmulticon=\"%s\"\n", fMultiCon ? "on" : "off");
|
---|
1065 | RTPrintf("vrdpreusecon=\"%s\"\n", fReuseCon ? "on" : "off");
|
---|
1066 | }
|
---|
1067 | else
|
---|
1068 | {
|
---|
1069 | if (address.isEmpty())
|
---|
1070 | address = "0.0.0.0";
|
---|
1071 | RTPrintf("VRDP: enabled (Address %lS, Port %d, MultiConn: %s, ReuseSingleConn: %s, Authentication type: %s)\n", address.raw(), port, fMultiCon ? "on" : "off", fReuseCon ? "on" : "off", strAuthType);
|
---|
1072 | }
|
---|
1073 | }
|
---|
1074 | else
|
---|
1075 | {
|
---|
1076 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1077 | RTPrintf("vrdp=\"off\"\n");
|
---|
1078 | else
|
---|
1079 | RTPrintf("VRDP: disabled\n");
|
---|
1080 | }
|
---|
1081 | }
|
---|
1082 |
|
---|
1083 | /*
|
---|
1084 | * USB.
|
---|
1085 | */
|
---|
1086 | ComPtr<IUSBController> USBCtl;
|
---|
1087 | rc = machine->COMGETTER(USBController)(USBCtl.asOutParam());
|
---|
1088 | if (SUCCEEDED(rc))
|
---|
1089 | {
|
---|
1090 | BOOL fEnabled;
|
---|
1091 | rc = USBCtl->COMGETTER(Enabled)(&fEnabled);
|
---|
1092 | if (FAILED(rc))
|
---|
1093 | fEnabled = false;
|
---|
1094 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1095 | RTPrintf("usb=\"%s\"\n", fEnabled ? "on" : "off");
|
---|
1096 | else
|
---|
1097 | RTPrintf("USB: %s\n", fEnabled ? "enabled" : "disabled");
|
---|
1098 |
|
---|
1099 | if (details != VMINFO_MACHINEREADABLE)
|
---|
1100 | RTPrintf("\nUSB Device Filters:\n\n");
|
---|
1101 |
|
---|
1102 | ComPtr<IUSBDeviceFilterCollection> Coll;
|
---|
1103 | CHECK_ERROR_RET (USBCtl, COMGETTER(DeviceFilters)(Coll.asOutParam()), rc);
|
---|
1104 |
|
---|
1105 | ComPtr<IUSBDeviceFilterEnumerator> Enum;
|
---|
1106 | CHECK_ERROR_RET (Coll, Enumerate(Enum.asOutParam()), rc);
|
---|
1107 |
|
---|
1108 | ULONG index = 0;
|
---|
1109 | BOOL fMore = FALSE;
|
---|
1110 | ASSERT(SUCCEEDED(rc = Enum->HasMore (&fMore)));
|
---|
1111 | if (FAILED(rc))
|
---|
1112 | return rc;
|
---|
1113 |
|
---|
1114 | if (!fMore)
|
---|
1115 | {
|
---|
1116 | if (details != VMINFO_MACHINEREADABLE)
|
---|
1117 | RTPrintf("<none>\n\n");
|
---|
1118 | }
|
---|
1119 | else
|
---|
1120 | while (fMore)
|
---|
1121 | {
|
---|
1122 | ComPtr<IUSBDeviceFilter> DevPtr;
|
---|
1123 | ASSERT(SUCCEEDED(rc = Enum->GetNext(DevPtr.asOutParam())));
|
---|
1124 | if (FAILED(rc))
|
---|
1125 | return rc;
|
---|
1126 |
|
---|
1127 | /* Query info. */
|
---|
1128 |
|
---|
1129 | if (details != VMINFO_MACHINEREADABLE)
|
---|
1130 | RTPrintf("Index: %lu\n", index);
|
---|
1131 |
|
---|
1132 | BOOL bActive = FALSE;
|
---|
1133 | CHECK_ERROR_RET (DevPtr, COMGETTER (Active) (&bActive), rc);
|
---|
1134 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1135 | RTPrintf("USBFilterActive%d=\"%s\"\n", index + 1, bActive ? "on" : "off");
|
---|
1136 | else
|
---|
1137 | RTPrintf("Active: %s\n", bActive ? "yes" : "no");
|
---|
1138 |
|
---|
1139 | Bstr bstr;
|
---|
1140 | CHECK_ERROR_RET (DevPtr, COMGETTER (Name) (bstr.asOutParam()), rc);
|
---|
1141 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1142 | RTPrintf("USBFilterName%d=\"%lS\"\n", index + 1, bstr.raw());
|
---|
1143 | else
|
---|
1144 | RTPrintf("Name: %lS\n", bstr.raw());
|
---|
1145 | CHECK_ERROR_RET (DevPtr, COMGETTER (VendorId) (bstr.asOutParam()), rc);
|
---|
1146 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1147 | RTPrintf("USBFilterVendorId%d=\"%lS\"\n", index + 1, bstr.raw());
|
---|
1148 | else
|
---|
1149 | RTPrintf("VendorId: %lS\n", bstr.raw());
|
---|
1150 | CHECK_ERROR_RET (DevPtr, COMGETTER (ProductId) (bstr.asOutParam()), rc);
|
---|
1151 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1152 | RTPrintf("USBFilterProductId%d=\"%lS\"\n", index + 1, bstr.raw());
|
---|
1153 | else
|
---|
1154 | RTPrintf("ProductId: %lS\n", bstr.raw());
|
---|
1155 | CHECK_ERROR_RET (DevPtr, COMGETTER (Revision) (bstr.asOutParam()), rc);
|
---|
1156 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1157 | RTPrintf("USBFilterRevision%d=\"%lS\"\n", index + 1, bstr.raw());
|
---|
1158 | else
|
---|
1159 | RTPrintf("Revision: %lS\n", bstr.raw());
|
---|
1160 | CHECK_ERROR_RET (DevPtr, COMGETTER (Manufacturer) (bstr.asOutParam()), rc);
|
---|
1161 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1162 | RTPrintf("USBFilterManufacturer%d=\"%lS\"\n", index + 1, bstr.raw());
|
---|
1163 | else
|
---|
1164 | RTPrintf("Manufacturer: %lS\n", bstr.raw());
|
---|
1165 | CHECK_ERROR_RET (DevPtr, COMGETTER (Product) (bstr.asOutParam()), rc);
|
---|
1166 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1167 | RTPrintf("USBFilterProduct%d=\"%lS\"\n", index + 1, bstr.raw());
|
---|
1168 | else
|
---|
1169 | RTPrintf("Product: %lS\n", bstr.raw());
|
---|
1170 | CHECK_ERROR_RET (DevPtr, COMGETTER (Remote) (bstr.asOutParam()), rc);
|
---|
1171 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1172 | RTPrintf("USBFilterRemote%d=\"%lS\"\n", index + 1, bstr.raw());
|
---|
1173 | else
|
---|
1174 | RTPrintf("Remote: %lS\n", bstr.raw());
|
---|
1175 | CHECK_ERROR_RET (DevPtr, COMGETTER (SerialNumber) (bstr.asOutParam()), rc);
|
---|
1176 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1177 | RTPrintf("USBFilterSerialNumber%d=\"%lS\"\n", index + 1, bstr.raw());
|
---|
1178 | else
|
---|
1179 | RTPrintf("Serial Number: %lS\n", bstr.raw());
|
---|
1180 | if (details != VMINFO_MACHINEREADABLE)
|
---|
1181 | {
|
---|
1182 | ULONG fMaskedIfs;
|
---|
1183 | CHECK_ERROR_RET (DevPtr, COMGETTER (MaskedInterfaces) (&fMaskedIfs), rc);
|
---|
1184 | if (fMaskedIfs)
|
---|
1185 | RTPrintf("Masked Interfaces: 0x%08x\n", fMaskedIfs);
|
---|
1186 | RTPrintf("\n");
|
---|
1187 | }
|
---|
1188 |
|
---|
1189 | ASSERT(SUCCEEDED(rc = Enum->HasMore (&fMore)));
|
---|
1190 | if (FAILED(rc))
|
---|
1191 | return rc;
|
---|
1192 |
|
---|
1193 | index ++;
|
---|
1194 | }
|
---|
1195 |
|
---|
1196 | if (console)
|
---|
1197 | {
|
---|
1198 | index = 0;
|
---|
1199 | /* scope */
|
---|
1200 | {
|
---|
1201 | if (details != VMINFO_MACHINEREADABLE)
|
---|
1202 | RTPrintf("Available remote USB devices:\n\n");
|
---|
1203 |
|
---|
1204 | ComPtr<IHostUSBDeviceCollection> coll;
|
---|
1205 | CHECK_ERROR_RET (console, COMGETTER(RemoteUSBDevices) (coll.asOutParam()), rc);
|
---|
1206 |
|
---|
1207 | ComPtr <IHostUSBDeviceEnumerator> en;
|
---|
1208 | CHECK_ERROR_RET (coll, Enumerate (en.asOutParam()), rc);
|
---|
1209 |
|
---|
1210 | BOOL more = FALSE;
|
---|
1211 | ASSERT(SUCCEEDED(rc = en->HasMore(&more)));
|
---|
1212 | if (FAILED(rc))
|
---|
1213 | return rc;
|
---|
1214 |
|
---|
1215 | if (!more)
|
---|
1216 | {
|
---|
1217 | if (details != VMINFO_MACHINEREADABLE)
|
---|
1218 | RTPrintf("<none>\n\n");
|
---|
1219 | }
|
---|
1220 | else
|
---|
1221 | while (more)
|
---|
1222 | {
|
---|
1223 | ComPtr <IHostUSBDevice> dev;
|
---|
1224 | ASSERT(SUCCEEDED(rc = en->GetNext (dev.asOutParam())));
|
---|
1225 | if (FAILED(rc))
|
---|
1226 | return rc;
|
---|
1227 |
|
---|
1228 | /* Query info. */
|
---|
1229 | Guid id;
|
---|
1230 | CHECK_ERROR_RET (dev, COMGETTER(Id)(id.asOutParam()), rc);
|
---|
1231 | USHORT usVendorId;
|
---|
1232 | CHECK_ERROR_RET (dev, COMGETTER(VendorId)(&usVendorId), rc);
|
---|
1233 | USHORT usProductId;
|
---|
1234 | CHECK_ERROR_RET (dev, COMGETTER(ProductId)(&usProductId), rc);
|
---|
1235 | USHORT bcdRevision;
|
---|
1236 | CHECK_ERROR_RET (dev, COMGETTER(Revision)(&bcdRevision), rc);
|
---|
1237 |
|
---|
1238 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1239 | RTPrintf("USBRemoteUUID%d=\"%S\"\n"
|
---|
1240 | "USBRemoteVendorId%d=\"%#06x\"\n"
|
---|
1241 | "USBRemoteProductId%d=\"%#06x\"\n"
|
---|
1242 | "USBRemoteRevision%d=\"%#04x%02x\"\n",
|
---|
1243 | index + 1, id.toString().raw(),
|
---|
1244 | index + 1, usVendorId,
|
---|
1245 | index + 1, usProductId,
|
---|
1246 | index + 1, bcdRevision >> 8, bcdRevision & 0xff);
|
---|
1247 | else
|
---|
1248 | RTPrintf("UUID: %S\n"
|
---|
1249 | "VendorId: 0x%04x (%04X)\n"
|
---|
1250 | "ProductId: 0x%04x (%04X)\n"
|
---|
1251 | "Revision: %u.%u (%02u%02u)\n",
|
---|
1252 | id.toString().raw(),
|
---|
1253 | usVendorId, usVendorId, usProductId, usProductId,
|
---|
1254 | bcdRevision >> 8, bcdRevision & 0xff,
|
---|
1255 | bcdRevision >> 8, bcdRevision & 0xff);
|
---|
1256 |
|
---|
1257 | /* optional stuff. */
|
---|
1258 | Bstr bstr;
|
---|
1259 | CHECK_ERROR_RET (dev, COMGETTER(Manufacturer)(bstr.asOutParam()), rc);
|
---|
1260 | if (!bstr.isEmpty())
|
---|
1261 | {
|
---|
1262 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1263 | RTPrintf("USBRemoteManufacturer%d=\"%lS\"\n", index + 1, bstr.raw());
|
---|
1264 | else
|
---|
1265 | RTPrintf("Manufacturer: %lS\n", bstr.raw());
|
---|
1266 | }
|
---|
1267 | CHECK_ERROR_RET (dev, COMGETTER(Product)(bstr.asOutParam()), rc);
|
---|
1268 | if (!bstr.isEmpty())
|
---|
1269 | {
|
---|
1270 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1271 | RTPrintf("USBRemoteProduct%d=\"%lS\"\n", index + 1, bstr.raw());
|
---|
1272 | else
|
---|
1273 | RTPrintf("Product: %lS\n", bstr.raw());
|
---|
1274 | }
|
---|
1275 | CHECK_ERROR_RET (dev, COMGETTER(SerialNumber)(bstr.asOutParam()), rc);
|
---|
1276 | if (!bstr.isEmpty())
|
---|
1277 | {
|
---|
1278 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1279 | RTPrintf("USBRemoteSerialNumber%d=\"%lS\"\n", index + 1, bstr.raw());
|
---|
1280 | else
|
---|
1281 | RTPrintf("SerialNumber: %lS\n", bstr.raw());
|
---|
1282 | }
|
---|
1283 | CHECK_ERROR_RET (dev, COMGETTER(Address)(bstr.asOutParam()), rc);
|
---|
1284 | if (!bstr.isEmpty())
|
---|
1285 | {
|
---|
1286 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1287 | RTPrintf("USBRemoteAddress%d=\"%lS\"\n", index + 1, bstr.raw());
|
---|
1288 | else
|
---|
1289 | RTPrintf("Address: %lS\n", bstr.raw());
|
---|
1290 | }
|
---|
1291 |
|
---|
1292 | if (details != VMINFO_MACHINEREADABLE)
|
---|
1293 | RTPrintf("\n");
|
---|
1294 |
|
---|
1295 | ASSERT(SUCCEEDED(rc = en->HasMore (&more)));
|
---|
1296 | if (FAILED(rc))
|
---|
1297 | return rc;
|
---|
1298 |
|
---|
1299 | index ++;
|
---|
1300 | }
|
---|
1301 | }
|
---|
1302 |
|
---|
1303 | index = 0;
|
---|
1304 | /* scope */
|
---|
1305 | {
|
---|
1306 | if (details != VMINFO_MACHINEREADABLE)
|
---|
1307 | RTPrintf ("Currently Attached USB Devices:\n\n");
|
---|
1308 |
|
---|
1309 | ComPtr <IUSBDeviceCollection> coll;
|
---|
1310 | CHECK_ERROR_RET (console, COMGETTER(USBDevices) (coll.asOutParam()), rc);
|
---|
1311 |
|
---|
1312 | ComPtr <IUSBDeviceEnumerator> en;
|
---|
1313 | CHECK_ERROR_RET (coll, Enumerate (en.asOutParam()), rc);
|
---|
1314 |
|
---|
1315 | BOOL more = FALSE;
|
---|
1316 | ASSERT(SUCCEEDED(rc = en->HasMore (&more)));
|
---|
1317 | if (FAILED(rc))
|
---|
1318 | return rc;
|
---|
1319 |
|
---|
1320 | if (!more)
|
---|
1321 | {
|
---|
1322 | if (details != VMINFO_MACHINEREADABLE)
|
---|
1323 | RTPrintf("<none>\n\n");
|
---|
1324 | }
|
---|
1325 | else
|
---|
1326 | while (more)
|
---|
1327 | {
|
---|
1328 | ComPtr <IUSBDevice> dev;
|
---|
1329 | ASSERT(SUCCEEDED(rc = en->GetNext (dev.asOutParam())));
|
---|
1330 | if (FAILED(rc))
|
---|
1331 | return rc;
|
---|
1332 |
|
---|
1333 | /* Query info. */
|
---|
1334 | Guid id;
|
---|
1335 | CHECK_ERROR_RET (dev, COMGETTER(Id)(id.asOutParam()), rc);
|
---|
1336 | USHORT usVendorId;
|
---|
1337 | CHECK_ERROR_RET (dev, COMGETTER(VendorId)(&usVendorId), rc);
|
---|
1338 | USHORT usProductId;
|
---|
1339 | CHECK_ERROR_RET (dev, COMGETTER(ProductId)(&usProductId), rc);
|
---|
1340 | USHORT bcdRevision;
|
---|
1341 | CHECK_ERROR_RET (dev, COMGETTER(Revision)(&bcdRevision), rc);
|
---|
1342 |
|
---|
1343 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1344 | RTPrintf("USBAttachedUUID%d=\"%S\"\n"
|
---|
1345 | "USBAttachedVendorId%d=\"%#06x\"\n"
|
---|
1346 | "USBAttachedProductId%d=\"%#06x\"\n"
|
---|
1347 | "USBAttachedRevision%d=\"%#04x%02x\"\n",
|
---|
1348 | index + 1, id.toString().raw(),
|
---|
1349 | index + 1, usVendorId,
|
---|
1350 | index + 1, usProductId,
|
---|
1351 | index + 1, bcdRevision >> 8, bcdRevision & 0xff);
|
---|
1352 | else
|
---|
1353 | RTPrintf("UUID: %S\n"
|
---|
1354 | "VendorId: 0x%04x (%04X)\n"
|
---|
1355 | "ProductId: 0x%04x (%04X)\n"
|
---|
1356 | "Revision: %u.%u (%02u%02u)\n",
|
---|
1357 | id.toString().raw(),
|
---|
1358 | usVendorId, usVendorId, usProductId, usProductId,
|
---|
1359 | bcdRevision >> 8, bcdRevision & 0xff,
|
---|
1360 | bcdRevision >> 8, bcdRevision & 0xff);
|
---|
1361 |
|
---|
1362 | /* optional stuff. */
|
---|
1363 | Bstr bstr;
|
---|
1364 | CHECK_ERROR_RET (dev, COMGETTER(Manufacturer)(bstr.asOutParam()), rc);
|
---|
1365 | if (!bstr.isEmpty())
|
---|
1366 | {
|
---|
1367 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1368 | RTPrintf("USBAttachedManufacturer%d=\"%lS\"\n", index + 1, bstr.raw());
|
---|
1369 | else
|
---|
1370 | RTPrintf("Manufacturer: %lS\n", bstr.raw());
|
---|
1371 | }
|
---|
1372 | CHECK_ERROR_RET (dev, COMGETTER(Product)(bstr.asOutParam()), rc);
|
---|
1373 | if (!bstr.isEmpty())
|
---|
1374 | {
|
---|
1375 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1376 | RTPrintf("USBAttachedProduct%d=\"%lS\"\n", index + 1, bstr.raw());
|
---|
1377 | else
|
---|
1378 | RTPrintf("Product: %lS\n", bstr.raw());
|
---|
1379 | }
|
---|
1380 | CHECK_ERROR_RET (dev, COMGETTER(SerialNumber)(bstr.asOutParam()), rc);
|
---|
1381 | if (!bstr.isEmpty())
|
---|
1382 | {
|
---|
1383 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1384 | RTPrintf("USBAttachedSerialNumber%d=\"%lS\"\n", index + 1, bstr.raw());
|
---|
1385 | else
|
---|
1386 | RTPrintf("SerialNumber: %lS\n", bstr.raw());
|
---|
1387 | }
|
---|
1388 | CHECK_ERROR_RET (dev, COMGETTER(Address)(bstr.asOutParam()), rc);
|
---|
1389 | if (!bstr.isEmpty())
|
---|
1390 | {
|
---|
1391 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1392 | RTPrintf("USBAttachedAddress%d=\"%lS\"\n", index + 1, bstr.raw());
|
---|
1393 | else
|
---|
1394 | RTPrintf("Address: %lS\n", bstr.raw());
|
---|
1395 | }
|
---|
1396 |
|
---|
1397 | if (details != VMINFO_MACHINEREADABLE)
|
---|
1398 | RTPrintf("\n");
|
---|
1399 |
|
---|
1400 | ASSERT(SUCCEEDED(rc = en->HasMore (&more)));
|
---|
1401 | if (FAILED(rc))
|
---|
1402 | return rc;
|
---|
1403 |
|
---|
1404 | index ++;
|
---|
1405 | }
|
---|
1406 | }
|
---|
1407 | }
|
---|
1408 | } /* USB */
|
---|
1409 |
|
---|
1410 | /*
|
---|
1411 | * Shared folders
|
---|
1412 | */
|
---|
1413 | if (details != VMINFO_MACHINEREADABLE)
|
---|
1414 | RTPrintf("Shared folders: ");
|
---|
1415 | uint32_t numSharedFolders = 0;
|
---|
1416 | #if 0 // not yet implemented
|
---|
1417 | /* globally shared folders first */
|
---|
1418 | {
|
---|
1419 | ComPtr<ISharedFolderCollection> sfColl;
|
---|
1420 | ComPtr<ISharedFolderEnumerator> sfEnum;
|
---|
1421 | CHECK_ERROR_RET(virtualBox, COMGETTER(SharedFolders)(sfColl.asOutParam()), rc);
|
---|
1422 | CHECK_ERROR_RET(sfColl, Enumerate(sfEnum.asOutParam()), rc);
|
---|
1423 | BOOL fMore;
|
---|
1424 | sfEnum->HasMore(&fMore);
|
---|
1425 | while (fMore)
|
---|
1426 | {
|
---|
1427 | ComPtr<ISharedFolder> sf;
|
---|
1428 | CHECK_ERROR_RET(sfEnum, GetNext(sf.asOutParam()), rc);
|
---|
1429 | Bstr name, hostPath;
|
---|
1430 | sf->COMGETTER(Name)(name.asOutParam());
|
---|
1431 | sf->COMGETTER(HostPath)(hostPath.asOutParam());
|
---|
1432 | RTPrintf("Name: '%lS', Host path: '%lS' (global mapping)\n", name.raw(), hostPath.raw());
|
---|
1433 | ++numSharedFolders;
|
---|
1434 | CHECK_ERROR_RET(sfEnum, HasMore(&fMore), rc);
|
---|
1435 | }
|
---|
1436 | }
|
---|
1437 | #endif
|
---|
1438 | /* now VM mappings */
|
---|
1439 | {
|
---|
1440 | ComPtr<ISharedFolderCollection> sfColl;
|
---|
1441 | ComPtr<ISharedFolderEnumerator> sfEnum;
|
---|
1442 | CHECK_ERROR_RET(machine, COMGETTER(SharedFolders)(sfColl.asOutParam()), rc);
|
---|
1443 | CHECK_ERROR_RET(sfColl, Enumerate(sfEnum.asOutParam()), rc);
|
---|
1444 | ULONG index = 0;
|
---|
1445 | BOOL fMore;
|
---|
1446 | sfEnum->HasMore(&fMore);
|
---|
1447 | while (fMore)
|
---|
1448 | {
|
---|
1449 | ComPtr<ISharedFolder> sf;
|
---|
1450 | CHECK_ERROR_RET(sfEnum, GetNext(sf.asOutParam()), rc);
|
---|
1451 | Bstr name, hostPath;
|
---|
1452 | BOOL writable;
|
---|
1453 | sf->COMGETTER(Name)(name.asOutParam());
|
---|
1454 | sf->COMGETTER(HostPath)(hostPath.asOutParam());
|
---|
1455 | sf->COMGETTER(Writable)(&writable);
|
---|
1456 | if (!numSharedFolders && details != VMINFO_MACHINEREADABLE)
|
---|
1457 | RTPrintf("\n\n");
|
---|
1458 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1459 | {
|
---|
1460 | RTPrintf("SharedFolderNameMachineMapping%d=\"%lS\"\n", index + 1,
|
---|
1461 | name.raw());
|
---|
1462 | RTPrintf("SharedFolderPathMachineMapping%d=\"%lS\"\n", index + 1,
|
---|
1463 | hostPath.raw());
|
---|
1464 | }
|
---|
1465 | else
|
---|
1466 | RTPrintf("Name: '%lS', Host path: '%lS' (machine mapping), %s\n",
|
---|
1467 | name.raw(), hostPath.raw(), writable ? "writable" : "readonly");
|
---|
1468 | ++numSharedFolders;
|
---|
1469 | CHECK_ERROR_RET(sfEnum, HasMore(&fMore), rc);
|
---|
1470 | }
|
---|
1471 | }
|
---|
1472 | /* transient mappings */
|
---|
1473 | if (console)
|
---|
1474 | {
|
---|
1475 | ComPtr<ISharedFolderCollection> sfColl;
|
---|
1476 | ComPtr<ISharedFolderEnumerator> sfEnum;
|
---|
1477 | CHECK_ERROR_RET(console, COMGETTER(SharedFolders)(sfColl.asOutParam()), rc);
|
---|
1478 | CHECK_ERROR_RET(sfColl, Enumerate(sfEnum.asOutParam()), rc);
|
---|
1479 | ULONG index = 0;
|
---|
1480 | BOOL fMore;
|
---|
1481 | sfEnum->HasMore(&fMore);
|
---|
1482 | while (fMore)
|
---|
1483 | {
|
---|
1484 | ComPtr<ISharedFolder> sf;
|
---|
1485 | CHECK_ERROR_RET(sfEnum, GetNext(sf.asOutParam()), rc);
|
---|
1486 | Bstr name, hostPath;
|
---|
1487 | sf->COMGETTER(Name)(name.asOutParam());
|
---|
1488 | sf->COMGETTER(HostPath)(hostPath.asOutParam());
|
---|
1489 | if (!numSharedFolders && details != VMINFO_MACHINEREADABLE)
|
---|
1490 | RTPrintf("\n\n");
|
---|
1491 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1492 | {
|
---|
1493 | RTPrintf("SharedFolderNameTransientMapping%d=\"%lS\"\n", index + 1,
|
---|
1494 | name.raw());
|
---|
1495 | RTPrintf("SharedFolderPathTransientMapping%d=\"%lS\"\n", index + 1,
|
---|
1496 | hostPath.raw());
|
---|
1497 | }
|
---|
1498 | else
|
---|
1499 | RTPrintf("Name: '%lS', Host path: '%lS' (transient mapping)\n", name.raw(), hostPath.raw());
|
---|
1500 | ++numSharedFolders;
|
---|
1501 | CHECK_ERROR_RET(sfEnum, HasMore(&fMore), rc);
|
---|
1502 | }
|
---|
1503 | }
|
---|
1504 | if (!numSharedFolders && details != VMINFO_MACHINEREADABLE)
|
---|
1505 | RTPrintf("<none>\n");
|
---|
1506 | if (details != VMINFO_MACHINEREADABLE)
|
---|
1507 | RTPrintf("\n");
|
---|
1508 |
|
---|
1509 | if (console)
|
---|
1510 | {
|
---|
1511 | /*
|
---|
1512 | * Live VRDP info.
|
---|
1513 | */
|
---|
1514 | ComPtr<IRemoteDisplayInfo> remoteDisplayInfo;
|
---|
1515 | CHECK_ERROR_RET(console, COMGETTER(RemoteDisplayInfo)(remoteDisplayInfo.asOutParam()), rc);
|
---|
1516 | BOOL Active;
|
---|
1517 | ULONG NumberOfClients;
|
---|
1518 | LONG64 BeginTime;
|
---|
1519 | LONG64 EndTime;
|
---|
1520 | ULONG64 BytesSent;
|
---|
1521 | ULONG64 BytesSentTotal;
|
---|
1522 | ULONG64 BytesReceived;
|
---|
1523 | ULONG64 BytesReceivedTotal;
|
---|
1524 | Bstr User;
|
---|
1525 | Bstr Domain;
|
---|
1526 | Bstr ClientName;
|
---|
1527 | Bstr ClientIP;
|
---|
1528 | ULONG ClientVersion;
|
---|
1529 | ULONG EncryptionStyle;
|
---|
1530 |
|
---|
1531 | CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(Active) (&Active), rc);
|
---|
1532 | CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(NumberOfClients) (&NumberOfClients), rc);
|
---|
1533 | CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(BeginTime) (&BeginTime), rc);
|
---|
1534 | CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(EndTime) (&EndTime), rc);
|
---|
1535 | CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(BytesSent) (&BytesSent), rc);
|
---|
1536 | CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(BytesSentTotal) (&BytesSentTotal), rc);
|
---|
1537 | CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(BytesReceived) (&BytesReceived), rc);
|
---|
1538 | CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(BytesReceivedTotal) (&BytesReceivedTotal), rc);
|
---|
1539 | CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(User) (User.asOutParam ()), rc);
|
---|
1540 | CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(Domain) (Domain.asOutParam ()), rc);
|
---|
1541 | CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(ClientName) (ClientName.asOutParam ()), rc);
|
---|
1542 | CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(ClientIP) (ClientIP.asOutParam ()), rc);
|
---|
1543 | CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(ClientVersion) (&ClientVersion), rc);
|
---|
1544 | CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(EncryptionStyle) (&EncryptionStyle), rc);
|
---|
1545 |
|
---|
1546 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1547 | RTPrintf("VRDPActiveConnection=\"%s\"\n", Active ? "on": "off");
|
---|
1548 | else
|
---|
1549 | RTPrintf("VRDP Connection: %s\n", Active? "active": "not active");
|
---|
1550 |
|
---|
1551 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1552 | RTPrintf("VRDPClients=%d\n", NumberOfClients);
|
---|
1553 | else
|
---|
1554 | RTPrintf("Clients so far: %d\n", NumberOfClients);
|
---|
1555 |
|
---|
1556 | if (NumberOfClients > 0)
|
---|
1557 | {
|
---|
1558 | char timestr[128];
|
---|
1559 |
|
---|
1560 | if (Active)
|
---|
1561 | {
|
---|
1562 | makeTimeStr (timestr, sizeof (timestr), BeginTime);
|
---|
1563 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1564 | RTPrintf("VRDPStartTime=\"%s\"\n", timestr);
|
---|
1565 | else
|
---|
1566 | RTPrintf("Start time: %s\n", timestr);
|
---|
1567 | }
|
---|
1568 | else
|
---|
1569 | {
|
---|
1570 | makeTimeStr (timestr, sizeof (timestr), BeginTime);
|
---|
1571 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1572 | RTPrintf("VRDPLastStartTime=\"%s\"\n", timestr);
|
---|
1573 | else
|
---|
1574 | RTPrintf("Last started: %s\n", timestr);
|
---|
1575 | makeTimeStr (timestr, sizeof (timestr), EndTime);
|
---|
1576 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1577 | RTPrintf("VRDPLastEndTime=\"%s\"\n", timestr);
|
---|
1578 | else
|
---|
1579 | RTPrintf("Last ended: %s\n", timestr);
|
---|
1580 | }
|
---|
1581 |
|
---|
1582 | uint64_t ThroughputSend = 0;
|
---|
1583 | uint64_t ThroughputReceive = 0;
|
---|
1584 | if (EndTime != BeginTime)
|
---|
1585 | {
|
---|
1586 | ThroughputSend = (BytesSent * 1000) / (EndTime - BeginTime);
|
---|
1587 | ThroughputReceive = (BytesReceived * 1000) / (EndTime - BeginTime);
|
---|
1588 | }
|
---|
1589 |
|
---|
1590 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1591 | {
|
---|
1592 | RTPrintf("VRDPBytesSent=%llu\n", BytesSent);
|
---|
1593 | RTPrintf("VRDPThroughputSend=%llu\n", ThroughputSend);
|
---|
1594 | RTPrintf("VRDPBytesSentTotal=%llu\n", BytesSentTotal);
|
---|
1595 |
|
---|
1596 | RTPrintf("VRDPBytesReceived=%llu\n", BytesReceived);
|
---|
1597 | RTPrintf("VRDPThroughputReceive=%llu\n", ThroughputReceive);
|
---|
1598 | RTPrintf("VRDPBytesReceivedTotal=%llu\n", BytesReceivedTotal);
|
---|
1599 | }
|
---|
1600 | else
|
---|
1601 | {
|
---|
1602 | RTPrintf("Sent: %llu Bytes\n", BytesSent);
|
---|
1603 | RTPrintf("Average speed: %llu B/s\n", ThroughputSend);
|
---|
1604 | RTPrintf("Sent total: %llu Bytes\n", BytesSentTotal);
|
---|
1605 |
|
---|
1606 | RTPrintf("Received: %llu Bytes\n", BytesReceived);
|
---|
1607 | RTPrintf("Speed: %llu B/s\n", ThroughputReceive);
|
---|
1608 | RTPrintf("Received total: %llu Bytes\n", BytesReceivedTotal);
|
---|
1609 | }
|
---|
1610 |
|
---|
1611 | if (Active)
|
---|
1612 | {
|
---|
1613 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1614 | {
|
---|
1615 | RTPrintf("VRDPUserName=\"%lS\"\n", User.raw());
|
---|
1616 | RTPrintf("VRDPDomain=\"%lS\"\n", Domain.raw());
|
---|
1617 | RTPrintf("VRDPClientName=\"%lS\"\n", ClientName.raw());
|
---|
1618 | RTPrintf("VRDPClientIP=\"%lS\"\n", ClientIP.raw());
|
---|
1619 | RTPrintf("VRDPClientVersion=%d\n", ClientVersion);
|
---|
1620 | RTPrintf("VRDPEncryption=\"%s\"\n", EncryptionStyle == 0? "RDP4": "RDP5 (X.509)");
|
---|
1621 | }
|
---|
1622 | else
|
---|
1623 | {
|
---|
1624 | RTPrintf("User name: %lS\n", User.raw());
|
---|
1625 | RTPrintf("Domain: %lS\n", Domain.raw());
|
---|
1626 | RTPrintf("Client name: %lS\n", ClientName.raw());
|
---|
1627 | RTPrintf("Client IP: %lS\n", ClientIP.raw());
|
---|
1628 | RTPrintf("Client version: %d\n", ClientVersion);
|
---|
1629 | RTPrintf("Encryption: %s\n", EncryptionStyle == 0? "RDP4": "RDP5 (X.509)");
|
---|
1630 | }
|
---|
1631 | }
|
---|
1632 | }
|
---|
1633 |
|
---|
1634 | if (details != VMINFO_MACHINEREADABLE)
|
---|
1635 | RTPrintf("\n");
|
---|
1636 | }
|
---|
1637 |
|
---|
1638 | if ( details == VMINFO_STANDARD
|
---|
1639 | || details == VMINFO_FULL
|
---|
1640 | || details == VMINFO_MACHINEREADABLE)
|
---|
1641 | {
|
---|
1642 | Bstr description;
|
---|
1643 | machine->COMGETTER(Description)(description.asOutParam());
|
---|
1644 | if (!description.isEmpty())
|
---|
1645 | {
|
---|
1646 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1647 | RTPrintf("description=\"%lS\"\n", description.raw());
|
---|
1648 | else
|
---|
1649 | RTPrintf("Description:\n%lS\n", description.raw());
|
---|
1650 | }
|
---|
1651 | }
|
---|
1652 |
|
---|
1653 | ULONG guestVal;
|
---|
1654 | if (details != VMINFO_MACHINEREADABLE)
|
---|
1655 | RTPrintf("Guest:\n\n");
|
---|
1656 |
|
---|
1657 | #ifdef VBOX_WITH_MEM_BALLOONING
|
---|
1658 | rc = machine->COMGETTER(MemoryBalloonSize)(&guestVal);
|
---|
1659 | if (SUCCEEDED(rc))
|
---|
1660 | {
|
---|
1661 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1662 | RTPrintf("GuestMemoryBalloon=%d\n", guestVal);
|
---|
1663 | else
|
---|
1664 | RTPrintf("Configured memory balloon size: %d MB\n", guestVal);
|
---|
1665 | }
|
---|
1666 | #endif
|
---|
1667 | rc = machine->COMGETTER(StatisticsUpdateInterval)(&guestVal);
|
---|
1668 | if (SUCCEEDED(rc))
|
---|
1669 | {
|
---|
1670 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1671 | RTPrintf("GuestStatisticsUpdateInterval=%d\n", guestVal);
|
---|
1672 | else
|
---|
1673 | {
|
---|
1674 | if (guestVal == 0)
|
---|
1675 | RTPrintf("Statistics update: disabled\n");
|
---|
1676 | else
|
---|
1677 | RTPrintf("Statistics update interval: %d seconds\n", guestVal);
|
---|
1678 | }
|
---|
1679 | }
|
---|
1680 | if (details != VMINFO_MACHINEREADABLE)
|
---|
1681 | RTPrintf("\n");
|
---|
1682 |
|
---|
1683 | if ( console
|
---|
1684 | && ( details == VMINFO_STATISTICS
|
---|
1685 | || details == VMINFO_FULL
|
---|
1686 | || details == VMINFO_MACHINEREADABLE))
|
---|
1687 | {
|
---|
1688 | ComPtr <IGuest> guest;
|
---|
1689 |
|
---|
1690 | rc = console->COMGETTER(Guest)(guest.asOutParam());
|
---|
1691 | if (SUCCEEDED(rc))
|
---|
1692 | {
|
---|
1693 | ULONG statVal;
|
---|
1694 |
|
---|
1695 | rc = guest->GetStatistic(0, GuestStatisticType_SampleNumber, &statVal);
|
---|
1696 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1697 | RTPrintf("StatGuestSample=%d\n", statVal);
|
---|
1698 | else
|
---|
1699 | RTPrintf("Guest statistics for sample %d:\n\n", statVal);
|
---|
1700 |
|
---|
1701 | rc = guest->GetStatistic(0, GuestStatisticType_CPULoad_Idle, &statVal);
|
---|
1702 | if (SUCCEEDED(rc))
|
---|
1703 | {
|
---|
1704 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1705 | RTPrintf("StatGuestLoadIdleCPU%d=%d\n", 0, statVal);
|
---|
1706 | else
|
---|
1707 | RTPrintf("CPU%d: CPU Load Idle %-3d%%\n", 0, statVal);
|
---|
1708 | }
|
---|
1709 |
|
---|
1710 | rc = guest->GetStatistic(0, GuestStatisticType_CPULoad_Kernel, &statVal);
|
---|
1711 | if (SUCCEEDED(rc))
|
---|
1712 | {
|
---|
1713 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1714 | RTPrintf("StatGuestLoadKernelCPU%d=%d\n", 0, statVal);
|
---|
1715 | else
|
---|
1716 | RTPrintf("CPU%d: CPU Load Kernel %-3d%%\n", 0, statVal);
|
---|
1717 | }
|
---|
1718 |
|
---|
1719 | rc = guest->GetStatistic(0, GuestStatisticType_CPULoad_User, &statVal);
|
---|
1720 | if (SUCCEEDED(rc))
|
---|
1721 | {
|
---|
1722 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1723 | RTPrintf("StatGuestLoadUserCPU%d=%d\n", 0, statVal);
|
---|
1724 | else
|
---|
1725 | RTPrintf("CPU%d: CPU Load User %-3d%%\n", 0, statVal);
|
---|
1726 | }
|
---|
1727 |
|
---|
1728 | rc = guest->GetStatistic(0, GuestStatisticType_Threads, &statVal);
|
---|
1729 | if (SUCCEEDED(rc))
|
---|
1730 | {
|
---|
1731 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1732 | RTPrintf("StatGuestThreadsCPU%d=%d\n", 0, statVal);
|
---|
1733 | else
|
---|
1734 | RTPrintf("CPU%d: Threads %d\n", 0, statVal);
|
---|
1735 | }
|
---|
1736 |
|
---|
1737 | rc = guest->GetStatistic(0, GuestStatisticType_Processes, &statVal);
|
---|
1738 | if (SUCCEEDED(rc))
|
---|
1739 | {
|
---|
1740 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1741 | RTPrintf("StatGuestProcessesCPU%d=%d\n", 0, statVal);
|
---|
1742 | else
|
---|
1743 | RTPrintf("CPU%d: Processes %d\n", 0, statVal);
|
---|
1744 | }
|
---|
1745 |
|
---|
1746 | rc = guest->GetStatistic(0, GuestStatisticType_Handles, &statVal);
|
---|
1747 | if (SUCCEEDED(rc))
|
---|
1748 | {
|
---|
1749 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1750 | RTPrintf("StatGuestHandlesCPU%d=%d\n", 0, statVal);
|
---|
1751 | else
|
---|
1752 | RTPrintf("CPU%d: Handles %d\n", 0, statVal);
|
---|
1753 | }
|
---|
1754 |
|
---|
1755 | rc = guest->GetStatistic(0, GuestStatisticType_MemoryLoad, &statVal);
|
---|
1756 | if (SUCCEEDED(rc))
|
---|
1757 | {
|
---|
1758 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1759 | RTPrintf("StatGuestMemoryLoadCPU%d=%d\n", 0, statVal);
|
---|
1760 | else
|
---|
1761 | RTPrintf("CPU%d: Memory Load %d%%\n", 0, statVal);
|
---|
1762 | }
|
---|
1763 |
|
---|
1764 | rc = guest->GetStatistic(0, GuestStatisticType_PhysMemTotal, &statVal);
|
---|
1765 | if (SUCCEEDED(rc))
|
---|
1766 | {
|
---|
1767 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1768 | RTPrintf("StatGuestMemoryTotalPhysCPU%d=%d\n", 0, statVal);
|
---|
1769 | else
|
---|
1770 | RTPrintf("CPU%d: Total physical memory %-4d MB\n", 0, statVal);
|
---|
1771 | }
|
---|
1772 |
|
---|
1773 | rc = guest->GetStatistic(0, GuestStatisticType_PhysMemAvailable, &statVal);
|
---|
1774 | if (SUCCEEDED(rc))
|
---|
1775 | {
|
---|
1776 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1777 | RTPrintf("StatGuestMemoryFreePhysCPU%d=%d\n", 0, statVal);
|
---|
1778 | else
|
---|
1779 | RTPrintf("CPU%d: Free physical memory %-4d MB\n", 0, statVal);
|
---|
1780 | }
|
---|
1781 |
|
---|
1782 | #ifdef VBOX_WITH_MEM_BALLOONING
|
---|
1783 | rc = guest->GetStatistic(0, GuestStatisticType_PhysMemBalloon, &statVal);
|
---|
1784 | if (SUCCEEDED(rc))
|
---|
1785 | {
|
---|
1786 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1787 | RTPrintf("StatGuestMemoryBalloonCPU%d=%d\n", 0, statVal);
|
---|
1788 | else
|
---|
1789 | RTPrintf("CPU%d: Memory balloon size %-4d MB\n", 0, statVal);
|
---|
1790 | }
|
---|
1791 | #endif
|
---|
1792 | rc = guest->GetStatistic(0, GuestStatisticType_MemCommitTotal, &statVal);
|
---|
1793 | if (SUCCEEDED(rc))
|
---|
1794 | {
|
---|
1795 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1796 | RTPrintf("StatGuestMemoryCommittedCPU%d=%d\n", 0, statVal);
|
---|
1797 | else
|
---|
1798 | RTPrintf("CPU%d: Committed memory %-4d MB\n", 0, statVal);
|
---|
1799 | }
|
---|
1800 |
|
---|
1801 | rc = guest->GetStatistic(0, GuestStatisticType_MemKernelTotal, &statVal);
|
---|
1802 | if (SUCCEEDED(rc))
|
---|
1803 | {
|
---|
1804 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1805 | RTPrintf("StatGuestMemoryTotalKernelCPU%d=%d\n", 0, statVal);
|
---|
1806 | else
|
---|
1807 | RTPrintf("CPU%d: Total kernel memory %-4d MB\n", 0, statVal);
|
---|
1808 | }
|
---|
1809 |
|
---|
1810 | rc = guest->GetStatistic(0, GuestStatisticType_MemKernelPaged, &statVal);
|
---|
1811 | if (SUCCEEDED(rc))
|
---|
1812 | {
|
---|
1813 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1814 | RTPrintf("StatGuestMemoryPagedKernelCPU%d=%d\n", 0, statVal);
|
---|
1815 | else
|
---|
1816 | RTPrintf("CPU%d: Paged kernel memory %-4d MB\n", 0, statVal);
|
---|
1817 | }
|
---|
1818 |
|
---|
1819 | rc = guest->GetStatistic(0, GuestStatisticType_MemKernelNonpaged, &statVal);
|
---|
1820 | if (SUCCEEDED(rc))
|
---|
1821 | {
|
---|
1822 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1823 | RTPrintf("StatGuestMemoryNonpagedKernelCPU%d=%d\n", 0, statVal);
|
---|
1824 | else
|
---|
1825 | RTPrintf("CPU%d: Nonpaged kernel memory %-4d MB\n", 0, statVal);
|
---|
1826 | }
|
---|
1827 |
|
---|
1828 | rc = guest->GetStatistic(0, GuestStatisticType_MemSystemCache, &statVal);
|
---|
1829 | if (SUCCEEDED(rc))
|
---|
1830 | {
|
---|
1831 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1832 | RTPrintf("StatGuestSystemCacheSizeCPU%d=%d\n", 0, statVal);
|
---|
1833 | else
|
---|
1834 | RTPrintf("CPU%d: System cache size %-4d MB\n", 0, statVal);
|
---|
1835 | }
|
---|
1836 |
|
---|
1837 | rc = guest->GetStatistic(0, GuestStatisticType_PageFileSize, &statVal);
|
---|
1838 | if (SUCCEEDED(rc))
|
---|
1839 | {
|
---|
1840 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1841 | RTPrintf("StatGuestPageFileSizeCPU%d=%d\n", 0, statVal);
|
---|
1842 | else
|
---|
1843 | RTPrintf("CPU%d: Page file size %-4d MB\n", 0, statVal);
|
---|
1844 | }
|
---|
1845 |
|
---|
1846 | RTPrintf("\n");
|
---|
1847 | }
|
---|
1848 | else
|
---|
1849 | {
|
---|
1850 | if (details != VMINFO_MACHINEREADABLE)
|
---|
1851 | {
|
---|
1852 | RTPrintf("[!] FAILED calling console->getGuest at line %d!\n", __LINE__);
|
---|
1853 | GluePrintRCMessage(rc);
|
---|
1854 | }
|
---|
1855 | }
|
---|
1856 | }
|
---|
1857 |
|
---|
1858 | /*
|
---|
1859 | * snapshots
|
---|
1860 | */
|
---|
1861 | ComPtr<ISnapshot> snapshot;
|
---|
1862 | rc = machine->GetSnapshot(Guid(), snapshot.asOutParam());
|
---|
1863 | if (SUCCEEDED(rc) && snapshot)
|
---|
1864 | {
|
---|
1865 | if (details != VMINFO_MACHINEREADABLE)
|
---|
1866 | RTPrintf("Snapshots:\n\n");
|
---|
1867 | showSnapshots(snapshot, details);
|
---|
1868 | }
|
---|
1869 |
|
---|
1870 | if (details != VMINFO_MACHINEREADABLE)
|
---|
1871 | RTPrintf("\n");
|
---|
1872 | return S_OK;
|
---|
1873 | }
|
---|
1874 |
|
---|
1875 | #if defined(_MSC_VER)
|
---|
1876 | # pragma optimize("", on)
|
---|
1877 | #endif
|
---|
1878 |
|
---|
1879 | int handleShowVMInfo(HandlerArg *a)
|
---|
1880 | {
|
---|
1881 | HRESULT rc;
|
---|
1882 |
|
---|
1883 | /* at least one option: the UUID or name of the VM */
|
---|
1884 | if (a->argc < 1)
|
---|
1885 | return errorSyntax(USAGE_SHOWVMINFO, "Incorrect number of parameters");
|
---|
1886 |
|
---|
1887 | /* try to find the given machine */
|
---|
1888 | ComPtr <IMachine> machine;
|
---|
1889 | Guid uuid (a->argv[0]);
|
---|
1890 | if (!uuid.isEmpty())
|
---|
1891 | {
|
---|
1892 | CHECK_ERROR (a->virtualBox, GetMachine (uuid, machine.asOutParam()));
|
---|
1893 | }
|
---|
1894 | else
|
---|
1895 | {
|
---|
1896 | CHECK_ERROR (a->virtualBox, FindMachine (Bstr(a->argv[0]), machine.asOutParam()));
|
---|
1897 | if (SUCCEEDED (rc))
|
---|
1898 | machine->COMGETTER(Id) (uuid.asOutParam());
|
---|
1899 | }
|
---|
1900 | if (FAILED (rc))
|
---|
1901 | return 1;
|
---|
1902 |
|
---|
1903 | /* 2nd option can be -details, -statistics or -argdump */
|
---|
1904 | VMINFO_DETAILS details = VMINFO_NONE;
|
---|
1905 | bool fDetails = false;
|
---|
1906 | bool fStatistics = false;
|
---|
1907 | bool fMachinereadable = false;
|
---|
1908 | for (int i=1;i<a->argc;i++)
|
---|
1909 | {
|
---|
1910 | if (!strcmp(a->argv[i], "-details"))
|
---|
1911 | fDetails = true;
|
---|
1912 | else
|
---|
1913 | if (!strcmp(a->argv[i], "-statistics"))
|
---|
1914 | fStatistics = true;
|
---|
1915 | if (!strcmp(a->argv[1], "-machinereadable"))
|
---|
1916 | fMachinereadable = true;
|
---|
1917 | }
|
---|
1918 | if (fMachinereadable)
|
---|
1919 | details = VMINFO_MACHINEREADABLE;
|
---|
1920 | else
|
---|
1921 | if (fDetails && fStatistics)
|
---|
1922 | details = VMINFO_FULL;
|
---|
1923 | else
|
---|
1924 | if (fDetails)
|
---|
1925 | details = VMINFO_STANDARD;
|
---|
1926 | else
|
---|
1927 | if (fStatistics)
|
---|
1928 | details = VMINFO_STATISTICS;
|
---|
1929 |
|
---|
1930 | ComPtr <IConsole> console;
|
---|
1931 |
|
---|
1932 | /* open an existing session for the VM */
|
---|
1933 | rc = a->virtualBox->OpenExistingSession (a->session, uuid);
|
---|
1934 | if (SUCCEEDED(rc))
|
---|
1935 | /* get the session machine */
|
---|
1936 | rc = a->session->COMGETTER(Machine)(machine.asOutParam());
|
---|
1937 | if (SUCCEEDED(rc))
|
---|
1938 | /* get the session console */
|
---|
1939 | rc = a->session->COMGETTER(Console)(console.asOutParam());
|
---|
1940 |
|
---|
1941 | rc = showVMInfo (a->virtualBox, machine, console, details);
|
---|
1942 |
|
---|
1943 | if (console)
|
---|
1944 | a->session->Close();
|
---|
1945 |
|
---|
1946 | return SUCCEEDED (rc) ? 0 : 1;
|
---|
1947 | }
|
---|
1948 |
|
---|
1949 | #endif /* !VBOX_ONLY_DOCS */
|
---|
1950 |
|
---|