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 <stefa...@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 >