drivers/vhost/vhost.h
Source file repositories/reference/linux-study-clean/drivers/vhost/vhost.h
File Facts
- System
- Linux kernel
- Corpus path
drivers/vhost/vhost.h- Extension
.h- Size
- 12019 bytes
- Lines
- 405
- Domain
- Driver Families
- Bucket
- drivers/vhost
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/eventfd.hlinux/vhost.hlinux/mm.hlinux/mutex.hlinux/poll.hlinux/file.hlinux/uio.hlinux/virtio_config.hlinux/virtio_ring.hlinux/atomic.hlinux/vhost_iotlb.hlinux/irqbypass.hlinux/unroll.h
Detected Declarations
struct vhost_workstruct vhost_taskstruct vhost_workstruct vhost_workerstruct vhost_devstruct vhost_worker_opsstruct vhost_workerstruct vhost_pollstruct vhost_logstruct vhost_vring_callstruct vhost_virtqueuestruct vhost_msg_nodestruct vhost_devenum vhost_uaddr_typefunction vhost_features_u64function UNROLLfunction vhost_has_featurefunction vhost_backend_has_featurefunction vhost_is_little_endianfunction vhost_is_little_endianfunction vhost16_to_cpufunction cpu_to_vhost16function vhost32_to_cpufunction cpu_to_vhost32function vhost64_to_cpufunction cpu_to_vhost64
Annotated Snippet
struct vhost_work {
struct llist_node node;
vhost_work_fn_t fn;
unsigned long flags;
};
struct vhost_worker;
struct vhost_dev;
struct vhost_worker_ops {
int (*create)(struct vhost_worker *worker, struct vhost_dev *dev,
const char *name);
void (*stop)(struct vhost_worker *worker);
void (*wakeup)(struct vhost_worker *worker);
};
struct vhost_worker {
struct task_struct *kthread_task;
struct vhost_task *vtsk;
struct vhost_dev *dev;
/* Used to serialize device wide flushing with worker swapping. */
struct mutex mutex;
struct llist_head work_list;
struct kcov_common_handle_id kcov_handle;
u32 id;
int attachment_cnt;
bool killed;
const struct vhost_worker_ops *ops;
};
/* Poll a file (eventfd or socket) */
/* Note: there's nothing vhost specific about this structure. */
struct vhost_poll {
poll_table table;
wait_queue_head_t *wqh;
wait_queue_entry_t wait;
struct vhost_work work;
__poll_t mask;
struct vhost_dev *dev;
struct vhost_virtqueue *vq;
};
void vhost_poll_init(struct vhost_poll *poll, vhost_work_fn_t fn,
__poll_t mask, struct vhost_dev *dev,
struct vhost_virtqueue *vq);
int vhost_poll_start(struct vhost_poll *poll, struct file *file);
void vhost_poll_stop(struct vhost_poll *poll);
void vhost_poll_queue(struct vhost_poll *poll);
void vhost_work_init(struct vhost_work *work, vhost_work_fn_t fn);
void vhost_dev_flush(struct vhost_dev *dev);
struct vhost_log {
u64 addr;
u64 len;
};
enum vhost_uaddr_type {
VHOST_ADDR_DESC = 0,
VHOST_ADDR_AVAIL = 1,
VHOST_ADDR_USED = 2,
VHOST_NUM_ADDRS = 3,
};
struct vhost_vring_call {
struct eventfd_ctx *ctx;
struct irq_bypass_producer producer;
};
/* The virtqueue structure describes a queue attached to a device. */
struct vhost_virtqueue {
struct vhost_dev *dev;
struct vhost_worker __rcu *worker;
/* The actual ring of buffers. */
struct mutex mutex;
unsigned int num;
vring_desc_t __user *desc;
vring_avail_t __user *avail;
vring_used_t __user *used;
const struct vhost_iotlb_map *meta_iotlb[VHOST_NUM_ADDRS];
struct file *kick;
struct vhost_vring_call call_ctx;
struct eventfd_ctx *error_ctx;
struct eventfd_ctx *log_ctx;
struct vhost_poll poll;
/* The routine to call when the Guest pings us, or timeout. */
vhost_work_fn_t handle_kick;
Annotation
- Immediate include surface: `linux/eventfd.h`, `linux/vhost.h`, `linux/mm.h`, `linux/mutex.h`, `linux/poll.h`, `linux/file.h`, `linux/uio.h`, `linux/virtio_config.h`.
- Detected declarations: `struct vhost_work`, `struct vhost_task`, `struct vhost_work`, `struct vhost_worker`, `struct vhost_dev`, `struct vhost_worker_ops`, `struct vhost_worker`, `struct vhost_poll`, `struct vhost_log`, `struct vhost_vring_call`.
- Atlas domain: Driver Families / drivers/vhost.
- Implementation status: source implementation candidate.
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.