* [Qemu-devel] Virtio interaction with the physical device
@ 2016-08-16 4:38 Gadre Nayan
2016-08-16 10:20 ` Stefan Hajnoczi
0 siblings, 1 reply; 2+ messages in thread
From: Gadre Nayan @ 2016-08-16 4:38 UTC (permalink / raw)
To: qemu-devel, qemu-discuss; +Cc: stefanha, Stefan Hajnoczi
Hi,
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)
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.
The device ID table simply specifies VIRTIO_ID_NET, VIRTIO_DEV_ANY_ID
The virtio-net in Guest kernel allocated virt-queue using virtnet_alloc_queues
SO the driver puts the packet into the queue and call the xmit
function which will do
virtqueue_add_outbuf() (virtio-ring.ko) which calls virtqueue_add() --
vq->notify().
It also calls virtqueue_kick() if num_added equals 2^16 -1.
virtqueue_kick calls notify function, where is the notify function defined ?
}
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)
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?
Kindly suggest.
Thanks
Nayan Gadre
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] Virtio interaction with the physical device
2016-08-16 4:38 [Qemu-devel] Virtio interaction with the physical device Gadre Nayan
@ 2016-08-16 10:20 ` Stefan Hajnoczi
0 siblings, 0 replies; 2+ messages in thread
From: Stefan Hajnoczi @ 2016-08-16 10:20 UTC (permalink / raw)
To: Gadre Nayan; +Cc: qemu-devel, qemu-discuss, stefanha
[-- Attachment #1: Type: text/plain, Size: 2210 bytes --]
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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-08-16 10:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-16 4:38 [Qemu-devel] Virtio interaction with the physical device Gadre Nayan
2016-08-16 10:20 ` Stefan Hajnoczi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).