- Timestamp:
- Jul 31, 2020 12:45:16 PM (5 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/Makefile.kmk
r85489 r85574 564 564 src-server/ClientToken.cpp \ 565 565 src-server/CloudProviderManagerImpl.cpp \ 566 src-server/CPUProfileImpl.cpp \ 566 567 src-server/DataStreamImpl.cpp \ 567 568 src-server/DHCPServerImpl.cpp \ -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r85569 r85574 978 978 The session is being unlocked. 979 979 </desc> 980 </const> 981 </enum> 982 983 <enum 984 name="CPUArchitecture" 985 uuid="4a2c9915-12f1-43b2-bb84-e4bd4d5ca227" 986 > 987 <desc>Basic CPU architecture types.</desc> 988 <const name="Any" value="0"> 989 <desc>Matches any CPU architecture.</desc> 990 </const> 991 <const name="x86" value="1"> 992 <desc>32-bit (and 16-bit) x86.</desc> 993 </const> 994 <const name="AMD64" value="2"> 995 <desc>64-bit x86. (Also known as x86-64 or x64.)</desc> 980 996 </const> 981 997 </enum> … … 6548 6564 to change. 6549 6565 6550 The profiles are found in src/VBox/VMM/VMMR3/cpus/. 6566 Use the <link to="ISystemProperties::getCPUProfiles" /> method to get 6567 currently available CPU profiles. 6551 6568 </desc> 6552 6569 </attribute> … … 10729 10746 10730 10747 <!-- 10748 // ICPUProfile 10749 ///////////////////////////////////////////////////////////////////////// 10750 --> 10751 <interface 10752 name="ICPUProfile" 10753 extends="$unknown" 10754 uuid="b7fda727-7a08-46ee-8dd8-f8d7308b519c" 10755 wsmap="managed" 10756 reservedMethods="4" reservedAttributes="8" 10757 > 10758 <desc>CPU profile. Immutable.</desc> 10759 <attribute name="name" type="wstring" readonly="yes"> 10760 <desc>The name.</desc> 10761 </attribute> 10762 <attribute name="fullName" type="wstring" readonly="yes"> 10763 <desc>The full name.</desc> 10764 </attribute> 10765 <attribute name="architecture" type="CPUArchitecture" readonly="yes"> 10766 <desc>The CPU architecture.</desc> 10767 </attribute> 10768 </interface> 10769 10770 <!-- 10731 10771 // ISystemProperties 10732 10772 ///////////////////////////////////////////////////////////////////////// … … 10749 10789 name="ISystemProperties" 10750 10790 extends="$unknown" 10751 uuid=" 027bc463-929c-40e8-bf16-fea557cd8e7e"10791 uuid="81c55eb1-d584-41a7-aa0b-08b71cddd773" 10752 10792 wsmap="managed" 10753 10793 reservedMethods="4" reservedAttributes="16" … … 11457 11497 <param name="maxInstances" type="unsigned long" dir="return"> 11458 11498 <desc>The maximum number of instances for the given USB controller type.</desc> 11499 </param> 11500 </method> 11501 11502 <method name="getCPUProfiles"> 11503 <desc>Returns CPU profiles matching the given criteria.</desc> 11504 11505 <param name="architecture" type="CPUArchitecture" dir="in"> 11506 <desc>The architecture to get profiles for. Required.</desc> 11507 </param> 11508 <param name="namePattern" type="wstring" dir="in"> 11509 <desc>Name pattern. Simple wildcard matching using asterisk (*) and 11510 question mark (?).</desc> 11511 </param> 11512 <param name="profiles" type="ICPUProfile" safearray="yes" dir="return"> 11513 <desc>The matching CPU profiles.</desc> 11459 11514 </param> 11460 11515 </method> -
trunk/src/VBox/Main/include/SystemPropertiesImpl.h
r82968 r85574 27 27 #include "SystemPropertiesWrap.h" 28 28 29 class CPUProfile; 29 30 30 31 namespace settings … … 38 39 public: 39 40 typedef std::list<ComObjPtr<MediumFormat> > MediumFormatList; 41 typedef std::list<ComObjPtr<CPUProfile> > CPUProfileList_T; 40 42 41 43 DECLARE_EMPTY_CTOR_DTOR(SystemProperties) … … 169 171 USBControllerType_T aType, 170 172 ULONG *aMaxInstances) RT_OVERRIDE; 173 HRESULT getCPUProfiles(CPUArchitecture_T aArchitecture, const com::Utf8Str &aNamePattern, 174 std::vector<ComPtr<ICPUProfile> > &aProfiles) RT_OVERRIDE; 171 175 172 176 HRESULT i_getUserHomeDirectory(Utf8Str &strPath); … … 188 192 MediumFormatList m_llMediumFormats; 189 193 194 bool m_fLoadedX86CPUProfiles; /**< Set if we've loaded the x86 and AMD64 CPU profiles. */ 195 CPUProfileList_T m_llCPUProfiles; /**< List of loaded CPU profiles. */ 196 190 197 friend class VirtualBox; 191 198 }; -
trunk/src/VBox/Main/src-server/SystemPropertiesImpl.cpp
r84978 r85574 23 23 # include "ExtPackManagerImpl.h" 24 24 #endif 25 #include "CPUProfileImpl.h" 25 26 #include "AutoCaller.h" 26 27 #include "Global.h" … … 42 43 #include <VBox/settings.h> 43 44 #include <VBox/vd.h> 45 #include <VBox/vmm/cpum.h> 44 46 45 47 // defines … … 50 52 51 53 SystemProperties::SystemProperties() 52 : mParent(NULL), 53 m(new settings::SystemProperties) 54 : mParent(NULL) 55 , m(new settings::SystemProperties) 56 , m_fLoadedX86CPUProfiles(false) 54 57 { 55 58 } … … 710 713 return S_OK; 711 714 } 715 716 HRESULT SystemProperties::getCPUProfiles(CPUArchitecture_T aArchitecture, const com::Utf8Str &aNamePattern, 717 std::vector<ComPtr<ICPUProfile> > &aProfiles) 718 { 719 /* 720 * Validate and adjust the architecture. 721 */ 722 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 723 CPUArchitecture_T enmSecondaryArch = aArchitecture; 724 bool fLoaded; 725 switch (aArchitecture) 726 { 727 case CPUArchitecture_Any: 728 aArchitecture = CPUArchitecture_AMD64; 729 RT_FALL_THROUGH(); 730 case CPUArchitecture_AMD64: 731 enmSecondaryArch = CPUArchitecture_x86; 732 RT_FALL_THROUGH(); 733 case CPUArchitecture_x86: 734 fLoaded = m_fLoadedX86CPUProfiles; 735 break; 736 default: 737 return setError(E_INVALIDARG, tr("Invalid or unsupported architecture value: %d"), aArchitecture); 738 } 739 740 /* 741 * Do we need to load the profiles? 742 */ 743 HRESULT hrc; 744 if (fLoaded) 745 hrc = S_OK; 746 else 747 { 748 alock.release(); 749 AutoWriteLock alockWrite(this COMMA_LOCKVAL_SRC_POS); 750 751 /* 752 * Translate the architecture to a VMM module handle. 753 */ 754 const char *pszVMM; 755 switch (aArchitecture) 756 { 757 case CPUArchitecture_AMD64: 758 case CPUArchitecture_x86: 759 pszVMM = "VBoxVMM"; 760 fLoaded = m_fLoadedX86CPUProfiles; 761 break; 762 default: 763 AssertFailedReturn(E_INVALIDARG); 764 } 765 if (fLoaded) 766 hrc = S_OK; 767 else 768 { 769 char szPath[RTPATH_MAX]; 770 int vrc = RTPathAppPrivateArch(szPath, sizeof(szPath)); 771 if (RT_SUCCESS(vrc)) 772 vrc = RTPathAppend(szPath, sizeof(szPath), pszVMM); 773 if (RT_SUCCESS(vrc)) 774 vrc = RTStrCat(szPath, sizeof(szPath), RTLdrGetSuff()); 775 if (RT_SUCCESS(vrc)) 776 { 777 RTLDRMOD hMod = NIL_RTLDRMOD; 778 vrc = RTLdrLoad(szPath, &hMod); 779 if (RT_SUCCESS(vrc)) 780 { 781 /* 782 * Resolve the CPUMDb APIs we need. 783 */ 784 PFNCPUMDBGETENTRIES pfnGetEntries 785 = (PFNCPUMDBGETENTRIES)RTLdrGetFunction(hMod, "CPUMR3DbGetEntries"); 786 PFNCPUMDBGETENTRYBYINDEX pfnGetEntryByIndex 787 = (PFNCPUMDBGETENTRYBYINDEX)RTLdrGetFunction(hMod, "CPUMR3DbGetEntryByIndex"); 788 if (pfnGetEntries && pfnGetEntryByIndex) 789 { 790 size_t const cExistingProfiles = m_llCPUProfiles.size(); 791 792 /* 793 * Instantate the profiles. 794 */ 795 hrc = S_OK; 796 uint32_t const cEntries = pfnGetEntries(); 797 for (uint32_t i = 0; i < cEntries; i++) 798 { 799 PCCPUMDBENTRY pDbEntry = pfnGetEntryByIndex(i); 800 AssertBreakStmt(pDbEntry, hrc = setError(E_UNEXPECTED, "CPUMR3DbGetEntryByIndex failed for %i", i)); 801 802 ComObjPtr<CPUProfile> ptrProfile; 803 hrc = ptrProfile.createObject(); 804 if (SUCCEEDED(hrc)) 805 { 806 hrc = ptrProfile->initFromDbEntry(pDbEntry); 807 if (SUCCEEDED(hrc)) 808 { 809 try 810 { 811 m_llCPUProfiles.push_back(ptrProfile); 812 continue; 813 } 814 catch (std::bad_alloc &) 815 { 816 hrc = E_OUTOFMEMORY; 817 } 818 } 819 } 820 break; 821 } 822 823 /* 824 * On success update the flag and retake the read lock. 825 * If we fail, drop the profiles we added to the list. 826 */ 827 if (SUCCEEDED(hrc)) 828 { 829 switch (aArchitecture) 830 { 831 case CPUArchitecture_AMD64: 832 case CPUArchitecture_x86: 833 m_fLoadedX86CPUProfiles = true; 834 break; 835 default: 836 AssertFailedStmt(hrc = E_INVALIDARG); 837 } 838 839 alockWrite.release(); 840 alock.acquire(); 841 } 842 else 843 m_llCPUProfiles.resize(cExistingProfiles); 844 } 845 else 846 hrc = setErrorVrc(VERR_SYMBOL_NOT_FOUND, 847 tr("'%s' is missing symbols: CPUMR3DbGetEntries, CPUMR3DbGetEntryByIndex"), szPath); 848 RTLdrClose(hMod); 849 } 850 else 851 hrc = setErrorVrc(vrc, tr("Failed to construct load '%s': %Rrc"), szPath, vrc); 852 } 853 else 854 hrc = setErrorVrc(vrc, tr("Failed to construct path to the VMM DLL/Dylib/SharedObject: %Rrc"), vrc); 855 } 856 } 857 if (SUCCEEDED(hrc)) 858 { 859 /* 860 * Return the matching profiles. 861 */ 862 /* Count matches: */ 863 size_t cMatches = 0; 864 for (CPUProfileList_T::const_iterator it = m_llCPUProfiles.begin(); it != m_llCPUProfiles.end(); ++it) 865 if ((*it)->i_match(aArchitecture, enmSecondaryArch, aNamePattern)) 866 cMatches++; 867 868 /* Resize the output array. */ 869 try 870 { 871 aProfiles.resize(cMatches); 872 } 873 catch (std::bad_alloc &) 874 { 875 aProfiles.resize(0); 876 hrc = E_OUTOFMEMORY; 877 } 878 879 /* Get the return objects: */ 880 if (SUCCEEDED(hrc) && cMatches > 0) 881 { 882 size_t iMatch = 0; 883 for (CPUProfileList_T::const_iterator it = m_llCPUProfiles.begin(); it != m_llCPUProfiles.end(); ++it) 884 if ((*it)->i_match(aArchitecture, enmSecondaryArch, aNamePattern)) 885 { 886 AssertBreakStmt(iMatch < cMatches, hrc = E_UNEXPECTED); 887 hrc = (*it).queryInterfaceTo(aProfiles[iMatch].asOutParam()); 888 if (SUCCEEDED(hrc)) 889 iMatch++; 890 else 891 break; 892 } 893 AssertStmt(iMatch == cMatches || FAILED(hrc), hrc = E_UNEXPECTED); 894 } 895 } 896 return hrc; 897 } 898 712 899 713 900 HRESULT SystemProperties::getDefaultMachineFolder(com::Utf8Str &aDefaultMachineFolder)
Note:
See TracChangeset
for help on using the changeset viewer.