On Wed Sep 30, 2026 at 12:57 PM CEST, Zhi Wang wrote:
> @@ -40,6 +40,14 @@ pub fn is_virtfn(&self) -> bool {
>          // SAFETY: `self.as_raw` is a valid pointer to a `struct pci_dev`.
>          unsafe { (*self.as_raw()).is_virtfn() != 0 }
>      }
> +
> +    /// Return the zero-based VF index within its PF, or an error for a 
> non-VF device.
> +    pub fn vf_id(&self) -> Result<u32> {
> +        // SAFETY: `self.as_raw()` points to a live PCI device; the helper 
> checks VF membership.
> +        let id = unsafe { bindings::pci_iov_vf_id(self.as_raw()) };
> +        to_result(id)?;
> +        Ok(id as u32)
> +    }

In my PoC I had this implemented for Device<Bound>, but here it is implemented
for just Device I think? It's not visible from the context, but IIRC you moved
is_virtfn() in an impl Device block (which is correct).

So, if this is correct, please move it under Device<Bound>, as offset and stride
are not guaranteed to not be concurrently modified otherwise.

Reply via email to