- Timestamp:
- Nov 26, 2008 12:37:24 AM (16 years ago)
- Location:
- trunk/src/VBox/Frontends/VBoxManage
- Files:
-
- 2 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/Makefile.kmk
r14555 r14612 44 44 VBoxManage.cpp \ 45 45 VBoxManageInfo.cpp \ 46 VBoxManageList.cpp \ 46 47 VBoxInternalManage.cpp \ 47 48 $(if $(VBOX_WITH_GUEST_PROPS),VBoxManageGuestProp.cpp) \ -
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.h
r14555 r14612 129 129 ComPtr<IVirtualBox> aVirtualBox, ComPtr<ISession> aSession); 130 130 131 /* VBoxManage Info.cpp */131 /* VBoxManageVMInfo.cpp */ 132 132 void showSnapshots(ComPtr<ISnapshot> rootSnapshot, VMINFO_DETAILS details, const com::Bstr &prefix = "", int level = 0); 133 133 int handleShowVMInfo(int argc, char *argv[], 134 134 ComPtr<IVirtualBox> virtualBox, ComPtr<ISession> session); 135 HRESULT showVMInfo (ComPtr <IVirtualBox> virtualBox, ComPtr<IMachine> machine, 136 ComPtr <IConsole> console = ComPtr <IConsole> (), 137 VMINFO_DETAILS details = VMINFO_NONE); 135 HRESULT showVMInfo(ComPtr <IVirtualBox> virtualBox, ComPtr<IMachine> machine, 136 ComPtr <IConsole> console = ComPtr <IConsole> (), 137 VMINFO_DETAILS details = VMINFO_NONE); 138 139 /* VBoxManageList.cpp */ 138 140 int handleList(int argc, char *argv[], 139 141 ComPtr<IVirtualBox> virtualBox, ComPtr<ISession> session); … … 147 149 148 150 #endif /* !___H_VBOXMANAGE */ 151 -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageList.cpp
r14610 r14612 30 30 #include <VBox/com/array.h> 31 31 #include <VBox/com/ErrorInfo.h> 32 #include <VBox/com/EventQueue.h>33 32 34 33 #include <VBox/com/VirtualBox.h> 35 34 36 #include <stdlib.h> 37 #include <stdarg.h> 38 39 #include <vector> 40 #include <list> 41 42 #include <iprt/runtime.h> 35 #include <VBox/log.h> 43 36 #include <iprt/stream.h> 44 37 #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> 38 #include <iprt/time.h> 57 39 58 40 #include "VBoxManage.h" 59 41 using namespace com; 60 42 61 62 // funcs63 ///////////////////////////////////////////////////////////////////////////////64 65 66 67 void 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 else81 {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 else105 newPrefix = Utf8StrFmt("%lS ", prefix.raw());106 /* recursive call */107 showSnapshots(snapshot, details, newPrefix, level + 1);108 }109 index++;110 }111 }112 }113 114 static 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 128 HRESULT 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. Any138 * other values printed are in CamelCase.139 * 2) strings (anything non-decimal) are printed surrounded by140 * double quotes '"'. If the strings themselves contain double141 * quotes, these characters are escaped by '\'. Any '\' character142 * 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 else157 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 else163 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 else184 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 else195 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 else202 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 else209 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 else216 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 else223 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 else240 pszBootMenu = "menu only";241 break;242 default:243 if (details == VMINFO_MACHINEREADABLE)244 pszBootMenu = "messageandmenu";245 else246 pszBootMenu = "message and menu";247 }248 if (details == VMINFO_MACHINEREADABLE)249 RTPrintf("bootmenu=\"%s\"\n", pszBootMenu);250 else251 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 else258 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 else265 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 else272 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 else279 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 else292 RTPrintf("Hardw. virt.ext: Default (%s)\n", fHWVirtExEnabled ? "on" : "off");293 }294 else295 {296 if (details == VMINFO_MACHINEREADABLE)297 RTPrintf("hwvirtex=\"%s\"\n", hwVirtExEnabled == TSBool_True ? "on" : "off");298 else299 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 else306 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 else313 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 else324 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 else366 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 else373 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 else380 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 else411 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 else427 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 else440 {441 pszFloppy = "disabled";442 }443 if (details == VMINFO_MACHINEREADABLE)444 RTPrintf("floppy=\"%s\"\n", pszFloppy.raw());445 else446 RTPrintf("Floppy: %s\n", pszFloppy.raw());447 }448 449 /*450 * SATA.451 *452 * Contributed by: James Lucas453 */454 #ifdef VBOX_WITH_AHCI455 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 else466 RTPrintf("SATA: %s\n", fSataEnabled ? "enabled" : "disabled");467 }468 469 /*470 * SATA Hard disks471 */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("sataport%d=\"%lS\"\n", i, filePath.raw());489 RTPrintf("SataPortImageUUID%d=\"%s\"\n", i, uuid.toString().raw());490 }491 else492 RTPrintf("SATA %d: %lS (UUID: %s)\n", i, filePath.raw(), uuid.toString().raw());493 }494 else495 {496 if (details == VMINFO_MACHINEREADABLE)497 RTPrintf("sata%d=\"none\"\n",i);498 }499 }500 }501 #endif502 503 /*504 * IDE Hard disks505 */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 else523 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 else538 RTPrintf("Primary master: %lS (UUID: %s)\n", filePath.raw(), uuid.toString().raw());539 }540 else541 {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 else556 RTPrintf("Primary slave: %lS (UUID: %s)\n", filePath.raw(), uuid.toString().raw());557 }558 else559 {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 else574 RTPrintf("Secondary slave: %lS (UUID: %s)\n", filePath.raw(), uuid.toString().raw());575 }576 else577 {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 else599 RTPrintf("DVD: %lS (UUID: %s)\n", filePath.raw(), uuid.toString().raw());600 }601 }602 else603 {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 else613 RTPrintf("DVD: Host drive %lS", name.raw());614 }615 else616 {617 if (details == VMINFO_MACHINEREADABLE)618 RTPrintf("dvd=\"none\"\n");619 else620 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 else629 {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 else655 RTPrintf("NIC %d: disabled\n", currentNIC + 1);656 }657 else658 {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 else670 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 else684 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 else697 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 else710 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_E1000740 case NetworkAdapterType_I82540EM:741 strNICType = "82540EM";742 break;743 case NetworkAdapterType_I82543GC:744 strNICType = "82543GC";745 break;746 #endif747 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 else763 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 else790 RTPrintf("UART %d: disabled\n", currentUART + 1);791 }792 else793 {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 else808 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 else817 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 else824 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 else832 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 else857 pszDrv = "Null";858 break;859 case AudioDriverType_WinMM:860 if (details == VMINFO_MACHINEREADABLE)861 pszDrv = "winmm";862 else863 pszDrv = "WINMM";864 break;865 case AudioDriverType_DirectSound:866 if (details == VMINFO_MACHINEREADABLE)867 pszDrv = "dsound";868 else869 pszDrv = "DSOUND";870 break;871 case AudioDriverType_OSS:872 if (details == VMINFO_MACHINEREADABLE)873 pszDrv = "oss";874 else875 pszDrv = "OSS";876 break;877 case AudioDriverType_ALSA:878 if (details == VMINFO_MACHINEREADABLE)879 pszDrv = "alsa";880 else881 pszDrv = "ALSA";882 break;883 case AudioDriverType_Pulse:884 if (details == VMINFO_MACHINEREADABLE)885 pszDrv = "pulse";886 else887 pszDrv = "PulseAudio";888 break;889 case AudioDriverType_CoreAudio:890 if (details == VMINFO_MACHINEREADABLE)891 pszDrv = "coreaudio";892 else893 pszDrv = "CoreAudio";894 break;895 case AudioDriverType_SolAudio:896 if (details == VMINFO_MACHINEREADABLE)897 pszDrv = "solaudio";898 else899 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 else914 pszCtrl = "AC97";915 break;916 case AudioControllerType_SB16:917 if (details == VMINFO_MACHINEREADABLE)918 pszCtrl = "sb16";919 else920 pszCtrl = "SB16";921 break;922 }923 }924 else925 fEnabled = FALSE;926 if (details == VMINFO_MACHINEREADABLE)927 {928 if (fEnabled)929 RTPrintf("audio=\"%s\"\n", pszDrv);930 else931 RTPrintf("audio=\"none\"\n");932 }933 else934 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 else949 psz = "disabled";950 break;951 case ClipboardMode_HostToGuest:952 if (details == VMINFO_MACHINEREADABLE)953 psz = "hosttoguest";954 else955 psz = "HostToGuest";956 break;957 case ClipboardMode_GuestToHost:958 if (details == VMINFO_MACHINEREADABLE)959 psz = "guesttohost";960 else961 psz = "GuestToHost";962 break;963 case ClipboardMode_Bidirectional:964 if (details == VMINFO_MACHINEREADABLE)965 psz = "bidirectional";966 else967 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 else977 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 do985 {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 else1017 RTPrintf("Video mode: %dx%dx%d\n", xRes, yRes, bpp);1018 }1019 while (0);1020 }1021 1022 /*1023 * VRDP1024 */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 else1069 {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 else1076 {1077 if (details == VMINFO_MACHINEREADABLE)1078 RTPrintf("vrdp=\"off\"\n");1079 else1080 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 else1098 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 else1120 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 else1136 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 else1143 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 else1148 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 else1153 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 else1158 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 else1163 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 else1168 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 else1173 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 else1178 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 else1218 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 else1244 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 else1261 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 else1269 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 else1277 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 else1285 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 else1320 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 else1346 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 else1363 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 else1371 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 else1379 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 else1387 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 folders1404 */1405 if (details != VMINFO_MACHINEREADABLE)1406 RTPrintf("Shared folders: ");1407 uint32_t numSharedFolders = 0;1408 #if 0 // not yet implemented1409 /* 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 #endif1430 /* 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 else1458 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 else1491 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 else1541 RTPrintf("VRDP Connection: %s\n", Active? "active": "not active");1542 1543 if (details == VMINFO_MACHINEREADABLE)1544 RTPrintf("VRDPClients=%d\n", NumberOfClients);1545 else1546 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 else1558 RTPrintf("Start time: %s\n", timestr);1559 }1560 else1561 {1562 makeTimeStr (timestr, sizeof (timestr), BeginTime);1563 if (details == VMINFO_MACHINEREADABLE)1564 RTPrintf("VRDPLastStartTime=\"%s\"\n", timestr);1565 else1566 RTPrintf("Last started: %s\n", timestr);1567 makeTimeStr (timestr, sizeof (timestr), EndTime);1568 if (details == VMINFO_MACHINEREADABLE)1569 RTPrintf("VRDPLastEndTime=\"%s\"\n", timestr);1570 else1571 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 else1593 {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 else1615 {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_STANDARD1631 || details == VMINFO_FULL1632 || 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 else1641 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_BALLOONING1650 rc = machine->COMGETTER(MemoryBalloonSize)(&guestVal);1651 if (SUCCEEDED(rc))1652 {1653 if (details == VMINFO_MACHINEREADABLE)1654 RTPrintf("GuestMemoryBalloon=%d\n", guestVal);1655 else1656 RTPrintf("Configured memory balloon size: %d MB\n", guestVal);1657 }1658 #endif1659 rc = machine->COMGETTER(StatisticsUpdateInterval)(&guestVal);1660 if (SUCCEEDED(rc))1661 {1662 if (details == VMINFO_MACHINEREADABLE)1663 RTPrintf("GuestStatisticsUpdateInterval=%d\n", guestVal);1664 else1665 {1666 if (guestVal == 0)1667 RTPrintf("Statistics update: disabled\n");1668 else1669 RTPrintf("Statistics update interval: %d seconds\n", guestVal);1670 }1671 }1672 if (details != VMINFO_MACHINEREADABLE)1673 RTPrintf("\n");1674 1675 if ( console1676 && ( details == VMINFO_STATISTICS1677 || details == VMINFO_FULL1678 || 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 else1691 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 else1699 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 else1708 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 else1717 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 else1726 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 else1735 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 else1744 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 else1753 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 else1762 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 else1771 RTPrintf("CPU%d: Free physical memory %-4d MB\n", 0, statVal);1772 }1773 1774 #ifdef VBOX_WITH_MEM_BALLOONING1775 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 else1781 RTPrintf("CPU%d: Memory balloon size %-4d MB\n", 0, statVal);1782 }1783 #endif1784 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 else1790 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 else1799 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 else1808 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 else1817 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 else1826 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 else1835 RTPrintf("CPU%d: Page file size %-4d MB\n", 0, statVal);1836 }1837 1838 RTPrintf("\n");1839 }1840 else1841 {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 * snapshots1852 */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 1867 int 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 else1884 {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 else1902 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 else1910 if (fDetails && fStatistics)1911 details = VMINFO_FULL;1912 else1913 if (fDetails)1914 details = VMINFO_STANDARD;1915 else1916 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 43 1938 44 int handleList(int argc, char *argv[], … … 2515 621 } 2516 622 2517 #endif /* VBOX_ONLY_DOCS */2518 623 #endif /* !VBOX_ONLY_DOCS */ 624
Note:
See TracChangeset
for help on using the changeset viewer.