VirtualBox

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

Last change on this file since 14555 was 14555, checked in by vboxsync, 16 years ago

VBoxManage: started splitting it up.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 96.0 KB
Line 
1/* $Id: VBoxManageInfo.cpp 14555 2008-11-25 09:08:06Z vboxsync $ */
2/** @file
3 * VBoxManage - VirtualBox's command-line interface.
4 */
5
6/*
7 * Copyright (C) 2006-2007 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/EventQueue.h>
33
34#include <VBox/com/VirtualBox.h>
35
36#include <stdlib.h>
37#include <stdarg.h>
38
39#include <vector>
40#include <list>
41
42#include <iprt/runtime.h>
43#include <iprt/stream.h>
44#include <iprt/string.h>
45#include <iprt/asm.h>
46#include <iprt/uuid.h>
47#include <iprt/thread.h>
48#include <iprt/path.h>
49#include <iprt/param.h>
50#include <iprt/dir.h>
51#include <iprt/file.h>
52#include <iprt/env.h>
53#include <iprt/cidr.h>
54#include <VBox/err.h>
55#include <VBox/version.h>
56#include <VBox/VBoxHDD.h>
57
58#include "VBoxManage.h"
59using namespace com;
60
61
62// funcs
63///////////////////////////////////////////////////////////////////////////////
64
65
66
67void showSnapshots(ComPtr<ISnapshot> rootSnapshot, VMINFO_DETAILS details, const Bstr &prefix /* = ""*/, int level /*= 0*/)
68{
69 /* start with the root */
70 Bstr name;
71 Guid uuid;
72 rootSnapshot->COMGETTER(Name)(name.asOutParam());
73 rootSnapshot->COMGETTER(Id)(uuid.asOutParam());
74 if (details == VMINFO_MACHINEREADABLE)
75 {
76 /* print with hierarchical numbering */
77 RTPrintf("SnapshotName%lS=\"%lS\"\n", prefix.raw(), name.raw());
78 RTPrintf("SnapshotUUID%lS=\"%s\"\n", prefix.raw(), uuid.toString().raw());
79 }
80 else
81 {
82 /* print with indentation */
83 RTPrintf(" %lSName: %lS (UUID: %s)\n", prefix.raw(), name.raw(), uuid.toString().raw());
84 }
85
86 /* get the children */
87 ComPtr<ISnapshotCollection> coll;
88 rootSnapshot->COMGETTER(Children)(coll.asOutParam());
89 if (coll)
90 {
91 ComPtr<ISnapshotEnumerator> enumerator;
92 coll->Enumerate(enumerator.asOutParam());
93 ULONG index = 0;
94 BOOL hasMore = FALSE;
95 while (enumerator->HasMore(&hasMore), hasMore)
96 {
97 ComPtr<ISnapshot> snapshot;
98 enumerator->GetNext(snapshot.asOutParam());
99 if (snapshot)
100 {
101 Bstr newPrefix;
102 if (details == VMINFO_MACHINEREADABLE)
103 newPrefix = Utf8StrFmt("%lS-%d", prefix.raw(), index + 1);
104 else
105 newPrefix = Utf8StrFmt("%lS ", prefix.raw());
106 /* recursive call */
107 showSnapshots(snapshot, details, newPrefix, level + 1);
108 }
109 index++;
110 }
111 }
112}
113
114static void makeTimeStr (char *s, int cb, int64_t millies)
115{
116 RTTIME t;
117 RTTIMESPEC ts;
118
119 RTTimeSpecSetMilli(&ts, millies);
120
121 RTTimeExplode (&t, &ts);
122
123 RTStrPrintf(s, cb, "%04d/%02d/%02d %02d:%02d:%02d UTC",
124 t.i32Year, t.u8Month, t.u8MonthDay,
125 t.u8Hour, t.u8Minute, t.u8Second);
126}
127
128HRESULT showVMInfo (ComPtr <IVirtualBox> virtualBox, ComPtr<IMachine> machine,
129 ComPtr <IConsole> console /*= ComPtr <IConsole> ()*/,
130 VMINFO_DETAILS details /*= VMINFO_NONE*/)
131{
132 HRESULT rc;
133
134 /*
135 * The rules for output in -argdump format:
136 * 1) the key part (the [0-9a-zA-Z_]+ string before the '=' delimiter)
137 * is all lowercase for "VBoxManage modifyvm" parameters. Any
138 * other values printed are in CamelCase.
139 * 2) strings (anything non-decimal) are printed surrounded by
140 * double quotes '"'. If the strings themselves contain double
141 * quotes, these characters are escaped by '\'. Any '\' character
142 * in the original string is also escaped by '\'.
143 * 3) numbers (containing just [0-9\-]) are written out unchanged.
144 */
145
146 /** @todo the quoting is not yet implemented! */
147
148 BOOL accessible = FALSE;
149 CHECK_ERROR (machine, COMGETTER(Accessible) (&accessible));
150 CheckComRCReturnRC (rc);
151
152 if (!accessible)
153 {
154 if (details == VMINFO_MACHINEREADABLE)
155 RTPrintf("name=\"<inaccessible>\"\n");
156 else
157 RTPrintf ("Name: <inaccessible!>\n");
158 Guid uuid;
159 rc = machine->COMGETTER(Id) (uuid.asOutParam());
160 if (details == VMINFO_MACHINEREADABLE)
161 RTPrintf ("UUID=\"%s\"\n", uuid.toString().raw());
162 else
163 RTPrintf ("UUID: %s\n", uuid.toString().raw());
164 if (details != VMINFO_MACHINEREADABLE)
165 {
166 Bstr settingsFilePath;
167 rc = machine->COMGETTER(SettingsFilePath) (settingsFilePath.asOutParam());
168 RTPrintf ("Config file: %lS\n", settingsFilePath.raw());
169 ComPtr<IVirtualBoxErrorInfo> accessError;
170 rc = machine->COMGETTER(AccessError) (accessError.asOutParam());
171 RTPrintf ("Access error details:\n");
172 ErrorInfo ei (accessError);
173 PRINT_ERROR_INFO (ei);
174 RTPrintf ("\n");
175 }
176 return S_OK;
177 }
178
179 Bstr machineName;
180 rc = machine->COMGETTER(Name)(machineName.asOutParam());
181 if (details == VMINFO_MACHINEREADABLE)
182 RTPrintf("name=\"%lS\"\n", machineName.raw());
183 else
184 RTPrintf("Name: %lS\n", machineName.raw());
185
186 Bstr osTypeId;
187 rc = machine->COMGETTER(OSTypeId)(osTypeId.asOutParam());
188 ComPtr<IGuestOSType> osType;
189 rc = virtualBox->GetGuestOSType (osTypeId, osType.asOutParam());
190 Bstr osName;
191 rc = osType->COMGETTER(Description)(osName.asOutParam());
192 if (details == VMINFO_MACHINEREADABLE)
193 RTPrintf("ostype=\"%lS\"\n", osTypeId.raw());
194 else
195 RTPrintf("Guest OS: %lS\n", osName.raw());
196
197 Guid uuid;
198 rc = machine->COMGETTER(Id)(uuid.asOutParam());
199 if (details == VMINFO_MACHINEREADABLE)
200 RTPrintf("UUID=\"%s\"\n", uuid.toString().raw());
201 else
202 RTPrintf("UUID: %s\n", uuid.toString().raw());
203
204 Bstr settingsFilePath;
205 rc = machine->COMGETTER(SettingsFilePath)(settingsFilePath.asOutParam());
206 if (details == VMINFO_MACHINEREADABLE)
207 RTPrintf("CfgFile=\"%lS\"\n", settingsFilePath.raw());
208 else
209 RTPrintf("Config file: %lS\n", settingsFilePath.raw());
210
211 ULONG memorySize;
212 rc = machine->COMGETTER(MemorySize)(&memorySize);
213 if (details == VMINFO_MACHINEREADABLE)
214 RTPrintf("memory=%u\n", memorySize);
215 else
216 RTPrintf("Memory size: %uMB\n", memorySize);
217
218 ULONG vramSize;
219 rc = machine->COMGETTER(VRAMSize)(&vramSize);
220 if (details == VMINFO_MACHINEREADABLE)
221 RTPrintf("vram=%u\n", vramSize);
222 else
223 RTPrintf("VRAM size: %uMB\n", vramSize);
224
225 ComPtr <IBIOSSettings> biosSettings;
226 machine->COMGETTER(BIOSSettings)(biosSettings.asOutParam());
227
228 BIOSBootMenuMode_T bootMenuMode;
229 biosSettings->COMGETTER(BootMenuMode)(&bootMenuMode);
230 const char *pszBootMenu = NULL;
231 switch (bootMenuMode)
232 {
233 case BIOSBootMenuMode_Disabled:
234 pszBootMenu = "disabled";
235 break;
236 case BIOSBootMenuMode_MenuOnly:
237 if (details == VMINFO_MACHINEREADABLE)
238 pszBootMenu = "menuonly";
239 else
240 pszBootMenu = "menu only";
241 break;
242 default:
243 if (details == VMINFO_MACHINEREADABLE)
244 pszBootMenu = "messageandmenu";
245 else
246 pszBootMenu = "message and menu";
247 }
248 if (details == VMINFO_MACHINEREADABLE)
249 RTPrintf("bootmenu=\"%s\"\n", pszBootMenu);
250 else
251 RTPrintf("Boot menu mode: %s\n", pszBootMenu);
252
253 BOOL acpiEnabled;
254 biosSettings->COMGETTER(ACPIEnabled)(&acpiEnabled);
255 if (details == VMINFO_MACHINEREADABLE)
256 RTPrintf("acpi=\"%s\"\n", acpiEnabled ? "on" : "off");
257 else
258 RTPrintf("ACPI: %s\n", acpiEnabled ? "on" : "off");
259
260 BOOL ioapicEnabled;
261 biosSettings->COMGETTER(IOAPICEnabled)(&ioapicEnabled);
262 if (details == VMINFO_MACHINEREADABLE)
263 RTPrintf("ioapic=\"%s\"\n", ioapicEnabled ? "on" : "off");
264 else
265 RTPrintf("IOAPIC: %s\n", ioapicEnabled ? "on" : "off");
266
267 BOOL PAEEnabled;
268 machine->COMGETTER(PAEEnabled)(&PAEEnabled);
269 if (details == VMINFO_MACHINEREADABLE)
270 RTPrintf("pae=\"%s\"\n", PAEEnabled ? "on" : "off");
271 else
272 RTPrintf("PAE: %s\n", PAEEnabled ? "on" : "off");
273
274 LONG64 timeOffset;
275 biosSettings->COMGETTER(TimeOffset)(&timeOffset);
276 if (details == VMINFO_MACHINEREADABLE)
277 RTPrintf("biossystemtimeoffset=%lld\n", timeOffset);
278 else
279 RTPrintf("Time offset: %lld ms\n", timeOffset);
280
281 TSBool_T hwVirtExEnabled;
282 machine->COMGETTER(HWVirtExEnabled)(&hwVirtExEnabled);
283 if (hwVirtExEnabled == TSBool_Default)
284 {
285 BOOL fHWVirtExEnabled;
286 ComPtr<ISystemProperties> systemProperties;
287 virtualBox->COMGETTER(SystemProperties)(systemProperties.asOutParam());
288 systemProperties->COMGETTER(HWVirtExEnabled)(&fHWVirtExEnabled);
289 if (details == VMINFO_MACHINEREADABLE)
290 RTPrintf("hwvirtex=\"default\"\n");
291 else
292 RTPrintf("Hardw. virt.ext: Default (%s)\n", fHWVirtExEnabled ? "on" : "off");
293 }
294 else
295 {
296 if (details == VMINFO_MACHINEREADABLE)
297 RTPrintf("hwvirtex=\"%s\"\n", hwVirtExEnabled == TSBool_True ? "on" : "off");
298 else
299 RTPrintf("Hardw. virt.ext: %s\n", hwVirtExEnabled == TSBool_True ? "on" : "off");
300 }
301 BOOL HWVirtExNestedPagingEnabled;
302 machine->COMGETTER(HWVirtExNestedPagingEnabled)(&HWVirtExNestedPagingEnabled);
303 if (details == VMINFO_MACHINEREADABLE)
304 RTPrintf("nestedpaging=\"%s\"\n", HWVirtExNestedPagingEnabled ? "on" : "off");
305 else
306 RTPrintf("Nested Paging: %s\n", HWVirtExNestedPagingEnabled ? "on" : "off");
307
308 BOOL HWVirtExVPIDEnabled;
309 machine->COMGETTER(HWVirtExVPIDEnabled)(&HWVirtExVPIDEnabled);
310 if (details == VMINFO_MACHINEREADABLE)
311 RTPrintf("vtxvpid=\"%s\"\n", HWVirtExVPIDEnabled ? "on" : "off");
312 else
313 RTPrintf("VT-x VPID: %s\n", HWVirtExVPIDEnabled ? "on" : "off");
314
315 MachineState_T machineState;
316 const char *pszState = NULL;
317 rc = machine->COMGETTER(State)(&machineState);
318 switch (machineState)
319 {
320 case MachineState_PoweredOff:
321 if (details == VMINFO_MACHINEREADABLE)
322 pszState = "poweroff";
323 else
324 pszState = "powered off";
325 break;
326 case MachineState_Saved:
327 pszState = "saved";
328 break;
329 case MachineState_Aborted:
330 pszState = "aborted";
331 break;
332 case MachineState_Running:
333 pszState = "running";
334 break;
335 case MachineState_Paused:
336 pszState = "paused";
337 break;
338 case MachineState_Starting:
339 pszState = "starting";
340 break;
341 case MachineState_Stopping:
342 pszState = "stopping";
343 break;
344 case MachineState_Saving:
345 pszState = "saving";
346 break;
347 case MachineState_Restoring:
348 pszState = "restoring";
349 break;
350 default:
351 pszState = "unknown";
352 break;
353 }
354 LONG64 stateSince;
355 machine->COMGETTER(LastStateChange)(&stateSince);
356 RTTIMESPEC timeSpec;
357 RTTimeSpecSetMilli(&timeSpec, stateSince);
358 char pszTime[30] = {0};
359 RTTimeSpecToString(&timeSpec, pszTime, sizeof(pszTime));
360 if (details == VMINFO_MACHINEREADABLE)
361 {
362 RTPrintf("VMState=\"%s\"\n", pszState);
363 RTPrintf("VMStateChangeTime=\"%s\"\n", pszTime);
364 }
365 else
366 RTPrintf("State: %s (since %s)\n", pszState, pszTime);
367
368 ULONG numMonitors;
369 machine->COMGETTER(MonitorCount)(&numMonitors);
370 if (details == VMINFO_MACHINEREADABLE)
371 RTPrintf("monitorcount=%d\n", numMonitors);
372 else
373 RTPrintf("Monitor count: %d\n", numMonitors);
374
375 BOOL accelerate3d;
376 machine->COMGETTER(Accelerate3DEnabled)(&accelerate3d);
377 if (details == VMINFO_MACHINEREADABLE)
378 RTPrintf("accelerate3d=\"%s\"\n", accelerate3d ? "on" : "off");
379 else
380 RTPrintf("3D Acceleration: %s\n", accelerate3d ? "on" : "off");
381
382 ComPtr<IFloppyDrive> floppyDrive;
383 rc = machine->COMGETTER(FloppyDrive)(floppyDrive.asOutParam());
384 if (SUCCEEDED(rc) && floppyDrive)
385 {
386 BOOL fFloppyEnabled;
387 floppyDrive->COMGETTER(Enabled)(&fFloppyEnabled);
388 Utf8Str pszFloppy = "invalid";
389 if (fFloppyEnabled)
390 {
391 DriveState_T floppyState;
392 floppyDrive->COMGETTER(State)(&floppyState);
393 switch (floppyState)
394 {
395 case DriveState_ImageMounted:
396 {
397 ComPtr<IFloppyImage2> floppyImage;
398 rc = floppyDrive->GetImage(floppyImage.asOutParam());
399 if (SUCCEEDED(rc) && floppyImage)
400 {
401 Bstr imagePath;
402 floppyImage->COMGETTER(Location)(imagePath.asOutParam());
403 Guid imageGuid;
404 floppyImage->COMGETTER(Id)(imageGuid.asOutParam());
405 if (details == VMINFO_MACHINEREADABLE)
406 {
407 RTPrintf("FloppyImageUUID=\"%s\"\n", imageGuid.toString().raw());
408 pszFloppy = Utf8StrFmt("%lS", imagePath.raw());
409 }
410 else
411 pszFloppy = Utf8StrFmt("%lS (UUID: %s)", imagePath.raw(), imageGuid.toString().raw());
412 }
413 break;
414 }
415
416 case DriveState_HostDriveCaptured:
417 {
418 ComPtr<IHostFloppyDrive> hostFloppyDrive;
419 rc = floppyDrive->GetHostDrive(hostFloppyDrive.asOutParam());
420 if (SUCCEEDED(rc) && floppyDrive)
421 {
422 Bstr driveName;
423 hostFloppyDrive->COMGETTER(Name)(driveName.asOutParam());
424 if (details == VMINFO_MACHINEREADABLE)
425 pszFloppy = Utf8StrFmt("host:%lS", driveName.raw());
426 else
427 pszFloppy = Utf8StrFmt("Host drive %lS", driveName.raw());
428 }
429 break;
430 }
431
432 case DriveState_NotMounted:
433 {
434 pszFloppy = "empty";
435 break;
436 }
437 }
438 }
439 else
440 {
441 pszFloppy = "disabled";
442 }
443 if (details == VMINFO_MACHINEREADABLE)
444 RTPrintf("floppy=\"%s\"\n", pszFloppy.raw());
445 else
446 RTPrintf("Floppy: %s\n", pszFloppy.raw());
447 }
448
449 /*
450 * SATA.
451 *
452 * Contributed by: James Lucas
453 */
454#ifdef VBOX_WITH_AHCI
455 ComPtr<ISATAController> SATACtl;
456 BOOL fSataEnabled;
457 rc = machine->COMGETTER(SATAController)(SATACtl.asOutParam());
458 if (SUCCEEDED(rc))
459 {
460 rc = SATACtl->COMGETTER(Enabled)(&fSataEnabled);
461 if (FAILED(rc))
462 fSataEnabled = false;
463 if (details == VMINFO_MACHINEREADABLE)
464 RTPrintf("sata=\"%s\"\n", fSataEnabled ? "on" : "off");
465 else
466 RTPrintf("SATA: %s\n", fSataEnabled ? "enabled" : "disabled");
467 }
468
469 /*
470 * SATA Hard disks
471 */
472 if (fSataEnabled)
473 {
474 ComPtr<IHardDisk2> hardDisk;
475 Bstr filePath;
476 ULONG cSataPorts;
477
478 SATACtl->COMGETTER(PortCount)(&cSataPorts);
479 for (ULONG i = 0; i < cSataPorts; ++ i)
480 {
481 rc = machine->GetHardDisk2(StorageBus_SATA, i, 0, hardDisk.asOutParam());
482 if (SUCCEEDED(rc) && hardDisk)
483 {
484 hardDisk->COMGETTER(Location)(filePath.asOutParam());
485 hardDisk->COMGETTER(Id)(uuid.asOutParam());
486 if (details == VMINFO_MACHINEREADABLE)
487 {
488 RTPrintf("sata%d=\"%lS\"\n", i, filePath.raw());
489 RTPrintf("sata%dImageUUID=\"%s\"\n", i, uuid.toString().raw());
490 }
491 else
492 RTPrintf("SATA %d: %lS (UUID: %s)\n", i, filePath.raw(), uuid.toString().raw());
493 }
494 else
495 {
496 if (details == VMINFO_MACHINEREADABLE)
497 RTPrintf("sata%d=\"none\"\n",i);
498 }
499 }
500 }
501#endif
502
503 /*
504 * IDE Hard disks
505 */
506 IDEControllerType_T ideController;
507 const char *pszIdeController = NULL;
508 biosSettings->COMGETTER(IDEControllerType)(&ideController);
509 switch (ideController)
510 {
511 case IDEControllerType_PIIX3:
512 pszIdeController = "PIIX3";
513 break;
514 case IDEControllerType_PIIX4:
515 pszIdeController = "PIIX4";
516 break;
517 default:
518 pszIdeController = "unknown";
519 }
520 if (details == VMINFO_MACHINEREADABLE)
521 RTPrintf("idecontroller=\"%s\"\n", pszIdeController);
522 else
523 RTPrintf("IDE Controller: %s\n", pszIdeController);
524
525 ComPtr<IHardDisk2> hardDisk;
526 Bstr filePath;
527 rc = machine->GetHardDisk2(StorageBus_IDE, 0, 0, hardDisk.asOutParam());
528 if (SUCCEEDED(rc) && hardDisk)
529 {
530 hardDisk->COMGETTER(Location)(filePath.asOutParam());
531 hardDisk->COMGETTER(Id)(uuid.asOutParam());
532 if (details == VMINFO_MACHINEREADABLE)
533 {
534 RTPrintf("hda=\"%lS\"\n", filePath.raw());
535 RTPrintf("HdaImageUUID=\"%s\"\n", uuid.toString().raw());
536 }
537 else
538 RTPrintf("Primary master: %lS (UUID: %s)\n", filePath.raw(), uuid.toString().raw());
539 }
540 else
541 {
542 if (details == VMINFO_MACHINEREADABLE)
543 RTPrintf("hda=\"none\"\n");
544 }
545 rc = machine->GetHardDisk2(StorageBus_IDE, 0, 1, hardDisk.asOutParam());
546 if (SUCCEEDED(rc) && hardDisk)
547 {
548 hardDisk->COMGETTER(Location)(filePath.asOutParam());
549 hardDisk->COMGETTER(Id)(uuid.asOutParam());
550 if (details == VMINFO_MACHINEREADABLE)
551 {
552 RTPrintf("hdb=\"%lS\"\n", filePath.raw());
553 RTPrintf("HdbImageUUID=\"%s\"\n", uuid.toString().raw());
554 }
555 else
556 RTPrintf("Primary slave: %lS (UUID: %s)\n", filePath.raw(), uuid.toString().raw());
557 }
558 else
559 {
560 if (details == VMINFO_MACHINEREADABLE)
561 RTPrintf("hdb=\"none\"\n");
562 }
563 rc = machine->GetHardDisk2(StorageBus_IDE, 1, 1, hardDisk.asOutParam());
564 if (SUCCEEDED(rc) && hardDisk)
565 {
566 hardDisk->COMGETTER(Location)(filePath.asOutParam());
567 hardDisk->COMGETTER(Id)(uuid.asOutParam());
568 if (details == VMINFO_MACHINEREADABLE)
569 {
570 RTPrintf("hdd=\"%lS\"\n", filePath.raw());
571 RTPrintf("HddImageUUID=\"%s\"\n", uuid.toString().raw());
572 }
573 else
574 RTPrintf("Secondary slave: %lS (UUID: %s)\n", filePath.raw(), uuid.toString().raw());
575 }
576 else
577 {
578 if (details == VMINFO_MACHINEREADABLE)
579 RTPrintf("hdd=\"none\"\n");
580 }
581 ComPtr<IDVDDrive> dvdDrive;
582 rc = machine->COMGETTER(DVDDrive)(dvdDrive.asOutParam());
583 if (SUCCEEDED(rc) && dvdDrive)
584 {
585 ComPtr<IDVDImage2> dvdImage;
586 rc = dvdDrive->GetImage(dvdImage.asOutParam());
587 if (SUCCEEDED(rc) && dvdImage)
588 {
589 rc = dvdImage->COMGETTER(Location)(filePath.asOutParam());
590 if (SUCCEEDED(rc) && filePath)
591 {
592 rc = dvdImage->COMGETTER(Id)(uuid.asOutParam());
593 if (details == VMINFO_MACHINEREADABLE)
594 {
595 RTPrintf("dvd=\"%lS\"\n", filePath.raw());
596 RTPrintf("DvdImageUUID=\"%s\"\n", uuid.toString().raw());
597 }
598 else
599 RTPrintf("DVD: %lS (UUID: %s)\n", filePath.raw(), uuid.toString().raw());
600 }
601 }
602 else
603 {
604 ComPtr<IHostDVDDrive> hostDVDDrive;
605 rc = dvdDrive->GetHostDrive(hostDVDDrive.asOutParam());
606 if (SUCCEEDED(rc) && hostDVDDrive)
607 {
608 Bstr name;
609 hostDVDDrive->COMGETTER(Name)(name.asOutParam());
610 if (details == VMINFO_MACHINEREADABLE)
611 RTPrintf("dvd=\"host:%lS\"\n", name.raw());
612 else
613 RTPrintf("DVD: Host drive %lS", name.raw());
614 }
615 else
616 {
617 if (details == VMINFO_MACHINEREADABLE)
618 RTPrintf("dvd=\"none\"\n");
619 else
620 RTPrintf("DVD: empty");
621 }
622 BOOL fPassthrough;
623 dvdDrive->COMGETTER(Passthrough)(&fPassthrough);
624 if (details == VMINFO_MACHINEREADABLE)
625 {
626 RTPrintf("dvdpassthrough=\"%s\"\n", fPassthrough ? "on" : "off");
627 }
628 else
629 {
630 if (fPassthrough)
631 RTPrintf(" (passthrough enabled)");
632 RTPrintf("\n");
633 }
634 }
635 }
636
637 /* get the maximum amount of NICS */
638 ComPtr<ISystemProperties> sysProps;
639 virtualBox->COMGETTER(SystemProperties)(sysProps.asOutParam());
640 ULONG maxNICs = 0;
641 sysProps->COMGETTER(NetworkAdapterCount)(&maxNICs);
642 for (ULONG currentNIC = 0; currentNIC < maxNICs; currentNIC++)
643 {
644 ComPtr<INetworkAdapter> nic;
645 rc = machine->GetNetworkAdapter(currentNIC, nic.asOutParam());
646 if (SUCCEEDED(rc) && nic)
647 {
648 BOOL fEnabled;
649 nic->COMGETTER(Enabled)(&fEnabled);
650 if (!fEnabled)
651 {
652 if (details == VMINFO_MACHINEREADABLE)
653 RTPrintf("nic%d=\"none\"\n", currentNIC + 1);
654 else
655 RTPrintf("NIC %d: disabled\n", currentNIC + 1);
656 }
657 else
658 {
659 Bstr strMACAddress;
660 nic->COMGETTER(MACAddress)(strMACAddress.asOutParam());
661 Utf8Str strAttachment;
662 NetworkAttachmentType_T attachment;
663 nic->COMGETTER(AttachmentType)(&attachment);
664 switch (attachment)
665 {
666 case NetworkAttachmentType_Null:
667 if (details == VMINFO_MACHINEREADABLE)
668 strAttachment = "null";
669 else
670 strAttachment = "none";
671 break;
672 case NetworkAttachmentType_NAT:
673 {
674 Bstr strNetwork;
675 nic->COMGETTER(NATNetwork)(strNetwork.asOutParam());
676 if (details == VMINFO_MACHINEREADABLE)
677 {
678 RTPrintf("natnet%d=\"%lS\"\n", currentNIC + 1, strNetwork.raw());
679 strAttachment = "nat";
680 }
681 else if (!strNetwork.isEmpty())
682 strAttachment = Utf8StrFmt("NAT (%lS)", strNetwork.raw());
683 else
684 strAttachment = "NAT";
685 break;
686 }
687 case NetworkAttachmentType_HostInterface:
688 {
689 Bstr strHostIfDev;
690 nic->COMGETTER(HostInterface)(strHostIfDev.asOutParam());
691 if (details == VMINFO_MACHINEREADABLE)
692 {
693 RTPrintf("hostifdev%d=\"%lS\"\n", currentNIC + 1, strHostIfDev.raw());
694 strAttachment = "hostif";
695 }
696 else
697 strAttachment = Utf8StrFmt("Host Interface '%lS'", strHostIfDev.raw());
698 break;
699 }
700 case NetworkAttachmentType_Internal:
701 {
702 Bstr strNetwork;
703 nic->COMGETTER(InternalNetwork)(strNetwork.asOutParam());
704 if (details == VMINFO_MACHINEREADABLE)
705 {
706 RTPrintf("intnet%d=\"%lS\"\n", currentNIC + 1, strNetwork.raw());
707 strAttachment = "intnet";
708 }
709 else
710 strAttachment = Utf8StrFmt("Internal Network '%s'", Utf8Str(strNetwork).raw());
711 break;
712 }
713 default:
714 strAttachment = "unknown";
715 break;
716 }
717
718 /* cable connected */
719 BOOL fConnected;
720 nic->COMGETTER(CableConnected)(&fConnected);
721
722 /* trace stuff */
723 BOOL fTraceEnabled;
724 nic->COMGETTER(TraceEnabled)(&fTraceEnabled);
725 Bstr traceFile;
726 nic->COMGETTER(TraceFile)(traceFile.asOutParam());
727
728 /* NIC type */
729 Utf8Str strNICType;
730 NetworkAdapterType_T NICType;
731 nic->COMGETTER(AdapterType)(&NICType);
732 switch (NICType) {
733 case NetworkAdapterType_Am79C970A:
734 strNICType = "Am79C970A";
735 break;
736 case NetworkAdapterType_Am79C973:
737 strNICType = "Am79C973";
738 break;
739#ifdef VBOX_WITH_E1000
740 case NetworkAdapterType_I82540EM:
741 strNICType = "82540EM";
742 break;
743 case NetworkAdapterType_I82543GC:
744 strNICType = "82543GC";
745 break;
746#endif
747 default:
748 strNICType = "unknown";
749 break;
750 }
751
752 /* reported line speed */
753 ULONG ulLineSpeed;
754 nic->COMGETTER(LineSpeed)(&ulLineSpeed);
755
756 if (details == VMINFO_MACHINEREADABLE)
757 {
758 RTPrintf("macaddress%d=\"%lS\"\n", currentNIC + 1, strMACAddress.raw());
759 RTPrintf("cableconnected%d=\"%s\"\n", currentNIC + 1, fConnected ? "on" : "off");
760 RTPrintf("nic%d=\"%s\"\n", currentNIC + 1, strAttachment.raw());
761 }
762 else
763 RTPrintf("NIC %d: MAC: %lS, Attachment: %s, Cable connected: %s, Trace: %s (file: %lS), Type: %s, Reported speed: %d Mbps\n",
764 currentNIC + 1, strMACAddress.raw(), strAttachment.raw(),
765 fConnected ? "on" : "off",
766 fTraceEnabled ? "on" : "off",
767 traceFile.isEmpty() ? Bstr("none").raw() : traceFile.raw(),
768 strNICType.raw(),
769 ulLineSpeed / 1000);
770 }
771 }
772 }
773
774 /* get the maximum amount of UARTs */
775 ULONG maxUARTs = 0;
776 sysProps->COMGETTER(SerialPortCount)(&maxUARTs);
777 for (ULONG currentUART = 0; currentUART < maxUARTs; currentUART++)
778 {
779 ComPtr<ISerialPort> uart;
780 rc = machine->GetSerialPort(currentUART, uart.asOutParam());
781 if (SUCCEEDED(rc) && uart)
782 {
783 BOOL fEnabled;
784 uart->COMGETTER(Enabled)(&fEnabled);
785 if (!fEnabled)
786 {
787 if (details == VMINFO_MACHINEREADABLE)
788 RTPrintf("uart%d=\"off\"\n", currentUART + 1);
789 else
790 RTPrintf("UART %d: disabled\n", currentUART + 1);
791 }
792 else
793 {
794 ULONG ulIRQ, ulIOBase;
795 PortMode_T HostMode;
796 Bstr path;
797 BOOL fServer;
798 uart->COMGETTER(IRQ)(&ulIRQ);
799 uart->COMGETTER(IOBase)(&ulIOBase);
800 uart->COMGETTER(Path)(path.asOutParam());
801 uart->COMGETTER(Server)(&fServer);
802 uart->COMGETTER(HostMode)(&HostMode);
803
804 if (details == VMINFO_MACHINEREADABLE)
805 RTPrintf("uart%d=\"%#06x,%d\"\n", currentUART + 1,
806 ulIOBase, ulIRQ);
807 else
808 RTPrintf("UART %d: I/O base: 0x%04x, IRQ: %d",
809 currentUART + 1, ulIOBase, ulIRQ);
810 switch (HostMode)
811 {
812 default:
813 case PortMode_Disconnected:
814 if (details == VMINFO_MACHINEREADABLE)
815 RTPrintf("uartmode%d=\"disconnected\"\n", currentUART + 1);
816 else
817 RTPrintf(", disconnected\n");
818 break;
819 case PortMode_HostPipe:
820 if (details == VMINFO_MACHINEREADABLE)
821 RTPrintf("uartmode%d=\"%s,%lS\"\n", currentUART + 1,
822 fServer ? "server" : "client", path.raw());
823 else
824 RTPrintf(", attached to pipe (%s) '%lS'\n",
825 fServer ? "server" : "client", path.raw());
826 break;
827 case PortMode_HostDevice:
828 if (details == VMINFO_MACHINEREADABLE)
829 RTPrintf("uartmode%d=\"%lS\"\n", currentUART + 1,
830 path.raw());
831 else
832 RTPrintf(", attached to device '%lS'\n", path.raw());
833 break;
834 }
835 }
836 }
837 }
838
839 ComPtr<IAudioAdapter> AudioAdapter;
840 rc = machine->COMGETTER(AudioAdapter)(AudioAdapter.asOutParam());
841 if (SUCCEEDED(rc))
842 {
843 const char *pszDrv = "Unknown";
844 const char *pszCtrl = "Unknown";
845 BOOL fEnabled;
846 rc = AudioAdapter->COMGETTER(Enabled)(&fEnabled);
847 if (SUCCEEDED(rc) && fEnabled)
848 {
849 AudioDriverType_T enmDrvType;
850 rc = AudioAdapter->COMGETTER(AudioDriver)(&enmDrvType);
851 switch (enmDrvType)
852 {
853 case AudioDriverType_Null:
854 if (details == VMINFO_MACHINEREADABLE)
855 pszDrv = "null";
856 else
857 pszDrv = "Null";
858 break;
859 case AudioDriverType_WinMM:
860 if (details == VMINFO_MACHINEREADABLE)
861 pszDrv = "winmm";
862 else
863 pszDrv = "WINMM";
864 break;
865 case AudioDriverType_DirectSound:
866 if (details == VMINFO_MACHINEREADABLE)
867 pszDrv = "dsound";
868 else
869 pszDrv = "DSOUND";
870 break;
871 case AudioDriverType_OSS:
872 if (details == VMINFO_MACHINEREADABLE)
873 pszDrv = "oss";
874 else
875 pszDrv = "OSS";
876 break;
877 case AudioDriverType_ALSA:
878 if (details == VMINFO_MACHINEREADABLE)
879 pszDrv = "alsa";
880 else
881 pszDrv = "ALSA";
882 break;
883 case AudioDriverType_Pulse:
884 if (details == VMINFO_MACHINEREADABLE)
885 pszDrv = "pulse";
886 else
887 pszDrv = "PulseAudio";
888 break;
889 case AudioDriverType_CoreAudio:
890 if (details == VMINFO_MACHINEREADABLE)
891 pszDrv = "coreaudio";
892 else
893 pszDrv = "CoreAudio";
894 break;
895 case AudioDriverType_SolAudio:
896 if (details == VMINFO_MACHINEREADABLE)
897 pszDrv = "solaudio";
898 else
899 pszDrv = "SolAudio";
900 break;
901 default:
902 if (details == VMINFO_MACHINEREADABLE)
903 pszDrv = "unknown";
904 break;
905 }
906 AudioControllerType_T enmCtrlType;
907 rc = AudioAdapter->COMGETTER(AudioController)(&enmCtrlType);
908 switch (enmCtrlType)
909 {
910 case AudioControllerType_AC97:
911 if (details == VMINFO_MACHINEREADABLE)
912 pszCtrl = "ac97";
913 else
914 pszCtrl = "AC97";
915 break;
916 case AudioControllerType_SB16:
917 if (details == VMINFO_MACHINEREADABLE)
918 pszCtrl = "sb16";
919 else
920 pszCtrl = "SB16";
921 break;
922 }
923 }
924 else
925 fEnabled = FALSE;
926 if (details == VMINFO_MACHINEREADABLE)
927 {
928 if (fEnabled)
929 RTPrintf("audio=\"%s\"\n", pszDrv);
930 else
931 RTPrintf("audio=\"none\"\n");
932 }
933 else
934 RTPrintf("Audio: %s (Driver: %s, Controller: %s)\n",
935 fEnabled ? "enabled" : "disabled", pszDrv, pszCtrl);
936 }
937
938 /* Shared clipboard */
939 {
940 const char *psz = "Unknown";
941 ClipboardMode_T enmMode;
942 rc = machine->COMGETTER(ClipboardMode)(&enmMode);
943 switch (enmMode)
944 {
945 case ClipboardMode_Disabled:
946 if (details == VMINFO_MACHINEREADABLE)
947 psz = "disabled";
948 else
949 psz = "disabled";
950 break;
951 case ClipboardMode_HostToGuest:
952 if (details == VMINFO_MACHINEREADABLE)
953 psz = "hosttoguest";
954 else
955 psz = "HostToGuest";
956 break;
957 case ClipboardMode_GuestToHost:
958 if (details == VMINFO_MACHINEREADABLE)
959 psz = "guesttohost";
960 else
961 psz = "GuestToHost";
962 break;
963 case ClipboardMode_Bidirectional:
964 if (details == VMINFO_MACHINEREADABLE)
965 psz = "bidirectional";
966 else
967 psz = "Bidirectional";
968 break;
969 default:
970 if (details == VMINFO_MACHINEREADABLE)
971 psz = "unknown";
972 break;
973 }
974 if (details == VMINFO_MACHINEREADABLE)
975 RTPrintf("clipboard=\"%s\"\n", psz);
976 else
977 RTPrintf("Clipboard Mode: %s\n", psz);
978 }
979
980 if (console)
981 {
982 ComPtr<IDisplay> display;
983 CHECK_ERROR_RET(console, COMGETTER(Display)(display.asOutParam()), rc);
984 do
985 {
986 ULONG xRes, yRes, bpp;
987 rc = display->COMGETTER(Width)(&xRes);
988 if (rc == E_ACCESSDENIED)
989 break; /* VM not powered up */
990 if (FAILED(rc))
991 {
992 com::ErrorInfo info (display);
993 PRINT_ERROR_INFO (info);
994 return rc;
995 }
996 rc = display->COMGETTER(Height)(&yRes);
997 if (rc == E_ACCESSDENIED)
998 break; /* VM not powered up */
999 if (FAILED(rc))
1000 {
1001 com::ErrorInfo info (display);
1002 PRINT_ERROR_INFO (info);
1003 return rc;
1004 }
1005 rc = display->COMGETTER(BitsPerPixel)(&bpp);
1006 if (rc == E_ACCESSDENIED)
1007 break; /* VM not powered up */
1008 if (FAILED(rc))
1009 {
1010 com::ErrorInfo info (display);
1011 PRINT_ERROR_INFO (info);
1012 return rc;
1013 }
1014 if (details == VMINFO_MACHINEREADABLE)
1015 RTPrintf("VideoMode=\"%d,%d,%d\"\n", xRes, yRes, bpp);
1016 else
1017 RTPrintf("Video mode: %dx%dx%d\n", xRes, yRes, bpp);
1018 }
1019 while (0);
1020 }
1021
1022 /*
1023 * VRDP
1024 */
1025 ComPtr<IVRDPServer> vrdpServer;
1026 rc = machine->COMGETTER(VRDPServer)(vrdpServer.asOutParam());
1027 if (SUCCEEDED(rc) && vrdpServer)
1028 {
1029 BOOL fEnabled = false;
1030 vrdpServer->COMGETTER(Enabled)(&fEnabled);
1031 if (fEnabled)
1032 {
1033 ULONG port;
1034 vrdpServer->COMGETTER(Port)(&port);
1035 Bstr address;
1036 vrdpServer->COMGETTER(NetAddress)(address.asOutParam());
1037 BOOL fMultiCon;
1038 vrdpServer->COMGETTER(AllowMultiConnection)(&fMultiCon);
1039 BOOL fReuseCon;
1040 vrdpServer->COMGETTER(ReuseSingleConnection)(&fReuseCon);
1041 VRDPAuthType_T vrdpAuthType;
1042 const char *strAuthType;
1043 vrdpServer->COMGETTER(AuthType)(&vrdpAuthType);
1044 switch (vrdpAuthType)
1045 {
1046 case VRDPAuthType_Null:
1047 strAuthType = "null";
1048 break;
1049 case VRDPAuthType_External:
1050 strAuthType = "external";
1051 break;
1052 case VRDPAuthType_Guest:
1053 strAuthType = "guest";
1054 break;
1055 default:
1056 strAuthType = "unknown";
1057 break;
1058 }
1059 if (details == VMINFO_MACHINEREADABLE)
1060 {
1061 RTPrintf("vrdp=\"on\"\n");
1062 RTPrintf("vrdpport=%d\n", port);
1063 RTPrintf("vrdpaddress=\"%lS\"\n", address.raw());
1064 RTPrintf("vrdpauthtype=\"%s\"\n", strAuthType);
1065 RTPrintf("vrdpmulticon=\"%s\"\n", fMultiCon ? "on" : "off");
1066 RTPrintf("vrdpreusecon=\"%s\"\n", fReuseCon ? "on" : "off");
1067 }
1068 else
1069 {
1070 if (address.isEmpty())
1071 address = "0.0.0.0";
1072 RTPrintf("VRDP: enabled (Address %lS, Port %d, MultiConn: %s, ReuseSingleConn: %s, Authentication type: %s)\n", address.raw(), port, fMultiCon ? "on" : "off", fReuseCon ? "on" : "off", strAuthType);
1073 }
1074 }
1075 else
1076 {
1077 if (details == VMINFO_MACHINEREADABLE)
1078 RTPrintf("vrdp=\"off\"\n");
1079 else
1080 RTPrintf("VRDP: disabled\n");
1081 }
1082 }
1083
1084 /*
1085 * USB.
1086 */
1087 ComPtr<IUSBController> USBCtl;
1088 rc = machine->COMGETTER(USBController)(USBCtl.asOutParam());
1089 if (SUCCEEDED(rc))
1090 {
1091 BOOL fEnabled;
1092 rc = USBCtl->COMGETTER(Enabled)(&fEnabled);
1093 if (FAILED(rc))
1094 fEnabled = false;
1095 if (details == VMINFO_MACHINEREADABLE)
1096 RTPrintf("usb=\"%s\"\n", fEnabled ? "on" : "off");
1097 else
1098 RTPrintf("USB: %s\n", fEnabled ? "enabled" : "disabled");
1099
1100 if (details != VMINFO_MACHINEREADABLE)
1101 RTPrintf("\nUSB Device Filters:\n\n");
1102
1103 ComPtr<IUSBDeviceFilterCollection> Coll;
1104 CHECK_ERROR_RET (USBCtl, COMGETTER(DeviceFilters)(Coll.asOutParam()), rc);
1105
1106 ComPtr<IUSBDeviceFilterEnumerator> Enum;
1107 CHECK_ERROR_RET (Coll, Enumerate(Enum.asOutParam()), rc);
1108
1109 ULONG index = 0;
1110 BOOL fMore = FALSE;
1111 rc = Enum->HasMore (&fMore);
1112 ASSERT_RET (SUCCEEDED (rc), rc);
1113
1114 if (!fMore)
1115 {
1116 if (details != VMINFO_MACHINEREADABLE)
1117 RTPrintf("<none>\n\n");
1118 }
1119 else
1120 while (fMore)
1121 {
1122 ComPtr<IUSBDeviceFilter> DevPtr;
1123 rc = Enum->GetNext(DevPtr.asOutParam());
1124 ASSERT_RET (SUCCEEDED (rc), rc);
1125
1126 /* Query info. */
1127
1128 if (details != VMINFO_MACHINEREADABLE)
1129 RTPrintf("Index: %lu\n", index);
1130
1131 BOOL bActive = FALSE;
1132 CHECK_ERROR_RET (DevPtr, COMGETTER (Active) (&bActive), rc);
1133 if (details == VMINFO_MACHINEREADABLE)
1134 RTPrintf("USBFilterActive%d=\"%s\"\n", index + 1, bActive ? "on" : "off");
1135 else
1136 RTPrintf("Active: %s\n", bActive ? "yes" : "no");
1137
1138 Bstr bstr;
1139 CHECK_ERROR_RET (DevPtr, COMGETTER (Name) (bstr.asOutParam()), rc);
1140 if (details == VMINFO_MACHINEREADABLE)
1141 RTPrintf("USBFilterName%d=\"%lS\"\n", index + 1, bstr.raw());
1142 else
1143 RTPrintf("Name: %lS\n", bstr.raw());
1144 CHECK_ERROR_RET (DevPtr, COMGETTER (VendorId) (bstr.asOutParam()), rc);
1145 if (details == VMINFO_MACHINEREADABLE)
1146 RTPrintf("USBFilterVendorId%d=\"%lS\"\n", index + 1, bstr.raw());
1147 else
1148 RTPrintf("VendorId: %lS\n", bstr.raw());
1149 CHECK_ERROR_RET (DevPtr, COMGETTER (ProductId) (bstr.asOutParam()), rc);
1150 if (details == VMINFO_MACHINEREADABLE)
1151 RTPrintf("USBFilterProductId%d=\"%lS\"\n", index + 1, bstr.raw());
1152 else
1153 RTPrintf("ProductId: %lS\n", bstr.raw());
1154 CHECK_ERROR_RET (DevPtr, COMGETTER (Revision) (bstr.asOutParam()), rc);
1155 if (details == VMINFO_MACHINEREADABLE)
1156 RTPrintf("USBFilterRevision%d=\"%lS\"\n", index + 1, bstr.raw());
1157 else
1158 RTPrintf("Revision: %lS\n", bstr.raw());
1159 CHECK_ERROR_RET (DevPtr, COMGETTER (Manufacturer) (bstr.asOutParam()), rc);
1160 if (details == VMINFO_MACHINEREADABLE)
1161 RTPrintf("USBFilterManufacturer%d=\"%lS\"\n", index + 1, bstr.raw());
1162 else
1163 RTPrintf("Manufacturer: %lS\n", bstr.raw());
1164 CHECK_ERROR_RET (DevPtr, COMGETTER (Product) (bstr.asOutParam()), rc);
1165 if (details == VMINFO_MACHINEREADABLE)
1166 RTPrintf("USBFilterProduct%d=\"%lS\"\n", index + 1, bstr.raw());
1167 else
1168 RTPrintf("Product: %lS\n", bstr.raw());
1169 CHECK_ERROR_RET (DevPtr, COMGETTER (Remote) (bstr.asOutParam()), rc);
1170 if (details == VMINFO_MACHINEREADABLE)
1171 RTPrintf("USBFilterRemote%d=\"%lS\"\n", index + 1, bstr.raw());
1172 else
1173 RTPrintf("Remote: %lS\n", bstr.raw());
1174 CHECK_ERROR_RET (DevPtr, COMGETTER (SerialNumber) (bstr.asOutParam()), rc);
1175 if (details == VMINFO_MACHINEREADABLE)
1176 RTPrintf("USBFilterSerialNumber%d=\"%lS\"\n", index + 1, bstr.raw());
1177 else
1178 RTPrintf("Serial Number: %lS\n", bstr.raw());
1179 if (details != VMINFO_MACHINEREADABLE)
1180 {
1181 ULONG fMaskedIfs;
1182 CHECK_ERROR_RET (DevPtr, COMGETTER (MaskedInterfaces) (&fMaskedIfs), rc);
1183 if (fMaskedIfs)
1184 RTPrintf("Masked Interfaces: 0x%08x\n", fMaskedIfs);
1185 RTPrintf("\n");
1186 }
1187
1188 rc = Enum->HasMore (&fMore);
1189 ASSERT_RET (SUCCEEDED (rc), rc);
1190
1191 index ++;
1192 }
1193
1194 if (console)
1195 {
1196 index = 0;
1197 /* scope */
1198 {
1199 if (details != VMINFO_MACHINEREADABLE)
1200 RTPrintf("Available remote USB devices:\n\n");
1201
1202 ComPtr<IHostUSBDeviceCollection> coll;
1203 CHECK_ERROR_RET (console, COMGETTER(RemoteUSBDevices) (coll.asOutParam()), rc);
1204
1205 ComPtr <IHostUSBDeviceEnumerator> en;
1206 CHECK_ERROR_RET (coll, Enumerate (en.asOutParam()), rc);
1207
1208 BOOL more = FALSE;
1209 rc = en->HasMore (&more);
1210 ASSERT_RET (SUCCEEDED (rc), rc);
1211
1212 if (!more)
1213 {
1214 if (details != VMINFO_MACHINEREADABLE)
1215 RTPrintf("<none>\n\n");
1216 }
1217 else
1218 while (more)
1219 {
1220 ComPtr <IHostUSBDevice> dev;
1221 rc = en->GetNext (dev.asOutParam());
1222 ASSERT_RET (SUCCEEDED (rc), rc);
1223
1224 /* Query info. */
1225 Guid id;
1226 CHECK_ERROR_RET (dev, COMGETTER(Id)(id.asOutParam()), rc);
1227 USHORT usVendorId;
1228 CHECK_ERROR_RET (dev, COMGETTER(VendorId)(&usVendorId), rc);
1229 USHORT usProductId;
1230 CHECK_ERROR_RET (dev, COMGETTER(ProductId)(&usProductId), rc);
1231 USHORT bcdRevision;
1232 CHECK_ERROR_RET (dev, COMGETTER(Revision)(&bcdRevision), rc);
1233
1234 if (details == VMINFO_MACHINEREADABLE)
1235 RTPrintf("USBRemoteUUID%d=\"%S\"\n"
1236 "USBRemoteVendorId%d=\"%#06x\"\n"
1237 "USBRemoteProductId%d=\"%#06x\"\n"
1238 "USBRemoteRevision%d=\"%#04x%02x\"\n",
1239 index + 1, id.toString().raw(),
1240 index + 1, usVendorId,
1241 index + 1, usProductId,
1242 index + 1, bcdRevision >> 8, bcdRevision & 0xff);
1243 else
1244 RTPrintf("UUID: %S\n"
1245 "VendorId: 0x%04x (%04X)\n"
1246 "ProductId: 0x%04x (%04X)\n"
1247 "Revision: %u.%u (%02u%02u)\n",
1248 id.toString().raw(),
1249 usVendorId, usVendorId, usProductId, usProductId,
1250 bcdRevision >> 8, bcdRevision & 0xff,
1251 bcdRevision >> 8, bcdRevision & 0xff);
1252
1253 /* optional stuff. */
1254 Bstr bstr;
1255 CHECK_ERROR_RET (dev, COMGETTER(Manufacturer)(bstr.asOutParam()), rc);
1256 if (!bstr.isEmpty())
1257 {
1258 if (details == VMINFO_MACHINEREADABLE)
1259 RTPrintf("USBRemoteManufacturer%d=\"%lS\"\n", index + 1, bstr.raw());
1260 else
1261 RTPrintf("Manufacturer: %lS\n", bstr.raw());
1262 }
1263 CHECK_ERROR_RET (dev, COMGETTER(Product)(bstr.asOutParam()), rc);
1264 if (!bstr.isEmpty())
1265 {
1266 if (details == VMINFO_MACHINEREADABLE)
1267 RTPrintf("USBRemoteProduct%d=\"%lS\"\n", index + 1, bstr.raw());
1268 else
1269 RTPrintf("Product: %lS\n", bstr.raw());
1270 }
1271 CHECK_ERROR_RET (dev, COMGETTER(SerialNumber)(bstr.asOutParam()), rc);
1272 if (!bstr.isEmpty())
1273 {
1274 if (details == VMINFO_MACHINEREADABLE)
1275 RTPrintf("USBRemoteSerialNumber%d=\"%lS\"\n", index + 1, bstr.raw());
1276 else
1277 RTPrintf("SerialNumber: %lS\n", bstr.raw());
1278 }
1279 CHECK_ERROR_RET (dev, COMGETTER(Address)(bstr.asOutParam()), rc);
1280 if (!bstr.isEmpty())
1281 {
1282 if (details == VMINFO_MACHINEREADABLE)
1283 RTPrintf("USBRemoteAddress%d=\"%lS\"\n", index + 1, bstr.raw());
1284 else
1285 RTPrintf("Address: %lS\n", bstr.raw());
1286 }
1287
1288 if (details != VMINFO_MACHINEREADABLE)
1289 RTPrintf("\n");
1290
1291 rc = en->HasMore (&more);
1292 ASSERT_RET (SUCCEEDED (rc), rc);
1293
1294 index ++;
1295 }
1296 }
1297
1298 index = 0;
1299 /* scope */
1300 {
1301 if (details != VMINFO_MACHINEREADABLE)
1302 RTPrintf ("Currently Attached USB Devices:\n\n");
1303
1304 ComPtr <IUSBDeviceCollection> coll;
1305 CHECK_ERROR_RET (console, COMGETTER(USBDevices) (coll.asOutParam()), rc);
1306
1307 ComPtr <IUSBDeviceEnumerator> en;
1308 CHECK_ERROR_RET (coll, Enumerate (en.asOutParam()), rc);
1309
1310 BOOL more = FALSE;
1311 rc = en->HasMore (&more);
1312 ASSERT_RET (SUCCEEDED (rc), rc);
1313
1314 if (!more)
1315 {
1316 if (details != VMINFO_MACHINEREADABLE)
1317 RTPrintf("<none>\n\n");
1318 }
1319 else
1320 while (more)
1321 {
1322 ComPtr <IUSBDevice> dev;
1323 rc = en->GetNext (dev.asOutParam());
1324 ASSERT_RET (SUCCEEDED (rc), rc);
1325
1326 /* Query info. */
1327 Guid id;
1328 CHECK_ERROR_RET (dev, COMGETTER(Id)(id.asOutParam()), rc);
1329 USHORT usVendorId;
1330 CHECK_ERROR_RET (dev, COMGETTER(VendorId)(&usVendorId), rc);
1331 USHORT usProductId;
1332 CHECK_ERROR_RET (dev, COMGETTER(ProductId)(&usProductId), rc);
1333 USHORT bcdRevision;
1334 CHECK_ERROR_RET (dev, COMGETTER(Revision)(&bcdRevision), rc);
1335
1336 if (details == VMINFO_MACHINEREADABLE)
1337 RTPrintf("USBAttachedUUID%d=\"%S\"\n"
1338 "USBAttachedVendorId%d=\"%#06x\"\n"
1339 "USBAttachedProductId%d=\"%#06x\"\n"
1340 "USBAttachedRevision%d=\"%#04x%02x\"\n",
1341 index + 1, id.toString().raw(),
1342 index + 1, usVendorId,
1343 index + 1, usProductId,
1344 index + 1, bcdRevision >> 8, bcdRevision & 0xff);
1345 else
1346 RTPrintf("UUID: %S\n"
1347 "VendorId: 0x%04x (%04X)\n"
1348 "ProductId: 0x%04x (%04X)\n"
1349 "Revision: %u.%u (%02u%02u)\n",
1350 id.toString().raw(),
1351 usVendorId, usVendorId, usProductId, usProductId,
1352 bcdRevision >> 8, bcdRevision & 0xff,
1353 bcdRevision >> 8, bcdRevision & 0xff);
1354
1355 /* optional stuff. */
1356 Bstr bstr;
1357 CHECK_ERROR_RET (dev, COMGETTER(Manufacturer)(bstr.asOutParam()), rc);
1358 if (!bstr.isEmpty())
1359 {
1360 if (details == VMINFO_MACHINEREADABLE)
1361 RTPrintf("USBAttachedManufacturer%d=\"%lS\"\n", index + 1, bstr.raw());
1362 else
1363 RTPrintf("Manufacturer: %lS\n", bstr.raw());
1364 }
1365 CHECK_ERROR_RET (dev, COMGETTER(Product)(bstr.asOutParam()), rc);
1366 if (!bstr.isEmpty())
1367 {
1368 if (details == VMINFO_MACHINEREADABLE)
1369 RTPrintf("USBAttachedProduct%d=\"%lS\"\n", index + 1, bstr.raw());
1370 else
1371 RTPrintf("Product: %lS\n", bstr.raw());
1372 }
1373 CHECK_ERROR_RET (dev, COMGETTER(SerialNumber)(bstr.asOutParam()), rc);
1374 if (!bstr.isEmpty())
1375 {
1376 if (details == VMINFO_MACHINEREADABLE)
1377 RTPrintf("USBAttachedSerialNumber%d=\"%lS\"\n", index + 1, bstr.raw());
1378 else
1379 RTPrintf("SerialNumber: %lS\n", bstr.raw());
1380 }
1381 CHECK_ERROR_RET (dev, COMGETTER(Address)(bstr.asOutParam()), rc);
1382 if (!bstr.isEmpty())
1383 {
1384 if (details == VMINFO_MACHINEREADABLE)
1385 RTPrintf("USBAttachedAddress%d=\"%lS\"\n", index + 1, bstr.raw());
1386 else
1387 RTPrintf("Address: %lS\n", bstr.raw());
1388 }
1389
1390 if (details != VMINFO_MACHINEREADABLE)
1391 RTPrintf("\n");
1392
1393 rc = en->HasMore (&more);
1394 ASSERT_RET (SUCCEEDED (rc), rc);
1395
1396 index ++;
1397 }
1398 }
1399 }
1400 } /* USB */
1401
1402 /*
1403 * Shared folders
1404 */
1405 if (details != VMINFO_MACHINEREADABLE)
1406 RTPrintf("Shared folders: ");
1407 uint32_t numSharedFolders = 0;
1408#if 0 // not yet implemented
1409 /* globally shared folders first */
1410 {
1411 ComPtr<ISharedFolderCollection> sfColl;
1412 ComPtr<ISharedFolderEnumerator> sfEnum;
1413 CHECK_ERROR_RET(virtualBox, COMGETTER(SharedFolders)(sfColl.asOutParam()), rc);
1414 CHECK_ERROR_RET(sfColl, Enumerate(sfEnum.asOutParam()), rc);
1415 BOOL fMore;
1416 sfEnum->HasMore(&fMore);
1417 while (fMore)
1418 {
1419 ComPtr<ISharedFolder> sf;
1420 CHECK_ERROR_RET(sfEnum, GetNext(sf.asOutParam()), rc);
1421 Bstr name, hostPath;
1422 sf->COMGETTER(Name)(name.asOutParam());
1423 sf->COMGETTER(HostPath)(hostPath.asOutParam());
1424 RTPrintf("Name: '%lS', Host path: '%lS' (global mapping)\n", name.raw(), hostPath.raw());
1425 ++numSharedFolders;
1426 CHECK_ERROR_RET(sfEnum, HasMore(&fMore), rc);
1427 }
1428 }
1429#endif
1430 /* now VM mappings */
1431 {
1432 ComPtr<ISharedFolderCollection> sfColl;
1433 ComPtr<ISharedFolderEnumerator> sfEnum;
1434 CHECK_ERROR_RET(machine, COMGETTER(SharedFolders)(sfColl.asOutParam()), rc);
1435 CHECK_ERROR_RET(sfColl, Enumerate(sfEnum.asOutParam()), rc);
1436 ULONG index = 0;
1437 BOOL fMore;
1438 sfEnum->HasMore(&fMore);
1439 while (fMore)
1440 {
1441 ComPtr<ISharedFolder> sf;
1442 CHECK_ERROR_RET(sfEnum, GetNext(sf.asOutParam()), rc);
1443 Bstr name, hostPath;
1444 BOOL writable;
1445 sf->COMGETTER(Name)(name.asOutParam());
1446 sf->COMGETTER(HostPath)(hostPath.asOutParam());
1447 sf->COMGETTER(Writable)(&writable);
1448 if (!numSharedFolders && details != VMINFO_MACHINEREADABLE)
1449 RTPrintf("\n\n");
1450 if (details == VMINFO_MACHINEREADABLE)
1451 {
1452 RTPrintf("SharedFolderNameMachineMapping%d=\"%lS\"\n", index + 1,
1453 name.raw());
1454 RTPrintf("SharedFolderPathMachineMapping%d=\"%lS\"\n", index + 1,
1455 hostPath.raw());
1456 }
1457 else
1458 RTPrintf("Name: '%lS', Host path: '%lS' (machine mapping), %s\n",
1459 name.raw(), hostPath.raw(), writable ? "writable" : "readonly");
1460 ++numSharedFolders;
1461 CHECK_ERROR_RET(sfEnum, HasMore(&fMore), rc);
1462 }
1463 }
1464 /* transient mappings */
1465 if (console)
1466 {
1467 ComPtr<ISharedFolderCollection> sfColl;
1468 ComPtr<ISharedFolderEnumerator> sfEnum;
1469 CHECK_ERROR_RET(console, COMGETTER(SharedFolders)(sfColl.asOutParam()), rc);
1470 CHECK_ERROR_RET(sfColl, Enumerate(sfEnum.asOutParam()), rc);
1471 ULONG index = 0;
1472 BOOL fMore;
1473 sfEnum->HasMore(&fMore);
1474 while (fMore)
1475 {
1476 ComPtr<ISharedFolder> sf;
1477 CHECK_ERROR_RET(sfEnum, GetNext(sf.asOutParam()), rc);
1478 Bstr name, hostPath;
1479 sf->COMGETTER(Name)(name.asOutParam());
1480 sf->COMGETTER(HostPath)(hostPath.asOutParam());
1481 if (!numSharedFolders && details != VMINFO_MACHINEREADABLE)
1482 RTPrintf("\n\n");
1483 if (details == VMINFO_MACHINEREADABLE)
1484 {
1485 RTPrintf("SharedFolderNameTransientMapping%d=\"%lS\"\n", index + 1,
1486 name.raw());
1487 RTPrintf("SharedFolderPathTransientMapping%d=\"%lS\"\n", index + 1,
1488 hostPath.raw());
1489 }
1490 else
1491 RTPrintf("Name: '%lS', Host path: '%lS' (transient mapping)\n", name.raw(), hostPath.raw());
1492 ++numSharedFolders;
1493 CHECK_ERROR_RET(sfEnum, HasMore(&fMore), rc);
1494 }
1495 }
1496 if (!numSharedFolders && details != VMINFO_MACHINEREADABLE)
1497 RTPrintf("<none>\n");
1498 if (details != VMINFO_MACHINEREADABLE)
1499 RTPrintf("\n");
1500
1501 if (console)
1502 {
1503 /*
1504 * Live VRDP info.
1505 */
1506 ComPtr<IRemoteDisplayInfo> remoteDisplayInfo;
1507 CHECK_ERROR_RET(console, COMGETTER(RemoteDisplayInfo)(remoteDisplayInfo.asOutParam()), rc);
1508 BOOL Active;
1509 ULONG NumberOfClients;
1510 LONG64 BeginTime;
1511 LONG64 EndTime;
1512 ULONG64 BytesSent;
1513 ULONG64 BytesSentTotal;
1514 ULONG64 BytesReceived;
1515 ULONG64 BytesReceivedTotal;
1516 Bstr User;
1517 Bstr Domain;
1518 Bstr ClientName;
1519 Bstr ClientIP;
1520 ULONG ClientVersion;
1521 ULONG EncryptionStyle;
1522
1523 CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(Active) (&Active), rc);
1524 CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(NumberOfClients) (&NumberOfClients), rc);
1525 CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(BeginTime) (&BeginTime), rc);
1526 CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(EndTime) (&EndTime), rc);
1527 CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(BytesSent) (&BytesSent), rc);
1528 CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(BytesSentTotal) (&BytesSentTotal), rc);
1529 CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(BytesReceived) (&BytesReceived), rc);
1530 CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(BytesReceivedTotal) (&BytesReceivedTotal), rc);
1531 CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(User) (User.asOutParam ()), rc);
1532 CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(Domain) (Domain.asOutParam ()), rc);
1533 CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(ClientName) (ClientName.asOutParam ()), rc);
1534 CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(ClientIP) (ClientIP.asOutParam ()), rc);
1535 CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(ClientVersion) (&ClientVersion), rc);
1536 CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(EncryptionStyle) (&EncryptionStyle), rc);
1537
1538 if (details == VMINFO_MACHINEREADABLE)
1539 RTPrintf("VRDPActiveConnection=\"%s\"\n", Active ? "on": "off");
1540 else
1541 RTPrintf("VRDP Connection: %s\n", Active? "active": "not active");
1542
1543 if (details == VMINFO_MACHINEREADABLE)
1544 RTPrintf("VRDPClients=%d\n", NumberOfClients);
1545 else
1546 RTPrintf("Clients so far: %d\n", NumberOfClients);
1547
1548 if (NumberOfClients > 0)
1549 {
1550 char timestr[128];
1551
1552 if (Active)
1553 {
1554 makeTimeStr (timestr, sizeof (timestr), BeginTime);
1555 if (details == VMINFO_MACHINEREADABLE)
1556 RTPrintf("VRDPStartTime=\"%s\"\n", timestr);
1557 else
1558 RTPrintf("Start time: %s\n", timestr);
1559 }
1560 else
1561 {
1562 makeTimeStr (timestr, sizeof (timestr), BeginTime);
1563 if (details == VMINFO_MACHINEREADABLE)
1564 RTPrintf("VRDPLastStartTime=\"%s\"\n", timestr);
1565 else
1566 RTPrintf("Last started: %s\n", timestr);
1567 makeTimeStr (timestr, sizeof (timestr), EndTime);
1568 if (details == VMINFO_MACHINEREADABLE)
1569 RTPrintf("VRDPLastEndTime=\"%s\"\n", timestr);
1570 else
1571 RTPrintf("Last ended: %s\n", timestr);
1572 }
1573
1574 uint64_t ThroughputSend = 0;
1575 uint64_t ThroughputReceive = 0;
1576 if (EndTime != BeginTime)
1577 {
1578 ThroughputSend = (BytesSent * 1000) / (EndTime - BeginTime);
1579 ThroughputReceive = (BytesReceived * 1000) / (EndTime - BeginTime);
1580 }
1581
1582 if (details == VMINFO_MACHINEREADABLE)
1583 {
1584 RTPrintf("VRDPBytesSent=%llu\n", BytesSent);
1585 RTPrintf("VRDPThroughputSend=%llu\n", ThroughputSend);
1586 RTPrintf("VRDPBytesSentTotal=%llu\n", BytesSentTotal);
1587
1588 RTPrintf("VRDPBytesReceived=%llu\n", BytesReceived);
1589 RTPrintf("VRDPThroughputReceive=%llu\n", ThroughputReceive);
1590 RTPrintf("VRDPBytesReceivedTotal=%llu\n", BytesReceivedTotal);
1591 }
1592 else
1593 {
1594 RTPrintf("Sent: %llu Bytes\n", BytesSent);
1595 RTPrintf("Average speed: %llu B/s\n", ThroughputSend);
1596 RTPrintf("Sent total: %llu Bytes\n", BytesSentTotal);
1597
1598 RTPrintf("Received: %llu Bytes\n", BytesReceived);
1599 RTPrintf("Speed: %llu B/s\n", ThroughputReceive);
1600 RTPrintf("Received total: %llu Bytes\n", BytesReceivedTotal);
1601 }
1602
1603 if (Active)
1604 {
1605 if (details == VMINFO_MACHINEREADABLE)
1606 {
1607 RTPrintf("VRDPUserName=\"%lS\"\n", User.raw());
1608 RTPrintf("VRDPDomain=\"%lS\"\n", Domain.raw());
1609 RTPrintf("VRDPClientName=\"%lS\"\n", ClientName.raw());
1610 RTPrintf("VRDPClientIP=\"%lS\"\n", ClientIP.raw());
1611 RTPrintf("VRDPClientVersion=%d\n", ClientVersion);
1612 RTPrintf("VRDPEncryption=\"%s\"\n", EncryptionStyle == 0? "RDP4": "RDP5 (X.509)");
1613 }
1614 else
1615 {
1616 RTPrintf("User name: %lS\n", User.raw());
1617 RTPrintf("Domain: %lS\n", Domain.raw());
1618 RTPrintf("Client name: %lS\n", ClientName.raw());
1619 RTPrintf("Client IP: %lS\n", ClientIP.raw());
1620 RTPrintf("Client version: %d\n", ClientVersion);
1621 RTPrintf("Encryption: %s\n", EncryptionStyle == 0? "RDP4": "RDP5 (X.509)");
1622 }
1623 }
1624 }
1625
1626 if (details != VMINFO_MACHINEREADABLE)
1627 RTPrintf("\n");
1628 }
1629
1630 if ( details == VMINFO_STANDARD
1631 || details == VMINFO_FULL
1632 || details == VMINFO_MACHINEREADABLE)
1633 {
1634 Bstr description;
1635 machine->COMGETTER(Description)(description.asOutParam());
1636 if (!description.isEmpty())
1637 {
1638 if (details == VMINFO_MACHINEREADABLE)
1639 RTPrintf("description=\"%lS\"\n", description.raw());
1640 else
1641 RTPrintf("Description:\n%lS\n", description.raw());
1642 }
1643 }
1644
1645 ULONG guestVal;
1646 if (details != VMINFO_MACHINEREADABLE)
1647 RTPrintf("Guest:\n\n");
1648
1649#ifdef VBOX_WITH_MEM_BALLOONING
1650 rc = machine->COMGETTER(MemoryBalloonSize)(&guestVal);
1651 if (SUCCEEDED(rc))
1652 {
1653 if (details == VMINFO_MACHINEREADABLE)
1654 RTPrintf("GuestMemoryBalloon=%d\n", guestVal);
1655 else
1656 RTPrintf("Configured memory balloon size: %d MB\n", guestVal);
1657 }
1658#endif
1659 rc = machine->COMGETTER(StatisticsUpdateInterval)(&guestVal);
1660 if (SUCCEEDED(rc))
1661 {
1662 if (details == VMINFO_MACHINEREADABLE)
1663 RTPrintf("GuestStatisticsUpdateInterval=%d\n", guestVal);
1664 else
1665 {
1666 if (guestVal == 0)
1667 RTPrintf("Statistics update: disabled\n");
1668 else
1669 RTPrintf("Statistics update interval: %d seconds\n", guestVal);
1670 }
1671 }
1672 if (details != VMINFO_MACHINEREADABLE)
1673 RTPrintf("\n");
1674
1675 if ( console
1676 && ( details == VMINFO_STATISTICS
1677 || details == VMINFO_FULL
1678 || details == VMINFO_MACHINEREADABLE))
1679 {
1680 ComPtr <IGuest> guest;
1681
1682 rc = console->COMGETTER(Guest)(guest.asOutParam());
1683 if (SUCCEEDED(rc))
1684 {
1685 ULONG statVal;
1686
1687 rc = guest->GetStatistic(0, GuestStatisticType_SampleNumber, &statVal);
1688 if (details == VMINFO_MACHINEREADABLE)
1689 RTPrintf("StatGuestSample=%d\n", statVal);
1690 else
1691 RTPrintf("Guest statistics for sample %d:\n\n", statVal);
1692
1693 rc = guest->GetStatistic(0, GuestStatisticType_CPULoad_Idle, &statVal);
1694 if (SUCCEEDED(rc))
1695 {
1696 if (details == VMINFO_MACHINEREADABLE)
1697 RTPrintf("StatGuestLoadIdleCPU%d=%d\n", 0, statVal);
1698 else
1699 RTPrintf("CPU%d: CPU Load Idle %-3d%%\n", 0, statVal);
1700 }
1701
1702 rc = guest->GetStatistic(0, GuestStatisticType_CPULoad_Kernel, &statVal);
1703 if (SUCCEEDED(rc))
1704 {
1705 if (details == VMINFO_MACHINEREADABLE)
1706 RTPrintf("StatGuestLoadKernelCPU%d=%d\n", 0, statVal);
1707 else
1708 RTPrintf("CPU%d: CPU Load Kernel %-3d%%\n", 0, statVal);
1709 }
1710
1711 rc = guest->GetStatistic(0, GuestStatisticType_CPULoad_User, &statVal);
1712 if (SUCCEEDED(rc))
1713 {
1714 if (details == VMINFO_MACHINEREADABLE)
1715 RTPrintf("StatGuestLoadUserCPU%d=%d\n", 0, statVal);
1716 else
1717 RTPrintf("CPU%d: CPU Load User %-3d%%\n", 0, statVal);
1718 }
1719
1720 rc = guest->GetStatistic(0, GuestStatisticType_Threads, &statVal);
1721 if (SUCCEEDED(rc))
1722 {
1723 if (details == VMINFO_MACHINEREADABLE)
1724 RTPrintf("StatGuestThreadsCPU%d=%d\n", 0, statVal);
1725 else
1726 RTPrintf("CPU%d: Threads %d\n", 0, statVal);
1727 }
1728
1729 rc = guest->GetStatistic(0, GuestStatisticType_Processes, &statVal);
1730 if (SUCCEEDED(rc))
1731 {
1732 if (details == VMINFO_MACHINEREADABLE)
1733 RTPrintf("StatGuestProcessesCPU%d=%d\n", 0, statVal);
1734 else
1735 RTPrintf("CPU%d: Processes %d\n", 0, statVal);
1736 }
1737
1738 rc = guest->GetStatistic(0, GuestStatisticType_Handles, &statVal);
1739 if (SUCCEEDED(rc))
1740 {
1741 if (details == VMINFO_MACHINEREADABLE)
1742 RTPrintf("StatGuestHandlesCPU%d=%d\n", 0, statVal);
1743 else
1744 RTPrintf("CPU%d: Handles %d\n", 0, statVal);
1745 }
1746
1747 rc = guest->GetStatistic(0, GuestStatisticType_MemoryLoad, &statVal);
1748 if (SUCCEEDED(rc))
1749 {
1750 if (details == VMINFO_MACHINEREADABLE)
1751 RTPrintf("StatGuestMemoryLoadCPU%d=%d\n", 0, statVal);
1752 else
1753 RTPrintf("CPU%d: Memory Load %d%%\n", 0, statVal);
1754 }
1755
1756 rc = guest->GetStatistic(0, GuestStatisticType_PhysMemTotal, &statVal);
1757 if (SUCCEEDED(rc))
1758 {
1759 if (details == VMINFO_MACHINEREADABLE)
1760 RTPrintf("StatGuestMemoryTotalPhysCPU%d=%d\n", 0, statVal);
1761 else
1762 RTPrintf("CPU%d: Total physical memory %-4d MB\n", 0, statVal);
1763 }
1764
1765 rc = guest->GetStatistic(0, GuestStatisticType_PhysMemAvailable, &statVal);
1766 if (SUCCEEDED(rc))
1767 {
1768 if (details == VMINFO_MACHINEREADABLE)
1769 RTPrintf("StatGuestMemoryFreePhysCPU%d=%d\n", 0, statVal);
1770 else
1771 RTPrintf("CPU%d: Free physical memory %-4d MB\n", 0, statVal);
1772 }
1773
1774#ifdef VBOX_WITH_MEM_BALLOONING
1775 rc = guest->GetStatistic(0, GuestStatisticType_PhysMemBalloon, &statVal);
1776 if (SUCCEEDED(rc))
1777 {
1778 if (details == VMINFO_MACHINEREADABLE)
1779 RTPrintf("StatGuestMemoryBalloonCPU%d=%d\n", 0, statVal);
1780 else
1781 RTPrintf("CPU%d: Memory balloon size %-4d MB\n", 0, statVal);
1782 }
1783#endif
1784 rc = guest->GetStatistic(0, GuestStatisticType_MemCommitTotal, &statVal);
1785 if (SUCCEEDED(rc))
1786 {
1787 if (details == VMINFO_MACHINEREADABLE)
1788 RTPrintf("StatGuestMemoryCommittedCPU%d=%d\n", 0, statVal);
1789 else
1790 RTPrintf("CPU%d: Committed memory %-4d MB\n", 0, statVal);
1791 }
1792
1793 rc = guest->GetStatistic(0, GuestStatisticType_MemKernelTotal, &statVal);
1794 if (SUCCEEDED(rc))
1795 {
1796 if (details == VMINFO_MACHINEREADABLE)
1797 RTPrintf("StatGuestMemoryTotalKernelCPU%d=%d\n", 0, statVal);
1798 else
1799 RTPrintf("CPU%d: Total kernel memory %-4d MB\n", 0, statVal);
1800 }
1801
1802 rc = guest->GetStatistic(0, GuestStatisticType_MemKernelPaged, &statVal);
1803 if (SUCCEEDED(rc))
1804 {
1805 if (details == VMINFO_MACHINEREADABLE)
1806 RTPrintf("StatGuestMemoryPagedKernelCPU%d=%d\n", 0, statVal);
1807 else
1808 RTPrintf("CPU%d: Paged kernel memory %-4d MB\n", 0, statVal);
1809 }
1810
1811 rc = guest->GetStatistic(0, GuestStatisticType_MemKernelNonpaged, &statVal);
1812 if (SUCCEEDED(rc))
1813 {
1814 if (details == VMINFO_MACHINEREADABLE)
1815 RTPrintf("StatGuestMemoryNonpagedKernelCPU%d=%d\n", 0, statVal);
1816 else
1817 RTPrintf("CPU%d: Nonpaged kernel memory %-4d MB\n", 0, statVal);
1818 }
1819
1820 rc = guest->GetStatistic(0, GuestStatisticType_MemSystemCache, &statVal);
1821 if (SUCCEEDED(rc))
1822 {
1823 if (details == VMINFO_MACHINEREADABLE)
1824 RTPrintf("StatGuestSystemCacheSizeCPU%d=%d\n", 0, statVal);
1825 else
1826 RTPrintf("CPU%d: System cache size %-4d MB\n", 0, statVal);
1827 }
1828
1829 rc = guest->GetStatistic(0, GuestStatisticType_PageFileSize, &statVal);
1830 if (SUCCEEDED(rc))
1831 {
1832 if (details == VMINFO_MACHINEREADABLE)
1833 RTPrintf("StatGuestPageFileSizeCPU%d=%d\n", 0, statVal);
1834 else
1835 RTPrintf("CPU%d: Page file size %-4d MB\n", 0, statVal);
1836 }
1837
1838 RTPrintf("\n");
1839 }
1840 else
1841 {
1842 if (details != VMINFO_MACHINEREADABLE)
1843 {
1844 RTPrintf("[!] FAILED calling console->getGuest at line %d!\n", __LINE__);
1845 PRINT_RC_MESSAGE(rc);
1846 }
1847 }
1848 }
1849
1850 /*
1851 * snapshots
1852 */
1853 ComPtr<ISnapshot> snapshot;
1854 rc = machine->GetSnapshot(Guid(), snapshot.asOutParam());
1855 if (SUCCEEDED(rc) && snapshot)
1856 {
1857 if (details != VMINFO_MACHINEREADABLE)
1858 RTPrintf("Snapshots:\n\n");
1859 showSnapshots(snapshot, details);
1860 }
1861
1862 if (details != VMINFO_MACHINEREADABLE)
1863 RTPrintf("\n");
1864 return S_OK;
1865}
1866
1867int handleShowVMInfo(int argc, char *argv[],
1868 ComPtr<IVirtualBox> virtualBox, ComPtr<ISession> session)
1869{
1870 HRESULT rc;
1871
1872 /* at least one option: the UUID or name of the VM */
1873 if (argc < 1)
1874 return errorSyntax(USAGE_SHOWVMINFO, "Incorrect number of parameters");
1875
1876 /* try to find the given machine */
1877 ComPtr <IMachine> machine;
1878 Guid uuid (argv[0]);
1879 if (!uuid.isEmpty())
1880 {
1881 CHECK_ERROR (virtualBox, GetMachine (uuid, machine.asOutParam()));
1882 }
1883 else
1884 {
1885 CHECK_ERROR (virtualBox, FindMachine (Bstr(argv[0]), machine.asOutParam()));
1886 if (SUCCEEDED (rc))
1887 machine->COMGETTER(Id) (uuid.asOutParam());
1888 }
1889 if (FAILED (rc))
1890 return 1;
1891
1892 /* 2nd option can be -details, -statistics or -argdump */
1893 VMINFO_DETAILS details = VMINFO_NONE;
1894 bool fDetails = false;
1895 bool fStatistics = false;
1896 bool fMachinereadable = false;
1897 for (int i=1;i<argc;i++)
1898 {
1899 if (!strcmp(argv[i], "-details"))
1900 fDetails = true;
1901 else
1902 if (!strcmp(argv[i], "-statistics"))
1903 fStatistics = true;
1904 if (!strcmp(argv[1], "-machinereadable"))
1905 fMachinereadable = true;
1906 }
1907 if (fMachinereadable)
1908 details = VMINFO_MACHINEREADABLE;
1909 else
1910 if (fDetails && fStatistics)
1911 details = VMINFO_FULL;
1912 else
1913 if (fDetails)
1914 details = VMINFO_STANDARD;
1915 else
1916 if (fStatistics)
1917 details = VMINFO_STATISTICS;
1918
1919 ComPtr <IConsole> console;
1920
1921 /* open an existing session for the VM */
1922 rc = virtualBox->OpenExistingSession (session, uuid);
1923 if (SUCCEEDED(rc))
1924 /* get the session machine */
1925 rc = session->COMGETTER(Machine)(machine.asOutParam());
1926 if (SUCCEEDED(rc))
1927 /* get the session console */
1928 rc = session->COMGETTER(Console)(console.asOutParam());
1929
1930 rc = showVMInfo (virtualBox, machine, console, details);
1931
1932 if (console)
1933 session->Close();
1934
1935 return SUCCEEDED (rc) ? 0 : 1;
1936}
1937
1938int handleList(int argc, char *argv[],
1939 ComPtr<IVirtualBox> virtualBox, ComPtr<ISession> session)
1940{
1941 HRESULT rc = S_OK;
1942
1943 /* exactly one option: the object */
1944 if (argc != 1)
1945 return errorSyntax(USAGE_LIST, "Incorrect number of parameters");
1946
1947 /* which object? */
1948 if (strcmp(argv[0], "vms") == 0)
1949 {
1950 /*
1951 * Get the list of all registered VMs
1952 */
1953 com::SafeIfaceArray <IMachine> machines;
1954 rc = virtualBox->COMGETTER(Machines2)(ComSafeArrayAsOutParam (machines));
1955 if (SUCCEEDED(rc))
1956 {
1957 /*
1958 * Iterate through the collection
1959 */
1960 for (size_t i = 0; i < machines.size(); ++ i)
1961 {
1962 if (machines [i])
1963 rc = showVMInfo(virtualBox, machines [i]);
1964 }
1965 }
1966 }
1967 else
1968 if (strcmp(argv[0], "runningvms") == 0)
1969 {
1970 /*
1971 * Get the list of all _running_ VMs
1972 */
1973 com::SafeIfaceArray <IMachine> machines;
1974 rc = virtualBox->COMGETTER(Machines2)(ComSafeArrayAsOutParam (machines));
1975 if (SUCCEEDED(rc))
1976 {
1977 /*
1978 * Iterate through the collection
1979 */
1980 for (size_t i = 0; i < machines.size(); ++ i)
1981 {
1982 if (machines [i])
1983 {
1984 MachineState_T machineState;
1985 rc = machines [i]->COMGETTER(State)(&machineState);
1986 if (SUCCEEDED(rc))
1987 {
1988 switch (machineState)
1989 {
1990 case MachineState_Running:
1991 case MachineState_Paused:
1992 {
1993 Guid uuid;
1994 rc = machines [i]->COMGETTER(Id) (uuid.asOutParam());
1995 if (SUCCEEDED(rc))
1996 RTPrintf ("%s\n", uuid.toString().raw());
1997 break;
1998 }
1999 }
2000 }
2001 }
2002 }
2003 }
2004 }
2005 else
2006 if (strcmp(argv[0], "ostypes") == 0)
2007 {
2008 ComPtr<IGuestOSTypeCollection> coll;
2009 ComPtr<IGuestOSTypeEnumerator> enumerator;
2010 CHECK_ERROR(virtualBox, COMGETTER(GuestOSTypes)(coll.asOutParam()));
2011 if (SUCCEEDED(rc) && coll)
2012 {
2013 CHECK_ERROR(coll, Enumerate(enumerator.asOutParam()));
2014 BOOL hasMore;
2015 while (SUCCEEDED(enumerator->HasMore(&hasMore)) && hasMore)
2016 {
2017 ComPtr<IGuestOSType> guestOS;
2018 CHECK_RC_BREAK(enumerator->GetNext(guestOS.asOutParam()));
2019 Bstr guestId;
2020 guestOS->COMGETTER(Id)(guestId.asOutParam());
2021 RTPrintf("ID: %lS\n", guestId.raw());
2022 Bstr guestDescription;
2023 guestOS->COMGETTER(Description)(guestDescription.asOutParam());
2024 RTPrintf("Description: %lS\n\n", guestDescription.raw());
2025 }
2026 }
2027 }
2028 else
2029 if (strcmp(argv[0], "hostdvds") == 0)
2030 {
2031 ComPtr<IHost> host;
2032 CHECK_ERROR(virtualBox, COMGETTER(Host)(host.asOutParam()));
2033 ComPtr<IHostDVDDriveCollection> coll;
2034 ComPtr<IHostDVDDriveEnumerator> enumerator;
2035 CHECK_ERROR(host, COMGETTER(DVDDrives)(coll.asOutParam()));
2036 if (SUCCEEDED(rc) && coll)
2037 {
2038 CHECK_ERROR(coll, Enumerate(enumerator.asOutParam()));
2039 BOOL hasMore;
2040 while (SUCCEEDED(enumerator->HasMore(&hasMore)) && hasMore)
2041 {
2042 ComPtr<IHostDVDDrive> dvdDrive;
2043 CHECK_RC_BREAK(enumerator->GetNext(dvdDrive.asOutParam()));
2044 Bstr name;
2045 dvdDrive->COMGETTER(Name)(name.asOutParam());
2046 RTPrintf("Name: %lS\n\n", name.raw());
2047 }
2048 }
2049 }
2050 else
2051 if (strcmp(argv[0], "hostfloppies") == 0)
2052 {
2053 ComPtr<IHost> host;
2054 CHECK_ERROR(virtualBox, COMGETTER(Host)(host.asOutParam()));
2055 ComPtr<IHostFloppyDriveCollection> coll;
2056 ComPtr<IHostFloppyDriveEnumerator> enumerator;
2057 CHECK_ERROR(host, COMGETTER(FloppyDrives)(coll.asOutParam()));
2058 if (SUCCEEDED(rc) && coll)
2059 {
2060 CHECK_ERROR(coll, Enumerate(enumerator.asOutParam()));
2061 BOOL hasMore;
2062 while (SUCCEEDED(enumerator->HasMore(&hasMore)) && hasMore)
2063 {
2064 ComPtr<IHostFloppyDrive> floppyDrive;
2065 CHECK_RC_BREAK(enumerator->GetNext(floppyDrive.asOutParam()));
2066 Bstr name;
2067 floppyDrive->COMGETTER(Name)(name.asOutParam());
2068 RTPrintf("Name: %lS\n\n", name.raw());
2069 }
2070 }
2071 }
2072 else
2073 if (strcmp(argv[0], "hostifs") == 0)
2074 {
2075 ComPtr<IHost> host;
2076 CHECK_ERROR(virtualBox, COMGETTER(Host)(host.asOutParam()));
2077 ComPtr<IHostNetworkInterfaceCollection> coll;
2078 ComPtr<IHostNetworkInterfaceEnumerator> enumerator;
2079 CHECK_ERROR(host, COMGETTER(NetworkInterfaces)(coll.asOutParam()));
2080 if (SUCCEEDED(rc) && coll)
2081 {
2082 CHECK_ERROR(coll, Enumerate(enumerator.asOutParam()));
2083 BOOL hasMore;
2084 while (SUCCEEDED(enumerator->HasMore(&hasMore)) && hasMore)
2085 {
2086 ComPtr<IHostNetworkInterface> networkInterface;
2087 CHECK_RC_BREAK(enumerator->GetNext(networkInterface.asOutParam()));
2088 Bstr interfaceName;
2089 networkInterface->COMGETTER(Name)(interfaceName.asOutParam());
2090 RTPrintf("Name: %lS\n", interfaceName.raw());
2091 Guid interfaceGuid;
2092 networkInterface->COMGETTER(Id)(interfaceGuid.asOutParam());
2093 RTPrintf("GUID: %lS\n\n", Bstr(interfaceGuid.toString()).raw());
2094 }
2095 }
2096 }
2097 else
2098 if (strcmp(argv[0], "hostinfo") == 0)
2099 {
2100 ComPtr<IHost> Host;
2101 CHECK_ERROR (virtualBox, COMGETTER(Host)(Host.asOutParam()));
2102
2103 RTPrintf("Host Information:\n\n");
2104
2105 LONG64 uTCTime = 0;
2106 CHECK_ERROR (Host, COMGETTER(UTCTime)(&uTCTime));
2107 RTTIMESPEC timeSpec;
2108 RTTimeSpecSetMilli(&timeSpec, uTCTime);
2109 char pszTime[30] = {0};
2110 RTTimeSpecToString(&timeSpec, pszTime, sizeof(pszTime));
2111 RTPrintf("Host time: %s\n", pszTime);
2112
2113 ULONG processorOnlineCount = 0;
2114 CHECK_ERROR (Host, COMGETTER(ProcessorOnlineCount)(&processorOnlineCount));
2115 RTPrintf("Processor online count: %lu\n", processorOnlineCount);
2116 ULONG processorCount = 0;
2117 CHECK_ERROR (Host, COMGETTER(ProcessorCount)(&processorCount));
2118 RTPrintf("Processor count: %lu\n", processorCount);
2119 ULONG processorSpeed = 0;
2120 Bstr processorDescription;
2121 for (ULONG i = 0; i < processorCount; i++)
2122 {
2123 CHECK_ERROR (Host, GetProcessorSpeed(i, &processorSpeed));
2124 if (processorSpeed)
2125 RTPrintf("Processor#%u speed: %lu MHz\n", i, processorSpeed);
2126 else
2127 RTPrintf("Processor#%u speed: unknown\n", i, processorSpeed);
2128 #if 0 /* not yet implemented in Main */
2129 CHECK_ERROR (Host, GetProcessorDescription(i, processorDescription.asOutParam()));
2130 RTPrintf("Processor#%u description: %lS\n", i, processorDescription.raw());
2131 #endif
2132 }
2133
2134 #if 0 /* not yet implemented in Main */
2135 ULONG memorySize = 0;
2136 CHECK_ERROR (Host, COMGETTER(MemorySize)(&memorySize));
2137 RTPrintf("Memory size: %lu MByte\n", memorySize);
2138
2139 ULONG memoryAvailable = 0;
2140 CHECK_ERROR (Host, COMGETTER(MemoryAvailable)(&memoryAvailable));
2141 RTPrintf("Memory available: %lu MByte\n", memoryAvailable);
2142
2143 Bstr operatingSystem;
2144 CHECK_ERROR (Host, COMGETTER(OperatingSystem)(operatingSystem.asOutParam()));
2145 RTPrintf("Operating system: %lS\n", operatingSystem.raw());
2146
2147 Bstr oSVersion;
2148 CHECK_ERROR (Host, COMGETTER(OSVersion)(oSVersion.asOutParam()));
2149 RTPrintf("Operating system version: %lS\n", oSVersion.raw());
2150 #endif
2151 }
2152 else
2153 if (strcmp(argv[0], "hddbackends") == 0)
2154 {
2155 ComPtr<ISystemProperties> systemProperties;
2156 CHECK_ERROR(virtualBox,
2157 COMGETTER(SystemProperties) (systemProperties.asOutParam()));
2158 com::SafeIfaceArray <IHardDiskFormat> hardDiskFormats;
2159 CHECK_ERROR(systemProperties,
2160 COMGETTER(HardDiskFormats) (ComSafeArrayAsOutParam (hardDiskFormats)));
2161
2162 RTPrintf("Supported hard disk backends:\n\n");
2163 for (size_t i = 0; i < hardDiskFormats.size(); ++ i)
2164 {
2165 /* General information */
2166 Bstr id;
2167 CHECK_ERROR(hardDiskFormats [i],
2168 COMGETTER(Id) (id.asOutParam()));
2169
2170 Bstr description;
2171 CHECK_ERROR(hardDiskFormats [i],
2172 COMGETTER(Id) (description.asOutParam()));
2173
2174 ULONG caps;
2175 CHECK_ERROR(hardDiskFormats [i],
2176 COMGETTER(Capabilities) (&caps));
2177
2178 RTPrintf("Backend %u: id='%ls' description='%ls' capabilities=%#06x extensions='",
2179 i, id.raw(), description.raw(), caps);
2180
2181 /* File extensions */
2182 com::SafeArray <BSTR> fileExtensions;
2183 CHECK_ERROR(hardDiskFormats [i],
2184 COMGETTER(FileExtensions) (ComSafeArrayAsOutParam (fileExtensions)));
2185 for (size_t a = 0; a < fileExtensions.size(); ++ a)
2186 {
2187 RTPrintf ("%ls", Bstr (fileExtensions [a]).raw());
2188 if (a != fileExtensions.size()-1)
2189 RTPrintf (",");
2190 }
2191 RTPrintf ("'");
2192
2193 /* Configuration keys */
2194 com::SafeArray <BSTR> propertyNames;
2195 com::SafeArray <BSTR> propertyDescriptions;
2196 com::SafeArray <DataType_T> propertyTypes;
2197 com::SafeArray <ULONG> propertyFlags;
2198 com::SafeArray <BSTR> propertyDefaults;
2199 CHECK_ERROR(hardDiskFormats [i],
2200 DescribeProperties (ComSafeArrayAsOutParam (propertyNames),
2201 ComSafeArrayAsOutParam (propertyDescriptions),
2202 ComSafeArrayAsOutParam (propertyTypes),
2203 ComSafeArrayAsOutParam (propertyFlags),
2204 ComSafeArrayAsOutParam (propertyDefaults)));
2205
2206 RTPrintf (" properties=(");
2207 if (propertyNames.size() > 0)
2208 {
2209 for (size_t a = 0; a < propertyNames.size(); ++ a)
2210 {
2211 RTPrintf ("\n name='%ls' desc='%ls' type=",
2212 Bstr (propertyNames [a]).raw(), Bstr (propertyDescriptions [a]).raw());
2213 switch (propertyTypes [a])
2214 {
2215 case DataType_Int32: RTPrintf ("int"); break;
2216 case DataType_Int8: RTPrintf ("byte"); break;
2217 case DataType_String: RTPrintf ("string"); break;
2218 }
2219 RTPrintf (" flags=%#04x", propertyFlags [a]);
2220 RTPrintf (" default='%ls'", Bstr (propertyDefaults [a]).raw());
2221 if (a != propertyNames.size()-1)
2222 RTPrintf (", ");
2223 }
2224 }
2225 RTPrintf (")\n");
2226 }
2227 }
2228 else
2229 if (strcmp(argv[0], "hdds") == 0)
2230 {
2231 com::SafeIfaceArray <IHardDisk2> hdds;
2232 CHECK_ERROR(virtualBox, COMGETTER(HardDisks2)(ComSafeArrayAsOutParam (hdds)));
2233 for (size_t i = 0; i < hdds.size(); ++ i)
2234 {
2235 ComPtr<IHardDisk2> hdd = hdds[i];
2236 Guid uuid;
2237 hdd->COMGETTER(Id)(uuid.asOutParam());
2238 RTPrintf("UUID: %s\n", uuid.toString().raw());
2239 Bstr format;
2240 hdd->COMGETTER(Format)(format.asOutParam());
2241 RTPrintf("Format: %lS\n", format.raw());
2242 Bstr filepath;
2243 hdd->COMGETTER(Location)(filepath.asOutParam());
2244 RTPrintf("Location: %lS\n", filepath.raw());
2245 MediaState_T enmState;
2246 /// @todo NEWMEDIA check accessibility of all parents
2247 /// @todo NEWMEDIA print the full state value
2248 hdd->COMGETTER(State)(&enmState);
2249 RTPrintf("Accessible: %s\n", enmState != MediaState_Inaccessible ? "yes" : "no");
2250 com::SafeGUIDArray machineIds;
2251 hdd->COMGETTER(MachineIds)(ComSafeArrayAsOutParam(machineIds));
2252 for (size_t j = 0; j < machineIds.size(); ++ j)
2253 {
2254 ComPtr<IMachine> machine;
2255 CHECK_ERROR(virtualBox, GetMachine(machineIds[j], machine.asOutParam()));
2256 ASSERT(machine);
2257 Bstr name;
2258 machine->COMGETTER(Name)(name.asOutParam());
2259 machine->COMGETTER(Id)(uuid.asOutParam());
2260 RTPrintf("%s%lS (UUID: %RTuuid)\n",
2261 j == 0 ? "Usage: " : " ",
2262 name.raw(), &machineIds[j]);
2263 }
2264 /// @todo NEWMEDIA check usage in snapshots too
2265 /// @todo NEWMEDIA also list children and say 'differencing' for
2266 /// hard disks with the parent or 'base' otherwise.
2267 RTPrintf("\n");
2268 }
2269 }
2270 else
2271 if (strcmp(argv[0], "dvds") == 0)
2272 {
2273 com::SafeIfaceArray<IDVDImage2> dvds;
2274 CHECK_ERROR(virtualBox, COMGETTER(DVDImages)(ComSafeArrayAsOutParam(dvds)));
2275 for (size_t i = 0; i < dvds.size(); ++ i)
2276 {
2277 ComPtr<IDVDImage2> dvdImage = dvds[i];
2278 Guid uuid;
2279 dvdImage->COMGETTER(Id)(uuid.asOutParam());
2280 RTPrintf("UUID: %s\n", uuid.toString().raw());
2281 Bstr filePath;
2282 dvdImage->COMGETTER(Location)(filePath.asOutParam());
2283 RTPrintf("Path: %lS\n", filePath.raw());
2284 MediaState_T enmState;
2285 dvdImage->COMGETTER(State)(&enmState);
2286 RTPrintf("Accessible: %s\n", enmState != MediaState_Inaccessible ? "yes" : "no");
2287 /** @todo usage */
2288 RTPrintf("\n");
2289 }
2290 }
2291 else
2292 if (strcmp(argv[0], "floppies") == 0)
2293 {
2294 com::SafeIfaceArray<IFloppyImage2> floppies;
2295 CHECK_ERROR(virtualBox, COMGETTER(FloppyImages)(ComSafeArrayAsOutParam(floppies)));
2296 for (size_t i = 0; i < floppies.size(); ++ i)
2297 {
2298 ComPtr<IFloppyImage2> floppyImage = floppies[i];
2299 Guid uuid;
2300 floppyImage->COMGETTER(Id)(uuid.asOutParam());
2301 RTPrintf("UUID: %s\n", uuid.toString().raw());
2302 Bstr filePath;
2303 floppyImage->COMGETTER(Location)(filePath.asOutParam());
2304 RTPrintf("Path: %lS\n", filePath.raw());
2305 MediaState_T enmState;
2306 floppyImage->COMGETTER(State)(&enmState);
2307 RTPrintf("Accessible: %s\n", enmState != MediaState_Inaccessible ? "yes" : "no");
2308 /** @todo usage */
2309 RTPrintf("\n");
2310 }
2311 }
2312 else
2313 if (strcmp(argv[0], "usbhost") == 0)
2314 {
2315 ComPtr<IHost> Host;
2316 CHECK_ERROR_RET (virtualBox, COMGETTER(Host)(Host.asOutParam()), 1);
2317
2318 ComPtr<IHostUSBDeviceCollection> CollPtr;
2319 CHECK_ERROR_RET (Host, COMGETTER(USBDevices)(CollPtr.asOutParam()), 1);
2320
2321 ComPtr<IHostUSBDeviceEnumerator> EnumPtr;
2322 CHECK_ERROR_RET (CollPtr, Enumerate(EnumPtr.asOutParam()), 1);
2323
2324 RTPrintf("Host USB Devices:\n\n");
2325
2326 BOOL fMore = FALSE;
2327 rc = EnumPtr->HasMore (&fMore);
2328 ASSERT_RET (SUCCEEDED (rc), 1);
2329
2330 if (!fMore)
2331 {
2332 RTPrintf("<none>\n\n");
2333 }
2334 else
2335 while (fMore)
2336 {
2337 ComPtr <IHostUSBDevice> dev;
2338 rc = EnumPtr->GetNext (dev.asOutParam());
2339 ASSERT_RET (SUCCEEDED (rc), 1);
2340
2341 /* Query info. */
2342 Guid id;
2343 CHECK_ERROR_RET (dev, COMGETTER(Id)(id.asOutParam()), 1);
2344 USHORT usVendorId;
2345 CHECK_ERROR_RET (dev, COMGETTER(VendorId)(&usVendorId), 1);
2346 USHORT usProductId;
2347 CHECK_ERROR_RET (dev, COMGETTER(ProductId)(&usProductId), 1);
2348 USHORT bcdRevision;
2349 CHECK_ERROR_RET (dev, COMGETTER(Revision)(&bcdRevision), 1);
2350
2351 RTPrintf("UUID: %S\n"
2352 "VendorId: 0x%04x (%04X)\n"
2353 "ProductId: 0x%04x (%04X)\n"
2354 "Revision: %u.%u (%02u%02u)\n",
2355 id.toString().raw(),
2356 usVendorId, usVendorId, usProductId, usProductId,
2357 bcdRevision >> 8, bcdRevision & 0xff,
2358 bcdRevision >> 8, bcdRevision & 0xff);
2359
2360 /* optional stuff. */
2361 Bstr bstr;
2362 CHECK_ERROR_RET (dev, COMGETTER(Manufacturer)(bstr.asOutParam()), 1);
2363 if (!bstr.isEmpty())
2364 RTPrintf("Manufacturer: %lS\n", bstr.raw());
2365 CHECK_ERROR_RET (dev, COMGETTER(Product)(bstr.asOutParam()), 1);
2366 if (!bstr.isEmpty())
2367 RTPrintf("Product: %lS\n", bstr.raw());
2368 CHECK_ERROR_RET (dev, COMGETTER(SerialNumber)(bstr.asOutParam()), 1);
2369 if (!bstr.isEmpty())
2370 RTPrintf("SerialNumber: %lS\n", bstr.raw());
2371 CHECK_ERROR_RET (dev, COMGETTER(Address)(bstr.asOutParam()), 1);
2372 if (!bstr.isEmpty())
2373 RTPrintf("Address: %lS\n", bstr.raw());
2374
2375 /* current state */
2376 USBDeviceState_T state;
2377 CHECK_ERROR_RET (dev, COMGETTER(State)(&state), 1);
2378 const char *pszState = "?";
2379 switch (state)
2380 {
2381 case USBDeviceState_NotSupported:
2382 pszState = "Not supported"; break;
2383 case USBDeviceState_Unavailable:
2384 pszState = "Unavailable"; break;
2385 case USBDeviceState_Busy:
2386 pszState = "Busy"; break;
2387 case USBDeviceState_Available:
2388 pszState = "Available"; break;
2389 case USBDeviceState_Held:
2390 pszState = "Held"; break;
2391 case USBDeviceState_Captured:
2392 pszState = "Captured"; break;
2393 default:
2394 ASSERT (false);
2395 break;
2396 }
2397 RTPrintf("Current State: %s\n\n", pszState);
2398
2399 rc = EnumPtr->HasMore (&fMore);
2400 ASSERT_RET (SUCCEEDED (rc), rc);
2401 }
2402 }
2403 else
2404 if (strcmp(argv[0], "usbfilters") == 0)
2405 {
2406 RTPrintf("Global USB Device Filters:\n\n");
2407
2408 ComPtr <IHost> host;
2409 CHECK_ERROR_RET (virtualBox, COMGETTER(Host) (host.asOutParam()), 1);
2410
2411 ComPtr<IHostUSBDeviceFilterCollection> coll;
2412 CHECK_ERROR_RET (host, COMGETTER (USBDeviceFilters)(coll.asOutParam()), 1);
2413
2414 ComPtr<IHostUSBDeviceFilterEnumerator> en;
2415 CHECK_ERROR_RET (coll, Enumerate(en.asOutParam()), 1);
2416
2417 ULONG index = 0;
2418 BOOL more = FALSE;
2419 rc = en->HasMore (&more);
2420 ASSERT_RET (SUCCEEDED (rc), 1);
2421
2422 if (!more)
2423 {
2424 RTPrintf("<none>\n\n");
2425 }
2426 else
2427 while (more)
2428 {
2429 ComPtr<IHostUSBDeviceFilter> flt;
2430 rc = en->GetNext (flt.asOutParam());
2431 ASSERT_RET (SUCCEEDED (rc), 1);
2432
2433 /* Query info. */
2434
2435 RTPrintf("Index: %lu\n", index);
2436
2437 BOOL active = FALSE;
2438 CHECK_ERROR_RET (flt, COMGETTER (Active) (&active), 1);
2439 RTPrintf("Active: %s\n", active ? "yes" : "no");
2440
2441 USBDeviceFilterAction_T action;
2442 CHECK_ERROR_RET (flt, COMGETTER (Action) (&action), 1);
2443 const char *pszAction = "<invalid>";
2444 switch (action)
2445 {
2446 case USBDeviceFilterAction_Ignore:
2447 pszAction = "Ignore";
2448 break;
2449 case USBDeviceFilterAction_Hold:
2450 pszAction = "Hold";
2451 break;
2452 default:
2453 break;
2454 }
2455 RTPrintf("Action: %s\n", pszAction);
2456
2457 Bstr bstr;
2458 CHECK_ERROR_RET (flt, COMGETTER (Name) (bstr.asOutParam()), 1);
2459 RTPrintf("Name: %lS\n", bstr.raw());
2460 CHECK_ERROR_RET (flt, COMGETTER (VendorId) (bstr.asOutParam()), 1);
2461 RTPrintf("VendorId: %lS\n", bstr.raw());
2462 CHECK_ERROR_RET (flt, COMGETTER (ProductId) (bstr.asOutParam()), 1);
2463 RTPrintf("ProductId: %lS\n", bstr.raw());
2464 CHECK_ERROR_RET (flt, COMGETTER (Revision) (bstr.asOutParam()), 1);
2465 RTPrintf("Revision: %lS\n", bstr.raw());
2466 CHECK_ERROR_RET (flt, COMGETTER (Manufacturer) (bstr.asOutParam()), 1);
2467 RTPrintf("Manufacturer: %lS\n", bstr.raw());
2468 CHECK_ERROR_RET (flt, COMGETTER (Product) (bstr.asOutParam()), 1);
2469 RTPrintf("Product: %lS\n", bstr.raw());
2470 CHECK_ERROR_RET (flt, COMGETTER (SerialNumber) (bstr.asOutParam()), 1);
2471 RTPrintf("Serial Number: %lS\n\n", bstr.raw());
2472
2473 rc = en->HasMore (&more);
2474 ASSERT_RET (SUCCEEDED (rc), 1);
2475
2476 index ++;
2477 }
2478 }
2479 else if (strcmp(argv[0], "systemproperties") == 0)
2480 {
2481 ComPtr<ISystemProperties> systemProperties;
2482 virtualBox->COMGETTER(SystemProperties)(systemProperties.asOutParam());
2483
2484 Bstr str;
2485 ULONG ulValue;
2486 ULONG64 ul64Value;
2487 BOOL flag;
2488
2489 systemProperties->COMGETTER(MinGuestRAM)(&ulValue);
2490 RTPrintf("Minimum guest RAM size: %u Megabytes\n", ulValue);
2491 systemProperties->COMGETTER(MaxGuestRAM)(&ulValue);
2492 RTPrintf("Maximum guest RAM size: %u Megabytes\n", ulValue);
2493 systemProperties->COMGETTER(MaxGuestVRAM)(&ulValue);
2494 RTPrintf("Maximum video RAM size: %u Megabytes\n", ulValue);
2495 systemProperties->COMGETTER(MaxVDISize)(&ul64Value);
2496 RTPrintf("Maximum VDI size: %lu Megabytes\n", ul64Value);
2497 systemProperties->COMGETTER(DefaultHardDiskFolder)(str.asOutParam());
2498 RTPrintf("Default hard disk filder: %lS\n", str.raw());
2499 systemProperties->COMGETTER(DefaultMachineFolder)(str.asOutParam());
2500 RTPrintf("Default machine folder: %lS\n", str.raw());
2501 systemProperties->COMGETTER(RemoteDisplayAuthLibrary)(str.asOutParam());
2502 RTPrintf("VRDP authentication library: %lS\n", str.raw());
2503 systemProperties->COMGETTER(WebServiceAuthLibrary)(str.asOutParam());
2504 RTPrintf("Webservice auth. library: %lS\n", str.raw());
2505 systemProperties->COMGETTER(HWVirtExEnabled)(&flag);
2506 RTPrintf("Hardware virt. extensions: %s\n", flag ? "yes" : "no");
2507 systemProperties->COMGETTER(LogHistoryCount)(&ulValue);
2508 RTPrintf("Log history count: %u\n", ulValue);
2509
2510 }
2511 else
2512 return errorSyntax(USAGE_LIST, "Invalid parameter '%s'", Utf8Str(argv[0]).raw());
2513
2514 return SUCCEEDED(rc) ? 0 : 1;
2515}
2516
2517#endif /* VBOX_ONLY_DOCS */
2518
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