Closed lauralt closed 2 years ago
Is this crate has only the abstraction for VsocketPacket, or there are other abstractions?
Is this crate has only the abstraction for VsocketPacket, or there are other abstractions?
By crate you mean virtio-vsock
? There are no abstractions in it so far, but we plan on upstreaming more vsock building blocks (starting with the packet).
Is this crate has only the abstraction for VsocketPacket, or there are other abstractions?
By crate you mean
virtio-vsock
? There are no abstractions in it so far, but we plan on upstreaming more vsock building blocks (starting with the packet).
Sure, the packet
is the common component of virtio-vsock, so move it to virtio-vsock
is reasonable, but the behavior of other components (like muxer
or csm
in firecracker) may be different in other vmm, would you plan to move them to this crate?
Is this crate has only the abstraction for VsocketPacket, or there are other abstractions?
By crate you mean
virtio-vsock
? There are no abstractions in it so far, but we plan on upstreaming more vsock building blocks (starting with the packet).Sure, the
packet
is the common component of virtio-vsock, so move it tovirtio-vsock
is reasonable, but the behavior of other components (likemuxer
orcsm
in firecracker) may be different in other vmm, would you plan to move them to this crate?
Yeah these are more debatable, I have to think a bit more what would be the best approach with these, for the backend things I wouldn't add something in vm-virtio (or maybe some traits make sense, but anyway no implementation), and for the connection
we could probably define some traits and have a default implementation for them (the connection
module is pretty similar in firecracker and cloud-hypervisor). I'll dive deep a bit more into these in the following weeks, but I don't think we should block the packet upstreaming until that point.
Is this crate has only the abstraction for VsocketPacket, or there are other abstractions?
By crate you mean
virtio-vsock
? There are no abstractions in it so far, but we plan on upstreaming more vsock building blocks (starting with the packet).Sure, the
packet
is the common component of virtio-vsock, so move it tovirtio-vsock
is reasonable, but the behavior of other components (likemuxer
orcsm
in firecracker) may be different in other vmm, would you plan to move them to this crate?Yeah these are more debatable, I have to think a bit more what would be the best approach with these, for the backend things I wouldn't add something in vm-virtio (or maybe some traits make sense, but anyway no implementation), and for the
connection
we could probably define some traits and have a default implementation for them (theconnection
module is pretty similar in firecracker and cloud-hypervisor). I'll dive deep a bit more into these in the following weeks, but I don't think we should block the packet upstreaming until that point.
I agree, we can move on. And different vmm implementation can select some parts if it to use.
Looks good! I think you can go ahead and proceed!
Can we document the lifetime requirements? Is there anything special going on here (given every part of the structure has the same lifetime) or is this just syntactic sugar to keep the compiler happy?
Thank you everyone for having a look, and for the comments!
Regarding documenting the lifetime requirements, I'm thinking whether it would make sense to have this kind of documentation around how the dirty page tracking and all the bitmap objects interact with the VolatileSlice
s lifetime 🤔 (probably somewhere in vm-memory).
In the meantime I opened https://github.com/rust-vmm/vm-virtio/pull/131. It still needs some improvements to docs, but I plan to do that in a separate PR.
We were thinking to start upstreaming the virtio vsock device, starting with the vsock packet. We already have some abstractions for the block device request, and we can go the same way for the vsock packet, i.e. have a new crate in vm-virtio:
virtio-vsock
.For a bit of context, the virtio vsock packet is defined in the standard as having a header of type
virtio_vsock_hdr
and an optionaldata
array of bytes. There are multiple operations that can be requested within a packet, e.g. VIRTIO_VSOCK_OP_RST for resetting the connection, VIRTIO_VSOCK_OP_RW for sending payload. Most operations are of the VIRTIO_VSOCK_OP_RW type, which means for data transfer, and the other ones are used for connection and buffer space management. data is non-empty only for the VIRTIO_VSOCK_OP_RW operations.Our proposal is to use vm-memory’s
VolatileSlice
, and define theVsockPacket
structure as follows:The advantage with this approach is that we don’t tie the packet implementation to the
GuestMemory
interface (which would happen if we would useGuestAddress
es instead ofVolatileSlice
s). A packet can be configured from simply pointers to a slice, not necessarily from aGuestMemory
object (e.g. the vm-virtio’sDescriptorChain
), so with this approach we would support this use case too. A limitation of this approach is that it doesn’t cover the scenario where the header or data buffer doesn't fit in a singleVolatileSlice
because the guest memory regions of the buffer are contiguous in the guest physical address space, but not in the host virtual one as well. This is not currently happening for the known customers (Firecracker, Cloud Hypervisor); the vsock packet corresponds to only one region of the host virtual space. For the multipleVolatileSlice
s use case, we can later extend this solution to use an array ofVolatileSlice
s for the header and data.Design
When using a
GuestMemory
object, aVsockPacket
instance is created by parsing a descriptor chain from either the TX virtqueue viafrom_tx_virtq_chain
or the RX virtqueue viafrom_rx_virtq_chain
. TheVsockPacket
API is also providing setters and getters for eachvirtio_vsock_hdr
field (e.g. src_cid, dst_port, op), which are using methods of theVolatileSlice
’sBytes
implementation for accessing parts of the header slice.POC here. I'll add tests and more documentation, and open a PR with the proposal once we agree on the high level design.
Thoughts?