VirtualBox

Ignore:
Timestamp:
Jul 10, 2024 9:39:16 AM (9 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
163901
Message:

Main,FE/VBoxManage: Add method to query which execution engines supported by a build are actually supported by the host. Primarily for querying whether the native API is accessible on a host

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageList.cpp

    r103598 r105254  
    21342134
    21352135
     2136static HRESULT listExecutionEnginesForCpuArchitecture(CPUArchitecture_T enmCpuArchitecture, const ComPtr<ISystemProperties> ptrSysProps, const ComPtr<IHost> pHost,
     2137                                                      HRESULT hrc)
     2138{
     2139    const char *pszArchitecture = "???";
     2140    switch (enmCpuArchitecture)
     2141    {
     2142        case CPUArchitecture_x86:      pszArchitecture = "x86"; break;
     2143        case CPUArchitecture_AMD64:    pszArchitecture = "AMD64"; break;
     2144        case CPUArchitecture_ARMv8_32: pszArchitecture = "ARMv8 (32-bit only)"; break;
     2145        case CPUArchitecture_ARMv8_64: pszArchitecture = "ARMv8 (64-bit)"; break;
     2146#ifdef VBOX_WITH_XPCOM_CPP_ENUM_HACK
     2147        case CPUArchitecture_32BitHack:
     2148#endif
     2149        case CPUArchitecture_Any:
     2150            break;
     2151    }
     2152
     2153    /* Query all possible execution engines supported by the build. */
     2154    com::SafeArray<VMExecutionEngine_T> aExecutionEngines;
     2155    CHECK_ERROR2I_RET(ptrSysProps, GetExecutionEnginesForVmCpuArchitecture(enmCpuArchitecture,
     2156                                                                           ComSafeArrayAsOutParam(aExecutionEngines)), hrcCheck);
     2157
     2158    /* Don't dump anything if the architecture is not supported at all. */
     2159    if (aExecutionEngines.size())
     2160    {
     2161        /* Now filter out the ones the host actually supports. */
     2162        std::vector<VMExecutionEngine_T> vecExecEnginesSupported;
     2163        for (size_t i = 0; i < aExecutionEngines.size(); i++)
     2164        {
     2165            BOOL fSupported = FALSE;
     2166            CHECK_ERROR2I_RET(pHost, IsExecutionEngineSupported(enmCpuArchitecture, aExecutionEngines[i], &fSupported), hrcCheck);
     2167            if (fSupported)
     2168                vecExecEnginesSupported.push_back(aExecutionEngines[i]);
     2169        }
     2170
     2171        RTPrintf(List::tr("CPU Architecture: %s\n"), pszArchitecture);
     2172
     2173        /* Print what we've got. */
     2174        for (size_t i = 0; i < vecExecEnginesSupported.size(); i++)
     2175        {
     2176            const char *pszExecEngine = "???";
     2177            switch (vecExecEnginesSupported[i])
     2178            {
     2179                case VMExecutionEngine_Default:     pszExecEngine = "Default";     break;
     2180                case VMExecutionEngine_HwVirt:      pszExecEngine = "HwVirt";      break;
     2181                case VMExecutionEngine_NativeApi:   pszExecEngine = "NativeApi";   break;
     2182                case VMExecutionEngine_Interpreter: pszExecEngine = "Interpreter"; break;
     2183                case VMExecutionEngine_Recompiler:  pszExecEngine = "Recompiler";  break;
     2184                default: break;
     2185            }
     2186
     2187            RTPrintf("  #%02zu: %s\n", i, pszExecEngine);
     2188        }
     2189    }
     2190
     2191    return hrc;
     2192}
     2193
     2194
     2195/**
     2196 * List all execution engines supported by the host.
     2197 *
     2198 * @returns See produceList.
     2199 * @param   ptrVirtualBox       Reference to the smart IVirtualBox pointer.
     2200 */
     2201static HRESULT listExecutionEngines(const ComPtr<IVirtualBox> &ptrVirtualBox)
     2202{
     2203    ComPtr<ISystemProperties> ptrSysProps;
     2204    CHECK_ERROR2I_RET(ptrVirtualBox, COMGETTER(SystemProperties)(ptrSysProps.asOutParam()), hrcCheck);
     2205    ComPtr<IHost> pHost;
     2206    CHECK_ERROR2I_RET(ptrVirtualBox, COMGETTER(Host)(pHost.asOutParam()), hrcCheck);
     2207
     2208    HRESULT hrc = listExecutionEnginesForCpuArchitecture(CPUArchitecture_x86,      ptrSysProps, pHost, S_OK);
     2209            hrc = listExecutionEnginesForCpuArchitecture(CPUArchitecture_AMD64,    ptrSysProps, pHost, hrc);
     2210            hrc = listExecutionEnginesForCpuArchitecture(CPUArchitecture_ARMv8_32, ptrSysProps, pHost, hrc);
     2211            hrc = listExecutionEnginesForCpuArchitecture(CPUArchitecture_ARMv8_64, ptrSysProps, pHost, hrc);
     2212
     2213    return hrc;
     2214}
     2215
     2216
    21362217/**
    21372218 * The type of lists we can produce.
     
    21782259    kListCloudProfiles,
    21792260    kListCPUProfiles,
    2180     kListHostDrives
     2261    kListHostDrives,
     2262    kListExecutionEngines
    21812263};
    21822264
     
    25332615            hrc = listHostDrives(pVirtualBox, fOptLong);
    25342616            break;
     2617
     2618        case kListExecutionEngines:
     2619            hrc = listExecutionEngines(pVirtualBox);
     2620            break;
     2621
    25352622        /* No default here, want gcc warnings. */
    25362623
     
    26042691        { "cpu-profiles",       kListCPUProfiles,        RTGETOPT_REQ_NOTHING },
    26052692        { "hostdrives",         kListHostDrives,         RTGETOPT_REQ_NOTHING },
     2693        { "execution-engines",  kListExecutionEngines,   RTGETOPT_REQ_NOTHING },
    26062694    };
    26072695
     
    26752763            case kListCPUProfiles:
    26762764            case kListHostDrives:
     2765            case kListExecutionEngines:
    26772766                enmOptCommand = (enum ListType_T)ch;
    26782767                if (fOptMultiple)
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette