- Timestamp:
- Jan 31, 2013 3:48:05 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 83528
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/manual/user_ChangeLogImpl.xml
r43817 r44498 21 21 <listitem> 22 22 <para>dummy</para> 23 </listitem> 24 25 <listitem> 26 <para>VBoxManage: list more information about hard disk/DVD/floppy 27 media, and support the <computeroutput>--long</computeroutput> 28 option to show really all available details.</para> 23 29 </listitem> 24 30 -
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.h
r44028 r44498 5 5 6 6 /* 7 * Copyright (C) 2006-201 2Oracle Corporation7 * Copyright (C) 2006-2013 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 239 239 int handleCloneHardDisk(HandlerArg *a); 240 240 RTEXITCODE handleConvertFromRaw(int argc, char *argv[]); 241 HRESULT showMediumInfo(const ComPtr<IVirtualBox> &pVirtualBox, 242 const ComPtr<IMedium> &pMedium, 243 const char *pszParentUUID, 244 bool fOptLong); 241 245 int handleShowHardDiskInfo(HandlerArg *a); 242 246 int handleCloseMedium(HandlerArg *a); -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageDisk.cpp
r44379 r44498 5 5 6 6 /* 7 * Copyright (C) 2006-201 2Oracle Corporation7 * Copyright (C) 2006-2013 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 894 894 } 895 895 896 HRESULT showMediumInfo(const ComPtr<IVirtualBox> &pVirtualBox, 897 const ComPtr<IMedium> &pMedium, 898 const char *pszParentUUID, 899 bool fOptLong) 900 { 901 HRESULT rc = S_OK; 902 do 903 { 904 Bstr uuid; 905 pMedium->COMGETTER(Id)(uuid.asOutParam()); 906 RTPrintf("UUID: %ls\n", uuid.raw()); 907 if (pszParentUUID) 908 RTPrintf("Parent UUID: %s\n", pszParentUUID); 909 910 /* check for accessibility */ 911 MediumState_T enmState; 912 CHECK_ERROR_BREAK(pMedium, RefreshState(&enmState)); 913 pMedium->RefreshState(&enmState); 914 const char *pszState = "unknown"; 915 switch (enmState) 916 { 917 case MediumState_NotCreated: 918 pszState = "not created"; 919 break; 920 case MediumState_Created: 921 pszState = "created"; 922 break; 923 case MediumState_LockedRead: 924 pszState = "locked read"; 925 break; 926 case MediumState_LockedWrite: 927 pszState = "locked write"; 928 break; 929 case MediumState_Inaccessible: 930 pszState = "inaccessible"; 931 break; 932 case MediumState_Creating: 933 pszState = "creating"; 934 break; 935 case MediumState_Deleting: 936 pszState = "deleting"; 937 break; 938 } 939 RTPrintf("State: %s\n", pszState); 940 941 if (fOptLong && enmState == MediumState_Inaccessible) 942 { 943 Bstr err; 944 CHECK_ERROR_BREAK(pMedium, COMGETTER(LastAccessError)(err.asOutParam())); 945 RTPrintf("Access Error: %ls\n", err.raw()); 946 } 947 948 if (fOptLong) 949 { 950 Bstr description; 951 pMedium->COMGETTER(Description)(description.asOutParam()); 952 if (!description.isEmpty()) 953 RTPrintf("Description: %ls\n", description.raw()); 954 } 955 956 MediumType_T type; 957 pMedium->COMGETTER(Type)(&type); 958 const char *typeStr = "unknown"; 959 switch (type) 960 { 961 case MediumType_Normal: 962 if (pszParentUUID && Guid(pszParentUUID).isValid()) 963 typeStr = "normal (differencing)"; 964 else 965 typeStr = "normal (base)"; 966 break; 967 case MediumType_Immutable: 968 typeStr = "immutable"; 969 break; 970 case MediumType_Writethrough: 971 typeStr = "writethrough"; 972 break; 973 case MediumType_Shareable: 974 typeStr = "shareable"; 975 break; 976 case MediumType_Readonly: 977 typeStr = "readonly"; 978 break; 979 case MediumType_MultiAttach: 980 typeStr = "multiattach"; 981 break; 982 } 983 RTPrintf("Type: %s\n", typeStr); 984 985 /* print out information specific for differencing hard disks */ 986 if (fOptLong && pszParentUUID && Guid(pszParentUUID).isValid()) 987 { 988 BOOL autoReset = FALSE; 989 pMedium->COMGETTER(AutoReset)(&autoReset); 990 RTPrintf("Auto-Reset: %s\n", autoReset ? "on" : "off"); 991 } 992 993 Bstr loc; 994 pMedium->COMGETTER(Location)(loc.asOutParam()); 995 RTPrintf("Location: %ls\n", loc.raw()); 996 997 Bstr format; 998 pMedium->COMGETTER(Format)(format.asOutParam()); 999 RTPrintf("Storage format: %ls\n", format.raw()); 1000 1001 if (fOptLong) 1002 { 1003 com::SafeArray<MediumVariant_T> safeArray_variant; 1004 1005 pMedium->COMGETTER(Variant)(ComSafeArrayAsOutParam(safeArray_variant)); 1006 ULONG variant=0; 1007 for (size_t i = 0; i < safeArray_variant.size(); i++) 1008 variant |= safeArray_variant[i]; 1009 1010 const char *variantStr = "unknown"; 1011 switch (variant & ~(MediumVariant_Fixed | MediumVariant_Diff)) 1012 { 1013 case MediumVariant_VmdkSplit2G: 1014 variantStr = "split2G"; 1015 break; 1016 case MediumVariant_VmdkStreamOptimized: 1017 variantStr = "streamOptimized"; 1018 break; 1019 case MediumVariant_VmdkESX: 1020 variantStr = "ESX"; 1021 break; 1022 case MediumVariant_Standard: 1023 variantStr = "default"; 1024 break; 1025 } 1026 const char *variantTypeStr = "dynamic"; 1027 if (variant & MediumVariant_Fixed) 1028 variantTypeStr = "fixed"; 1029 else if (variant & MediumVariant_Diff) 1030 variantTypeStr = "differencing"; 1031 RTPrintf("Format variant: %s %s\n", variantTypeStr, variantStr); 1032 } 1033 1034 LONG64 logicalSize; 1035 pMedium->COMGETTER(LogicalSize)(&logicalSize); 1036 RTPrintf("Capacity: %lld MBytes\n", logicalSize >> 20); 1037 if (fOptLong) 1038 { 1039 LONG64 actualSize; 1040 pMedium->COMGETTER(Size)(&actualSize); 1041 RTPrintf("Size on disk: %lld MBytes\n", actualSize >> 20); 1042 } 1043 1044 if (fOptLong) 1045 { 1046 com::SafeArray<BSTR> names; 1047 com::SafeArray<BSTR> values; 1048 pMedium->GetProperties(Bstr().raw(), ComSafeArrayAsOutParam(names), ComSafeArrayAsOutParam(values)); 1049 size_t cNames = names.size(); 1050 size_t cValues = values.size(); 1051 bool fFirst = true; 1052 for (size_t i = 0; i < cNames; i++) 1053 { 1054 Bstr value; 1055 if (i < cValues) 1056 value = values[i]; 1057 RTPrintf("%s%ls=%ls\n", 1058 fFirst ? "Property: " : " ", 1059 names[i], value.raw()); 1060 } 1061 } 1062 1063 if (fOptLong) 1064 { 1065 bool fFirst = true; 1066 com::SafeArray<BSTR> machineIds; 1067 pMedium->COMGETTER(MachineIds)(ComSafeArrayAsOutParam(machineIds)); 1068 for (size_t i = 0; i < machineIds.size(); i++) 1069 { 1070 ComPtr<IMachine> machine; 1071 CHECK_ERROR(pVirtualBox, FindMachine(machineIds[i], machine.asOutParam())); 1072 if (machine) 1073 { 1074 Bstr name; 1075 machine->COMGETTER(Name)(name.asOutParam()); 1076 machine->COMGETTER(Id)(uuid.asOutParam()); 1077 RTPrintf("%s%ls (UUID: %ls)", 1078 fFirst ? "In use by VMs: " : " ", 1079 name.raw(), machineIds[i]); 1080 fFirst = false; 1081 com::SafeArray<BSTR> snapshotIds; 1082 pMedium->GetSnapshotIds(machineIds[i], 1083 ComSafeArrayAsOutParam(snapshotIds)); 1084 for (size_t j = 0; j < snapshotIds.size(); j++) 1085 { 1086 ComPtr<ISnapshot> snapshot; 1087 machine->FindSnapshot(snapshotIds[j], snapshot.asOutParam()); 1088 if (snapshot) 1089 { 1090 Bstr snapshotName; 1091 snapshot->COMGETTER(Name)(snapshotName.asOutParam()); 1092 RTPrintf(" [%ls (UUID: %ls)]", snapshotName.raw(), snapshotIds[j]); 1093 } 1094 } 1095 RTPrintf("\n"); 1096 } 1097 } 1098 } 1099 1100 if (fOptLong) 1101 { 1102 com::SafeIfaceArray<IMedium> children; 1103 pMedium->COMGETTER(Children)(ComSafeArrayAsOutParam(children)); 1104 bool fFirst = true; 1105 for (size_t i = 0; i < children.size(); i++) 1106 { 1107 ComPtr<IMedium> pChild(children[i]); 1108 if (pChild) 1109 { 1110 Bstr childUUID; 1111 pChild->COMGETTER(Id)(childUUID.asOutParam()); 1112 RTPrintf("%s%ls\n", 1113 fFirst ? "Child UUIDs: " : " ", 1114 childUUID.raw()); 1115 fFirst = false; 1116 } 1117 } 1118 } 1119 } 1120 while (0); 1121 1122 return rc; 1123 } 1124 896 1125 static const RTGETOPTDEF g_aShowHardDiskInfoOptions[] = 897 1126 { … … 943 1172 944 1173 ComPtr<IMedium> hardDisk; 945 946 1174 rc = openMedium(a, FilenameOrUuid, DeviceType_HardDisk, 947 1175 AccessMode_ReadOnly, hardDisk, … … 950 1178 return 1; 951 1179 952 do 953 { 954 Bstr uuid; 955 hardDisk->COMGETTER(Id)(uuid.asOutParam()); 956 RTPrintf("UUID: %s\n", Utf8Str(uuid).c_str()); 957 958 /* check for accessibility */ 959 /// @todo NEWMEDIA check accessibility of all parents 960 /// @todo NEWMEDIA print the full state value 961 MediumState_T state; 962 CHECK_ERROR_BREAK(hardDisk, RefreshState(&state)); 963 RTPrintf("Accessible: %s\n", state != MediumState_Inaccessible ? "yes" : "no"); 964 965 if (state == MediumState_Inaccessible) 966 { 967 Bstr err; 968 CHECK_ERROR_BREAK(hardDisk, COMGETTER(LastAccessError)(err.asOutParam())); 969 RTPrintf("Access Error: %ls\n", err.raw()); 970 } 971 972 Bstr description; 973 hardDisk->COMGETTER(Description)(description.asOutParam()); 974 if (!description.isEmpty()) 975 { 976 RTPrintf("Description: %ls\n", description.raw()); 977 } 978 979 LONG64 logicalSize; 980 hardDisk->COMGETTER(LogicalSize)(&logicalSize); 981 RTPrintf("Logical size: %lld MBytes\n", logicalSize >> 20); 982 LONG64 actualSize; 983 hardDisk->COMGETTER(Size)(&actualSize); 984 RTPrintf("Current size on disk: %lld MBytes\n", actualSize >> 20); 985 986 ComPtr <IMedium> parent; 987 hardDisk->COMGETTER(Parent)(parent.asOutParam()); 988 989 MediumType_T type; 990 hardDisk->COMGETTER(Type)(&type); 991 const char *typeStr = "unknown"; 992 switch (type) 993 { 994 case MediumType_Normal: 995 if (!parent.isNull()) 996 typeStr = "normal (differencing)"; 997 else 998 typeStr = "normal (base)"; 999 break; 1000 case MediumType_Immutable: 1001 typeStr = "immutable"; 1002 break; 1003 case MediumType_Writethrough: 1004 typeStr = "writethrough"; 1005 break; 1006 case MediumType_Shareable: 1007 typeStr = "shareable"; 1008 break; 1009 case MediumType_Readonly: 1010 typeStr = "readonly"; 1011 break; 1012 case MediumType_MultiAttach: 1013 typeStr = "multiattach"; 1014 break; 1015 } 1016 RTPrintf("Type: %s\n", typeStr); 1017 1018 Bstr format; 1019 hardDisk->COMGETTER(Format)(format.asOutParam()); 1020 RTPrintf("Storage format: %ls\n", format.raw()); 1021 1022 com::SafeArray<MediumVariant_T> safeArray_variant; 1023 1024 hardDisk->COMGETTER(Variant)(ComSafeArrayAsOutParam(safeArray_variant)); 1025 ULONG variant=0; 1026 for (size_t i = 0; i < safeArray_variant.size(); i++) 1027 variant |= safeArray_variant[i]; 1028 1029 const char *variantStr = "unknown"; 1030 switch (variant & ~(MediumVariant_Fixed | MediumVariant_Diff)) 1031 { 1032 case MediumVariant_VmdkSplit2G: 1033 variantStr = "split2G"; 1034 break; 1035 case MediumVariant_VmdkStreamOptimized: 1036 variantStr = "streamOptimized"; 1037 break; 1038 case MediumVariant_VmdkESX: 1039 variantStr = "ESX"; 1040 break; 1041 case MediumVariant_Standard: 1042 variantStr = "default"; 1043 break; 1044 } 1045 const char *variantTypeStr = "dynamic"; 1046 if (variant & MediumVariant_Fixed) 1047 variantTypeStr = "fixed"; 1048 else if (variant & MediumVariant_Diff) 1049 variantTypeStr = "differencing"; 1050 RTPrintf("Format variant: %s %s\n", variantTypeStr, variantStr); 1051 1052 /// @todo also dump config parameters (iSCSI) 1053 1054 com::SafeArray<BSTR> machineIds; 1055 hardDisk->COMGETTER(MachineIds)(ComSafeArrayAsOutParam(machineIds)); 1056 for (size_t j = 0; j < machineIds.size(); ++ j) 1057 { 1058 ComPtr<IMachine> machine; 1059 CHECK_ERROR(a->virtualBox, FindMachine(machineIds[j], machine.asOutParam())); 1060 ASSERT(machine); 1061 Bstr name; 1062 machine->COMGETTER(Name)(name.asOutParam()); 1063 machine->COMGETTER(Id)(uuid.asOutParam()); 1064 RTPrintf("%s%ls (UUID: %ls)\n", 1065 j == 0 ? "In use by VMs: " : " ", 1066 name.raw(), machineIds[j]); 1067 } 1068 /// @todo NEWMEDIA check usage in snapshots too 1069 /// @todo NEWMEDIA also list children 1070 1071 Bstr loc; 1072 hardDisk->COMGETTER(Location)(loc.asOutParam()); 1073 RTPrintf("Location: %ls\n", loc.raw()); 1074 1075 /* print out information specific for differencing hard disks */ 1076 if (!parent.isNull()) 1077 { 1078 BOOL autoReset = FALSE; 1079 hardDisk->COMGETTER(AutoReset)(&autoReset); 1080 RTPrintf("Auto-Reset: %s\n", autoReset ? "on" : "off"); 1081 } 1082 } 1083 while (0); 1180 Utf8Str strParentUUID("base"); 1181 ComPtr<IMedium> parent; 1182 hardDisk->COMGETTER(Parent)(parent.asOutParam()); 1183 if (!parent.isNull()) 1184 { 1185 Bstr bstrParentUUID; 1186 parent->COMGETTER(Id)(bstrParentUUID.asOutParam()); 1187 strParentUUID = bstrParentUUID; 1188 } 1189 1190 rc = showMediumInfo(a->virtualBox, hardDisk, strParentUUID.c_str(), true); 1084 1191 1085 1192 return SUCCEEDED(rc) ? 0 : 1; -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageList.cpp
r43876 r44498 5 5 6 6 /* 7 * Copyright (C) 2006-201 2Oracle Corporation7 * Copyright (C) 2006-2013 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 212 212 * @returns See produceList. 213 213 * @param pVirtualBox Reference to the IVirtualBox smart pointer. 214 * @param aMedia Medium objects to list information for. 215 * @param pszParentUUIDStr String with the parent UUID string (or "base"). 216 * @param fOptLong Long (@c true) or short list format. 214 217 */ 215 218 static HRESULT listMedia(const ComPtr<IVirtualBox> pVirtualBox, 216 219 const com::SafeIfaceArray<IMedium> &aMedia, 217 const char *pszParentUUIDStr) 220 const char *pszParentUUIDStr, 221 bool fOptLong) 218 222 { 219 223 HRESULT rc = S_OK; … … 221 225 { 222 226 ComPtr<IMedium> pMedium = aMedia[i]; 223 Bstr uuid; 224 pMedium->COMGETTER(Id)(uuid.asOutParam()); 225 RTPrintf("UUID: %s\n", Utf8Str(uuid).c_str()); 226 if (pszParentUUIDStr) 227 RTPrintf("Parent UUID: %s\n", pszParentUUIDStr); 228 Bstr format; 229 pMedium->COMGETTER(Format)(format.asOutParam()); 230 RTPrintf("Format: %ls\n", format.raw()); 231 Bstr filepath; 232 pMedium->COMGETTER(Location)(filepath.asOutParam()); 233 RTPrintf("Location: %ls\n", filepath.raw()); 234 235 MediumState_T enmState; 236 pMedium->RefreshState(&enmState); 237 const char *stateStr = "unknown"; 238 switch (enmState) 239 { 240 case MediumState_NotCreated: 241 stateStr = "not created"; 242 break; 243 case MediumState_Created: 244 stateStr = "created"; 245 break; 246 case MediumState_LockedRead: 247 stateStr = "locked read"; 248 break; 249 case MediumState_LockedWrite: 250 stateStr = "locked write"; 251 break; 252 case MediumState_Inaccessible: 253 stateStr = "inaccessible"; 254 break; 255 case MediumState_Creating: 256 stateStr = "creating"; 257 break; 258 case MediumState_Deleting: 259 stateStr = "deleting"; 260 break; 261 } 262 RTPrintf("State: %s\n", stateStr); 263 264 MediumType_T type; 265 pMedium->COMGETTER(Type)(&type); 266 const char *typeStr = "unknown"; 267 switch (type) 268 { 269 case MediumType_Normal: 270 typeStr = "normal"; 271 break; 272 case MediumType_Immutable: 273 typeStr = "immutable"; 274 break; 275 case MediumType_Writethrough: 276 typeStr = "writethrough"; 277 break; 278 case MediumType_Shareable: 279 typeStr = "shareable"; 280 break; 281 case MediumType_Readonly: 282 typeStr = "readonly"; 283 break; 284 case MediumType_MultiAttach: 285 typeStr = "multiattach"; 286 break; 287 } 288 RTPrintf("Type: %s\n", typeStr); 289 290 com::SafeArray<BSTR> machineIds; 291 pMedium->COMGETTER(MachineIds)(ComSafeArrayAsOutParam(machineIds)); 292 for (size_t j = 0; j < machineIds.size(); ++j) 293 { 294 ComPtr<IMachine> machine; 295 CHECK_ERROR(pVirtualBox, FindMachine(machineIds[j], machine.asOutParam())); 296 ASSERT(machine); 297 Bstr name; 298 machine->COMGETTER(Name)(name.asOutParam()); 299 RTPrintf("%s%ls (UUID: %ls)", 300 j == 0 ? "Usage: " : " ", 301 name.raw(), machineIds[j]); 302 com::SafeArray<BSTR> snapshotIds; 303 pMedium->GetSnapshotIds(machineIds[j], 304 ComSafeArrayAsOutParam(snapshotIds)); 305 for (size_t k = 0; k < snapshotIds.size(); ++k) 306 { 307 ComPtr<ISnapshot> snapshot; 308 machine->FindSnapshot(snapshotIds[k], snapshot.asOutParam()); 309 if (snapshot) 310 { 311 Bstr snapshotName; 312 snapshot->COMGETTER(Name)(snapshotName.asOutParam()); 313 RTPrintf(" [%ls (UUID: %ls)]", snapshotName.raw(), snapshotIds[k]); 314 } 315 } 316 RTPrintf("\n"); 317 } 227 228 rc = showMediumInfo(pVirtualBox, pMedium, pszParentUUIDStr, fOptLong); 229 318 230 RTPrintf("\n"); 319 231 … … 322 234 if (children.size() > 0) 323 235 { 236 Bstr uuid; 237 pMedium->COMGETTER(Id)(uuid.asOutParam()); 238 324 239 // depth first listing of child media 325 rc = listMedia(pVirtualBox, children, Utf8Str(uuid).c_str() );240 rc = listMedia(pVirtualBox, children, Utf8Str(uuid).c_str(), fOptLong); 326 241 } 327 242 } … … 1003 918 com::SafeIfaceArray<IMedium> hdds; 1004 919 CHECK_ERROR(pVirtualBox, COMGETTER(HardDisks)(ComSafeArrayAsOutParam(hdds))); 1005 rc = listMedia(pVirtualBox, hdds, "base" );920 rc = listMedia(pVirtualBox, hdds, "base", fOptLong); 1006 921 break; 1007 922 } … … 1011 926 com::SafeIfaceArray<IMedium> dvds; 1012 927 CHECK_ERROR(pVirtualBox, COMGETTER(DVDImages)(ComSafeArrayAsOutParam(dvds))); 1013 rc = listMedia(pVirtualBox, dvds, NULL );928 rc = listMedia(pVirtualBox, dvds, NULL, fOptLong); 1014 929 break; 1015 930 } … … 1019 934 com::SafeIfaceArray<IMedium> floppies; 1020 935 CHECK_ERROR(pVirtualBox, COMGETTER(FloppyImages)(ComSafeArrayAsOutParam(floppies))); 1021 rc = listMedia(pVirtualBox, floppies, NULL );936 rc = listMedia(pVirtualBox, floppies, NULL, fOptLong); 1022 937 break; 1023 938 }
Note:
See TracChangeset
for help on using the changeset viewer.