Changeset 85575 in vbox for trunk/src/VBox/Frontends/VBoxManage
- Timestamp:
- Jul 31, 2020 12:45:54 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 139647
- Location:
- trunk/src/VBox/Frontends/VBoxManage
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp
r85178 r85575 480 480 " groups|webcams|screenshotformats|cloudproviders|\n" 481 481 #if defined(VBOX_WITH_CLOUD_NET) 482 " cloudprofiles|cloudnets \n"482 " cloudprofiles|cloudnets|cpu-profiles\n" 483 483 #else 484 " cloudprofiles \n"484 " cloudprofiles|cpu-profiles\n" 485 485 #endif 486 486 "\n", SEP); -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageList.cpp
r83169 r85575 1155 1155 * @param pVirtualBox Reference to the IVirtualBox pointer. 1156 1156 */ 1157 static HRESULT listVideoInputDevices(const ComPtr<IVirtualBox> pVirtualBox)1157 static HRESULT listVideoInputDevices(const ComPtr<IVirtualBox> &pVirtualBox) 1158 1158 { 1159 1159 HRESULT rc; … … 1183 1183 * @param pVirtualBox Reference to the IVirtualBox pointer. 1184 1184 */ 1185 static HRESULT listScreenShotFormats(const ComPtr<IVirtualBox> pVirtualBox)1185 static HRESULT listScreenShotFormats(const ComPtr<IVirtualBox> &pVirtualBox) 1186 1186 { 1187 1187 HRESULT rc = S_OK; … … 1212 1212 * @param pVirtualBox Reference to the IVirtualBox pointer. 1213 1213 */ 1214 static HRESULT listCloudProviders(const ComPtr<IVirtualBox> pVirtualBox)1214 static HRESULT listCloudProviders(const ComPtr<IVirtualBox> &pVirtualBox) 1215 1215 { 1216 1216 HRESULT rc = S_OK; … … 1246 1246 * @param fOptLong If true, list all profile properties. 1247 1247 */ 1248 static HRESULT listCloudProfiles(const ComPtr<IVirtualBox> pVirtualBox, bool fOptLong)1248 static HRESULT listCloudProfiles(const ComPtr<IVirtualBox> &pVirtualBox, bool fOptLong) 1249 1249 { 1250 1250 HRESULT rc = S_OK; … … 1295 1295 } 1296 1296 1297 static HRESULT displayCPUProfile(ICPUProfile *pProfile, size_t idx, int cchIdx, bool fOptLong, HRESULT hrc) 1298 { 1299 /* Retrieve the attributes needed for both long and short display. */ 1300 Bstr bstrName; 1301 CHECK_ERROR2I_RET(pProfile, COMGETTER(Name)(bstrName.asOutParam()), hrcCheck); 1302 1303 CPUArchitecture_T enmArchitecture = CPUArchitecture_Any; 1304 CHECK_ERROR2I_RET(pProfile, COMGETTER(Architecture)(&enmArchitecture), hrcCheck); 1305 const char *pszArchitecture = "???"; 1306 switch (enmArchitecture) 1307 { 1308 case CPUArchitecture_x86: pszArchitecture = "x86"; break; 1309 case CPUArchitecture_AMD64: pszArchitecture = "AMD64"; break; 1310 1311 case CPUArchitecture_32BitHack: 1312 case CPUArchitecture_Any: 1313 break; 1314 } 1315 1316 /* Print what we've got. */ 1317 if (!fOptLong) 1318 RTPrintf("#%0*zu: %ls [%s]\n", cchIdx, idx, bstrName.raw(), pszArchitecture); 1319 else 1320 { 1321 RTPrintf("CPU Profile #%02zu:\n", idx); 1322 RTPrintf(" Architecture: %s\n", pszArchitecture); 1323 RTPrintf(" Name: %ls\n", bstrName.raw()); 1324 CHECK_ERROR2I_RET(pProfile, COMGETTER(FullName)(bstrName.asOutParam()), hrcCheck); 1325 RTPrintf(" Full Name: %ls\n", bstrName.raw()); 1326 } 1327 return hrc; 1328 } 1329 1330 1331 /** 1332 * List all CPU profiles. 1333 * 1334 * @returns See produceList. 1335 * @param ptrVirtualBox Reference to the smart IVirtualBox pointer. 1336 * @param fOptLong If true, list all profile properties. 1337 * @param fOptSorted Sort the output if true, otherwise display in 1338 * system order. 1339 */ 1340 static HRESULT listCPUProfiles(const ComPtr<IVirtualBox> &ptrVirtualBox, bool fOptLong, bool fOptSorted) 1341 { 1342 ComPtr<ISystemProperties> ptrSysProps; 1343 CHECK_ERROR2I_RET(ptrVirtualBox, COMGETTER(SystemProperties)(ptrSysProps.asOutParam()), hrcCheck); 1344 com::SafeIfaceArray<ICPUProfile> aCPUProfiles; 1345 CHECK_ERROR2I_RET(ptrSysProps, GetCPUProfiles(CPUArchitecture_Any, Bstr().raw(), 1346 ComSafeArrayAsOutParam(aCPUProfiles)), hrcCheck); 1347 1348 int const cchIdx = 1 + (aCPUProfiles.size() >= 10) + (aCPUProfiles.size() >= 100); 1349 1350 HRESULT hrc = S_OK; 1351 if (!fOptSorted) 1352 for (size_t i = 0; i < aCPUProfiles.size(); i++) 1353 hrc = displayCPUProfile(aCPUProfiles[i], i, cchIdx, fOptLong, hrc); 1354 else 1355 { 1356 std::vector<std::pair<com::Bstr, ICPUProfile *> > vecSortedProfiles; 1357 for (size_t i = 0; i < aCPUProfiles.size(); ++i) 1358 { 1359 Bstr bstrName; 1360 CHECK_ERROR2I_RET(aCPUProfiles[i], COMGETTER(Name)(bstrName.asOutParam()), hrcCheck); 1361 try 1362 { 1363 vecSortedProfiles.push_back(std::pair<com::Bstr, ICPUProfile *>(bstrName, aCPUProfiles[i])); 1364 } 1365 catch (std::bad_alloc &) 1366 { 1367 return E_OUTOFMEMORY; 1368 } 1369 } 1370 1371 std::sort(vecSortedProfiles.begin(), vecSortedProfiles.end()); 1372 1373 for (size_t i = 0; i < vecSortedProfiles.size(); i++) 1374 hrc = displayCPUProfile(vecSortedProfiles[i].second, i, cchIdx, fOptLong, hrc); 1375 } 1376 1377 return hrc; 1378 } 1379 1297 1380 1298 1381 /** 1299 1382 * The type of lists we can produce. 1300 1383 */ 1301 enum enmListType1384 enum ListType_T 1302 1385 { 1303 1386 kListNotSpecified = 1000, … … 1332 1415 kListCloudProviders, 1333 1416 kListCloudProfiles, 1417 kListCPUProfiles 1334 1418 }; 1335 1419 … … 1343 1427 * @param pVirtualBox Reference to the IVirtualBox smart pointer. 1344 1428 */ 1345 static HRESULT produceList(enum enmListTypeenmCommand, bool fOptLong, bool fOptSorted, const ComPtr<IVirtualBox> &pVirtualBox)1429 static HRESULT produceList(enum ListType_T enmCommand, bool fOptLong, bool fOptSorted, const ComPtr<IVirtualBox> &pVirtualBox) 1346 1430 { 1347 1431 HRESULT rc = S_OK; … … 1684 1768 break; 1685 1769 1770 case kListCPUProfiles: 1771 rc = listCPUProfiles(pVirtualBox, fOptLong, fOptSorted); 1772 break; 1773 1686 1774 /* No default here, want gcc warnings. */ 1687 1775 … … 1702 1790 bool fOptMultiple = false; 1703 1791 bool fOptSorted = false; 1704 enum enmListTypeenmOptCommand = kListNotSpecified;1792 enum ListType_T enmOptCommand = kListNotSpecified; 1705 1793 1706 1794 static const RTGETOPTDEF s_aListOptions[] = … … 1741 1829 { "cloudproviders", kListCloudProviders, RTGETOPT_REQ_NOTHING }, 1742 1830 { "cloudprofiles", kListCloudProfiles, RTGETOPT_REQ_NOTHING }, 1831 { "cpu-profiles", kListCPUProfiles, RTGETOPT_REQ_NOTHING }, 1743 1832 }; 1744 1833 … … 1797 1886 case kListCloudProviders: 1798 1887 case kListCloudProfiles: 1799 enmOptCommand = (enum enmListType)ch; 1888 case kListCPUProfiles: 1889 enmOptCommand = (enum ListType_T)ch; 1800 1890 if (fOptMultiple) 1801 1891 { 1802 HRESULT hrc = produceList( (enum enmListType)ch, fOptLong, fOptSorted, a->virtualBox);1892 HRESULT hrc = produceList(enmOptCommand, fOptLong, fOptSorted, a->virtualBox); 1803 1893 if (FAILED(hrc)) 1804 1894 return RTEXITCODE_FAILURE;
Note:
See TracChangeset
for help on using the changeset viewer.