qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: Ady Wahyudi Paundu <awpaundu@gmail.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] Help for beginner
Date: Thu, 15 Jan 2015 15:32:00 +0000	[thread overview]
Message-ID: <20150115153200.GE4005@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <CAOzyQ1F7qZiPSB0r=JD=KTpCHjxRepGa0H+g97-ypdEgKNLKpA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1849 bytes --]

On Tue, Jan 13, 2015 at 10:40:01AM +0900, Ady Wahyudi Paundu wrote:
> Hi all, Happy New Year (not too late I hope)
> I also hope you guys don't' mind to be bothered by newbie questions
> related to Qemu, because I really don't know where else to ask.  I
> want to learn how several aspects of qemu works, and it really hard to
> find resources (physical or virtual) about it.  From qemu
> documentation "QEMU does not have a high level design description
> document - only the source code tells the full story"
> My question, if i want to learn CPU and/or Network related operation
> within Qemu, what file (or function) should i put my focus into? for
> example, simple ping operation from within a guest VM will use what
> functions?

Assuming you run qemu-system-x86_64 the default network card is an
emulated Intel e1000 NIC.

See hw/net/e1000.c:start_xmit() for the function that emulates packet
transmission.  It loops over the transmit descriptor ring and send off
each packet that the guest has enqueued using qemu_send_packet().

qemu_send_packet() is a QEMU network subsystem API that passes the
packet to a host network device (for example, -netdev tap).  What
happens next depends on which netdev the user launched QEMU with (the
default is 'user').

The most popular netdev in production is tap.  Look at
net/tap.c:tap_receive() to see how QEMU writes the guest's packet to the
tap device on the host.

The tap driver in the host kernel will then "receive" the packet from
the guest and process it further (often the user has configured a
software bridge device so the packet will be forwarded onto the host's
physical NIC).

Just to recap the structure is:

 guest <-> emulated e1000 NIC <-> tap netdev <-> host kernel

Use tcpdump in the guest or host, or add printfs to QEMU if you want to
follow traffic further.

Good luck,
Stefan

[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]

  reply	other threads:[~2015-01-15 15:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-13  1:40 [Qemu-devel] Help for beginner Ady Wahyudi Paundu
2015-01-15 15:32 ` Stefan Hajnoczi [this message]
2015-01-26  2:11   ` Ady Wahyudi Paundu
2015-01-26  4:10     ` Ady Wahyudi Paundu
2015-01-15 15:53 ` Alex Bennée

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=20150115153200.GE4005@stefanha-thinkpad.redhat.com \
    --to=stefanha@gmail.com \
    --cc=awpaundu@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /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).