Milan
Milan

Reputation: 1539

Confusion about virtio-net-pci and virtio-net in QEMU

I am bit confused about two emulated device hw/net/virtio-net.c and hw/virtio/virtio-net-pci.c present in QEMU source. It looks to be that virio-net-pci.c is NIC emulation based on virtio specs but I didn't get what hw/net/virtio-net.c is used for ?

Apart from that I see, hw/net/vhost_net.c but didn't understand under what scenario this has been used ?

Upvotes: 8

Views: 12917

Answers (1)

Peter Maydell
Peter Maydell

Reputation: 11533

Conceptually, virtio devices in QEMU's implementation come in two parts: the "transport" and the "backend". The "backend" is the part that does the actual job (network, block device, random-number generator, etc); the "transport" is the part that is the interface to the guest (PCI, MMIO, s390 CCW...). This allows us to provide the virtio devices in multiple different ways without code duplication.

hw/net/virtio-net.c implements the 'net' backend. hw/virtio/virtio-pci.c implements the PCI transport. hw/virtio/virtio-net-pci.c implements a PCI device that provides a PCI transport to a virtio net backend device (and is a fairly small file because it's just gluing together the common transport and common backend code).

hw/net/vhost_net.c is, unsurprisingly, the implementation of the vhost-net support as described in the RedHat blog post that KagurazakaKotori gave you a link to. You can pass the guest a virtio network device without having to use vhost-net -- you can use any of the QEMU network backends.

Upvotes: 14

Related Questions