vhost_get_vq_desc_n(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– vhost_get_vq_desc_n(9) β€” the group chat version πŸ’–

okay so bestie, today we're doing vhost_get_vq_desc_n from the <cyan>vhost_get_vq_desc_n(9)</cyan> kernel API manual β€” yes that's the manpage name, and yes it's a mouthful, but she's iconic and she's about to hand you your next descriptor chain πŸŽ€


✨ NAME ✨

vhost_get_vq_desc_n β€” fetch the next available descriptor chain and build iovecs. literally her whole personality πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

int vhost_get_vq_desc_n (struct vhost_virtqueue *vq , struct iovec iov[]
, unsigned int iov_size , unsigned int *out_num , unsigned int *in_num ,
struct vhost_log *log , unsigned int *log_num , unsigned int *ndesc );

no cap, that's the whole signature. keep it close 🫢


🌸 ARGUMENTS 🌸

girl, there are a LOT of them, but each one is serving a purpose:

  • vq β€” the target virtqueue. the main character, fr fr πŸ‘‘
  • iov β€” the array that receives the scatter/gather segments. she collects the pieces ✨
  • iov_size β€” capacity of iov in elements. don't overfill her, bestie 🌈
  • out_num β€” the number of output segments
  • in_num β€” the number of input segments
  • log β€” optional array to record addr/len for each writable segment; NULL if unused. optional, like your third coffee β˜•
  • log_num β€” optional output; number of entries written to log when provided
  • ndesc β€” optional output; number of descriptors consumed from the available ring (useful for rollback via vhost_discard_vq_desc). this one's lowkey the receipts 🧾

πŸ’œ DESCRIPTION πŸ’œ

So what does she actually do? She extracts one available descriptor chain from vq and translates guest addresses into host iovecs. it's giving translator-girlie, it's giving bridge between two worlds πŸŒ‰

On success, she advances vq->last_avail_idx by 1 and vq->next_avail_head by the number of descriptors consumed (also stored via ndesc when non-NULL).

careful bestie β€” those indices move on success, and that's exactly why ndesc exists. if you need to roll back, vhost_discard_vq_desc is your girl πŸ™ˆ

πŸ”₯ RETURN πŸ”₯

the vibe check results, in order:

  • head index in [0, vq->num) on success πŸŽ‰
  • vq->num if no descriptor is currently available 😭 (yes, that's the "nothing rn" signal β€” not an error!)
  • negative errno on failure πŸ’€

πŸŽ€ SEE ALSO πŸŽ€

Kernel file ./drivers/vhost/vhost.c β€” go read __vhost_worker_flush(9) and vhost_discard_vq_desc(9), they're the supporting cast and they ATE ⭐


okay that's the whole page, bestie. mwah πŸ’‹

this lil masterpiece lives in ./drivers/vhost, dated October 2026 β€” that's the source and the version-date, noted with love so you never have to squint at a footer again πŸ§šπŸ’–βœ¨

πŸ“¦ where this page comes from