qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] Help for beginner


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] Help for beginner
Date: Thu, 15 Jan 2015 15:32:00 +0000
User-agent: Mutt/1.5.23 (2014-03-12)

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: pgp4DIhvKO2LV.pgp
Description: PGP signature


reply via email to

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