qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: Alexander Binun <binun@cs.bgu.ac.il>
Cc: kahilm@post.bgu.ac.il, markbl@post.bgu.ac.il, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] sniffing traffic between VMs
Date: Thu, 10 Oct 2013 11:02:04 +0200	[thread overview]
Message-ID: <20131010090204.GD10516@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <201310071447.r97ElkFK029746@indigo.cs.bgu.ac.il>

On Mon, Oct 07, 2013 at 05:47:46PM +0300, Alexander Binun wrote:
> Our first task is to trace the traffic between individual VMs and between VMs and the VMM (the KVM driver). So we are searching for proper places to insert "sniffer code". We suspect that some functions in qemu/hw/virtio should be targeted. And we will appreciate any hints on this places.

My blog post about -netdev pcap in QEMU is useful for QEMU network code
development setups.  But the simplest way to sniff traffic in a
production x86 KVM configuration is using tcpdump on the host.

The common networking setup on the host is a Linux software bridge (e.g.
virbr0) and one tap device per guest (e.g. vm001-tap, vm002-tap).  The
tap devices are added to the bridge so guests can communicate with each
other.

When a guest sends a packet, the vhost_net host kernel driver injects
the packet into the guest's tap device.  The Linux network stack then
hands the packet from the tap device to the bridge.

The bridge will forward the packet as appropriate.  In guest<->guest
communication this means the packet is forwarded to the destination
guest's tap device.

The vhost_net driver instance for the destination guest then reads the
packet from its tap device and places it into the guest's virtio-net
receive buffer.

This configuration means you have 3 places where you can run tcpdump on
the host:

1. On the source guest's tap device (e.g. vm001-tap).
2. On the bridge interface (e.g. virbr0).
3. On the destination guest's tap device (e.g. vm002-tap).

There are other options too like using openvswitch or macvtap.
Openvswitch might be interesting because I think it allows you to add
filtering rules into the kernel and send packets that match the rules up
to a userspace process for inspection.

Stefan

  reply	other threads:[~2013-10-10  9:02 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-07 14:47 [Qemu-devel] sniffing traffic between VMs Alexander Binun
2013-10-10  9:02 ` Stefan Hajnoczi [this message]
2013-10-10 11:00   ` [Qemu-devel] kvm binary is deprecated Alexander Binun
2013-10-11  9:05     ` Stefan Hajnoczi
2013-10-12 14:45       ` Alexander Binun
2013-10-14  9:12         ` Stefan Hajnoczi
2013-10-14 10:36           ` Alexander Binun
2013-10-14 14:16             ` Stefan Hajnoczi
2013-10-24  9:23               ` [Qemu-devel] kvm binary is deprecated - solved! Alexander Binun
2013-10-24  9:49                 ` Stefan Hajnoczi
2013-10-24  9:54                   ` [Qemu-devel] observing VM actions Alexander Binun
2013-12-18 11:53           ` [Qemu-devel] sniffing traffic between virtual machines Alexander Binun
2013-12-19  9:05             ` Stefan Hajnoczi
2014-03-05 16:35               ` [Qemu-devel] kill /destroy a VM - help Alexander Binun
2014-03-06 10:22                 ` Stefan Hajnoczi
2014-03-06 10:31                   ` Alexander Binun
2014-03-06 11:28                     ` Paolo Bonzini
2014-03-06 15:54                       ` [Qemu-devel] kill /destroy a VM - still hangs! Alexander Binun
2014-03-09 15:40                       ` [Qemu-devel] trying to kill a VM Alexander Binun
2014-03-13 12:59                       ` [Qemu-devel] different IDTs of the same VCPU Alexander Binun
2014-03-13 15:15                         ` Paolo Bonzini
2014-03-17 11:54                           ` Alexander Binun
2014-03-17 12:20                             ` Paolo Bonzini

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=20131010090204.GD10516@stefanha-thinkpad.redhat.com \
    --to=stefanha@gmail.com \
    --cc=binun@cs.bgu.ac.il \
    --cc=kahilm@post.bgu.ac.il \
    --cc=markbl@post.bgu.ac.il \
    --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).