Skip to content

Commit 5b47f5a

Browse files
committed
Documentation: kvm: reorganize introduction
Reorganize the text to mention file descriptors as early as possible. Also mention capabilities early as they are a central part of KVM's API. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-ID: <20241023124507.280382-5-pbonzini@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent badd537 commit 5b47f5a

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

Documentation/virt/kvm/api.rst

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,19 @@ The Definitive KVM (Kernel-based Virtual Machine) API Documentation
77
1. General description
88
======================
99

10-
The kvm API is a set of ioctls that are issued to control various aspects
11-
of a virtual machine. The ioctls belong to the following classes:
10+
The kvm API is centered around different kinds of file descriptors
11+
and ioctls that can be issued to these file descriptors. An initial
12+
open("/dev/kvm") obtains a handle to the kvm subsystem; this handle
13+
can be used to issue system ioctls. A KVM_CREATE_VM ioctl on this
14+
handle will create a VM file descriptor which can be used to issue VM
15+
ioctls. A KVM_CREATE_VCPU or KVM_CREATE_DEVICE ioctl on a VM fd will
16+
create a virtual cpu or device and return a file descriptor pointing to
17+
the new resource.
18+
19+
In other words, the kvm API is a set of ioctls that are issued to
20+
different kinds of file descriptor in order to control various aspects of
21+
a virtual machine. Depending on the file descriptor that accepts them,
22+
ioctls belong to the following classes:
1223

1324
- System ioctls: These query and set global attributes which affect the
1425
whole kvm subsystem. In addition a system ioctl is used to create
@@ -35,18 +46,19 @@ of a virtual machine. The ioctls belong to the following classes:
3546
device ioctls must be issued from the same process (address space) that
3647
was used to create the VM.
3748

38-
2. File descriptors
39-
===================
49+
While most ioctls are specific to one kind of file descriptor, in some
50+
cases the same ioctl can belong to more than one class.
4051

41-
The kvm API is centered around file descriptors. An initial
42-
open("/dev/kvm") obtains a handle to the kvm subsystem; this handle
43-
can be used to issue system ioctls. A KVM_CREATE_VM ioctl on this
44-
handle will create a VM file descriptor which can be used to issue VM
45-
ioctls. A KVM_CREATE_VCPU or KVM_CREATE_DEVICE ioctl on a VM fd will
46-
create a virtual cpu or device and return a file descriptor pointing to
47-
the new resource. Finally, ioctls on a vcpu or device fd can be used
48-
to control the vcpu or device. For vcpus, this includes the important
49-
task of actually running guest code.
52+
The KVM API grew over time. For this reason, KVM defines many constants
53+
of the form ``KVM_CAP_*``, each corresponding to a set of functionality
54+
provided by one or more ioctls. Availability of these "capabilities" can
55+
be checked with :ref:`KVM_CHECK_EXTENSION <KVM_CHECK_EXTENSION>`. Some
56+
capabilities also need to be enabled for VMs or VCPUs where their
57+
functionality is desired (see :ref:`cap_enable` and :ref:`cap_enable_vm`).
58+
59+
60+
2. Restrictions
61+
===============
5062

5163
In general file descriptors can be migrated among processes by means
5264
of fork() and the SCM_RIGHTS facility of unix domain socket. These

0 commit comments

Comments
 (0)