virtqueue_get_buf_ctx(9)
π virtqueue_get_buf_ctx β get the next used buffer π
okay so bestie, this is virtqueue_get_buf_ctx(9) from the Kernel API Manual and honestly? it's a whole vibe. it's the little function that goes "hey, the device finished with a buffer, here's your stuff back" β¨
πΈ NAME πΈ
virtqueue_get_buf_ctx β get the next used buffer π
π¦ SYNOPSIS π¦
void * virtqueue_get_buf_ctx (struct virtqueue *_vq , unsigned int *len
, void **ctx );
like yes, that's the whole signature, no cap π
β¨ ARGUMENTS β¨
_vqβ thestruct virtqueuewe're talking about. your main character struct π«Άlenβ the length written into the buffer πctxβ extra context for the token, iykyk π
π DESCRIPTION π
so here's the tea β β if the device wrote data into the buffer, len will be set to the amount written. which lowkey slays, because it means you don't need to clear the buffer beforehand to make sure there's no data leakage in the case of short writes. not me being protected from myself ππ
β οΈ real talk though: the caller must ensure we don't call this with other virtqueue operations at the same time (except where noted). fr fr, don't do it. π¨
it returns NULL if there are no used buffers β sad girl hours π β or the "data" token handed to virtqueue_add_*(). yup, the token comes back home π β¨
π SEE ALSO π
the whole friend group π«Ά and also: Kernel file ./drivers/virtio/virtio_ring.c
virtqueue_add_sgs(9)virtqueue_add_outbuf(9)virtqueue_add_outbuf_premapped(9)virtqueue_add_inbuf(9)virtqueue_add_inbuf_cache_clean(9)virtqueue_add_inbuf_ctx(9)virtqueue_add_inbuf_premapped(9)virtqueue_dma_dev(9)virtqueue_kick_prepare(9)virtqueue_notify(9)virtqueue_kick(9)virtqueue_disable_cb(9)virtqueue_enable_cb_prepare(9)virtqueue_poll(9)virtqueue_enable_cb(9)virtqueue_enable_cb_delayed(9)virtqueue_detach_unused_buf(9)vring_interrupt(9)virtqueue_resize(9)virtqueue_reset(9)virtqueue_get_vring_size(9)virtqueue_map_alloc_coherent(9)virtqueue_map_free_coherent(9)virtqueue_map_page_attrs(9)virtqueue_unmap_page_attrs(9)virtqueue_map_single_attrs(9)virtqueue_unmap_single_attrs(9)virtqueue_map_mapping_error(9)virtqueue_map_need_sync(9)virtqueue_map_sync_single_range_for_cpu(9)virtqueue_map_sync_single_range_for_device(9)
k that's the whole page bestie, mwah π
shoutout to the source ./drivers/virtio, dated October 2026, and to virtqueue_get_buf_ctx(9) itself β iconic, ate, no crumbs ππ
β¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms