Add virtio-net support to Lumper
Closed this issue · 2 comments
See this crate for an already existing implementation of virtio in Rust: https://github.com/rust-vmm/vm-virtio
The virtio-bindings
crate might be interesting, as it contains a virtio_net
module: https://docs.rs/virtio-bindings/
The three big steps for implementing networking support in Lumper:
-
Set up a TAP interface on the host. #11
For this, there are two possibilities:- Either we let Lumper create the TAP interface itself (see cloud-hypervisor), and in that case we get the IP address of that interface from the CLI args (such as
--network-host-ip x.x.x.x/x
). - Or, we get a TAP interface that was already created for us (see rust-vmm/vmm-reference) from the CLI args (such as
--network-tap tapX
).
This should leave us with a file descriptor open to read from/write to the TAP interface.
Note: can we call the TAP interfacestaplets
? Liketaplet0
,taplet1
... - Either we let Lumper create the TAP interface itself (see cloud-hypervisor), and in that case we get the IP address of that interface from the CLI args (such as
-
Set up the virtio-net device in Lumper. #22
Because we don't really need the fancy features such as multi-queues, the control queue... we can directly use the implementation from rust-vmm/vmm-reference (and because it's free, we have support for segmentation and checksum offloads).We will be using Virtio over MMIO, so we shall not forget to add the
virtio_mmio.device=4K@0x<device_register_address>:<notification_irq>
thingy to the kernel cmdline.
Note: it might be nice, but certainly more work, to explore vhost-net to move the virtio-net data plane outside of Lumper and into the host kernel. -
Set up the IP address of the interface inside the VM. #35
This one doesn't seem too hard, we can seemingly pass the IP configuration of a network interface right from the kernel cmdline. We'll also need to get the guest IP address from the CLI args (such as--network-guest-ip x.x.x.x/x
).