From: Stefan Hajnoczi <stefanha@gmail.com>
To: Gadre Nayan <gadrenayan@gmail.com>
Cc: qemu-devel@nongnu.org, qemu-discuss@nongnu.org, stefanha@redhat.com
Subject: Re: [Qemu-devel] Virtio interaction with the physical device
Date: Tue, 16 Aug 2016 11:20:08 +0100 [thread overview]
Message-ID: <20160816102008.GA8157@stefanha-x1.localdomain> (raw)
In-Reply-To: <CAKJ7aR7Vdm0_kMNuR6fn1J-bTuODDqVz4RveyA_4zmSYpH5+4A@mail.gmail.com>
[-- 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 --]
prev parent reply other threads:[~2016-08-16 10:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-16 4:38 [Qemu-devel] Virtio interaction with the physical device Gadre Nayan
2016-08-16 10:20 ` Stefan Hajnoczi [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160816102008.GA8157@stefanha-x1.localdomain \
--to=stefanha@gmail.com \
--cc=gadrenayan@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-discuss@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).