VirtualBox

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

Last change on this file since 35891 was 35891, checked in by vboxsync, 14 years ago

Burn fix.

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