STRUCT VFIO_LOG_OPS(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… struct vfio_log_ops(9) πŸ’…

okay so bestie, welcome to the kernel API manual page for struct vfio_log_ops β€” VFIO bus device driver logging callbacks. yes that's a mouthful. we're gonna get through it together 🫢


✨ NAME ✨

struct vfio_log_ops β€” literally the VFIO bus device driver logging callbacks. that's the whole vibe. no cap.


πŸ¦‹ SYNOPSIS πŸ¦‹

struct vfio_log_ops {
    int (*log_start)(struct vfio_device *device, struct rb_root_cached *ranges, u32 nnodes, u64 *page_size);
    int (*log_stop)(struct vfio_device *device);
    int (*log_read_and_clear)(struct vfio_device *device, unsigned long iova, unsigned long length, struct iova_bitmap *dirty);
};

like, three function pointers. that's the girlies. look at them go ✨


🌸 Members 🌸

  • log_start β€” an optional callback that asks the device to start DMA logging. key word optional, so don't come for me if your driver doesn't have one πŸ’…
  • log_stop β€” another optional callback, this one asking the device to stop DMA logging. cute, simple, iconic.
  • log_read_and_clear β€” the third optional callback, and it's the busy one: it asks the device to read and clear the dirty DMAs in some given range. two jobs, one callback, main character energy fr fr πŸ‘‘

πŸ’– Description πŸ’–

okay so this is the part where it gets real. the vfio core implementation of the DEVICE_FEATURE_DMA_LOGGING_ set of features does not track logging state relative to the device. read that again. the core is not keeping score for you. 😭

so because of that, the device implementation of vfio_log_ops has to handle arbitrary user requests. yes, arbitrary. the users are feral and the core is not your mom.

that means, highkey:

  • you must reject subsequent calls to log_start without an intervening log_stop (no sneaky double-starts, bestie, that's not the vibe)
  • you must gracefully handle log_stop and log_read_and_clear from invalid states (graceful. not dramatic. we don't throw tantrums in kernel space πŸ’€)

that's it. that's the whole contract. slay.


πŸ‘‘ SEE ALSO πŸ‘‘

go touch grass in these files and pages, iykyk:


⭐ reminder bestie: log_start, log_stop, and log_read_and_clear are all optional callbacks β€” but the state-handling rules in the Description are not. if the core isn't tracking state for you, you're the one doing the tracking. periodt.

🌈 that's the page!! this one lives in ./include/linux, dated October 2026 β€” mwah, take care of her, she's iconic πŸ’œπŸŽ€

πŸ“¦ where this page comes from