VirtualBox

source: vbox/trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp@ 26956

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

introduced VBOX_WITH_VUSB

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

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