Skip to content

"Slim down" VolatileSlice to be a #[repr(transparent)] wrapper around libc::iovec #342

@roypat

Description

@roypat

Lots of virtio code first converts descriptor chains to Vec<VolatileSlice>, and then later converts that into Vec<iovec> for use with readv/ writev, which has a nasty intermediate allocation of a vector. Firecracker works around this problem by going straight to Vec<iovec>, and then loosing all the safety of the VolatileSlice abstractions, which is also not great. For that reason, we'd like to slim down VolatileSlice to get rid of all metadata, so just the pointer and length fields remain.

Currently, VolatileSlice is defined as follows:

pub struct VolatileSlice<'a, B = ()> {
addr: *mut u8,
size: usize,
bitmap: B,
mmap: Option<&'a MmapInfo>,
}

So what we need to move out is

  1. The dirty bitmap tracking: Potentially, this can be done via a decorator instead
  2. The Xen-only MmapInfo: This can be removed by re-framing Xen memory as an IoMemory implementation (instead of GuestMemory), as defined in I/O virtual memory (IOMMU) support #327 (the xen stuff is in VolatileSlice because in the past, that was the only place where we definitely know whether an access is a read or a write, but with IoMemory, we will have permission information way further up the stack, and can do all the Xen ioctls/mmap calls prior to VolatileSlice creation)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions