From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60339) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YBmP3-0007v7-EK for qemu-devel@nongnu.org; Thu, 15 Jan 2015 10:32:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YBmOz-0002Wc-Ap for qemu-devel@nongnu.org; Thu, 15 Jan 2015 10:32:09 -0500 Received: from mail-wg0-x230.google.com ([2a00:1450:400c:c00::230]:43285) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YBmOz-0002WO-5R for qemu-devel@nongnu.org; Thu, 15 Jan 2015 10:32:05 -0500 Received: by mail-wg0-f48.google.com with SMTP id l2so15599392wgh.7 for ; Thu, 15 Jan 2015 07:32:04 -0800 (PST) Date: Thu, 15 Jan 2015 15:32:00 +0000 From: Stefan Hajnoczi Message-ID: <20150115153200.GE4005@stefanha-thinkpad.redhat.com> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="UnaWdueM1EBWVRzC" Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] Help for beginner List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Ady Wahyudi Paundu Cc: qemu-devel@nongnu.org --UnaWdueM1EBWVRzC Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 --UnaWdueM1EBWVRzC Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJUt91wAAoJEJykq7OBq3PIQQoIAIqLu8ldwMj4KL6rC3Lnw3oX /7kVs0ac0g5X+xwuFV5BShhaJSBMT0PjfTYSizDFd/wyEmYBy38HVO9QtQtnaGMg tx5Tzv1P2y6BqoV/jQkBfJoau8f+KDLbX4e8Mbc89tQSOo+0gpcCCr7dYw0nxB7d NzHK7wAD+NTn1MjolaqmUnOdcpW0Usk+td2aLHOaSIrIdfAFrOk+/grwG9qX88mY fIF6IVjENPbtIcg05cfDOReiTZOca3Kv8BppqGw5vF8k7qyd9kUXITuCPJ/EYYsT 2kfJrjSBGnIka4rQut3ebdTERFDzNv6UzGe+OYN+g4uMjXhU0WO7wzhxvzL71n4= =+0Mw -----END PGP SIGNATURE----- --UnaWdueM1EBWVRzC--