/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _LINUX_VHOST_H #define _LINUX_VHOST_H /* Userspace interface for in-kernel virtio accelerators. */
/* vhost is used to reduce the number of system calls involved in virtio. * *Existingvirtionetcodeisusedintheguestwithoutmodification. * *Thisheaderincludesinterfaceusedbyuserspacehypervisorfor *deviceconfiguration.
*/
/* Features bitmask for forward compatibility. Transport bits are used for
* vhost specific features. */ #define VHOST_GET_FEATURES _IOR(VHOST_VIRTIO, 0x00, __u64) #define VHOST_SET_FEATURES _IOW(VHOST_VIRTIO, 0x00, __u64)
/* Set current process as the (exclusive) owner of this file descriptor. This *mustbecalledbeforeanyothervhostcommand.Furthercallsto
* VHOST_SET_OWNER fail until VHOST_RESET_OWNER is called. */ #define VHOST_SET_OWNER _IO(VHOST_VIRTIO, 0x01) /* Give up ownership, and reset the device to default values.
* Allows subsequent call to VHOST_SET_OWNER to succeed. */ #define VHOST_RESET_OWNER _IO(VHOST_VIRTIO, 0x02)
/* Write logging setup. */ /* Memory writes can optionally be logged by setting bit at an offset *(calculatedfromthephysicaladdress)fromspecifiedlogbase.
* The bit is set using an atomic 32 bit operation. */ /* Set base address for logging. */ #define VHOST_SET_LOG_BASE _IOW(VHOST_VIRTIO, 0x04, __u64) /* Specify an eventfd file descriptor to signal on log write. */ #define VHOST_SET_LOG_FD _IOW(VHOST_VIRTIO, 0x07, int) /* By default, a device gets one vhost_worker that its virtqueues share. This *commandallowstheownerofthedevicetocreateanadditionalvhost_worker *forthedevice.Itcanlaterbeboundto1ormoreofitsvirtqueuesusing *theVHOST_ATTACH_VRING_WORKERcommand. * *ThismustbecalledafterVHOST_SET_OWNERandthecallermustbetheowner *ofthedevice.Thenewthreadwillinheritcaller'scgroupsandnamespaces, *andwillsharethecaller'smemoryspace.Thenewthreadwillalsobe *countedagainstthecaller'sRLIMIT_NPROCvalue. * *Theworker'sIDusedinothercommandswillbereturnedin *vhost_worker_state.
*/ #define VHOST_NEW_WORKER _IOR(VHOST_VIRTIO, 0x8, struct vhost_worker_state) /* Free a worker created with VHOST_NEW_WORKER if it's not attached to any *virtqueue.Ifuserspaceisnotabletocallthisforworkersitscreated, *thekernelwillfreeallthedevice'sworkerswhenthedeviceisclosed.
*/ #define VHOST_FREE_WORKER _IOW(VHOST_VIRTIO, 0x9, struct vhost_worker_state)
/* Ring setup. */ /* Set number of descriptors in ring. This parameter can not
* be modified while ring is running (bound to a device). */ #define VHOST_SET_VRING_NUM _IOW(VHOST_VIRTIO, 0x10, struct vhost_vring_state) /* Set addresses for the ring. */ #define VHOST_SET_VRING_ADDR _IOW(VHOST_VIRTIO, 0x11, struct vhost_vring_addr) /* Base value where queue looks for available descriptors */ #define VHOST_SET_VRING_BASE _IOW(VHOST_VIRTIO, 0x12, struct vhost_vring_state) /* Get accessor: reads index, writes value in num */ #define VHOST_GET_VRING_BASE _IOWR(VHOST_VIRTIO, 0x12, struct vhost_vring_state)
/* Set the vring byte order in num. Valid values are VHOST_VRING_LITTLE_ENDIAN *orVHOST_VRING_BIG_ENDIAN(othervaluesreturn-EINVAL). *Thebyteordercannotbechangedwhilethedeviceisactive:tryingtodoso *returns-EBUSY. *ThisisalegacyonlyAPIthatissimplyignoredwhenVIRTIO_F_VERSION_1is *set. *Notallkernelconfigurationssupportthisioctl,butallconfigurationsthat *supportSETalsosupportGET.
*/ #define VHOST_VRING_LITTLE_ENDIAN 0 #define VHOST_VRING_BIG_ENDIAN 1 #define VHOST_SET_VRING_ENDIAN _IOW(VHOST_VIRTIO, 0x13, struct vhost_vring_state) #define VHOST_GET_VRING_ENDIAN _IOW(VHOST_VIRTIO, 0x14, struct vhost_vring_state) /* Attach a vhost_worker created with VHOST_NEW_WORKER to one of the device's *virtqueues. * *Thiswillreplacethevirtqueue'sexistingworker.Ifthereplacedworker *isnolongerattachedtoanyvirtqueues,itcanbefreedwith *VHOST_FREE_WORKER.
*/ #define VHOST_ATTACH_VRING_WORKER _IOW(VHOST_VIRTIO, 0x15, \ struct vhost_vring_worker) /* Return the vring worker's ID */ #define VHOST_GET_VRING_WORKER _IOWR(VHOST_VIRTIO, 0x16, \ struct vhost_vring_worker)
/* The following ioctls use eventfd file descriptors to signal and poll
* for events. */
/* Set eventfd to poll for added buffers */ #define VHOST_SET_VRING_KICK _IOW(VHOST_VIRTIO, 0x20, struct vhost_vring_file) /* Set eventfd to signal when buffers have beed used */ #define VHOST_SET_VRING_CALL _IOW(VHOST_VIRTIO, 0x21, struct vhost_vring_file) /* Set eventfd to signal an error */ #define VHOST_SET_VRING_ERR _IOW(VHOST_VIRTIO, 0x22, struct vhost_vring_file) /* Set busy loop timeout (in us) */ #define VHOST_SET_VRING_BUSYLOOP_TIMEOUT _IOW(VHOST_VIRTIO, 0x23, \ struct vhost_vring_state) /* Get busy loop timeout (in us) */ #define VHOST_GET_VRING_BUSYLOOP_TIMEOUT _IOW(VHOST_VIRTIO, 0x24, \ struct vhost_vring_state)
/* Attach virtio net ring to a raw socket, or tap device. *Thesocketmustbealreadyboundtoanethernetdevice,thisdevicewillbe *usedfortransmit.Passfd-1tounbindfromthesocketandthetransmit
* device. This can be used to stop the ring (e.g. for migration). */ #define VHOST_NET_SET_BACKEND _IOW(VHOST_VIRTIO, 0x30, struct vhost_vring_file)
/* VHOST_SCSI specific defines */
#define VHOST_SCSI_SET_ENDPOINT _IOW(VHOST_VIRTIO, 0x40, struct vhost_scsi_target) #define VHOST_SCSI_CLEAR_ENDPOINT _IOW(VHOST_VIRTIO, 0x41, struct vhost_scsi_target) /* Changing this breaks userspace. */ #define VHOST_SCSI_GET_ABI_VERSION _IOW(VHOST_VIRTIO, 0x42, int) /* Set and get the events missed flag */ #define VHOST_SCSI_SET_EVENTS_MISSED _IOW(VHOST_VIRTIO, 0x43, __u32) #define VHOST_SCSI_GET_EVENTS_MISSED _IOW(VHOST_VIRTIO, 0x44, __u32)
/* Get the device id. The device ids follow the same definition of *thedeviceiddefinedinvirtio-spec.
*/ #define VHOST_VDPA_GET_DEVICE_ID _IOR(VHOST_VIRTIO, 0x70, __u32) /* Get and set the status. The status bits follow the same definition *ofthedevicestatusdefinedinvirtio-spec.
*/ #define VHOST_VDPA_GET_STATUS _IOR(VHOST_VIRTIO, 0x71, __u8) #define VHOST_VDPA_SET_STATUS _IOW(VHOST_VIRTIO, 0x72, __u8) /* Get and set the device config. The device config follows the same *definitionofthedeviceconfigdefinedinvirtio-spec.
*/ #define VHOST_VDPA_GET_CONFIG _IOR(VHOST_VIRTIO, 0x73, \ struct vhost_vdpa_config) #define VHOST_VDPA_SET_CONFIG _IOW(VHOST_VIRTIO, 0x74, \ struct vhost_vdpa_config) /* Enable/disable the ring. */ #define VHOST_VDPA_SET_VRING_ENABLE _IOW(VHOST_VIRTIO, 0x75, \ struct vhost_vring_state) /* Get the max ring size. */ #define VHOST_VDPA_GET_VRING_NUM _IOR(VHOST_VIRTIO, 0x76, __u16)
/* Set event fd for config interrupt*/ #define VHOST_VDPA_SET_CONFIG_CALL _IOW(VHOST_VIRTIO, 0x77, int)
/* Get the valid iova range */ #define VHOST_VDPA_GET_IOVA_RANGE _IOR(VHOST_VIRTIO, 0x78, \ struct vhost_vdpa_iova_range) /* Get the config size */ #define VHOST_VDPA_GET_CONFIG_SIZE _IOR(VHOST_VIRTIO, 0x79, __u32)
/* Get the number of address spaces. */ #define VHOST_VDPA_GET_AS_NUM _IOR(VHOST_VIRTIO, 0x7A, unsignedint)
/* Get the group for a virtqueue: read index, write group in num, *Thevirtqueueindexisstoredintheindexfieldof *vhost_vring_state.Thegroupforthisspecificvirtqueueis *returnedvianumfieldofvhost_vring_state.
*/ #define VHOST_VDPA_GET_VRING_GROUP _IOWR(VHOST_VIRTIO, 0x7B, \ struct vhost_vring_state) /* Set the ASID for a virtqueue group. The group index is stored in *theindexfieldofvhost_vring_state,theASIDassociatedwiththis *groupisstoredatnumfieldofvhost_vring_state.
*/ #define VHOST_VDPA_SET_GROUP_ASID _IOW(VHOST_VIRTIO, 0x7C, \ struct vhost_vring_state)
/* Suspend a device so it does not process virtqueue requests anymore * *Afterthereturnofioctlthedevicemustpreserveallthenecessarystate *(thevirtqueuevringbaseplusthepossibledevicespecificstates)thatis *requiredforrestoringinthefuture.Thedevicemustnotchangeits *configurationafterthatpoint.
*/ #define VHOST_VDPA_SUSPEND _IO(VHOST_VIRTIO, 0x7D)
/* Resume a device so it can resume processing virtqueue requests * *Afterthereturnofthisioctlthedevicewillhaverestoredallthe *necessarystatesanditisfullyoperationaltocontinueprocessingthe *virtqueuedescriptors.
*/ #define VHOST_VDPA_RESUME _IO(VHOST_VIRTIO, 0x7E)
/* Get the group for the descriptor table including driver & device areas *ofavirtqueue:readindex,writegroupinnum. *Thevirtqueueindexisstoredintheindexfieldofvhost_vring_state. *ThegroupIDofthedescriptortableforthisspecificvirtqueue *isreturnedvianumfieldofvhost_vring_state.
*/ #define VHOST_VDPA_GET_VRING_DESC_GROUP _IOWR(VHOST_VIRTIO, 0x7F, \ struct vhost_vring_state)
/* Get the count of all virtqueues */ #define VHOST_VDPA_GET_VQS_COUNT _IOR(VHOST_VIRTIO, 0x80, __u32)
/* Get the number of virtqueue groups. */ #define VHOST_VDPA_GET_GROUP_NUM _IOR(VHOST_VIRTIO, 0x81, __u32)
/* Get the queue size of a specific virtqueue. *userspacesetthevringindexinvhost_vring_state.index *kernelsetthequeuesizeinvhost_vring_state.num
*/ #define VHOST_VDPA_GET_VRING_SIZE _IOWR(VHOST_VIRTIO, 0x82, \ struct vhost_vring_state)
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.13Bemerkung:
(vorverarbeitet am 2026-09-28)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.