On 02/04/2016 03:43 PM, Zhang Chen wrote: > From: ZhangChen <zhangchen.f...@cn.fujitsu.com> > > 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 <zhangchen.f...@cn.fujitsu.com> > Signed-off-by: Wen Congyang <we...@cn.fujitsu.com> > [...]