On 03/31/2016 05:24 PM, Dr. David Alan Gilbert wrote: > * Zhang Chen (zhangchen.f...@cn.fujitsu.com) wrote: >> >> On 03/30/2016 05:25 PM, Dr. David Alan Gilbert wrote: >>> * Zhang Chen (zhangchen.f...@cn.fujitsu.com) wrote: >>>> packet come from primary char indev will be send to >>>> outdev - packet come from secondary char dev will be drop >>> Please put in the description an example of how you invoke >>> the filter on the primary and secondary. >> OK. >> colo-compare get packet from chardev(primary_in,secondary_in), >> and output to other chardev(outdev), so, we can use it with the >> help of filter-mirror and filter-redirector. like that: > Wow, this is a bit more complicated than I expected - I was expecting just one > socket. So let me draw this out; see comments below. > >> primary: >> -netdev >> tap,id=hn0,vhost=off,script=/etc/qemu-ifup,downscript=/etc/qemu-ifdown >> -device e1000,id=e0,netdev=hn0,mac=52:a4:00:12:78:66 >> -chardev socket,id=mirror0,host=3.3.3.3,port=9003,server,nowait >> -chardev socket,id=compare1,host=3.3.3.3,port=9004,server,nowait >> -chardev socket,id=compare0,host=3.3.3.3,port=9001,server,nowait >> -chardev socket,id=compare0-0,host=3.3.3.3,port=9001 >> -chardev socket,id=compare_out,host=3.3.3.3,port=9005,server,nowait >> -chardev socket,id=compare_out0,host=3.3.3.3,port=9005 >> -object filter-mirror,id=m0,netdev=hn0,queue=tx,outdev=mirror0 >> -object filter-redirector,netdev=hn0,id=redire0,queue=rx,indev=compare_out >> -object filter-redirector,netdev=hn0,id=redire1,queue=rx,outdev=compare0 >> -object >> colo-compare,id=comp0,primary_in=compare0-0,secondary_in=compare1,outdev=compare_out0 > ----> mirror0: socket:secondary:9003 > | > mirror-m0 <-- e1000 > | > v > redirector-redire1 ---> compare0 socket:primary:9001 (to compare0-0) > > -----< compare0-0 socket:primary:9001 (to compare0) > | primary_in > | > compare-comp0 -----> compare_out0 socket:primary:9005 > | > | secondary_in > -----< compare1 socket:secondary:9004 > > tap <-- redirector-redire0 <--- compare_out socket:primary:9005 (from > compare_out0) > > >> secondary: >> -netdev tap,id=hn0,vhost=off,script=/etc/qemu-ifup,down >> script=/etc/qemu-ifdown >> -device e1000,netdev=hn0,mac=52:a4:00:12:78:66 >> -chardev socket,id=red0,host=3.3.3.3,port=9003 >> -chardev socket,id=red1,host=3.3.3.3,port=9004 >> -object filter-redirector,id=f1,netdev=hn0,queue=tx,indev=red0 >> -object filter-redirector,id=f2,netdev=hn0,queue=rx,outdev=red1 > ----> red0 socket::9003 > | > tap <-- redirector-f1 <-- > e1000 > --> redirector-f2 --> > | > ----< red1 socket::9004 > > OK, so I think we need to find a way to fix two things: > a) There must be an easier way of connecting two filters within the same > qemu than going up to the kernel's socket code, around it's TCP stack > and back. Is there a better type of chardev to use we can short circuit > with - it shouldn't need to leave QEMU (although I can see it's easier > for debugging like this). Jason/Dan - any ideas?
Looks like there's no such type of chardev. I think we could start with tcp socket chardev first and do necessary optimization on top. In fact, there's also advantages, with tcp sockets, the colo-compare codes could even be an independent program out of qemu. For the chardev type, this also reminds me one thing. Since mirror/redirector can only work for tcp socket, we may need inspect the chardev types and fail if not a tcp socket like what vhost-user did. > > b) We should only need one socket for the connection between primary and > secondary - I'm not sure how to change it to let it do that. Looks like we can (e.g for secondary): -device e1000,netdev=hn0,mac=52:a4:00:12:78:66 -chardev socket,id=red0,host=3.3.3.3,port=9003 -object filter-redirector,id=f1,netdev=hn0,queue=tx,indev=red0 -object filter-redirector,id=f2,netdev=hn0,queue=rx,outdev=red0 If not, probably a bug. > c) You need to be able to turn off nagling (socket no delay) on the > sockets; > I found a noticeable benefit of doing this on the connection between > primary > and secondary in my world. Right. > > Dave >