aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/virtual
diff options
context:
space:
mode:
authorScott Wood <scottwood@freescale.com>2013-04-12 10:08:42 -0400
committerAlexander Graf <agraf@suse.de>2013-04-26 14:27:20 -0400
commit852b6d57dc7fa378019786fa84727036e56839ea (patch)
tree4d617ba91f6fc5de3fddac349e695d914e626a49 /Documentation/virtual
parent7df35f549606e8a9004a77ef31dc80dfa893a590 (diff)
kvm: add device control API
Currently, devices that are emulated inside KVM are configured in a hardcoded manner based on an assumption that any given architecture only has one way to do it. If there's any need to access device state, it is done through inflexible one-purpose-only IOCTLs (e.g. KVM_GET/SET_LAPIC). Defining new IOCTLs for every little thing is cumbersome and depletes a limited numberspace. This API provides a mechanism to instantiate a device of a certain type, returning an ID that can be used to set/get attributes of the device. Attributes may include configuration parameters (e.g. register base address), device state, operational commands, etc. It is similar to the ONE_REG API, except that it acts on devices rather than vcpus. Both device types and individual attributes can be tested without having to create the device or get/set the attribute, without the need for separately managing enumerated capabilities. Signed-off-by: Scott Wood <scottwood@freescale.com> Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'Documentation/virtual')
-rw-r--r--Documentation/virtual/kvm/api.txt70
-rw-r--r--Documentation/virtual/kvm/devices/README1
2 files changed, 71 insertions, 0 deletions
diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt
index a1f2200e43d0..66b58e494935 100644
--- a/Documentation/virtual/kvm/api.txt
+++ b/Documentation/virtual/kvm/api.txt
@@ -2189,6 +2189,76 @@ header; first `n_valid' valid entries with contents from the data
2189written, then `n_invalid' invalid entries, invalidating any previously 2189written, then `n_invalid' invalid entries, invalidating any previously
2190valid entries found. 2190valid entries found.
2191 2191
21924.79 KVM_CREATE_DEVICE
2193
2194Capability: KVM_CAP_DEVICE_CTRL
2195Type: vm ioctl
2196Parameters: struct kvm_create_device (in/out)
2197Returns: 0 on success, -1 on error
2198Errors:
2199 ENODEV: The device type is unknown or unsupported
2200 EEXIST: Device already created, and this type of device may not
2201 be instantiated multiple times
2202
2203 Other error conditions may be defined by individual device types or
2204 have their standard meanings.
2205
2206Creates an emulated device in the kernel. The file descriptor returned
2207in fd can be used with KVM_SET/GET/HAS_DEVICE_ATTR.
2208
2209If the KVM_CREATE_DEVICE_TEST flag is set, only test whether the
2210device type is supported (not necessarily whether it can be created
2211in the current vm).
2212
2213Individual devices should not define flags. Attributes should be used
2214for specifying any behavior that is not implied by the device type
2215number.
2216
2217struct kvm_create_device {
2218 __u32 type; /* in: KVM_DEV_TYPE_xxx */
2219 __u32 fd; /* out: device handle */
2220 __u32 flags; /* in: KVM_CREATE_DEVICE_xxx */
2221};
2222
22234.80 KVM_SET_DEVICE_ATTR/KVM_GET_DEVICE_ATTR
2224
2225Capability: KVM_CAP_DEVICE_CTRL
2226Type: device ioctl
2227Parameters: struct kvm_device_attr
2228Returns: 0 on success, -1 on error
2229Errors:
2230 ENXIO: The group or attribute is unknown/unsupported for this device
2231 EPERM: The attribute cannot (currently) be accessed this way
2232 (e.g. read-only attribute, or attribute that only makes
2233 sense when the device is in a different state)
2234
2235 Other error conditions may be defined by individual device types.
2236
2237Gets/sets a specified piece of device configuration and/or state. The
2238semantics are device-specific. See individual device documentation in
2239the "devices" directory. As with ONE_REG, the size of the data
2240transferred is defined by the particular attribute.
2241
2242struct kvm_device_attr {
2243 __u32 flags; /* no flags currently defined */
2244 __u32 group; /* device-defined */
2245 __u64 attr; /* group-defined */
2246 __u64 addr; /* userspace address of attr data */
2247};
2248
22494.81 KVM_HAS_DEVICE_ATTR
2250
2251Capability: KVM_CAP_DEVICE_CTRL
2252Type: device ioctl
2253Parameters: struct kvm_device_attr
2254Returns: 0 on success, -1 on error
2255Errors:
2256 ENXIO: The group or attribute is unknown/unsupported for this device
2257
2258Tests whether a device supports a particular attribute. A successful
2259return indicates the attribute is implemented. It does not necessarily
2260indicate that the attribute can be read or written in the device's
2261current state. "addr" is ignored.
2192 2262
21934.77 KVM_ARM_VCPU_INIT 22634.77 KVM_ARM_VCPU_INIT
2194 2264
diff --git a/Documentation/virtual/kvm/devices/README b/Documentation/virtual/kvm/devices/README
new file mode 100644
index 000000000000..34a69834124a
--- /dev/null
+++ b/Documentation/virtual/kvm/devices/README
@@ -0,0 +1 @@
This directory contains specific device bindings for KVM_CAP_DEVICE_CTRL.