mirror of
https://github.com/Motorhead1991/qemu.git
synced 2026-02-24 13:15:07 -07:00
In this unit test,we will test the filter redirector function.
Case 1, tx traffic flow:
qemu side | test side
|
+---------+ | +-------+
| backend <---------------+ sock0 |
+----+----+ | +-------+
| |
+----v----+ +-------+ |
| rd0 +->+chardev| |
+---------+ +---+---+ |
| |
+---------+ | |
| rd1 <------+ |
+----+----+ |
| |
+----v----+ | +-------+
| rd2 +--------------->sock1 |
+---------+ | +-------+
+
a. we(sock0) inject packet to qemu socket backend
b. backend pass packet to filter redirector0(rd0)
c. rd0 redirect packet to out_dev(chardev) which is connected with
filter redirector1's(rd1) in_dev
d. rd1 read this packet from in_dev, and pass to next filter redirector2(rd2)
e. rd2 redirect packet to rd2's out_dev which is connected with an opened socketed(sock1)
f. we read packet from sock1 and compare to what we inject
Start qemu with:
"-netdev socket,id=qtest-bn0,fd=%d "
"-device rtl8139,netdev=qtest-bn0,id=qtest-e0 "
"-chardev socket,id=redirector0,path=%s,server,nowait "
"-chardev socket,id=redirector1,path=%s,server,nowait "
"-chardev socket,id=redirector2,path=%s,nowait "
"-object filter-redirector,id=qtest-f0,netdev=qtest-bn0,"
"queue=tx,outdev=redirector0 "
"-object filter-redirector,id=qtest-f1,netdev=qtest-bn0,"
"queue=tx,indev=redirector2 "
"-object filter-redirector,id=qtest-f2,netdev=qtest-bn0,"
"queue=tx,outdev=redirector1 "
--------------------------------------
Case 2, rx traffic flow
qemu side | test side
|
+---------+ | +-------+
| backend +---------------> sock1 |
+----^----+ | +-------+
| |
+----+----+ +-------+ |
| rd0 +<-+chardev| |
+---------+ +---+---+ |
^ |
+---------+ | |
| rd1 +------+ |
+----^----+ |
| |
+----+----+ | +-------+
| rd2 <---------------+sock0 |
+---------+ | +-------+
a. we(sock0) insert packet to filter redirector2(rd2)
b. rd2 pass packet to filter redirector1(rd1)
c. rd1 redirect packet to out_dev(chardev) which is connected with
filter redirector0's(rd0) in_dev
d. rd0 read this packet from in_dev, and pass ti to qemu backend which is
connected with an opened socketed(sock1)
e. we read packet from sock1 and compare to what we inject
Start qemu with:
"-netdev socket,id=qtest-bn0,fd=%d "
"-device rtl8139,netdev=qtest-bn0,id=qtest-e0 "
"-chardev socket,id=redirector0,path=%s,server,nowait "
"-chardev socket,id=redirector1,path=%s,server,nowait "
"-chardev socket,id=redirector2,path=%s,nowait "
"-object filter-redirector,id=qtest-f0,netdev=qtest-bn0,"
"queue=rx,outdev=redirector0 "
"-object filter-redirector,id=qtest-f1,netdev=qtest-bn0,"
"queue=rx,indev=redirector2 "
"-object filter-redirector,id=qtest-f2,netdev=qtest-bn0,"
"queue=rx,outdev=redirector1 "
Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
|
||
|---|---|---|
| .. | ||
| acpi-test-data | ||
| guest-debug | ||
| image-fuzzer | ||
| libqos | ||
| multiboot | ||
| qapi-schema | ||
| qemu-iotests | ||
| rocker | ||
| tcg | ||
| vmstate-static-checker-data | ||
| .gitignore | ||
| ac97-test.c | ||
| ahci-test.c | ||
| bios-tables-test.c | ||
| boot-order-test.c | ||
| boot-sector.c | ||
| boot-sector.h | ||
| check-block.sh | ||
| check-qdict.c | ||
| check-qfloat.c | ||
| check-qint.c | ||
| check-qjson.c | ||
| check-qlist.c | ||
| check-qom-interface.c | ||
| check-qom-proplist.c | ||
| check-qstring.c | ||
| crypto-tls-x509-helpers.c | ||
| crypto-tls-x509-helpers.h | ||
| device-introspect-test.c | ||
| display-vga-test.c | ||
| drive_del-test.c | ||
| ds1338-test.c | ||
| e1000-test.c | ||
| eepro100-test.c | ||
| endianness-test.c | ||
| es1370-test.c | ||
| fdc-test.c | ||
| fw_cfg-test.c | ||
| hd-geo-test.c | ||
| i440fx-test.c | ||
| i82801b11-test.c | ||
| ide-test.c | ||
| intel-hda-test.c | ||
| io-channel-helpers.c | ||
| io-channel-helpers.h | ||
| ioh3420-test.c | ||
| ipmi-bt-test.c | ||
| ipmi-kcs-test.c | ||
| ipoctal232-test.c | ||
| ivshmem-test.c | ||
| libqtest.c | ||
| libqtest.h | ||
| m48t59-test.c | ||
| Makefile | ||
| ne2000-test.c | ||
| nvme-test.c | ||
| pc-cpu-test.c | ||
| pcnet-test.c | ||
| pkix_asn1_tab.c | ||
| pvpanic-test.c | ||
| pxe-test.c | ||
| q35-test.c | ||
| qemu-iotests-quick.sh | ||
| qom-test.c | ||
| rcutorture.c | ||
| rtc-test.c | ||
| rtl8139-test.c | ||
| spapr-phb-test.c | ||
| tco-test.c | ||
| test-aio.c | ||
| test-base64.c | ||
| test-bitops.c | ||
| test-blockjob-txn.c | ||
| test-coroutine.c | ||
| test-crypto-afsplit.c | ||
| test-crypto-block.c | ||
| test-crypto-cipher.c | ||
| test-crypto-hash.c | ||
| test-crypto-ivgen.c | ||
| test-crypto-pbkdf.c | ||
| test-crypto-secret.c | ||
| test-crypto-tlscredsx509.c | ||
| test-crypto-tlssession.c | ||
| test-crypto-xts.c | ||
| test-cutils.c | ||
| test-filter-mirror.c | ||
| test-filter-redirector.c | ||
| test-hbitmap.c | ||
| test-int128.c | ||
| test-io-channel-buffer.c | ||
| test-io-channel-command.c | ||
| test-io-channel-file.c | ||
| test-io-channel-socket.c | ||
| test-io-channel-tls.c | ||
| test-io-task.c | ||
| test-iov.c | ||
| test-logging.c | ||
| test-mul64.c | ||
| test-netfilter.c | ||
| test-opts-visitor.c | ||
| test-qdev-global-props.c | ||
| test-qemu-opts.c | ||
| test-qga.c | ||
| test-qmp-commands.c | ||
| test-qmp-event.c | ||
| test-qmp-input-strict.c | ||
| test-qmp-input-visitor.c | ||
| test-qmp-output-visitor.c | ||
| test-rcu-list.c | ||
| test-rfifolock.c | ||
| test-string-input-visitor.c | ||
| test-string-output-visitor.c | ||
| test-thread-pool.c | ||
| test-throttle.c | ||
| test-timed-average.c | ||
| test-visitor-serialization.c | ||
| test-vmstate.c | ||
| test-write-threshold.c | ||
| test-x86-cpuid.c | ||
| test-xbzrle.c | ||
| tmp105-test.c | ||
| tpci200-test.c | ||
| usb-hcd-ehci-test.c | ||
| usb-hcd-ohci-test.c | ||
| usb-hcd-uhci-test.c | ||
| usb-hcd-xhci-test.c | ||
| vhost-user-bridge.c | ||
| vhost-user-test.c | ||
| virtio-9p-test.c | ||
| virtio-balloon-test.c | ||
| virtio-blk-test.c | ||
| virtio-console-test.c | ||
| virtio-net-test.c | ||
| virtio-rng-test.c | ||
| virtio-scsi-test.c | ||
| virtio-serial-test.c | ||
| vmxnet3-test.c | ||
| wdt_ib700-test.c | ||