drivers/vhost/test.c
Source file repositories/reference/linux-study-clean/drivers/vhost/test.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/vhost/test.c- Extension
.c- Size
- 8458 bytes
- Lines
- 380
- Domain
- Driver Families
- Bucket
- drivers/vhost
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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 an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/compat.hlinux/eventfd.hlinux/vhost.hlinux/miscdevice.hlinux/module.hlinux/mutex.hlinux/workqueue.hlinux/file.hlinux/slab.htest.hvhost.h
Detected Declarations
struct vhost_testfunction handle_vqfunction handle_vq_kickfunction vhost_test_openfunction vhost_test_stopfunction vhost_test_flushfunction vhost_test_releasefunction vhost_test_runfunction vhost_test_reset_ownerfunction vhost_test_set_featuresfunction vhost_test_set_backendfunction vhost_test_ioctl
Annotated Snippet
static const struct file_operations vhost_test_fops = {
.owner = THIS_MODULE,
.release = vhost_test_release,
.unlocked_ioctl = vhost_test_ioctl,
.compat_ioctl = compat_ptr_ioctl,
.open = vhost_test_open,
.llseek = noop_llseek,
};
static struct miscdevice vhost_test_misc = {
MISC_DYNAMIC_MINOR,
"vhost-test",
&vhost_test_fops,
};
module_misc_device(vhost_test_misc);
MODULE_VERSION("0.0.1");
MODULE_LICENSE("GPL v2");
MODULE_AUTHOR("Michael S. Tsirkin");
MODULE_DESCRIPTION("Host kernel side for virtio simulator");
Annotation
- Immediate include surface: `linux/compat.h`, `linux/eventfd.h`, `linux/vhost.h`, `linux/miscdevice.h`, `linux/module.h`, `linux/mutex.h`, `linux/workqueue.h`, `linux/file.h`.
- Detected declarations: `struct vhost_test`, `function handle_vq`, `function handle_vq_kick`, `function vhost_test_open`, `function vhost_test_stop`, `function vhost_test_flush`, `function vhost_test_release`, `function vhost_test_run`, `function vhost_test_reset_owner`, `function vhost_test_set_features`.
- Atlas domain: Driver Families / drivers/vhost.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.