From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35819) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YvsWa-0008VY-Nq for qemu-devel@nongnu.org; Fri, 22 May 2015 15:22:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YvsWW-0001nV-Gy for qemu-devel@nongnu.org; Fri, 22 May 2015 15:22:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52944) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YvsWW-0001nD-Cb for qemu-devel@nongnu.org; Fri, 22 May 2015 15:22:24 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 70B053674AE for ; Fri, 22 May 2015 19:22:23 +0000 (UTC) From: Thomas Huth Date: Fri, 22 May 2015 21:22:19 +0200 Message-Id: <1432322539-23719-1-git-send-email-thuth@redhat.com> Subject: [Qemu-devel] [RFC PATCH] net: Enable vlans and dump for -netdev, too, List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, Stefan Hajnoczi , Jason Wang Cc: Markus Armbruster , "Michael S. Tsirkin" So far, it is not possible to use the network dump interface with the "-netdev" option yet, it only works with the legacy "-net" option. To be able to use it with "-netdev", too, this patch now enables the "vlan" packet distribution for the "-netdev" option, too, so that you can now dump network packets like this: qemu... -device e1000,netdev=myhub -netdev hubport,hubid=1,id=myhub \ -netdev user,id=n1,vlan=1,tftp=/tmp/tftp,bootfile=zImage \ -netdev dump,id=n2,vlan=1,file=/tmp/dump.dat Signed-off-by: Thomas Huth --- net/net.c | 3 +++ qapi-schema.json | 1 + 2 files changed, 4 insertions(+) [Note: I'm quite new to this area of the code, please review carefully whether this approach makes sense or whether it should be done differently] diff --git a/net/net.c b/net/net.c index 7427f6a..3595910 100644 --- a/net/net.c +++ b/net/net.c @@ -872,6 +872,7 @@ static int net_client_init1(const void *object, int is_netdev, Error **errp) #ifdef CONFIG_L2TPV3 case NET_CLIENT_OPTIONS_KIND_L2TPV3: #endif + case NET_CLIENT_OPTIONS_KIND_DUMP: break; default: @@ -895,6 +896,8 @@ static int net_client_init1(const void *object, int is_netdev, Error **errp) (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); + } else if (is_netdev && u.netdev->has_vlan) { + peer = net_hub_add_port(u.netdev->vlan, NULL); } if (net_client_init_fun[opts->kind](opts, name, peer) < 0) { diff --git a/qapi-schema.json b/qapi-schema.json index f97ffa1..adb0722 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -2512,6 +2512,7 @@ { 'struct': 'Netdev', 'data': { 'id': 'str', + '*vlan': 'int32', 'opts': 'NetClientOptions' } } ## -- 1.8.3.1