STRUCT VIRTQUEUE(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ struct virtqueue(9) ✨

okay bestie, welcome to the struct virtqueue(9) page, straight out of the Kernel API Manual πŸ’… this is literally the little data structure that says "hey, here's a queue, go register some buffers in it" β€” for sending or receiving, no cap πŸŽ€


🌸 NAME 🌸

struct virtqueue β€” a queue to register buffers for sending or receiving. that's it, that's the whole vibe ✨


πŸ¦‹ SYNOPSIS πŸ¦‹

here's the whole struct, character for character, don't touch a thing:

struct virtqueue {
    struct list_head list;
    void (*callback)(struct virtqueue *vq);
    const char *name;
    struct virtio_device *vdev;
    unsigned int index;
    unsigned int num_free;
    unsigned int num_max;
    bool reset;
    void *priv;
 };

πŸ‘‘ Members πŸ‘‘

okay so let's meet the cast, each one gets a moment:

  • list β€” the chain of virtqueues for this device. it's giving linked-list energy, one vq holding hands with the next 🫢
  • callback β€” the function to call when buffers are consumed. and yes, it can be NULL β€” sometimes we just don't want the drama πŸ’€
  • name β€” the name of this virtqueue. mainly for debugging, so it's lowkey the vq's government name πŸ‘‘
  • vdev β€” the virtio device this queue was created for. every queue has a parent, iconic 🌈
  • index β€” the zero-based ordinal number for this queue. zero-based, so the first one is 0, that's just how we do it πŸ“
  • num_free β€” number of elements we expect to be able to fit. like how many more snacks fit in the bag πŸŽ€
  • num_max β€” the maximum number of elements supported by the device. the absolute ceiling, the hard limit, periodt πŸ”₯
  • reset β€” vq is in reset state or not. it's a bool, so it's a yes-or-no baddie ⭐
  • priv β€” a pointer for the virtqueue implementation to use. free real estate for whoever's implementing this thing πŸ™ˆ

πŸ’– Description πŸ’–

the num_free note (important, pay attention bestie)

  • with indirect buffers, each buffer needs one element in the queue. one buffer, one element. simple, clean, slay ✨
  • otherwise, a buffer will need one element per sg element. so more sg elements = more elements needed, fr fr πŸ’…
not me making you count queue elements πŸ’€ but like, that's genuinely what it says in the source, so.

πŸ”₯ SEE ALSO πŸ”₯

go read these next, iykyk:

  • Kernel file ./include/linux/virtio.h
  • struct virtio_device(9)
  • struct virtio_driver(9)

and that's the whole page, bestie 🧚 this one came from ./include/linux β€” Copyright October 2026, struct virtqueue(9) β€” ok bye love u, go queue some buffers πŸ’œ

πŸ“¦ where this page comes from