diff options
author | Scott Wood <scottwood@freescale.com> | 2013-04-12 10:08:42 -0400 |
---|---|---|
committer | Alexander Graf <agraf@suse.de> | 2013-04-26 14:27:20 -0400 |
commit | 852b6d57dc7fa378019786fa84727036e56839ea (patch) | |
tree | 4d617ba91f6fc5de3fddac349e695d914e626a49 /Documentation/virtual | |
parent | 7df35f549606e8a9004a77ef31dc80dfa893a590 (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.txt | 70 | ||||
-rw-r--r-- | Documentation/virtual/kvm/devices/README | 1 |
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 | |||
2189 | written, then `n_invalid' invalid entries, invalidating any previously | 2189 | written, then `n_invalid' invalid entries, invalidating any previously |
2190 | valid entries found. | 2190 | valid entries found. |
2191 | 2191 | ||
2192 | 4.79 KVM_CREATE_DEVICE | ||
2193 | |||
2194 | Capability: KVM_CAP_DEVICE_CTRL | ||
2195 | Type: vm ioctl | ||
2196 | Parameters: struct kvm_create_device (in/out) | ||
2197 | Returns: 0 on success, -1 on error | ||
2198 | Errors: | ||
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 | |||
2206 | Creates an emulated device in the kernel. The file descriptor returned | ||
2207 | in fd can be used with KVM_SET/GET/HAS_DEVICE_ATTR. | ||
2208 | |||
2209 | If the KVM_CREATE_DEVICE_TEST flag is set, only test whether the | ||
2210 | device type is supported (not necessarily whether it can be created | ||
2211 | in the current vm). | ||
2212 | |||
2213 | Individual devices should not define flags. Attributes should be used | ||
2214 | for specifying any behavior that is not implied by the device type | ||
2215 | number. | ||
2216 | |||
2217 | struct 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 | |||
2223 | 4.80 KVM_SET_DEVICE_ATTR/KVM_GET_DEVICE_ATTR | ||
2224 | |||
2225 | Capability: KVM_CAP_DEVICE_CTRL | ||
2226 | Type: device ioctl | ||
2227 | Parameters: struct kvm_device_attr | ||
2228 | Returns: 0 on success, -1 on error | ||
2229 | Errors: | ||
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 | |||
2237 | Gets/sets a specified piece of device configuration and/or state. The | ||
2238 | semantics are device-specific. See individual device documentation in | ||
2239 | the "devices" directory. As with ONE_REG, the size of the data | ||
2240 | transferred is defined by the particular attribute. | ||
2241 | |||
2242 | struct 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 | |||
2249 | 4.81 KVM_HAS_DEVICE_ATTR | ||
2250 | |||
2251 | Capability: KVM_CAP_DEVICE_CTRL | ||
2252 | Type: device ioctl | ||
2253 | Parameters: struct kvm_device_attr | ||
2254 | Returns: 0 on success, -1 on error | ||
2255 | Errors: | ||
2256 | ENXIO: The group or attribute is unknown/unsupported for this device | ||
2257 | |||
2258 | Tests whether a device supports a particular attribute. A successful | ||
2259 | return indicates the attribute is implemented. It does not necessarily | ||
2260 | indicate that the attribute can be read or written in the device's | ||
2261 | current state. "addr" is ignored. | ||
2192 | 2262 | ||
2193 | 4.77 KVM_ARM_VCPU_INIT | 2263 | 4.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. | |||