Question about KVM internal network stack

voidindigo

Well-Known Member
Sep 18, 2018
31
5
48
56
This might be a little deep, but I'm curious about how the network stack actually works between KVM VMs and the host layer.

I believe I read once (and I can't find it now) that the VM kernel is aware that it's virtualized, and the host has interface(s) available for the guests to connect to specifically for networking. Basically, a kernel device driver interface for the network layer that knows how to talk directly to an equivalent interface on the host.

So, if you create a virtual bridge between VMs, the data flow is effectively `VM guest app` -> `VM kernel network layer` directly to -> `HOST kernel network layer` rather than going through the VM kernel network stack (building ethernet frames, sending what it believes are packets, etc).

Is that correct?
 
Last edited:
We use tap devices [1] as virtual network devices - it basically hands a file descriptor to QEMU where it can write/read raw ethernet frames. The packet goes through the whole guest network stack - it has to - since otherwise you couldn't use basic functionality like IP routing or firewalling. When the packet pops out of the guest and it is part of a bridge, then it additionally traverses the host network stack.

[1] https://en.wikipedia.org/wiki/TUN/TAP
 
  • Like
Reactions: voidindigo