From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46944) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aVC74-0002tF-4r for qemu-devel@nongnu.org; Mon, 15 Feb 2016 00:54:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aVC6z-000577-GA for qemu-devel@nongnu.org; Mon, 15 Feb 2016 00:54:22 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39289) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aVC6z-00056k-Aq for qemu-devel@nongnu.org; Mon, 15 Feb 2016 00:54:17 -0500 References: <1454571834-18021-1-git-send-email-zhangchen.fnst@cn.fujitsu.com> <1454571834-18021-3-git-send-email-zhangchen.fnst@cn.fujitsu.com> From: Jason Wang Message-ID: <56C167FE.3050803@redhat.com> Date: Mon, 15 Feb 2016 13:54:06 +0800 MIME-Version: 1.0 In-Reply-To: <1454571834-18021-3-git-send-email-zhangchen.fnst@cn.fujitsu.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH V3 2/2] tests/test-filter-mirror:add filter-mirror unit test List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Zhang Chen , qemu devel Cc: zhanghailiang , Li Zhijian , Gui jianfeng , "eddie.dong" , "Dr. David Alan Gilbert" , Yang Hongyang On 02/04/2016 03:43 PM, Zhang Chen wrote: > From: ZhangChen > > Using qtest qmp interface to implement following cases: > 1) add/remove filter-mirror > 2) add a filter-mirror then delete the netdev > 3) add/remove more than one filter-mirrors > 4) add more than one filter-mirrors and then delete the netdev The steps here is rather similar to test-netfilter.c. Let's try to generalize them instead of duplicating codes. > 5) add filter-mirror with: > -object filter-mirror,id=qtest-f0,netdev=qtest-bn0,queue=tx,outdev=mirror0 > > then inject packet from the socket connected to qtest-bn0, > filter-mirror will copy and mirror the packet to mirror0. > we read packet from mirror0 and then compare to what we inject. > del filter-mirror. > > we start qemu with: > -netdev socket,id=qtest-bn0,listen=127.0.0.1:9005 > -device e1000,netdev=qtest-bn0,id=qtest-e0 > -chardev socket,id=mirror0,host=127.0.0.1,port=9003,server,nowait > -chardev socket,id=mirror1,host=127.0.0.1,port=9004,server,nowait Hardcoded port is not good here since it may cause false positive (consider the tests may be trigged by lots of automated script both upstream and downstream). A better solution is using socketpair(2) and passing pre-created fd(s) to file chardev. > > Signed-off-by: zhangchen > Signed-off-by: Wen Congyang > [...]