Skip to content

Add basic detection of virtualization, hypervisors and emulation

Simon McVittie requested to merge wip/smcv/detect-virt into master
  • architecture: Use a table to identify ELF executables' architectures

  • architecture: Add SrtMachineType

  • json-utils: Factor out _srt_json_object_get_enum_member()

  • tests: Add test coverage for x86 CPU feature detection

    We can test this by inserting the ability to take mock data.

  • _srt_x86_cpuid: Optionally skip capability checking

    __get_cpuid() uses CPUID leaves 0 (highest function parameter and manufacturer ID) and 0x8000_0000 (highest extended function parameter) to check whether the requested leaf is available, but this doesn't work for pseudo-CPUIDs coming from the hypervisor, such as the hypervisor interface starting at 0x4000_0000. For those, we will have to do the capability checks ourselves. Add a parameter to indicate that we already did so.

  • Add basic detection of virtualization, hypervisors and emulation

    At the moment this handles anything that systemd detects via the easier mechanisms like CPUID or DMI ID, plus FEX-Emu. It does not handle more complicated detection mechanisms such as PCI devices or DeviceTree.

    As a design-for-test feature, the low-level detection function can be given mock information to use instead of the real system.

  • system-info: Add public API for virtualization detection

  • system-info: Add JSON (de)serialization for virtualization info


I've been meaning to add this for a while. Helps: #81 (closed).

Edited by Simon McVittie

Merge request reports