Changeset 27916 in vbox
- Timestamp:
- Mar 31, 2010 4:39:54 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageList.cpp
r27857 r27916 5 5 6 6 /* 7 * Copyright (C) 2006-20 09Sun Microsystems, Inc.7 * Copyright (C) 2006-2010 Sun Microsystems, Inc. 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 66 66 } 67 67 #endif 68 69 static void listHardDisks(const ComPtr<IVirtualBox> aVirtualBox, 70 const com::SafeIfaceArray<IMedium> &aMedia, 71 const char *pszParentUUIDStr) 72 { 73 HRESULT rc; 74 for (size_t i = 0; i < aMedia.size(); ++ i) 75 { 76 ComPtr<IMedium> hdd = aMedia[i]; 77 Bstr uuid; 78 hdd->COMGETTER(Id)(uuid.asOutParam()); 79 RTPrintf("UUID: %s\n", Utf8Str(uuid).raw()); 80 RTPrintf("Parent UUID: %s\n", pszParentUUIDStr); 81 Bstr format; 82 hdd->COMGETTER(Format)(format.asOutParam()); 83 RTPrintf("Format: %lS\n", format.raw()); 84 Bstr filepath; 85 hdd->COMGETTER(Location)(filepath.asOutParam()); 86 RTPrintf("Location: %lS\n", filepath.raw()); 87 88 MediumState_T enmState; 89 hdd->RefreshState(&enmState); 90 const char *stateStr = "unknown"; 91 switch (enmState) 92 { 93 case MediumState_NotCreated: 94 stateStr = "not created"; 95 break; 96 case MediumState_Created: 97 stateStr = "created"; 98 break; 99 case MediumState_LockedRead: 100 stateStr = "locked read"; 101 break; 102 case MediumState_LockedWrite: 103 stateStr = "locked write"; 104 break; 105 case MediumState_Inaccessible: 106 stateStr = "inaccessible"; 107 break; 108 case MediumState_Creating: 109 stateStr = "creating"; 110 break; 111 case MediumState_Deleting: 112 stateStr = "deleting"; 113 break; 114 } 115 RTPrintf("State: %s\n", stateStr); 116 117 MediumType_T type; 118 hdd->COMGETTER(Type)(&type); 119 const char *typeStr = "unknown"; 120 switch (type) 121 { 122 case MediumType_Normal: 123 typeStr = "normal"; 124 break; 125 case MediumType_Immutable: 126 typeStr = "immutable"; 127 break; 128 case MediumType_Writethrough: 129 typeStr = "writethrough"; 130 break; 131 } 132 RTPrintf("Type: %s\n", typeStr); 133 134 com::SafeArray<BSTR> machineIds; 135 hdd->COMGETTER(MachineIds)(ComSafeArrayAsOutParam(machineIds)); 136 for (size_t j = 0; j < machineIds.size(); ++ j) 137 { 138 ComPtr<IMachine> machine; 139 CHECK_ERROR(aVirtualBox, GetMachine(machineIds[j], machine.asOutParam())); 140 ASSERT(machine); 141 Bstr name; 142 machine->COMGETTER(Name)(name.asOutParam()); 143 RTPrintf("%s%lS (UUID: %lS)\n", 144 j == 0 ? "Usage: " : " ", 145 name.raw(), machineIds[j]); 146 } 147 RTPrintf("\n"); 148 149 com::SafeIfaceArray<IMedium> children; 150 CHECK_ERROR(hdd, COMGETTER(Children)(ComSafeArrayAsOutParam(children))); 151 if (children.size() > 0) 152 { 153 // depth first listing of child media 154 listHardDisks(aVirtualBox, children, Utf8Str(uuid).raw()); 155 } 156 } 157 } 68 158 69 159 enum enOptionCodes … … 141 231 if (a->argc < 2) 142 232 return errorSyntax(USAGE_LIST, "Missing vm name for \"list\" %S.\n", a->argv[0]); 143 233 144 234 case LISTVMS: 145 235 case LISTRUNNINGVMS: … … 200 290 */ 201 291 com::SafeIfaceArray <IMachine> machines; 202 rc = a->virtualBox->COMGETTER(Machines)(ComSafeArrayAsOutParam 292 rc = a->virtualBox->COMGETTER(Machines)(ComSafeArrayAsOutParam(machines)); 203 293 if (SUCCEEDED(rc)) 204 294 { … … 223 313 */ 224 314 com::SafeIfaceArray <IMachine> machines; 225 rc = a->virtualBox->COMGETTER(Machines)(ComSafeArrayAsOutParam 315 rc = a->virtualBox->COMGETTER(Machines)(ComSafeArrayAsOutParam(machines)); 226 316 if (SUCCEEDED(rc)) 227 317 { … … 234 324 { 235 325 MachineState_T machineState; 236 rc = machines 326 rc = machines[i]->COMGETTER(State)(&machineState); 237 327 if (SUCCEEDED(rc)) 238 328 { … … 395 485 { 396 486 ComPtr<IHost> Host; 397 CHECK_ERROR 487 CHECK_ERROR(a->virtualBox, COMGETTER(Host)(Host.asOutParam())); 398 488 399 489 RTPrintf("Host Information:\n\n"); 400 490 401 491 LONG64 uTCTime = 0; 402 CHECK_ERROR 492 CHECK_ERROR(Host, COMGETTER(UTCTime)(&uTCTime)); 403 493 RTTIMESPEC timeSpec; 404 494 RTTimeSpecSetMilli(&timeSpec, uTCTime); … … 408 498 409 499 ULONG processorOnlineCount = 0; 410 CHECK_ERROR 500 CHECK_ERROR(Host, COMGETTER(ProcessorOnlineCount)(&processorOnlineCount)); 411 501 RTPrintf("Processor online count: %lu\n", processorOnlineCount); 412 502 ULONG processorCount = 0; 413 CHECK_ERROR 503 CHECK_ERROR(Host, COMGETTER(ProcessorCount)(&processorCount)); 414 504 RTPrintf("Processor count: %lu\n", processorCount); 415 505 ULONG processorSpeed = 0; … … 417 507 for (ULONG i = 0; i < processorCount; i++) 418 508 { 419 CHECK_ERROR 509 CHECK_ERROR(Host, GetProcessorSpeed(i, &processorSpeed)); 420 510 if (processorSpeed) 421 511 RTPrintf("Processor#%u speed: %lu MHz\n", i, processorSpeed); 422 512 else 423 513 RTPrintf("Processor#%u speed: unknown\n", i, processorSpeed); 424 CHECK_ERROR 514 CHECK_ERROR(Host, GetProcessorDescription(i, processorDescription.asOutParam())); 425 515 RTPrintf("Processor#%u description: %lS\n", i, processorDescription.raw()); 426 516 } 427 517 428 518 ULONG memorySize = 0; 429 CHECK_ERROR 519 CHECK_ERROR(Host, COMGETTER(MemorySize)(&memorySize)); 430 520 RTPrintf("Memory size: %lu MByte\n", memorySize); 431 521 432 522 ULONG memoryAvailable = 0; 433 CHECK_ERROR 523 CHECK_ERROR(Host, COMGETTER(MemoryAvailable)(&memoryAvailable)); 434 524 RTPrintf("Memory available: %lu MByte\n", memoryAvailable); 435 525 436 526 Bstr operatingSystem; 437 CHECK_ERROR 527 CHECK_ERROR(Host, COMGETTER(OperatingSystem)(operatingSystem.asOutParam())); 438 528 RTPrintf("Operating system: %lS\n", operatingSystem.raw()); 439 529 440 530 Bstr oSVersion; 441 CHECK_ERROR 531 CHECK_ERROR(Host, COMGETTER(OSVersion)(oSVersion.asOutParam())); 442 532 RTPrintf("Operating system version: %lS\n", oSVersion.raw()); 443 533 } … … 477 567 ComPtr<ISystemProperties> systemProperties; 478 568 CHECK_ERROR(a->virtualBox, 479 COMGETTER(SystemProperties) 569 COMGETTER(SystemProperties)(systemProperties.asOutParam())); 480 570 com::SafeIfaceArray <IMediumFormat> mediumFormats; 481 571 CHECK_ERROR(systemProperties, 482 COMGETTER(MediumFormats) (ComSafeArrayAsOutParam(mediumFormats)));572 COMGETTER(MediumFormats)(ComSafeArrayAsOutParam(mediumFormats))); 483 573 484 574 RTPrintf("Supported hard disk backends:\n\n"); … … 487 577 /* General information */ 488 578 Bstr id; 489 CHECK_ERROR(mediumFormats [i], 490 COMGETTER(Id) (id.asOutParam())); 579 CHECK_ERROR(mediumFormats[i], COMGETTER(Id)(id.asOutParam())); 491 580 492 581 Bstr description; 493 CHECK_ERROR(mediumFormats 494 COMGETTER(Id) 582 CHECK_ERROR(mediumFormats[i], 583 COMGETTER(Id)(description.asOutParam())); 495 584 496 585 ULONG caps; 497 CHECK_ERROR(mediumFormats 498 COMGETTER(Capabilities) 586 CHECK_ERROR(mediumFormats[i], 587 COMGETTER(Capabilities)(&caps)); 499 588 500 589 RTPrintf("Backend %u: id='%ls' description='%ls' capabilities=%#06x extensions='", … … 503 592 /* File extensions */ 504 593 com::SafeArray <BSTR> fileExtensions; 505 CHECK_ERROR(mediumFormats 506 COMGETTER(FileExtensions) (ComSafeArrayAsOutParam(fileExtensions)));594 CHECK_ERROR(mediumFormats[i], 595 COMGETTER(FileExtensions)(ComSafeArrayAsOutParam(fileExtensions))); 507 596 for (size_t j = 0; j < fileExtensions.size(); ++ j) 508 597 { 509 RTPrintf ("%ls", Bstr (fileExtensions[j]).raw());598 RTPrintf("%ls", Bstr(fileExtensions[j]).raw()); 510 599 if (j != fileExtensions.size()-1) 511 RTPrintf 512 } 513 RTPrintf 600 RTPrintf(","); 601 } 602 RTPrintf("'"); 514 603 515 604 /* Configuration keys */ … … 519 608 com::SafeArray <ULONG> propertyFlags; 520 609 com::SafeArray <BSTR> propertyDefaults; 521 CHECK_ERROR(mediumFormats 522 DescribeProperties (ComSafeArrayAsOutParam(propertyNames),523 ComSafeArrayAsOutParam 524 ComSafeArrayAsOutParam 525 ComSafeArrayAsOutParam 526 ComSafeArrayAsOutParam 527 528 RTPrintf 610 CHECK_ERROR(mediumFormats[i], 611 DescribeProperties(ComSafeArrayAsOutParam(propertyNames), 612 ComSafeArrayAsOutParam(propertyDescriptions), 613 ComSafeArrayAsOutParam(propertyTypes), 614 ComSafeArrayAsOutParam(propertyFlags), 615 ComSafeArrayAsOutParam(propertyDefaults))); 616 617 RTPrintf(" properties=("); 529 618 if (propertyNames.size() > 0) 530 619 { 531 620 for (size_t j = 0; j < propertyNames.size(); ++ j) 532 621 { 533 RTPrintf 534 Bstr (propertyNames [j]).raw(), Bstr (propertyDescriptions[j]).raw());535 switch (propertyTypes 622 RTPrintf("\n name='%ls' desc='%ls' type=", 623 Bstr(propertyNames[j]).raw(), Bstr(propertyDescriptions[j]).raw()); 624 switch (propertyTypes[j]) 536 625 { 537 case DataType_Int32: RTPrintf 538 case DataType_Int8: RTPrintf 539 case DataType_String: RTPrintf 626 case DataType_Int32: RTPrintf("int"); break; 627 case DataType_Int8: RTPrintf("byte"); break; 628 case DataType_String: RTPrintf("string"); break; 540 629 } 541 RTPrintf (" flags=%#04x", propertyFlags[j]);542 RTPrintf (" default='%ls'", Bstr (propertyDefaults[j]).raw());630 RTPrintf(" flags=%#04x", propertyFlags[j]); 631 RTPrintf(" default='%ls'", Bstr(propertyDefaults[j]).raw()); 543 632 if (j != propertyNames.size()-1) 544 RTPrintf 633 RTPrintf(", "); 545 634 } 546 635 } 547 RTPrintf 636 RTPrintf(")\n"); 548 637 } 549 638 } … … 553 642 { 554 643 com::SafeIfaceArray<IMedium> hdds; 555 CHECK_ERROR(a->virtualBox, COMGETTER(HardDisks)(ComSafeArrayAsOutParam (hdds))); 556 for (size_t i = 0; i < hdds.size(); ++ i) 557 { 558 ComPtr<IMedium> hdd = hdds[i]; 559 Bstr uuid; 560 hdd->COMGETTER(Id)(uuid.asOutParam()); 561 RTPrintf("UUID: %s\n", Utf8Str(uuid).raw()); 562 Bstr format; 563 hdd->COMGETTER(Format)(format.asOutParam()); 564 RTPrintf("Format: %lS\n", format.raw()); 565 Bstr filepath; 566 hdd->COMGETTER(Location)(filepath.asOutParam()); 567 RTPrintf("Location: %lS\n", filepath.raw()); 568 MediumState_T enmState; 569 /// @todo NEWMEDIA check accessibility of all parents 570 /// @todo NEWMEDIA print the full state value 571 hdd->RefreshState(&enmState); 572 RTPrintf("Accessible: %s\n", enmState != MediumState_Inaccessible ? "yes" : "no"); 573 574 MediumType_T type; 575 hdd->COMGETTER(Type)(&type); 576 const char *typeStr = "unknown"; 577 switch (type) 578 { 579 case MediumType_Normal: 580 typeStr = "normal"; 581 break; 582 case MediumType_Immutable: 583 typeStr = "immutable"; 584 break; 585 case MediumType_Writethrough: 586 typeStr = "writethrough"; 587 break; 588 } 589 RTPrintf("Type: %s\n", typeStr); 590 591 com::SafeArray<BSTR> machineIds; 592 hdd->COMGETTER(MachineIds)(ComSafeArrayAsOutParam(machineIds)); 593 for (size_t j = 0; j < machineIds.size(); ++ j) 594 { 595 ComPtr<IMachine> machine; 596 CHECK_ERROR(a->virtualBox, GetMachine(machineIds[j], machine.asOutParam())); 597 ASSERT(machine); 598 Bstr name; 599 machine->COMGETTER(Name)(name.asOutParam()); 600 machine->COMGETTER(Id)(uuid.asOutParam()); 601 RTPrintf("%s%lS (UUID: %lS)\n", 602 j == 0 ? "Usage: " : " ", 603 name.raw(), machineIds[j]); 604 } 605 /// @todo NEWMEDIA check usage in snapshots too 606 /// @todo NEWMEDIA also list children and say 'differencing' for 607 /// hard disks with the parent or 'base' otherwise. 608 RTPrintf("\n"); 609 } 644 CHECK_ERROR(a->virtualBox, COMGETTER(HardDisks)(ComSafeArrayAsOutParam(hdds))); 645 listHardDisks(a->virtualBox, hdds, "base"); 610 646 } 611 647 break; … … 686 722 { 687 723 ComPtr<IHost> Host; 688 CHECK_ERROR_RET 724 CHECK_ERROR_RET(a->virtualBox, COMGETTER(Host)(Host.asOutParam()), 1); 689 725 690 726 SafeIfaceArray <IHostUSBDevice> CollPtr; 691 CHECK_ERROR_RET 727 CHECK_ERROR_RET(Host, COMGETTER(USBDevices)(ComSafeArrayAsOutParam(CollPtr)), 1); 692 728 693 729 RTPrintf("Host USB Devices:\n\n"); … … 705 741 /* Query info. */ 706 742 Bstr id; 707 CHECK_ERROR_RET 743 CHECK_ERROR_RET(dev, COMGETTER(Id)(id.asOutParam()), 1); 708 744 USHORT usVendorId; 709 CHECK_ERROR_RET 745 CHECK_ERROR_RET(dev, COMGETTER(VendorId)(&usVendorId), 1); 710 746 USHORT usProductId; 711 CHECK_ERROR_RET 747 CHECK_ERROR_RET(dev, COMGETTER(ProductId)(&usProductId), 1); 712 748 USHORT bcdRevision; 713 CHECK_ERROR_RET 749 CHECK_ERROR_RET(dev, COMGETTER(Revision)(&bcdRevision), 1); 714 750 715 751 RTPrintf("UUID: %S\n" … … 724 760 /* optional stuff. */ 725 761 Bstr bstr; 726 CHECK_ERROR_RET 762 CHECK_ERROR_RET(dev, COMGETTER(Manufacturer)(bstr.asOutParam()), 1); 727 763 if (!bstr.isEmpty()) 728 764 RTPrintf("Manufacturer: %lS\n", bstr.raw()); 729 CHECK_ERROR_RET 765 CHECK_ERROR_RET(dev, COMGETTER(Product)(bstr.asOutParam()), 1); 730 766 if (!bstr.isEmpty()) 731 767 RTPrintf("Product: %lS\n", bstr.raw()); 732 CHECK_ERROR_RET 768 CHECK_ERROR_RET(dev, COMGETTER(SerialNumber)(bstr.asOutParam()), 1); 733 769 if (!bstr.isEmpty()) 734 770 RTPrintf("SerialNumber: %lS\n", bstr.raw()); 735 CHECK_ERROR_RET 771 CHECK_ERROR_RET(dev, COMGETTER(Address)(bstr.asOutParam()), 1); 736 772 if (!bstr.isEmpty()) 737 773 RTPrintf("Address: %lS\n", bstr.raw()); … … 739 775 /* current state */ 740 776 USBDeviceState_T state; 741 CHECK_ERROR_RET 777 CHECK_ERROR_RET(dev, COMGETTER(State)(&state), 1); 742 778 const char *pszState = "?"; 743 779 switch (state) … … 756 792 pszState = "Captured"; break; 757 793 default: 758 ASSERT 794 ASSERT(false); 759 795 break; 760 796 } … … 770 806 771 807 ComPtr <IHost> host; 772 CHECK_ERROR_RET (a->virtualBox, COMGETTER(Host)(host.asOutParam()), 1);808 CHECK_ERROR_RET(a->virtualBox, COMGETTER(Host)(host.asOutParam()), 1); 773 809 774 810 SafeIfaceArray <IHostUSBDeviceFilter> coll; 775 CHECK_ERROR_RET (host, COMGETTER(USBDeviceFilters)(ComSafeArrayAsOutParam(coll)), 1);811 CHECK_ERROR_RET(host, COMGETTER(USBDeviceFilters)(ComSafeArrayAsOutParam(coll)), 1); 776 812 777 813 if (coll.size() == 0) … … 790 826 791 827 BOOL active = FALSE; 792 CHECK_ERROR_RET (flt, COMGETTER (Active)(&active), 1);828 CHECK_ERROR_RET(flt, COMGETTER(Active)(&active), 1); 793 829 RTPrintf("Active: %s\n", active ? "yes" : "no"); 794 830 795 831 USBDeviceFilterAction_T action; 796 CHECK_ERROR_RET (flt, COMGETTER (Action)(&action), 1);832 CHECK_ERROR_RET(flt, COMGETTER(Action)(&action), 1); 797 833 const char *pszAction = "<invalid>"; 798 834 switch (action) … … 810 846 811 847 Bstr bstr; 812 CHECK_ERROR_RET (flt, COMGETTER (Name)(bstr.asOutParam()), 1);848 CHECK_ERROR_RET(flt, COMGETTER(Name)(bstr.asOutParam()), 1); 813 849 RTPrintf("Name: %lS\n", bstr.raw()); 814 CHECK_ERROR_RET (flt, COMGETTER (VendorId)(bstr.asOutParam()), 1);850 CHECK_ERROR_RET(flt, COMGETTER(VendorId)(bstr.asOutParam()), 1); 815 851 RTPrintf("VendorId: %lS\n", bstr.raw()); 816 CHECK_ERROR_RET (flt, COMGETTER (ProductId)(bstr.asOutParam()), 1);852 CHECK_ERROR_RET(flt, COMGETTER(ProductId)(bstr.asOutParam()), 1); 817 853 RTPrintf("ProductId: %lS\n", bstr.raw()); 818 CHECK_ERROR_RET (flt, COMGETTER (Revision)(bstr.asOutParam()), 1);854 CHECK_ERROR_RET(flt, COMGETTER(Revision)(bstr.asOutParam()), 1); 819 855 RTPrintf("Revision: %lS\n", bstr.raw()); 820 CHECK_ERROR_RET (flt, COMGETTER (Manufacturer)(bstr.asOutParam()), 1);856 CHECK_ERROR_RET(flt, COMGETTER(Manufacturer)(bstr.asOutParam()), 1); 821 857 RTPrintf("Manufacturer: %lS\n", bstr.raw()); 822 CHECK_ERROR_RET (flt, COMGETTER (Product)(bstr.asOutParam()), 1);858 CHECK_ERROR_RET(flt, COMGETTER(Product)(bstr.asOutParam()), 1); 823 859 RTPrintf("Product: %lS\n", bstr.raw()); 824 CHECK_ERROR_RET (flt, COMGETTER (SerialNumber)(bstr.asOutParam()), 1);860 CHECK_ERROR_RET(flt, COMGETTER(SerialNumber)(bstr.asOutParam()), 1); 825 861 RTPrintf("Serial Number: %lS\n\n", bstr.raw()); 826 862 } … … 900 936 { 901 937 com::SafeIfaceArray<IDHCPServer> svrs; 902 CHECK_ERROR(a->virtualBox, COMGETTER(DHCPServers)(ComSafeArrayAsOutParam 938 CHECK_ERROR(a->virtualBox, COMGETTER(DHCPServers)(ComSafeArrayAsOutParam(svrs))); 903 939 for (size_t i = 0; i < svrs.size(); ++ i) 904 940 { … … 946 982 ASSERT(nic); 947 983 CHECK_ERROR(nic, COMGETTER(NatDriver)(driver.asOutParam())); 948 CHECK_ERROR(driver, COMGETTER(Redirects)(ComSafeArrayAsOutParam 984 CHECK_ERROR(driver, COMGETTER(Redirects)(ComSafeArrayAsOutParam(rules))); 949 985 for (size_t i = 0; i < rules.size(); ++ i) 950 986 { … … 971 1007 Log2((#res " %s pos:%d, ppos:%d\n", res.raw(), pos, ppos)); \ 972 1008 ppos = pos + 1; \ 973 } while (0)1009 } while (0) 974 1010 ITERATE_TO_NEXT_TERM(strName, utf, pos, ppos); 975 1011 ITERATE_TO_NEXT_TERM(strProto, utf, pos, ppos); … … 991 1027 break; 992 1028 } 993 RTPrintf("%s:%s:%s:%s:%s:%s\n", strName.raw(), strProto.raw(), 994 strHostIP.isEmpty() ? "": strHostIP.raw(), strHostPort.raw(), 1029 RTPrintf("%s:%s:%s:%s:%s:%s\n", strName.raw(), strProto.raw(), 1030 strHostIP.isEmpty() ? "": strHostIP.raw(), strHostPort.raw(), 995 1031 strGuestIP.isEmpty() ? "": strGuestIP.raw(), strGuestPort.raw()); 996 1032 } 997 1033 998 1034 } 999 1035 break;
Note:
See TracChangeset
for help on using the changeset viewer.