VirtualBox

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

Last change on this file since 28248 was 28215, checked in by vboxsync, 15 years ago

IDisplay API changes for multimonitor (xTracker 4655)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 76.8 KB
Line 
1/* $Id: VBoxManageInfo.cpp 28215 2010-04-12 15:31:54Z vboxsync $ */
2/** @file
3 * VBoxManage - The 'showvminfo' command and helper routines.
4 */
5
6/*
7 * Copyright (C) 2006-2010 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 HWVirtExLargePagesEnabled;
436 machine->GetHWVirtExProperty(HWVirtExPropertyType_LargePages, &HWVirtExLargePagesEnabled);
437 if (details == VMINFO_MACHINEREADABLE)
438 RTPrintf("largepages=\"%s\"\n", HWVirtExLargePagesEnabled ? "on" : "off");
439 else
440 RTPrintf("Large Pages: %s\n", HWVirtExLargePagesEnabled ? "on" : "off");
441
442 BOOL HWVirtExVPIDEnabled;
443 machine->GetHWVirtExProperty(HWVirtExPropertyType_VPID, &HWVirtExVPIDEnabled);
444 if (details == VMINFO_MACHINEREADABLE)
445 RTPrintf("vtxvpid=\"%s\"\n", HWVirtExVPIDEnabled ? "on" : "off");
446 else
447 RTPrintf("VT-x VPID: %s\n", HWVirtExVPIDEnabled ? "on" : "off");
448
449 MachineState_T machineState;
450 const char *pszState = NULL;
451 rc = machine->COMGETTER(State)(&machineState);
452 switch (machineState)
453 {
454 case MachineState_PoweredOff:
455 pszState = details == VMINFO_MACHINEREADABLE ? "poweroff" : "powered off";
456 break;
457 case MachineState_Saved:
458 pszState = "saved";
459 break;
460 case MachineState_Aborted:
461 pszState = "aborted";
462 break;
463 case MachineState_Teleported:
464 pszState = "teleported";
465 break;
466 case MachineState_Running:
467 pszState = "running";
468 break;
469 case MachineState_Paused:
470 pszState = "paused";
471 break;
472 case MachineState_Stuck:
473 pszState = details == VMINFO_MACHINEREADABLE ? "gurumeditation" : "guru meditation";
474 break;
475 case MachineState_LiveSnapshotting:
476 pszState = details == VMINFO_MACHINEREADABLE ? "livesnapshotting" : "live snapshotting";
477 break;
478 case MachineState_Teleporting:
479 pszState = "teleporting";
480 break;
481 case MachineState_Starting:
482 pszState = "starting";
483 break;
484 case MachineState_Stopping:
485 pszState = "stopping";
486 break;
487 case MachineState_Saving:
488 pszState = "saving";
489 break;
490 case MachineState_Restoring:
491 pszState = "restoring";
492 break;
493 case MachineState_TeleportingPausedVM:
494 pszState = details == VMINFO_MACHINEREADABLE ? "teleportingpausedvm" : "teleporting paused vm";
495 break;
496 case MachineState_TeleportingIn:
497 pszState = details == VMINFO_MACHINEREADABLE ? "teleportingin" : "teleporting (incoming)";
498 break;
499 case MachineState_RestoringSnapshot:
500 pszState = details == VMINFO_MACHINEREADABLE ? "restoringsnapshot" : "restoring snapshot";
501 case MachineState_DeletingSnapshot:
502 pszState = details == VMINFO_MACHINEREADABLE ? "deletingsnapshot" : "deleting snapshot";
503 case MachineState_SettingUp:
504 pszState = details == VMINFO_MACHINEREADABLE ? "settingup" : "setting up";
505 break;
506 default:
507 pszState = "unknown";
508 break;
509 }
510 LONG64 stateSince;
511 machine->COMGETTER(LastStateChange)(&stateSince);
512 RTTIMESPEC timeSpec;
513 RTTimeSpecSetMilli(&timeSpec, stateSince);
514 char pszTime[30] = {0};
515 RTTimeSpecToString(&timeSpec, pszTime, sizeof(pszTime));
516 Bstr stateFile;
517 machine->COMGETTER(StateFilePath)(stateFile.asOutParam());
518 if (details == VMINFO_MACHINEREADABLE)
519 {
520 RTPrintf("VMState=\"%s\"\n", pszState);
521 RTPrintf("VMStateChangeTime=\"%s\"\n", pszTime);
522 if (!stateFile.isEmpty())
523 RTPrintf("VMStateFile=\"%lS\"\n", stateFile.raw());
524 }
525 else
526 RTPrintf("State: %s (since %s)\n", pszState, pszTime);
527
528 ULONG numMonitors;
529 machine->COMGETTER(MonitorCount)(&numMonitors);
530 if (details == VMINFO_MACHINEREADABLE)
531 RTPrintf("monitorcount=%d\n", numMonitors);
532 else
533 RTPrintf("Monitor count: %d\n", numMonitors);
534
535 BOOL accelerate3d;
536 machine->COMGETTER(Accelerate3DEnabled)(&accelerate3d);
537 if (details == VMINFO_MACHINEREADABLE)
538 RTPrintf("accelerate3d=\"%s\"\n", accelerate3d ? "on" : "off");
539 else
540 RTPrintf("3D Acceleration: %s\n", accelerate3d ? "on" : "off");
541
542#ifdef VBOX_WITH_VIDEOHWACCEL
543 BOOL accelerate2dVideo;
544 machine->COMGETTER(Accelerate2DVideoEnabled)(&accelerate2dVideo);
545 if (details == VMINFO_MACHINEREADABLE)
546 RTPrintf("accelerate2dvideo=\"%s\"\n", accelerate2dVideo ? "on" : "off");
547 else
548 RTPrintf("2D Video Acceleration: %s\n", accelerate2dVideo ? "on" : "off");
549#endif
550
551 BOOL teleporterEnabled;
552 machine->COMGETTER(TeleporterEnabled)(&teleporterEnabled);
553 if (details == VMINFO_MACHINEREADABLE)
554 RTPrintf("teleporterenabled=\"%s\"\n", teleporterEnabled ? "on" : "off");
555 else
556 RTPrintf("Teleporter Enabled: %s\n", teleporterEnabled ? "on" : "off");
557
558 ULONG teleporterPort;
559 machine->COMGETTER(TeleporterPort)(&teleporterPort);
560 if (details == VMINFO_MACHINEREADABLE)
561 RTPrintf("teleporterport=%u\n", teleporterPort);
562 else
563 RTPrintf("Teleporter Port: %u\n", teleporterPort);
564
565 Bstr teleporterAddress;
566 machine->COMGETTER(TeleporterAddress)(teleporterAddress.asOutParam());
567 if (details == VMINFO_MACHINEREADABLE)
568 RTPrintf("teleporteraddress=\"%lS\"\n", teleporterAddress.raw());
569 else
570 RTPrintf("Teleporter Address: %lS\n", teleporterAddress.raw());
571
572 Bstr teleporterPassword;
573 machine->COMGETTER(TeleporterPassword)(teleporterPassword.asOutParam());
574 if (details == VMINFO_MACHINEREADABLE)
575 RTPrintf("teleporterpassword=\"%lS\"\n", teleporterPassword.raw());
576 else
577 RTPrintf("Teleporter Password: %lS\n", teleporterPassword.raw());
578
579 /*
580 * Storage Controllers and their attached Mediums.
581 */
582 com::SafeIfaceArray<IStorageController> storageCtls;
583 CHECK_ERROR(machine, COMGETTER(StorageControllers)(ComSafeArrayAsOutParam (storageCtls)));
584 for (size_t i = 0; i < storageCtls.size(); ++ i)
585 {
586 ComPtr<IStorageController> storageCtl = storageCtls[i];
587 StorageControllerType_T enmCtlType = StorageControllerType_Null;
588 const char *pszCtl = NULL;
589 ULONG ulValue = 0;
590 Bstr storageCtlName;
591
592 storageCtl->COMGETTER(Name)(storageCtlName.asOutParam());
593 if (details == VMINFO_MACHINEREADABLE)
594 RTPrintf("storagecontrollername%u=\"%lS\"\n", i, storageCtlName.raw());
595 else
596 RTPrintf("Storage Controller Name (%u): %lS\n", i, storageCtlName.raw());
597
598 storageCtl->COMGETTER(ControllerType)(&enmCtlType);
599 switch (enmCtlType)
600 {
601 case StorageControllerType_LsiLogic:
602 pszCtl = "LsiLogic";
603 break;
604 case StorageControllerType_BusLogic:
605 pszCtl = "BusLogic";
606 break;
607 case StorageControllerType_IntelAhci:
608 pszCtl = "IntelAhci";
609 break;
610 case StorageControllerType_PIIX3:
611 pszCtl = "PIIX3";
612 break;
613 case StorageControllerType_PIIX4:
614 pszCtl = "PIIX4";
615 break;
616 case StorageControllerType_ICH6:
617 pszCtl = "ICH6";
618 break;
619 case StorageControllerType_I82078:
620 pszCtl = "I82078";
621 break;
622
623 default:
624 pszCtl = "unknown";
625 }
626 if (details == VMINFO_MACHINEREADABLE)
627 RTPrintf("storagecontrollertype%u=\"%s\"\n", i, pszCtl);
628 else
629 RTPrintf("Storage Controller Type (%u): %s\n", i, pszCtl);
630
631 storageCtl->COMGETTER(Instance)(&ulValue);
632 if (details == VMINFO_MACHINEREADABLE)
633 RTPrintf("storagecontrollerinstance%u=\"%lu\"\n", i, ulValue);
634 else
635 RTPrintf("Storage Controller Instance Number (%u): %lu\n", i, ulValue);
636
637 storageCtl->COMGETTER(MaxPortCount)(&ulValue);
638 if (details == VMINFO_MACHINEREADABLE)
639 RTPrintf("storagecontrollermaxportcount%u=\"%lu\"\n", i, ulValue);
640 else
641 RTPrintf("Storage Controller Max Port Count (%u): %lu\n", i, ulValue);
642
643 storageCtl->COMGETTER(PortCount)(&ulValue);
644 if (details == VMINFO_MACHINEREADABLE)
645 RTPrintf("storagecontrollerportcount%u=\"%lu\"\n", i, ulValue);
646 else
647 RTPrintf("Storage Controller Port Count (%u): %lu\n", i, ulValue);
648 }
649
650 for (size_t j = 0; j < storageCtls.size(); ++ j)
651 {
652 ComPtr<IStorageController> storageCtl = storageCtls[j];
653 ComPtr<IMedium> medium;
654 Bstr storageCtlName;
655 Bstr filePath;
656 ULONG cDevices;
657 ULONG cPorts;
658
659 storageCtl->COMGETTER(Name)(storageCtlName.asOutParam());
660 storageCtl->COMGETTER(MaxDevicesPerPortCount)(&cDevices);
661 storageCtl->COMGETTER(PortCount)(&cPorts);
662
663 for (ULONG i = 0; i < cPorts; ++ i)
664 {
665 for (ULONG k = 0; k < cDevices; ++ k)
666 {
667 rc = machine->GetMedium(storageCtlName, i, k, medium.asOutParam());
668 if (SUCCEEDED(rc) && medium)
669 {
670 BOOL fPassthrough;
671 ComPtr<IMediumAttachment> mediumAttach;
672
673 rc = machine->GetMediumAttachment(storageCtlName, i, k, mediumAttach.asOutParam());
674 if (SUCCEEDED(rc) && mediumAttach)
675 mediumAttach->COMGETTER(Passthrough)(&fPassthrough);
676
677 medium->COMGETTER(Location)(filePath.asOutParam());
678 medium->COMGETTER(Id)(uuid.asOutParam());
679
680 if (details == VMINFO_MACHINEREADABLE)
681 {
682 RTPrintf("\"%lS-%d-%d\"=\"%lS\"\n", storageCtlName.raw(),
683 i, k, filePath.raw());
684 RTPrintf("\"%lS-ImageUUID-%d-%d\"=\"%s\"\n",
685 storageCtlName.raw(), i, k, Utf8Str(uuid).raw());
686 if (fPassthrough)
687 RTPrintf("\"%lS-dvdpassthrough\"=\"%s\"\n", storageCtlName.raw(),
688 fPassthrough ? "on" : "off");
689 }
690 else
691 {
692 RTPrintf("%lS (%d, %d): %lS (UUID: %s)",
693 storageCtlName.raw(), i, k, filePath.raw(),
694 Utf8Str(uuid).raw());
695 if (fPassthrough)
696 RTPrintf(" (passthrough enabled)");
697 RTPrintf("\n");
698 }
699 }
700 else if (SUCCEEDED(rc))
701 {
702 if (details == VMINFO_MACHINEREADABLE)
703 RTPrintf("\"%lS-%d-%d\"=\"emptydrive\"\n", storageCtlName.raw(), i, k);
704 else
705 RTPrintf("%lS (%d, %d): Empty\n", storageCtlName.raw(), i, k);
706 }
707 else
708 {
709 if (details == VMINFO_MACHINEREADABLE)
710 RTPrintf("\"%lS-%d-%d\"=\"none\"\n", storageCtlName.raw(), i, k);
711 }
712 }
713 }
714 }
715
716 /* get the maximum amount of NICS */
717 ComPtr<ISystemProperties> sysProps;
718 virtualBox->COMGETTER(SystemProperties)(sysProps.asOutParam());
719 ULONG maxNICs = 0;
720 sysProps->COMGETTER(NetworkAdapterCount)(&maxNICs);
721 for (ULONG currentNIC = 0; currentNIC < maxNICs; currentNIC++)
722 {
723 ComPtr<INetworkAdapter> nic;
724 rc = machine->GetNetworkAdapter(currentNIC, nic.asOutParam());
725 if (SUCCEEDED(rc) && nic)
726 {
727 BOOL fEnabled;
728 nic->COMGETTER(Enabled)(&fEnabled);
729 if (!fEnabled)
730 {
731 if (details == VMINFO_MACHINEREADABLE)
732 RTPrintf("nic%d=\"none\"\n", currentNIC + 1);
733 else
734 RTPrintf("NIC %d: disabled\n", currentNIC + 1);
735 }
736 else
737 {
738 Bstr strMACAddress;
739 nic->COMGETTER(MACAddress)(strMACAddress.asOutParam());
740 Utf8Str strAttachment;
741 NetworkAttachmentType_T attachment;
742 nic->COMGETTER(AttachmentType)(&attachment);
743 switch (attachment)
744 {
745 case NetworkAttachmentType_Null:
746 if (details == VMINFO_MACHINEREADABLE)
747 strAttachment = "null";
748 else
749 strAttachment = "none";
750 break;
751 case NetworkAttachmentType_NAT:
752 {
753 Bstr strNetwork;
754 nic->COMGETTER(NATNetwork)(strNetwork.asOutParam());
755 if (details == VMINFO_MACHINEREADABLE)
756 {
757 RTPrintf("natnet%d=\"%lS\"\n", currentNIC + 1, strNetwork.raw());
758 strAttachment = "nat";
759 }
760 else if (!strNetwork.isEmpty())
761 strAttachment = Utf8StrFmt("NAT (%lS)", strNetwork.raw());
762 else
763 strAttachment = "NAT";
764 break;
765 }
766 case NetworkAttachmentType_Bridged:
767 {
768 Bstr strBridgeAdp;
769 nic->COMGETTER(HostInterface)(strBridgeAdp.asOutParam());
770 if (details == VMINFO_MACHINEREADABLE)
771 {
772 RTPrintf("bridgeadapter%d=\"%lS\"\n", currentNIC + 1, strBridgeAdp.raw());
773 strAttachment = "bridged";
774 }
775 else
776 strAttachment = Utf8StrFmt("Bridged Interface '%lS'", strBridgeAdp.raw());
777 break;
778 }
779 case NetworkAttachmentType_Internal:
780 {
781 Bstr strNetwork;
782 nic->COMGETTER(InternalNetwork)(strNetwork.asOutParam());
783 if (details == VMINFO_MACHINEREADABLE)
784 {
785 RTPrintf("intnet%d=\"%lS\"\n", currentNIC + 1, strNetwork.raw());
786 strAttachment = "intnet";
787 }
788 else
789 strAttachment = Utf8StrFmt("Internal Network '%s'", Utf8Str(strNetwork).raw());
790 break;
791 }
792#if defined(VBOX_WITH_NETFLT)
793 case NetworkAttachmentType_HostOnly:
794 {
795 Bstr strHostonlyAdp;
796 nic->COMGETTER(HostInterface)(strHostonlyAdp.asOutParam());
797 if (details == VMINFO_MACHINEREADABLE)
798 {
799 RTPrintf("hostonlyadapter%d=\"%lS\"\n", currentNIC + 1, strHostonlyAdp.raw());
800 strAttachment = "hostonly";
801 }
802 else
803 strAttachment = Utf8StrFmt("Host-only Interface '%lS'", strHostonlyAdp.raw());
804 break;
805 }
806#endif
807 default:
808 strAttachment = "unknown";
809 break;
810 }
811
812 /* cable connected */
813 BOOL fConnected;
814 nic->COMGETTER(CableConnected)(&fConnected);
815
816 /* trace stuff */
817 BOOL fTraceEnabled;
818 nic->COMGETTER(TraceEnabled)(&fTraceEnabled);
819 Bstr traceFile;
820 nic->COMGETTER(TraceFile)(traceFile.asOutParam());
821
822 /* NIC type */
823 Utf8Str strNICType;
824 NetworkAdapterType_T NICType;
825 nic->COMGETTER(AdapterType)(&NICType);
826 switch (NICType) {
827 case NetworkAdapterType_Am79C970A:
828 strNICType = "Am79C970A";
829 break;
830 case NetworkAdapterType_Am79C973:
831 strNICType = "Am79C973";
832 break;
833#ifdef VBOX_WITH_E1000
834 case NetworkAdapterType_I82540EM:
835 strNICType = "82540EM";
836 break;
837 case NetworkAdapterType_I82543GC:
838 strNICType = "82543GC";
839 break;
840 case NetworkAdapterType_I82545EM:
841 strNICType = "82545EM";
842 break;
843#endif
844#ifdef VBOX_WITH_VIRTIO
845 case NetworkAdapterType_Virtio:
846 strNICType = "virtio";
847 break;
848#endif /* VBOX_WITH_VIRTIO */
849 default:
850 strNICType = "unknown";
851 break;
852 }
853
854 /* reported line speed */
855 ULONG ulLineSpeed;
856 nic->COMGETTER(LineSpeed)(&ulLineSpeed);
857
858 /* boot priority of the adapter */
859 ULONG ulBootPriority;
860 nic->COMGETTER(BootPriority)(&ulBootPriority);
861
862 if (details == VMINFO_MACHINEREADABLE)
863 {
864 RTPrintf("macaddress%d=\"%lS\"\n", currentNIC + 1, strMACAddress.raw());
865 RTPrintf("cableconnected%d=\"%s\"\n", currentNIC + 1, fConnected ? "on" : "off");
866 RTPrintf("nic%d=\"%s\"\n", currentNIC + 1, strAttachment.raw());
867 }
868 else
869 RTPrintf("NIC %d: MAC: %lS, Attachment: %s, Cable connected: %s, Trace: %s (file: %lS), Type: %s, Reported speed: %d Mbps, Boot priority: %d\n",
870 currentNIC + 1, strMACAddress.raw(), strAttachment.raw(),
871 fConnected ? "on" : "off",
872 fTraceEnabled ? "on" : "off",
873 traceFile.isEmpty() ? Bstr("none").raw() : traceFile.raw(),
874 strNICType.raw(),
875 ulLineSpeed / 1000,
876 (int)ulBootPriority);
877 }
878 }
879 }
880
881 /* Pointing device information */
882 PointingHidType_T aPointingHid;
883 const char *pszHid = "Unknown";
884 const char *pszMrHid = "unknown";
885 machine->COMGETTER(PointingHidType)(&aPointingHid);
886 switch (aPointingHid)
887 {
888 case PointingHidType_None:
889 pszHid = "None";
890 pszMrHid = "none";
891 break;
892 case PointingHidType_PS2Mouse:
893 pszHid = "PS/2 Mouse";
894 pszMrHid = "ps2mouse";
895 break;
896 case PointingHidType_USBMouse:
897 pszHid = "USB Mouse";
898 pszMrHid = "usbmouse";
899 break;
900 case PointingHidType_USBTablet:
901 pszHid = "USB Tablet";
902 pszMrHid = "usbtablet";
903 break;
904 case PointingHidType_ComboMouse:
905 pszHid = "USB Tablet and PS/2 Mouse";
906 pszMrHid = "combomouse";
907 break;
908 default:
909 break;
910 }
911 if (details == VMINFO_MACHINEREADABLE)
912 RTPrintf("hidpointing=\"%s\"\n", pszMrHid);
913 else
914 RTPrintf("Pointing Device: %s\n", pszHid);
915
916 /* Keyboard device information */
917 KeyboardHidType_T aKeyboardHid;
918 machine->COMGETTER(KeyboardHidType)(&aKeyboardHid);
919 pszHid = "Unknown";
920 pszMrHid = "unknown";
921 switch (aKeyboardHid)
922 {
923 case KeyboardHidType_None:
924 pszHid = "None";
925 pszMrHid = "none";
926 break;
927 case KeyboardHidType_PS2Keyboard:
928 pszHid = "PS/2 Keyboard";
929 pszMrHid = "ps2kbd";
930 break;
931 case KeyboardHidType_USBKeyboard:
932 pszHid = "USB Keyboard";
933 pszMrHid = "usbkbd";
934 break;
935 case KeyboardHidType_ComboKeyboard:
936 pszHid = "USB and PS/2 Keyboard";
937 pszMrHid = "combokbd";
938 break;
939 default:
940 break;
941 }
942 if (details == VMINFO_MACHINEREADABLE)
943 RTPrintf("hidkeyboard=\"%s\"\n", pszMrHid);
944 else
945 RTPrintf("Keyboard Device: %s\n", pszHid);
946
947 /* get the maximum amount of UARTs */
948 ULONG maxUARTs = 0;
949 sysProps->COMGETTER(SerialPortCount)(&maxUARTs);
950 for (ULONG currentUART = 0; currentUART < maxUARTs; currentUART++)
951 {
952 ComPtr<ISerialPort> uart;
953 rc = machine->GetSerialPort(currentUART, uart.asOutParam());
954 if (SUCCEEDED(rc) && uart)
955 {
956 BOOL fEnabled;
957 uart->COMGETTER(Enabled)(&fEnabled);
958 if (!fEnabled)
959 {
960 if (details == VMINFO_MACHINEREADABLE)
961 RTPrintf("uart%d=\"off\"\n", currentUART + 1);
962 else
963 RTPrintf("UART %d: disabled\n", currentUART + 1);
964 }
965 else
966 {
967 ULONG ulIRQ, ulIOBase;
968 PortMode_T HostMode;
969 Bstr path;
970 BOOL fServer;
971 uart->COMGETTER(IRQ)(&ulIRQ);
972 uart->COMGETTER(IOBase)(&ulIOBase);
973 uart->COMGETTER(Path)(path.asOutParam());
974 uart->COMGETTER(Server)(&fServer);
975 uart->COMGETTER(HostMode)(&HostMode);
976
977 if (details == VMINFO_MACHINEREADABLE)
978 RTPrintf("uart%d=\"%#06x,%d\"\n", currentUART + 1,
979 ulIOBase, ulIRQ);
980 else
981 RTPrintf("UART %d: I/O base: 0x%04x, IRQ: %d",
982 currentUART + 1, ulIOBase, ulIRQ);
983 switch (HostMode)
984 {
985 default:
986 case PortMode_Disconnected:
987 if (details == VMINFO_MACHINEREADABLE)
988 RTPrintf("uartmode%d=\"disconnected\"\n", currentUART + 1);
989 else
990 RTPrintf(", disconnected\n");
991 break;
992 case PortMode_RawFile:
993 if (details == VMINFO_MACHINEREADABLE)
994 RTPrintf("uartmode%d=\"%lS\"\n", currentUART + 1,
995 path.raw());
996 else
997 RTPrintf(", attached to raw file '%lS'\n",
998 path.raw());
999 break;
1000 case PortMode_HostPipe:
1001 if (details == VMINFO_MACHINEREADABLE)
1002 RTPrintf("uartmode%d=\"%s,%lS\"\n", currentUART + 1,
1003 fServer ? "server" : "client", path.raw());
1004 else
1005 RTPrintf(", attached to pipe (%s) '%lS'\n",
1006 fServer ? "server" : "client", path.raw());
1007 break;
1008 case PortMode_HostDevice:
1009 if (details == VMINFO_MACHINEREADABLE)
1010 RTPrintf("uartmode%d=\"%lS\"\n", currentUART + 1,
1011 path.raw());
1012 else
1013 RTPrintf(", attached to device '%lS'\n", path.raw());
1014 break;
1015 }
1016 }
1017 }
1018 }
1019
1020 ComPtr<IAudioAdapter> AudioAdapter;
1021 rc = machine->COMGETTER(AudioAdapter)(AudioAdapter.asOutParam());
1022 if (SUCCEEDED(rc))
1023 {
1024 const char *pszDrv = "Unknown";
1025 const char *pszCtrl = "Unknown";
1026 BOOL fEnabled;
1027 rc = AudioAdapter->COMGETTER(Enabled)(&fEnabled);
1028 if (SUCCEEDED(rc) && fEnabled)
1029 {
1030 AudioDriverType_T enmDrvType;
1031 rc = AudioAdapter->COMGETTER(AudioDriver)(&enmDrvType);
1032 switch (enmDrvType)
1033 {
1034 case AudioDriverType_Null:
1035 if (details == VMINFO_MACHINEREADABLE)
1036 pszDrv = "null";
1037 else
1038 pszDrv = "Null";
1039 break;
1040 case AudioDriverType_WinMM:
1041 if (details == VMINFO_MACHINEREADABLE)
1042 pszDrv = "winmm";
1043 else
1044 pszDrv = "WINMM";
1045 break;
1046 case AudioDriverType_DirectSound:
1047 if (details == VMINFO_MACHINEREADABLE)
1048 pszDrv = "dsound";
1049 else
1050 pszDrv = "DSOUND";
1051 break;
1052 case AudioDriverType_OSS:
1053 if (details == VMINFO_MACHINEREADABLE)
1054 pszDrv = "oss";
1055 else
1056 pszDrv = "OSS";
1057 break;
1058 case AudioDriverType_ALSA:
1059 if (details == VMINFO_MACHINEREADABLE)
1060 pszDrv = "alsa";
1061 else
1062 pszDrv = "ALSA";
1063 break;
1064 case AudioDriverType_Pulse:
1065 if (details == VMINFO_MACHINEREADABLE)
1066 pszDrv = "pulse";
1067 else
1068 pszDrv = "PulseAudio";
1069 break;
1070 case AudioDriverType_CoreAudio:
1071 if (details == VMINFO_MACHINEREADABLE)
1072 pszDrv = "coreaudio";
1073 else
1074 pszDrv = "CoreAudio";
1075 break;
1076 case AudioDriverType_SolAudio:
1077 if (details == VMINFO_MACHINEREADABLE)
1078 pszDrv = "solaudio";
1079 else
1080 pszDrv = "SolAudio";
1081 break;
1082 default:
1083 if (details == VMINFO_MACHINEREADABLE)
1084 pszDrv = "unknown";
1085 break;
1086 }
1087 AudioControllerType_T enmCtrlType;
1088 rc = AudioAdapter->COMGETTER(AudioController)(&enmCtrlType);
1089 switch (enmCtrlType)
1090 {
1091 case AudioControllerType_AC97:
1092 if (details == VMINFO_MACHINEREADABLE)
1093 pszCtrl = "ac97";
1094 else
1095 pszCtrl = "AC97";
1096 break;
1097 case AudioControllerType_SB16:
1098 if (details == VMINFO_MACHINEREADABLE)
1099 pszCtrl = "sb16";
1100 else
1101 pszCtrl = "SB16";
1102 break;
1103 }
1104 }
1105 else
1106 fEnabled = FALSE;
1107 if (details == VMINFO_MACHINEREADABLE)
1108 {
1109 if (fEnabled)
1110 RTPrintf("audio=\"%s\"\n", pszDrv);
1111 else
1112 RTPrintf("audio=\"none\"\n");
1113 }
1114 else
1115 {
1116 RTPrintf("Audio: %s",
1117 fEnabled ? "enabled" : "disabled");
1118 if (fEnabled)
1119 RTPrintf(" (Driver: %s, Controller: %s)",
1120 pszDrv, pszCtrl);
1121 RTPrintf("\n");
1122 }
1123 }
1124
1125 /* Shared clipboard */
1126 {
1127 const char *psz = "Unknown";
1128 ClipboardMode_T enmMode;
1129 rc = machine->COMGETTER(ClipboardMode)(&enmMode);
1130 switch (enmMode)
1131 {
1132 case ClipboardMode_Disabled:
1133 if (details == VMINFO_MACHINEREADABLE)
1134 psz = "disabled";
1135 else
1136 psz = "disabled";
1137 break;
1138 case ClipboardMode_HostToGuest:
1139 if (details == VMINFO_MACHINEREADABLE)
1140 psz = "hosttoguest";
1141 else
1142 psz = "HostToGuest";
1143 break;
1144 case ClipboardMode_GuestToHost:
1145 if (details == VMINFO_MACHINEREADABLE)
1146 psz = "guesttohost";
1147 else
1148 psz = "GuestToHost";
1149 break;
1150 case ClipboardMode_Bidirectional:
1151 if (details == VMINFO_MACHINEREADABLE)
1152 psz = "bidirectional";
1153 else
1154 psz = "Bidirectional";
1155 break;
1156 default:
1157 if (details == VMINFO_MACHINEREADABLE)
1158 psz = "unknown";
1159 break;
1160 }
1161 if (details == VMINFO_MACHINEREADABLE)
1162 RTPrintf("clipboard=\"%s\"\n", psz);
1163 else
1164 RTPrintf("Clipboard Mode: %s\n", psz);
1165 }
1166
1167 if (console)
1168 {
1169 ComPtr<IDisplay> display;
1170 CHECK_ERROR_RET(console, COMGETTER(Display)(display.asOutParam()), rc);
1171 do
1172 {
1173 ULONG xRes, yRes, bpp;
1174 rc = display->GetScreenResolution (0, &xRes, &yRes, &bpp);
1175 if (rc == E_ACCESSDENIED)
1176 break; /* VM not powered up */
1177 if (FAILED(rc))
1178 {
1179 com::ErrorInfo info (display);
1180 GluePrintErrorInfo(info);
1181 return rc;
1182 }
1183 if (details == VMINFO_MACHINEREADABLE)
1184 RTPrintf("VideoMode=\"%d,%d,%d\"\n", xRes, yRes, bpp);
1185 else
1186 RTPrintf("Video mode: %dx%dx%d\n", xRes, yRes, bpp);
1187 }
1188 while (0);
1189 }
1190
1191 /*
1192 * VRDP
1193 */
1194 ComPtr<IVRDPServer> vrdpServer;
1195 rc = machine->COMGETTER(VRDPServer)(vrdpServer.asOutParam());
1196 if (SUCCEEDED(rc) && vrdpServer)
1197 {
1198 BOOL fEnabled = false;
1199 vrdpServer->COMGETTER(Enabled)(&fEnabled);
1200 if (fEnabled)
1201 {
1202 LONG vrdpPort = -1;
1203 Bstr ports;
1204 vrdpServer->COMGETTER(Ports)(ports.asOutParam());
1205 Bstr address;
1206 vrdpServer->COMGETTER(NetAddress)(address.asOutParam());
1207 BOOL fMultiCon;
1208 vrdpServer->COMGETTER(AllowMultiConnection)(&fMultiCon);
1209 BOOL fReuseCon;
1210 vrdpServer->COMGETTER(ReuseSingleConnection)(&fReuseCon);
1211 VRDPAuthType_T vrdpAuthType;
1212 const char *strAuthType;
1213 vrdpServer->COMGETTER(AuthType)(&vrdpAuthType);
1214 switch (vrdpAuthType)
1215 {
1216 case VRDPAuthType_Null:
1217 strAuthType = "null";
1218 break;
1219 case VRDPAuthType_External:
1220 strAuthType = "external";
1221 break;
1222 case VRDPAuthType_Guest:
1223 strAuthType = "guest";
1224 break;
1225 default:
1226 strAuthType = "unknown";
1227 break;
1228 }
1229 if (console)
1230 {
1231 ComPtr<IRemoteDisplayInfo> remoteDisplayInfo;
1232 CHECK_ERROR_RET(console, COMGETTER(RemoteDisplayInfo)(remoteDisplayInfo.asOutParam()), rc);
1233 rc = remoteDisplayInfo->COMGETTER(Port)(&vrdpPort);
1234 if (rc == E_ACCESSDENIED)
1235 {
1236 vrdpPort = -1; /* VM not powered up */
1237 }
1238 if (FAILED(rc))
1239 {
1240 com::ErrorInfo info (remoteDisplayInfo);
1241 GluePrintErrorInfo(info);
1242 return rc;
1243 }
1244 }
1245 if (details == VMINFO_MACHINEREADABLE)
1246 {
1247 RTPrintf("vrdp=\"on\"\n");
1248 RTPrintf("vrdpport=%d\n", vrdpPort);
1249 RTPrintf("vrdpports=\"%lS\"\n", ports.raw());
1250 RTPrintf("vrdpaddress=\"%lS\"\n", address.raw());
1251 RTPrintf("vrdpauthtype=\"%s\"\n", strAuthType);
1252 RTPrintf("vrdpmulticon=\"%s\"\n", fMultiCon ? "on" : "off");
1253 RTPrintf("vrdpreusecon=\"%s\"\n", fReuseCon ? "on" : "off");
1254 }
1255 else
1256 {
1257 if (address.isEmpty())
1258 address = "0.0.0.0";
1259 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);
1260 if (console && vrdpPort != -1 && vrdpPort != 0)
1261 RTPrintf("VRDP port: %d\n", vrdpPort);
1262 }
1263 }
1264 else
1265 {
1266 if (details == VMINFO_MACHINEREADABLE)
1267 RTPrintf("vrdp=\"off\"\n");
1268 else
1269 RTPrintf("VRDP: disabled\n");
1270 }
1271 }
1272
1273 /*
1274 * USB.
1275 */
1276 ComPtr<IUSBController> USBCtl;
1277 rc = machine->COMGETTER(USBController)(USBCtl.asOutParam());
1278 if (SUCCEEDED(rc))
1279 {
1280 BOOL fEnabled;
1281 rc = USBCtl->COMGETTER(Enabled)(&fEnabled);
1282 if (FAILED(rc))
1283 fEnabled = false;
1284 if (details == VMINFO_MACHINEREADABLE)
1285 RTPrintf("usb=\"%s\"\n", fEnabled ? "on" : "off");
1286 else
1287 RTPrintf("USB: %s\n", fEnabled ? "enabled" : "disabled");
1288
1289 SafeIfaceArray <IUSBDeviceFilter> Coll;
1290 rc = USBCtl->COMGETTER(DeviceFilters)(ComSafeArrayAsOutParam(Coll));
1291 if (SUCCEEDED(rc))
1292 {
1293 if (details != VMINFO_MACHINEREADABLE)
1294 RTPrintf("\nUSB Device Filters:\n\n");
1295
1296 if (Coll.size() == 0)
1297 {
1298 if (details != VMINFO_MACHINEREADABLE)
1299 RTPrintf("<none>\n\n");
1300 }
1301 else
1302 {
1303 for (size_t index = 0; index < Coll.size(); ++index)
1304 {
1305 ComPtr<IUSBDeviceFilter> DevPtr = Coll[index];
1306
1307 /* Query info. */
1308
1309 if (details != VMINFO_MACHINEREADABLE)
1310 RTPrintf("Index: %zu\n", index);
1311
1312 BOOL bActive = FALSE;
1313 CHECK_ERROR_RET (DevPtr, COMGETTER (Active) (&bActive), rc);
1314 if (details == VMINFO_MACHINEREADABLE)
1315 RTPrintf("USBFilterActive%zu=\"%s\"\n", index + 1, bActive ? "on" : "off");
1316 else
1317 RTPrintf("Active: %s\n", bActive ? "yes" : "no");
1318
1319 Bstr bstr;
1320 CHECK_ERROR_RET (DevPtr, COMGETTER (Name) (bstr.asOutParam()), rc);
1321 if (details == VMINFO_MACHINEREADABLE)
1322 RTPrintf("USBFilterName%zu=\"%lS\"\n", index + 1, bstr.raw());
1323 else
1324 RTPrintf("Name: %lS\n", bstr.raw());
1325 CHECK_ERROR_RET (DevPtr, COMGETTER (VendorId) (bstr.asOutParam()), rc);
1326 if (details == VMINFO_MACHINEREADABLE)
1327 RTPrintf("USBFilterVendorId%zu=\"%lS\"\n", index + 1, bstr.raw());
1328 else
1329 RTPrintf("VendorId: %lS\n", bstr.raw());
1330 CHECK_ERROR_RET (DevPtr, COMGETTER (ProductId) (bstr.asOutParam()), rc);
1331 if (details == VMINFO_MACHINEREADABLE)
1332 RTPrintf("USBFilterProductId%zu=\"%lS\"\n", index + 1, bstr.raw());
1333 else
1334 RTPrintf("ProductId: %lS\n", bstr.raw());
1335 CHECK_ERROR_RET (DevPtr, COMGETTER (Revision) (bstr.asOutParam()), rc);
1336 if (details == VMINFO_MACHINEREADABLE)
1337 RTPrintf("USBFilterRevision%zu=\"%lS\"\n", index + 1, bstr.raw());
1338 else
1339 RTPrintf("Revision: %lS\n", bstr.raw());
1340 CHECK_ERROR_RET (DevPtr, COMGETTER (Manufacturer) (bstr.asOutParam()), rc);
1341 if (details == VMINFO_MACHINEREADABLE)
1342 RTPrintf("USBFilterManufacturer%zu=\"%lS\"\n", index + 1, bstr.raw());
1343 else
1344 RTPrintf("Manufacturer: %lS\n", bstr.raw());
1345 CHECK_ERROR_RET (DevPtr, COMGETTER (Product) (bstr.asOutParam()), rc);
1346 if (details == VMINFO_MACHINEREADABLE)
1347 RTPrintf("USBFilterProduct%zu=\"%lS\"\n", index + 1, bstr.raw());
1348 else
1349 RTPrintf("Product: %lS\n", bstr.raw());
1350 CHECK_ERROR_RET (DevPtr, COMGETTER (Remote) (bstr.asOutParam()), rc);
1351 if (details == VMINFO_MACHINEREADABLE)
1352 RTPrintf("USBFilterRemote%zu=\"%lS\"\n", index + 1, bstr.raw());
1353 else
1354 RTPrintf("Remote: %lS\n", bstr.raw());
1355 CHECK_ERROR_RET (DevPtr, COMGETTER (SerialNumber) (bstr.asOutParam()), rc);
1356 if (details == VMINFO_MACHINEREADABLE)
1357 RTPrintf("USBFilterSerialNumber%zu=\"%lS\"\n", index + 1, bstr.raw());
1358 else
1359 RTPrintf("Serial Number: %lS\n", bstr.raw());
1360 if (details != VMINFO_MACHINEREADABLE)
1361 {
1362 ULONG fMaskedIfs;
1363 CHECK_ERROR_RET (DevPtr, COMGETTER (MaskedInterfaces) (&fMaskedIfs), rc);
1364 if (fMaskedIfs)
1365 RTPrintf("Masked Interfaces: 0x%08x\n", fMaskedIfs);
1366 RTPrintf("\n");
1367 }
1368 }
1369 }
1370 }
1371
1372 if (console)
1373 {
1374 /* scope */
1375 {
1376 if (details != VMINFO_MACHINEREADABLE)
1377 RTPrintf("Available remote USB devices:\n\n");
1378
1379 SafeIfaceArray <IHostUSBDevice> coll;
1380 CHECK_ERROR_RET (console, COMGETTER(RemoteUSBDevices) (ComSafeArrayAsOutParam(coll)), rc);
1381
1382 if (coll.size() == 0)
1383 {
1384 if (details != VMINFO_MACHINEREADABLE)
1385 RTPrintf("<none>\n\n");
1386 }
1387 else
1388 {
1389 for (size_t index = 0; index < coll.size(); ++index)
1390 {
1391 ComPtr <IHostUSBDevice> dev = coll[index];
1392
1393 /* Query info. */
1394 Bstr id;
1395 CHECK_ERROR_RET (dev, COMGETTER(Id)(id.asOutParam()), rc);
1396 USHORT usVendorId;
1397 CHECK_ERROR_RET (dev, COMGETTER(VendorId)(&usVendorId), rc);
1398 USHORT usProductId;
1399 CHECK_ERROR_RET (dev, COMGETTER(ProductId)(&usProductId), rc);
1400 USHORT bcdRevision;
1401 CHECK_ERROR_RET (dev, COMGETTER(Revision)(&bcdRevision), rc);
1402
1403 if (details == VMINFO_MACHINEREADABLE)
1404 RTPrintf("USBRemoteUUID%zu=\"%S\"\n"
1405 "USBRemoteVendorId%zu=\"%#06x\"\n"
1406 "USBRemoteProductId%zu=\"%#06x\"\n"
1407 "USBRemoteRevision%zu=\"%#04x%02x\"\n",
1408 index + 1, Utf8Str(id).raw(),
1409 index + 1, usVendorId,
1410 index + 1, usProductId,
1411 index + 1, bcdRevision >> 8, bcdRevision & 0xff);
1412 else
1413 RTPrintf("UUID: %S\n"
1414 "VendorId: 0x%04x (%04X)\n"
1415 "ProductId: 0x%04x (%04X)\n"
1416 "Revision: %u.%u (%02u%02u)\n",
1417 Utf8Str(id).raw(),
1418 usVendorId, usVendorId, usProductId, usProductId,
1419 bcdRevision >> 8, bcdRevision & 0xff,
1420 bcdRevision >> 8, bcdRevision & 0xff);
1421
1422 /* optional stuff. */
1423 Bstr bstr;
1424 CHECK_ERROR_RET (dev, COMGETTER(Manufacturer)(bstr.asOutParam()), rc);
1425 if (!bstr.isEmpty())
1426 {
1427 if (details == VMINFO_MACHINEREADABLE)
1428 RTPrintf("USBRemoteManufacturer%zu=\"%lS\"\n", index + 1, bstr.raw());
1429 else
1430 RTPrintf("Manufacturer: %lS\n", bstr.raw());
1431 }
1432 CHECK_ERROR_RET (dev, COMGETTER(Product)(bstr.asOutParam()), rc);
1433 if (!bstr.isEmpty())
1434 {
1435 if (details == VMINFO_MACHINEREADABLE)
1436 RTPrintf("USBRemoteProduct%zu=\"%lS\"\n", index + 1, bstr.raw());
1437 else
1438 RTPrintf("Product: %lS\n", bstr.raw());
1439 }
1440 CHECK_ERROR_RET (dev, COMGETTER(SerialNumber)(bstr.asOutParam()), rc);
1441 if (!bstr.isEmpty())
1442 {
1443 if (details == VMINFO_MACHINEREADABLE)
1444 RTPrintf("USBRemoteSerialNumber%zu=\"%lS\"\n", index + 1, bstr.raw());
1445 else
1446 RTPrintf("SerialNumber: %lS\n", bstr.raw());
1447 }
1448 CHECK_ERROR_RET (dev, COMGETTER(Address)(bstr.asOutParam()), rc);
1449 if (!bstr.isEmpty())
1450 {
1451 if (details == VMINFO_MACHINEREADABLE)
1452 RTPrintf("USBRemoteAddress%zu=\"%lS\"\n", index + 1, bstr.raw());
1453 else
1454 RTPrintf("Address: %lS\n", bstr.raw());
1455 }
1456
1457 if (details != VMINFO_MACHINEREADABLE)
1458 RTPrintf("\n");
1459 }
1460 }
1461 }
1462
1463 /* scope */
1464 {
1465 if (details != VMINFO_MACHINEREADABLE)
1466 RTPrintf ("Currently Attached USB Devices:\n\n");
1467
1468 SafeIfaceArray <IUSBDevice> coll;
1469 CHECK_ERROR_RET (console, COMGETTER(USBDevices) (ComSafeArrayAsOutParam(coll)), rc);
1470
1471 if (coll.size() == 0)
1472 {
1473 if (details != VMINFO_MACHINEREADABLE)
1474 RTPrintf("<none>\n\n");
1475 }
1476 else
1477 {
1478 for (size_t index = 0; index < coll.size(); ++index)
1479 {
1480 ComPtr <IUSBDevice> dev = coll[index];
1481
1482 /* Query info. */
1483 Bstr id;
1484 CHECK_ERROR_RET (dev, COMGETTER(Id)(id.asOutParam()), rc);
1485 USHORT usVendorId;
1486 CHECK_ERROR_RET (dev, COMGETTER(VendorId)(&usVendorId), rc);
1487 USHORT usProductId;
1488 CHECK_ERROR_RET (dev, COMGETTER(ProductId)(&usProductId), rc);
1489 USHORT bcdRevision;
1490 CHECK_ERROR_RET (dev, COMGETTER(Revision)(&bcdRevision), rc);
1491
1492 if (details == VMINFO_MACHINEREADABLE)
1493 RTPrintf("USBAttachedUUID%zu=\"%S\"\n"
1494 "USBAttachedVendorId%zu=\"%#06x\"\n"
1495 "USBAttachedProductId%zu=\"%#06x\"\n"
1496 "USBAttachedRevision%zu=\"%#04x%02x\"\n",
1497 index + 1, Utf8Str(id).raw(),
1498 index + 1, usVendorId,
1499 index + 1, usProductId,
1500 index + 1, bcdRevision >> 8, bcdRevision & 0xff);
1501 else
1502 RTPrintf("UUID: %S\n"
1503 "VendorId: 0x%04x (%04X)\n"
1504 "ProductId: 0x%04x (%04X)\n"
1505 "Revision: %u.%u (%02u%02u)\n",
1506 Utf8Str(id).raw(),
1507 usVendorId, usVendorId, usProductId, usProductId,
1508 bcdRevision >> 8, bcdRevision & 0xff,
1509 bcdRevision >> 8, bcdRevision & 0xff);
1510
1511 /* optional stuff. */
1512 Bstr bstr;
1513 CHECK_ERROR_RET (dev, COMGETTER(Manufacturer)(bstr.asOutParam()), rc);
1514 if (!bstr.isEmpty())
1515 {
1516 if (details == VMINFO_MACHINEREADABLE)
1517 RTPrintf("USBAttachedManufacturer%zu=\"%lS\"\n", index + 1, bstr.raw());
1518 else
1519 RTPrintf("Manufacturer: %lS\n", bstr.raw());
1520 }
1521 CHECK_ERROR_RET (dev, COMGETTER(Product)(bstr.asOutParam()), rc);
1522 if (!bstr.isEmpty())
1523 {
1524 if (details == VMINFO_MACHINEREADABLE)
1525 RTPrintf("USBAttachedProduct%zu=\"%lS\"\n", index + 1, bstr.raw());
1526 else
1527 RTPrintf("Product: %lS\n", bstr.raw());
1528 }
1529 CHECK_ERROR_RET (dev, COMGETTER(SerialNumber)(bstr.asOutParam()), rc);
1530 if (!bstr.isEmpty())
1531 {
1532 if (details == VMINFO_MACHINEREADABLE)
1533 RTPrintf("USBAttachedSerialNumber%zu=\"%lS\"\n", index + 1, bstr.raw());
1534 else
1535 RTPrintf("SerialNumber: %lS\n", bstr.raw());
1536 }
1537 CHECK_ERROR_RET (dev, COMGETTER(Address)(bstr.asOutParam()), rc);
1538 if (!bstr.isEmpty())
1539 {
1540 if (details == VMINFO_MACHINEREADABLE)
1541 RTPrintf("USBAttachedAddress%zu=\"%lS\"\n", index + 1, bstr.raw());
1542 else
1543 RTPrintf("Address: %lS\n", bstr.raw());
1544 }
1545
1546 if (details != VMINFO_MACHINEREADABLE)
1547 RTPrintf("\n");
1548 }
1549 }
1550 }
1551 }
1552 } /* USB */
1553
1554 /*
1555 * Shared folders
1556 */
1557 if (details != VMINFO_MACHINEREADABLE)
1558 RTPrintf("Shared folders: ");
1559 uint32_t numSharedFolders = 0;
1560#if 0 // not yet implemented
1561 /* globally shared folders first */
1562 {
1563 SafeIfaceArray <ISharedFolder> sfColl;
1564 CHECK_ERROR_RET(virtualBox, COMGETTER(SharedFolders)(ComSafeArrayAsOutParam(sfColl)), rc);
1565 for (size_t i = 0; i < sfColl.size(); ++i)
1566 {
1567 ComPtr<ISharedFolder> sf = sfColl[i];
1568 Bstr name, hostPath;
1569 sf->COMGETTER(Name)(name.asOutParam());
1570 sf->COMGETTER(HostPath)(hostPath.asOutParam());
1571 RTPrintf("Name: '%lS', Host path: '%lS' (global mapping)\n", name.raw(), hostPath.raw());
1572 ++numSharedFolders;
1573 }
1574 }
1575#endif
1576 /* now VM mappings */
1577 {
1578 com::SafeIfaceArray <ISharedFolder> folders;
1579
1580 CHECK_ERROR_RET(machine, COMGETTER(SharedFolders)(ComSafeArrayAsOutParam(folders)), rc);
1581
1582 for (size_t i = 0; i < folders.size(); ++i)
1583 {
1584 ComPtr <ISharedFolder> sf = folders[i];
1585
1586 Bstr name, hostPath;
1587 BOOL writable;
1588 sf->COMGETTER(Name)(name.asOutParam());
1589 sf->COMGETTER(HostPath)(hostPath.asOutParam());
1590 sf->COMGETTER(Writable)(&writable);
1591 if (!numSharedFolders && details != VMINFO_MACHINEREADABLE)
1592 RTPrintf("\n\n");
1593 if (details == VMINFO_MACHINEREADABLE)
1594 {
1595 RTPrintf("SharedFolderNameMachineMapping%zu=\"%lS\"\n", i + 1,
1596 name.raw());
1597 RTPrintf("SharedFolderPathMachineMapping%zu=\"%lS\"\n", i + 1,
1598 hostPath.raw());
1599 }
1600 else
1601 RTPrintf("Name: '%lS', Host path: '%lS' (machine mapping), %s\n",
1602 name.raw(), hostPath.raw(), writable ? "writable" : "readonly");
1603 ++numSharedFolders;
1604 }
1605 }
1606 /* transient mappings */
1607 if (console)
1608 {
1609 com::SafeIfaceArray <ISharedFolder> folders;
1610
1611 CHECK_ERROR_RET(console, COMGETTER(SharedFolders)(ComSafeArrayAsOutParam(folders)), rc);
1612
1613 for (size_t i = 0; i < folders.size(); ++i)
1614 {
1615 ComPtr <ISharedFolder> sf = folders[i];
1616
1617 Bstr name, hostPath;
1618 sf->COMGETTER(Name)(name.asOutParam());
1619 sf->COMGETTER(HostPath)(hostPath.asOutParam());
1620 if (!numSharedFolders && details != VMINFO_MACHINEREADABLE)
1621 RTPrintf("\n\n");
1622 if (details == VMINFO_MACHINEREADABLE)
1623 {
1624 RTPrintf("SharedFolderNameTransientMapping%zu=\"%lS\"\n", i + 1,
1625 name.raw());
1626 RTPrintf("SharedFolderPathTransientMapping%zu=\"%lS\"\n", i + 1,
1627 hostPath.raw());
1628 }
1629 else
1630 RTPrintf("Name: '%lS', Host path: '%lS' (transient mapping)\n", name.raw(), hostPath.raw());
1631 ++numSharedFolders;
1632 }
1633 }
1634 if (!numSharedFolders && details != VMINFO_MACHINEREADABLE)
1635 RTPrintf("<none>\n");
1636 if (details != VMINFO_MACHINEREADABLE)
1637 RTPrintf("\n");
1638
1639 if (console)
1640 {
1641 /*
1642 * Live VRDP info.
1643 */
1644 ComPtr<IRemoteDisplayInfo> remoteDisplayInfo;
1645 CHECK_ERROR_RET(console, COMGETTER(RemoteDisplayInfo)(remoteDisplayInfo.asOutParam()), rc);
1646 BOOL Active;
1647 ULONG NumberOfClients;
1648 LONG64 BeginTime;
1649 LONG64 EndTime;
1650 ULONG64 BytesSent;
1651 ULONG64 BytesSentTotal;
1652 ULONG64 BytesReceived;
1653 ULONG64 BytesReceivedTotal;
1654 Bstr User;
1655 Bstr Domain;
1656 Bstr ClientName;
1657 Bstr ClientIP;
1658 ULONG ClientVersion;
1659 ULONG EncryptionStyle;
1660
1661 CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(Active) (&Active), rc);
1662 CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(NumberOfClients) (&NumberOfClients), rc);
1663 CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(BeginTime) (&BeginTime), rc);
1664 CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(EndTime) (&EndTime), rc);
1665 CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(BytesSent) (&BytesSent), rc);
1666 CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(BytesSentTotal) (&BytesSentTotal), rc);
1667 CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(BytesReceived) (&BytesReceived), rc);
1668 CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(BytesReceivedTotal) (&BytesReceivedTotal), rc);
1669 CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(User) (User.asOutParam ()), rc);
1670 CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(Domain) (Domain.asOutParam ()), rc);
1671 CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(ClientName) (ClientName.asOutParam ()), rc);
1672 CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(ClientIP) (ClientIP.asOutParam ()), rc);
1673 CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(ClientVersion) (&ClientVersion), rc);
1674 CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(EncryptionStyle) (&EncryptionStyle), rc);
1675
1676 if (details == VMINFO_MACHINEREADABLE)
1677 RTPrintf("VRDPActiveConnection=\"%s\"\n", Active ? "on": "off");
1678 else
1679 RTPrintf("VRDP Connection: %s\n", Active? "active": "not active");
1680
1681 if (details == VMINFO_MACHINEREADABLE)
1682 RTPrintf("VRDPClients=%d\n", NumberOfClients);
1683 else
1684 RTPrintf("Clients so far: %d\n", NumberOfClients);
1685
1686 if (NumberOfClients > 0)
1687 {
1688 char timestr[128];
1689
1690 if (Active)
1691 {
1692 makeTimeStr (timestr, sizeof (timestr), BeginTime);
1693 if (details == VMINFO_MACHINEREADABLE)
1694 RTPrintf("VRDPStartTime=\"%s\"\n", timestr);
1695 else
1696 RTPrintf("Start time: %s\n", timestr);
1697 }
1698 else
1699 {
1700 makeTimeStr (timestr, sizeof (timestr), BeginTime);
1701 if (details == VMINFO_MACHINEREADABLE)
1702 RTPrintf("VRDPLastStartTime=\"%s\"\n", timestr);
1703 else
1704 RTPrintf("Last started: %s\n", timestr);
1705 makeTimeStr (timestr, sizeof (timestr), EndTime);
1706 if (details == VMINFO_MACHINEREADABLE)
1707 RTPrintf("VRDPLastEndTime=\"%s\"\n", timestr);
1708 else
1709 RTPrintf("Last ended: %s\n", timestr);
1710 }
1711
1712 uint64_t ThroughputSend = 0;
1713 uint64_t ThroughputReceive = 0;
1714 if (EndTime != BeginTime)
1715 {
1716 ThroughputSend = (BytesSent * 1000) / (EndTime - BeginTime);
1717 ThroughputReceive = (BytesReceived * 1000) / (EndTime - BeginTime);
1718 }
1719
1720 if (details == VMINFO_MACHINEREADABLE)
1721 {
1722 RTPrintf("VRDPBytesSent=%llu\n", BytesSent);
1723 RTPrintf("VRDPThroughputSend=%llu\n", ThroughputSend);
1724 RTPrintf("VRDPBytesSentTotal=%llu\n", BytesSentTotal);
1725
1726 RTPrintf("VRDPBytesReceived=%llu\n", BytesReceived);
1727 RTPrintf("VRDPThroughputReceive=%llu\n", ThroughputReceive);
1728 RTPrintf("VRDPBytesReceivedTotal=%llu\n", BytesReceivedTotal);
1729 }
1730 else
1731 {
1732 RTPrintf("Sent: %llu Bytes\n", BytesSent);
1733 RTPrintf("Average speed: %llu B/s\n", ThroughputSend);
1734 RTPrintf("Sent total: %llu Bytes\n", BytesSentTotal);
1735
1736 RTPrintf("Received: %llu Bytes\n", BytesReceived);
1737 RTPrintf("Speed: %llu B/s\n", ThroughputReceive);
1738 RTPrintf("Received total: %llu Bytes\n", BytesReceivedTotal);
1739 }
1740
1741 if (Active)
1742 {
1743 if (details == VMINFO_MACHINEREADABLE)
1744 {
1745 RTPrintf("VRDPUserName=\"%lS\"\n", User.raw());
1746 RTPrintf("VRDPDomain=\"%lS\"\n", Domain.raw());
1747 RTPrintf("VRDPClientName=\"%lS\"\n", ClientName.raw());
1748 RTPrintf("VRDPClientIP=\"%lS\"\n", ClientIP.raw());
1749 RTPrintf("VRDPClientVersion=%d\n", ClientVersion);
1750 RTPrintf("VRDPEncryption=\"%s\"\n", EncryptionStyle == 0? "RDP4": "RDP5 (X.509)");
1751 }
1752 else
1753 {
1754 RTPrintf("User name: %lS\n", User.raw());
1755 RTPrintf("Domain: %lS\n", Domain.raw());
1756 RTPrintf("Client name: %lS\n", ClientName.raw());
1757 RTPrintf("Client IP: %lS\n", ClientIP.raw());
1758 RTPrintf("Client version: %d\n", ClientVersion);
1759 RTPrintf("Encryption: %s\n", EncryptionStyle == 0? "RDP4": "RDP5 (X.509)");
1760 }
1761 }
1762 }
1763
1764 if (details != VMINFO_MACHINEREADABLE)
1765 RTPrintf("\n");
1766 }
1767
1768 if ( details == VMINFO_STANDARD
1769 || details == VMINFO_FULL
1770 || details == VMINFO_MACHINEREADABLE)
1771 {
1772 Bstr description;
1773 machine->COMGETTER(Description)(description.asOutParam());
1774 if (!description.isEmpty())
1775 {
1776 if (details == VMINFO_MACHINEREADABLE)
1777 RTPrintf("description=\"%lS\"\n", description.raw());
1778 else
1779 RTPrintf("Description:\n%lS\n", description.raw());
1780 }
1781 }
1782
1783 ULONG guestVal;
1784 if (details != VMINFO_MACHINEREADABLE)
1785 RTPrintf("Guest:\n\n");
1786
1787 rc = machine->COMGETTER(MemoryBalloonSize)(&guestVal);
1788 if (SUCCEEDED(rc))
1789 {
1790 if (details == VMINFO_MACHINEREADABLE)
1791 RTPrintf("GuestMemoryBalloon=%d\n", guestVal);
1792 else
1793 RTPrintf("Configured memory balloon size: %d MB\n", guestVal);
1794 }
1795 if (details != VMINFO_MACHINEREADABLE)
1796 RTPrintf("\n");
1797
1798 /*
1799 * snapshots
1800 */
1801 ComPtr<ISnapshot> snapshot;
1802 rc = machine->GetSnapshot(Bstr(), snapshot.asOutParam());
1803 if (SUCCEEDED(rc) && snapshot)
1804 {
1805 ComPtr<ISnapshot> currentSnapshot;
1806 rc = machine->COMGETTER(CurrentSnapshot)(currentSnapshot.asOutParam());
1807 if (SUCCEEDED(rc))
1808 {
1809 if (details != VMINFO_MACHINEREADABLE)
1810 RTPrintf("Snapshots:\n\n");
1811 showSnapshots(snapshot, currentSnapshot, details);
1812 }
1813 }
1814
1815 if (details != VMINFO_MACHINEREADABLE)
1816 RTPrintf("\n");
1817 return S_OK;
1818}
1819
1820#if defined(_MSC_VER)
1821# pragma optimize("", on)
1822#endif
1823
1824static const RTGETOPTDEF g_aShowVMInfoOptions[] =
1825{
1826 { "--details", 'D', RTGETOPT_REQ_NOTHING },
1827 { "-details", 'D', RTGETOPT_REQ_NOTHING }, // deprecated
1828 { "--machinereadable", 'M', RTGETOPT_REQ_NOTHING },
1829 { "-machinereadable", 'M', RTGETOPT_REQ_NOTHING }, // deprecated
1830 { "--log", 'l', RTGETOPT_REQ_UINT32 },
1831};
1832
1833int handleShowVMInfo(HandlerArg *a)
1834{
1835 HRESULT rc;
1836 const char *VMNameOrUuid = NULL;
1837 bool fLog = false;
1838 uint32_t uLogIdx;
1839 bool fDetails = false;
1840 bool fMachinereadable = false;
1841
1842 int c;
1843 RTGETOPTUNION ValueUnion;
1844 RTGETOPTSTATE GetState;
1845 // start at 0 because main() has hacked both the argc and argv given to us
1846 RTGetOptInit(&GetState, a->argc, a->argv, g_aShowVMInfoOptions, RT_ELEMENTS(g_aShowVMInfoOptions),
1847 0, RTGETOPTINIT_FLAGS_NO_STD_OPTS);
1848 while ((c = RTGetOpt(&GetState, &ValueUnion)))
1849 {
1850 switch (c)
1851 {
1852 case 'D': // --details
1853 fDetails = true;
1854 break;
1855
1856 case 'M': // --machinereadable
1857 fMachinereadable = true;
1858 break;
1859
1860 case 'l': // --log
1861 fLog = true;
1862 uLogIdx = ValueUnion.u32;
1863 break;
1864
1865 case VINF_GETOPT_NOT_OPTION:
1866 if (!VMNameOrUuid)
1867 VMNameOrUuid = ValueUnion.psz;
1868 else
1869 return errorSyntax(USAGE_SHOWVMINFO, "Invalid parameter '%s'", ValueUnion.psz);
1870 break;
1871
1872 default:
1873 if (c > 0)
1874 {
1875 if (RT_C_IS_PRINT(c))
1876 return errorSyntax(USAGE_SHOWVMINFO, "Invalid option -%c", c);
1877 else
1878 return errorSyntax(USAGE_SHOWVMINFO, "Invalid option case %i", c);
1879 }
1880 else if (c == VERR_GETOPT_UNKNOWN_OPTION)
1881 return errorSyntax(USAGE_SHOWVMINFO, "unknown option: %s\n", ValueUnion.psz);
1882 else if (ValueUnion.pDef)
1883 return errorSyntax(USAGE_SHOWVMINFO, "%s: %Rrs", ValueUnion.pDef->pszLong, c);
1884 else
1885 return errorSyntax(USAGE_SHOWVMINFO, "error: %Rrs", c);
1886 }
1887 }
1888
1889 /* check for required options */
1890 if (!VMNameOrUuid)
1891 return errorSyntax(USAGE_SHOWVMINFO, "VM name or UUID required");
1892
1893 /* try to find the given machine */
1894 ComPtr <IMachine> machine;
1895 Bstr uuid(VMNameOrUuid);
1896 if (!Guid(VMNameOrUuid).isEmpty())
1897 {
1898 CHECK_ERROR(a->virtualBox, GetMachine(uuid, machine.asOutParam()));
1899 }
1900 else
1901 {
1902 CHECK_ERROR(a->virtualBox, FindMachine(Bstr(VMNameOrUuid), machine.asOutParam()));
1903 if (SUCCEEDED(rc))
1904 machine->COMGETTER(Id)(uuid.asOutParam());
1905 }
1906 if (FAILED(rc))
1907 return 1;
1908
1909 /* Printing the log is exclusive. */
1910 if (fLog && (fMachinereadable || fDetails))
1911 return errorSyntax(USAGE_SHOWVMINFO, "Option --log is exclusive");
1912
1913 if (fLog)
1914 {
1915 ULONG64 uOffset = 0;
1916 SafeArray<BYTE> aLogData;
1917 ULONG cbLogData;
1918 while (true)
1919 {
1920 CHECK_ERROR_BREAK(machine, ReadLog(uLogIdx, uOffset, _1M,
1921 ComSafeArrayAsOutParam(aLogData)));
1922 cbLogData = aLogData.size();
1923 if (cbLogData == 0)
1924 break;
1925 /* aLogData has a platform dependent line ending, standardize on
1926 * Unix style, as RTStrmWrite does the LF -> CR/LF replacement on
1927 * Windows. Otherwise we end up with CR/CR/LF on Windows. */
1928 ULONG cbLogDataPrint = cbLogData;
1929 for (BYTE *s = aLogData.raw(), *d = s;
1930 s - aLogData.raw() < (ssize_t)cbLogData;
1931 s++, d++)
1932 {
1933 if (*s == '\r')
1934 {
1935 /* skip over CR, adjust destination */
1936 d--;
1937 cbLogDataPrint--;
1938 }
1939 else if (s != d)
1940 *d = *s;
1941 }
1942 RTStrmWrite(g_pStdOut, aLogData.raw(), cbLogDataPrint);
1943 uOffset += cbLogData;
1944 }
1945 }
1946 else
1947 {
1948 /* 2nd option can be -details or -argdump */
1949 VMINFO_DETAILS details = VMINFO_NONE;
1950 if (fMachinereadable)
1951 details = VMINFO_MACHINEREADABLE;
1952 else if (fDetails)
1953 details = VMINFO_FULL;
1954 else
1955 details = VMINFO_STANDARD;
1956
1957 ComPtr <IConsole> console;
1958
1959 /* open an existing session for the VM */
1960 rc = a->virtualBox->OpenExistingSession(a->session, uuid);
1961 if (SUCCEEDED(rc))
1962 /* get the session machine */
1963 rc = a->session->COMGETTER(Machine)(machine.asOutParam());
1964 if (SUCCEEDED(rc))
1965 /* get the session console */
1966 rc = a->session->COMGETTER(Console)(console.asOutParam());
1967
1968 rc = showVMInfo(a->virtualBox, machine, details, console);
1969
1970 if (console)
1971 a->session->Close();
1972 }
1973
1974 return SUCCEEDED(rc) ? 0 : 1;
1975}
1976
1977#endif /* !VBOX_ONLY_DOCS */
1978/* 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