qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] using -net dump with tap networking


From: Alexey Kardashevskiy
Subject: Re: [Qemu-devel] using -net dump with tap networking
Date: Thu, 14 Feb 2013 11:51:42 +1100
User-agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:17.0) Gecko/20130107 Thunderbird/17.0.2

On 14/02/13 05:02, Laszlo Ersek wrote:
On 02/13/13 15:48, Alexey Kardashevskiy wrote:
Hi!

I am running qemu as:

qemu/ppc64-softmmu/qemu-system-ppc64 -m 1024 -M pseries -trace
events=trace_events -netdev user,id=virtnet,hostfwd=tcp::5000-:22
-device virtio-net-pci,netdev=virtnet -nographic -vga none -enable-kvm
-kernel vml36_64k -initrd 1.cpio

Now I want to enable network dump. With the old "-net" syntax I could do
that with "-net dump" but I cannot with the new syntax, tried many
variants, none works. What would the correct syntax be for the case above?

Ugh, I'm a bit confused, but if I say something stupid that should still
help "ignite" the discussion.

So, in general there are two ways to specify this:

(1) -net dump,id=dump0,vlan=VLAN_ID,len=SIZE_LIMIT,file=PATHNAME

(2) -netdev dump,id=dump0,len=SIZE_LIMIT,file=PATHNAME

I believe the first option (legacy) should work.

The second one will not work; actually I think it will trigger an
assert. The generic init code in net_client_init1() [net/net.c] says:

         NetClientState *peer = NULL;

         /* Do not add to a vlan if it's a -netdev or a nic with a netdev=
          * parameter. */
         if (!is_netdev &&
             (opts->kind != NET_CLIENT_OPTIONS_KIND_NIC ||
              !opts->nic->has_netdev)) {
             peer = net_hub_add_port(u.net->has_vlan ? u.net->vlan : 0, NULL);
         }

         if (net_client_init_fun[opts->kind](opts, name, peer) < 0) {

So in (2) we don't add the dump netdev to any hub/vlan; however the
specific code (net_init_dump(), [net/dump.c]) asserts (peer != NULL).

Otherwise I think the idea would be to add the dump netdev *afterwards*
to a vlan/hub, by changing its vlan property. See set_vlan() in
[hw/qdev-properties-system.c]; it calls net_hub_port_find() [net/hub.c]
whose task is to "Find a available port on a hub; otherwise create one
new port".

See
<http://lists.nongnu.org/archive/html/qemu-devel/2012-07/msg03182.html>.

Hence I think you're back to (1), the legacy format. Assuming qemu
doesn't barf on that option immediately, I believe you *also* have to
add your "-netdev user" to the same hub as the dumper is on.

In total you have to create both netdevs (a, b) and assign both to a
common hub/vlan (c, d). Again, unfortunately the dump netdev only works
with the legacy format, but that already includes the assignment to the
hub (a, c). So you have to take care of creating the other netdev
(-netdev user, b), and assign it through its vlan qdev property to the
same hub (d), so that data can flow from it to the dump netdev.

Hm... Looks like you can't do that directly on "-netdev user" (it seems
to have no such property). "virtio-net-pci" does have it however. At
least in a quick "info qtree" check:

bus: main-system-bus
   type System
   dev: i440FX-pcihost, id ""
     bus: pci.0
       type PCI
       dev: virtio-net-pci, id "net0"
         dev-prop: vlan = <null>

Also confirmed by "qemu-system-x86_64 -device virtio-net-pci,help".

So

-netdev user,id=virtnet,hostfwd=tcp::5000-:22 \
-device virtio-net-pci,netdev=virtnet,vlan=2 \
-net dump,vlan=2,len=SIZE_LIMIT,file=PATHNAME

Or some such...

Ok. So, there is "user" device (interface to the world) and 2 QEMU network devices - "virtio" and "dump", attached to the same virtual bridge within the QEMU.

Now let's make it more fun. Actually I want to trace a "tap" config (I put it into the subject but later changed the actual example in a hope that it makes things simpler but I was wrong :-) ):

qemu-impreza/ppc64-softmmu/qemu-system-ppc64 -m 1024 -M pseries
-nographic -vga none -enable-kvm -kernel vml36_64k -initrd 1.cpio
        -netdev tap,id=tapnet,ifname=tap0,script=qemu-ifup.sh
        -device virtio-net-pci,netdev=tapnet,vlan=100
        -net dump,vlan=100,file=./dump.lan.qemu.virtio

So I have a virtual bridge but it is in the host, not in the QEMU. To the command line above QEMU says:

Warning: vlan 100 is not connected to host network
Warning: netdev tapnet has no peer

"qemu -help" says "-net tap" accepts "vlan=n" but "-netdev tap,vlan=100,..." generates an error (Invalid parameter 'vlan').

Sure I can run tcpdump on the host with the tap0 interface but I would like to catch trafic between virtio-net-pci and tap0 if it is possible. Is it?

btw is there any way to get for the -netdev device what "-device NAME,help" does (i.e. list of actually supported parameters)?


--
Alexey



reply via email to

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