qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] Virtio interaction with the physical device


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] Virtio interaction with the physical device
Date: Tue, 16 Aug 2016 11:20:08 +0100
User-agent: Mutt/1.6.2 (2016-07-01)

On Tue, Aug 16, 2016 at 10:08:09AM +0530, Gadre Nayan wrote:
> I was trying to understand the flow of packets from the Guest OS to my
> NIC card, while using the Virtio paravirtualized drivers. (Qemu is not
> emulating the NIC)

QEMU always emulates paravirtualized NICs to some extent.  Why do you
think that QEMU isn't emulating the NIC?

> THis is as far as I have understood:
> {
> THe guest OS starts with a virtio nic:
> -net nic,model=virtio -net user -redir tcp:2222::22
> 
> A socket application sends data on an interface (which would have been
> created by this nic (alloc_etherdev and net_device creation and some
> such). This net_device would be created by the virtio-net.ko in the
> Guest Kernel.
> 
> Where is the underlying hardware on the Host getting mapped with the
> virtio-net in the guest.

That's not how virtio-net emulation works.  The physical NIC on the host
isn't mapped to virtio-net somehow.

> 1. Where is the notify function defined, I only saw assignment.
> 2. Now once the other side ( the Host side ) is notified (need to see
> exactly how ) who takes care of the packet on the HOST. How is this
> packet received from a generic virtio framework mapped to a specific
> Physical NIC. (The TX and RX registers of the physical hardware must
> have been mapped to the virtio-net somehow to achieve this)

QEMU implements virtio-net emulation in hw/net/virtio-net.c.  Take a
look at that code to learn more.

There is also the vhost_net.ko host kernel module for high-performance
network I/O.  It emulates the virtio-net rx/tx virtqueues inside the
host kernel and passes packets to a tap-like interface (either tap or
macvtap).

I've written about how vhost works here:
http://blog.vmsplice.net/2011/09/qemu-internals-vhost-architecture.html

> 3. Suppose I have virtio-blk also enabled through:
> -drive file=/home/gnayan/u1.img,if=virtio,format=raw
> 
> Then how are the two buffers in the virtio-ring differentiated if
> belonging to block layer or network layer?

Each virtio device has a PCI adapter.  The two devices are independent.
They don't share anything (generally speaking) or interfere with each
other.

Stefan

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]