All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] Help for beginner
@ 2015-01-13  1:40 Ady Wahyudi Paundu
  2015-01-15 15:32 ` Stefan Hajnoczi
  2015-01-15 15:53 ` Alex Bennée
  0 siblings, 2 replies; 5+ messages in thread
From: Ady Wahyudi Paundu @ 2015-01-13  1:40 UTC (permalink / raw)
  To: qemu-devel

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?
Thank you in advance.

regards,
ady

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] Help for beginner
  2015-01-13  1:40 [Qemu-devel] Help for beginner Ady Wahyudi Paundu
@ 2015-01-15 15:32 ` Stefan Hajnoczi
  2015-01-26  2:11   ` Ady Wahyudi Paundu
  2015-01-15 15:53 ` Alex Bennée
  1 sibling, 1 reply; 5+ messages in thread
From: Stefan Hajnoczi @ 2015-01-15 15:32 UTC (permalink / raw)
  To: Ady Wahyudi Paundu; +Cc: qemu-devel

[-- 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 --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] Help for beginner
  2015-01-13  1:40 [Qemu-devel] Help for beginner Ady Wahyudi Paundu
  2015-01-15 15:32 ` Stefan Hajnoczi
@ 2015-01-15 15:53 ` Alex Bennée
  1 sibling, 0 replies; 5+ messages in thread
From: Alex Bennée @ 2015-01-15 15:53 UTC (permalink / raw)
  To: Ady Wahyudi Paundu; +Cc: qemu-devel


Ady Wahyudi Paundu <awpaundu@gmail.com> writes:

> 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?

If you are interested in the TCG emulation then you'll probably want to
start with:

target-${PROCESSOR}/translate.c

Where the instruction decode is carried out to translate guest
instructions into TCG ops which are then used to generate host code.


> for
> example, simple ping operation from within a guest VM will use what
> functions?
> Thank you in advance.
>
> regards,
> ady

-- 
Alex Bennée

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] Help for beginner
  2015-01-15 15:32 ` Stefan Hajnoczi
@ 2015-01-26  2:11   ` Ady Wahyudi Paundu
  2015-01-26  4:10     ` Ady Wahyudi Paundu
  0 siblings, 1 reply; 5+ messages in thread
From: Ady Wahyudi Paundu @ 2015-01-26  2:11 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: qemu-devel

Hi Stefan, thank you for the tips.

I was trying the way you suggested to add printfs.
For starter I try to put them into all function within net/net.c,
net/tap.c and hw/net/virtio-net.c (I run qemu using virtio netcard).
However, there were no printf message showed up (when i started a qemu
process and when i tried ping from within the guest OS of that qemu
process). As if those functions were not used.
Do you think I put those trace points in a wrong functions?

Thanks in advance
~Ady

On 1/16/15, Stefan Hajnoczi <stefanha@gmail.com> wrote:

>
> 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
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] Help for beginner
  2015-01-26  2:11   ` Ady Wahyudi Paundu
@ 2015-01-26  4:10     ` Ady Wahyudi Paundu
  0 siblings, 0 replies; 5+ messages in thread
From: Ady Wahyudi Paundu @ 2015-01-26  4:10 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: qemu-devel

Hi again, I am sorry for multiple reply, but i forget to mention one
other thing.

I also use lttng-ust method, and like my printf() attempt, I put my
new defined trace points into all function within net/net.c, net/tap.c
and hw/net/virtio-net.c.  Using this approach, i also cannot capture
my new trace points when doing 'ping'.  I am sure that i added my new
trace points correctly because i can list them using 'lttng list -u'

what did i do wrong?

~Ady

On 1/26/15, Ady Wahyudi Paundu <awpaundu@gmail.com> wrote:
> Hi Stefan, thank you for the tips.
>
> I was trying the way you suggested to add printfs.
> For starter I try to put them into all function within net/net.c,
> net/tap.c and hw/net/virtio-net.c (I run qemu using virtio netcard).
> However, there were no printf message showed up (when i started a qemu
> process and when i tried ping from within the guest OS of that qemu
> process). As if those functions were not used.
> Do you think I put those trace points in a wrong functions?
>
> Thanks in advance
> ~Ady
>
> On 1/16/15, Stefan Hajnoczi <stefanha@gmail.com> wrote:
>
>>
>> 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
>>
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-01-26  4:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-13  1:40 [Qemu-devel] Help for beginner Ady Wahyudi Paundu
2015-01-15 15:32 ` Stefan Hajnoczi
2015-01-26  2:11   ` Ady Wahyudi Paundu
2015-01-26  4:10     ` Ady Wahyudi Paundu
2015-01-15 15:53 ` Alex Bennée

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.