Documentation/virt/kvm/api.rst
Source file repositories/reference/linux-study-clean/Documentation/virt/kvm/api.rst
File Facts
- System
- Linux kernel
- Corpus path
Documentation/virt/kvm/api.rst- Extension
.rst- Size
- 344571 bytes
- Lines
- 9556
- Domain
- Support Tooling And Documentation
- Bucket
- Documentation
- Inferred role
- Support Tooling And Documentation: documentation
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
struct kvm_msr_liststruct kvm_dirty_logstruct kvm_regsstruct kvm_regsstruct kvm_regsstruct kvm_sregsstruct kvm_translationstruct kvm_interruptstruct kvm_msrsstruct kvm_msr_entrystruct kvm_cpuid_entrystruct kvm_cpuidstruct kvm_signal_maskstruct kvm_fpustruct kvm_fpustruct kvm_fpuregstruct kvm_fpustruct kvm_fpustruct kvm_fpuregstruct kvm_irq_levelstruct kvm_irqchipstruct kvm_irqchipstruct kvm_xen_hvm_configstruct kvm_clock_datastruct kvm_clock_datastruct kvm_vcpu_eventsstruct kvm_vcpu_eventsstruct kvm_debugregsstruct kvm_userspace_memory_regionstruct kvm_enable_capstruct kvm_mp_statestruct kvm_xsavestruct kvm_xsavestruct kvm_xcrstruct kvm_xcrsstruct kvm_xcrstruct kvm_xcrsstruct kvm_cpuid2struct kvm_cpuid_entry2struct kvm_ppc_pvinfostruct kvm_irq_routingstruct kvm_irq_routing_entrystruct kvm_irq_routing_irqchipstruct kvm_irq_routing_msistruct kvm_irq_routing_s390_adapterstruct kvm_irq_routing_hv_sintstruct kvm_irq_routing_xen_evtchnstruct kvm_lapic_state
Annotated Snippet
struct kvm_msr_list {
__u32 nmsrs; /* number of msrs in entries */
__u32 indices[0];
};
The user fills in the size of the indices array in nmsrs, and in return
kvm adjusts nmsrs to reflect the actual number of msrs and fills in the
indices array with their numbers.
KVM_GET_MSR_INDEX_LIST returns the guest msrs that are supported. The list
varies by kvm version and host processor, but does not change otherwise.
Note: if kvm indicates supports MCE (KVM_CAP_MCE), then the MCE bank MSRs are
not returned in the MSR list, as different vcpus can have a different number
of banks, as set via the KVM_X86_SETUP_MCE ioctl.
KVM_GET_MSR_FEATURE_INDEX_LIST returns the list of MSRs that can be passed
to the KVM_GET_MSRS system ioctl. This lets userspace probe host capabilities
and processor features that are exposed via MSRs (e.g., VMX capabilities).
This list also varies by kvm version and host processor, but does not change
otherwise.
.. _KVM_CHECK_EXTENSION:
4.4 KVM_CHECK_EXTENSION
-----------------------
:Capability: basic, KVM_CAP_CHECK_EXTENSION_VM for vm ioctl
:Architectures: all
:Type: system ioctl, vm ioctl
:Parameters: extension identifier (KVM_CAP_*)
:Returns: 0 if unsupported; 1 (or some other positive integer) if supported
The API allows the application to query about extensions to the core
kvm API. Userspace passes an extension identifier (an integer) and
receives an integer that describes the extension availability.
Generally 0 means no and 1 means yes, but some extensions may report
additional information in the integer return value.
Based on their initialization different VMs may have different capabilities.
It is thus encouraged to use the vm ioctl to query for capabilities (available
with KVM_CAP_CHECK_EXTENSION_VM on the vm fd)
4.5 KVM_GET_VCPU_MMAP_SIZE
--------------------------
:Capability: basic
:Architectures: all
:Type: system ioctl
:Parameters: none
:Returns: size of vcpu mmap area, in bytes
The KVM_RUN ioctl (cf.) communicates with userspace via a shared
memory region. This ioctl returns the size of that region. See the
KVM_RUN documentation for details.
Besides the size of the KVM_RUN communication region, other areas of
the VCPU file descriptor can be mmap-ed, including:
- if KVM_CAP_COALESCED_MMIO is available, a page at
KVM_COALESCED_MMIO_PAGE_OFFSET * PAGE_SIZE; for historical reasons,
this page is included in the result of KVM_GET_VCPU_MMAP_SIZE.
KVM_CAP_COALESCED_MMIO is not documented yet.
- if KVM_CAP_DIRTY_LOG_RING is available, a number of pages at
KVM_DIRTY_LOG_PAGE_OFFSET * PAGE_SIZE. For more information on
KVM_CAP_DIRTY_LOG_RING, see :ref:`KVM_CAP_DIRTY_LOG_RING`.
Annotation
- Detected declarations: `struct kvm_msr_list`, `struct kvm_dirty_log`, `struct kvm_regs`, `struct kvm_regs`, `struct kvm_regs`, `struct kvm_sregs`, `struct kvm_translation`, `struct kvm_interrupt`, `struct kvm_msrs`, `struct kvm_msr_entry`.
- Atlas domain: Support Tooling And Documentation / Documentation.
- Implementation status: atlas-only.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.