tests/pxe-test: add pxe vhost user test
RFC PATCH 1/1 tests/pxe-test: add pxe vhost user test
Add one more testcase to pxe-test for checking vhost-user interface. The test is based on spawning vhost-user-bridge process in addition to qemu under test.
---
The patch is a quick and dirty, but working implementation of Michal's idea. It is based on latest vhost-user-bridge test and latest change in rules: "[PATCH] rules: filter out irrelevant files".
tests/pxe-test.c | 39 +++++++++++++++++++++++++++++++++++++++ tests/Makefile | 4 +++- 2 files changed, 42 insertions(+), 1 deletion(-)
tests/pxe-test.c +39 -0
@@ -48,6 +48,44 @@ static void test_pxe_virtio_pci(void)test_pxe_one ("-device virtio-net-pci,netdev=" NETNAME ); } +static void test_pxe_vhost_user (void ) +{ +pid_t pid; +int status; + + pid =fork (); +if (!pid) { +char *vubr_binary; +char *args; + + vubr_binary =getenv ("QTEST_VUBR_BINARY" ); +assert (vubr_binary); + + args = +g_strdup_printf ("%s -u /tmp/vubr.sock -l 127.0.0.1:4444 " +"-r 127.0.0.1:5555 1> /dev/null 2>&1" , + vubr_binary); +system (args); +free (args); +exit (0 ); + } + +g_usleep (1 *G_USEC_PER_SEC ); +qtest_start ( +"-enable-kvm " +"-m 1024 " +"-object memory-backend-file,id=mem,size=1024M,mem-path=/tmp/hugepages,share=on " +"-numa node,memdev=mem -mem-prealloc " +"-device virtio-net-pci,netdev=net0 " +"-chardev socket,id=char0,path=/tmp/vubr.sock " +"-netdev type=vhost-user,id=net0,chardev=char0,vhostforce " +"-net user,vlan=5,tftp=./,bootfile=tests/pxe-test-disk.raw " +"-net socket,vlan=5,udp=localhost:4444,localaddr=localhost:5555 " ); +boot_sector_test (); +qtest_quit (global_qtest); +waitpid (pid, &status,0 ); +} +int main (int argc,char *argv[]) {int ret;
@@ -60,6 +98,7 @@ int main(int argc, char *argv[])g_test_init (&argc, &argv,NULL );if (strcmp (arch,"i386" ) ==0 ||strcmp (arch,"x86_64" ) ==0 ) { +qtest_add_func ("pxe/vhost-user" , test_pxe_vhost_user);qtest_add_func ("pxe/e1000" , test_pxe_e1000);qtest_add_func ("pxe/virtio" , test_pxe_virtio_pci); }
tests/Makefile +3 -1
@@ -521,7 +521,8 @@ tests/hd-geo-test$(EXESUF): tests/hd-geo-test.o tests/boot-order-test$(EXESUF): tests/boot-order-test.o $(libqos-obj-y) tests/bios-tables-test$(EXESUF): tests/bios-tables-test.o \ tests/boot-sector.o $(libqos-obj-y) -tests/pxe-test$(EXESUF): tests/pxe-test.o tests/boot-sector.o $(libqos-obj-y) +tests/pxe-test$(EXESUF): tests/pxe-test.o tests/boot-sector.o \ + tests/vhost-user-bridge$(EXESUF) $(libqos-obj-y) tests/tmp105-test$(EXESUF): tests/tmp105-test.o $(libqos-omap-obj-y) tests/ds1338-test$(EXESUF): tests/ds1338-test.o $(libqos-imx-obj-y) tests/i440fx-test$(EXESUF): tests/i440fx-test.o $(libqos-pc-obj-y)
@@ -620,6 +621,7 @@ $(patsubst %, check-qtest-%, $(QTEST_TARGETS)): check-qtest-%: $(check-qtest-y) $(if $(CONFIG_GCOV),@rm -f *.gcda */*.gcda */*/*.gcda */*/*/*.gcda,) $(call quiet-command,QTEST_QEMU_BINARY=$*-softmmu/qemu-system-$* \ QTEST_QEMU_IMG=qemu-img$(EXESUF) \ + QTEST_VUBR_BINARY=./tests/vhost-user-bridge$(EXESUF) \ MALLOC_PERTURB_=$${MALLOC_PERTURB_:-$$((RANDOM % 255 + 1))} \ gtester $(GTESTER_OPTIONS) -m=$(SPEED) $(check-qtest-$*-y) $(check-qtest-generic-y),"GTESTER $@") $(if $(CONFIG_GCOV),@for f in $(gcov-files-$*-y) $(gcov-files-generic-y); do \
Signature · 1 line
Victor
Quoted 11 lines · Victor Kaplansky
Add one more testcase to pxe-test for checking vhost-user interface. The test is based on spawning vhost-user-bridge process in addition to qemu under test.
Suggested-by Michael S. Tsirkin <[email protected]>Signed-off-by Victor Kaplansky <[email protected]>---
The patch is a quick and dirty, but working implementation of Michal's idea. It is based on latest vhost-user-bridge test and latest change in rules: "[PATCH] rules: filter out irrelevant files".
you asked how to fix warning about no nics being there. I think that maybe we should just drop this warning. It's bogus in case of a hotplug, anyway.
Or, check qtest_enabled and print if not there only.
Quoted 19 lines
tests/pxe-test.c | 39 +++++++++++++++++++++++++++++++++++++++ tests/Makefile | 4 +++- 2 files changed, 42 insertions(+), 1 deletion(-)tests/pxe-test.c +6
-0@@ -48,6 +48,44 @@ static void test_pxe_virtio_pci(void)test_pxe_one ("-device virtio-net-pci,netdev=" NETNAME ); } +static void test_pxe_vhost_user (void ) +{ +pid_t pid; +int status; + + pid =fork ();
tests/pxe-test.c static void test_pxe_virtio_pci(void) · line 66
Quoted 10 lines
tests/pxe-test.c +10
-0+if (!pid) { +char *vubr_binary; +char *args; + + vubr_binary =getenv ("QTEST_VUBR_BINARY" ); +assert (vubr_binary); + + args = + g_strdup_printf("%s -u /tmp/vubr.sock -l 127.0.0.1:4444 " + "-r 127.0.0.1:5555 1> /dev/null 2>&1",
Don't hard-code port numbers. open sockets and pass their FDs around.
tests/pxe-test.c static void test_pxe_virtio_pci(void) · line 67
Quoted 1 line
tests/pxe-test.c +1
-0+ vubr_binary);
Pls don't use /tmp like this, this is a security problem. Pls use g_file_open_tmp, mkdtemp or some such. See tests/vhost-user-test.c as one example.
tests/pxe-test.c static void test_pxe_virtio_pci(void) · line 76
Quoted 9 lines
tests/pxe-test.c +9
-0+system (args); +free (args); +exit (0 ); + } + +g_usleep (1 *G_USEC_PER_SEC ); +qtest_start ( +"-enable-kvm " + "-m 1024 "
1G for a pxe test? seems way too much.
tests/pxe-test.c static void test_pxe_virtio_pci(void) · line 77
Quoted 1 line
tests/pxe-test.c +1
-0+"-object memory-backend-file,id=mem,size=1024M,mem-path=/tmp/hugepages,share=on "
again, look at vhost-user test for a clean way to do this.
Quoted 46 lines
tests/pxe-test.c +12
-0+"-numa node,memdev=mem -mem-prealloc " +"-device virtio-net-pci,netdev=net0 " +"-chardev socket,id=char0,path=/tmp/vubr.sock " +"-netdev type=vhost-user,id=net0,chardev=char0,vhostforce " +"-net user,vlan=5,tftp=./,bootfile=tests/pxe-test-disk.raw " + "-net socket,vlan=5,udp=localhost:4444,localaddr=localhost:5555 "); +boot_sector_test (); +qtest_quit (global_qtest); +waitpid (pid, &status,0 ); +} +int main (int argc,char *argv[]) {int ret;@@ -60,6 +98,7 @@ int main(int argc, char *argv[])g_test_init (&argc, &argv,NULL );if (strcmp (arch,"i386" ) ==0 ||strcmp (arch,"x86_64" ) ==0 ) { +qtest_add_func ("pxe/vhost-user" , test_pxe_vhost_user);qtest_add_func ("pxe/e1000" , test_pxe_e1000);qtest_add_func ("pxe/virtio" , test_pxe_virtio_pci); }tests/Makefile +3
-1@@ -521,7 +521,8 @@ tests/hd-geo-test$(EXESUF): tests/hd-geo-test.o tests/boot-order-test$(EXESUF): tests/boot-order-test.o $(libqos-obj-y) tests/bios-tables-test$(EXESUF): tests/bios-tables-test.o \ tests/boot-sector.o $(libqos-obj-y) -tests/pxe-test$(EXESUF): tests/pxe-test.o tests/boot-sector.o $(libqos-obj-y) +tests/pxe-test$(EXESUF): tests/pxe-test.o tests/boot-sector.o \ + tests/vhost-user-bridge$(EXESUF) $(libqos-obj-y) tests/tmp105-test$(EXESUF): tests/tmp105-test.o $(libqos-omap-obj-y) tests/ds1338-test$(EXESUF): tests/ds1338-test.o $(libqos-imx-obj-y) tests/i440fx-test$(EXESUF): tests/i440fx-test.o $(libqos-pc-obj-y)@@ -620,6 +621,7 @@ $(patsubst %, check-qtest-%, $(QTEST_TARGETS)): check-qtest-%: $(check-qtest-y) $(if $(CONFIG_GCOV),@rm -f *.gcda */*.gcda */*/*.gcda */*/*/*.gcda,) $(call quiet-command,QTEST_QEMU_BINARY=$*-softmmu/qemu-system-$* \ QTEST_QEMU_IMG=qemu-img$(EXESUF) \ + QTEST_VUBR_BINARY=./tests/vhost-user-bridge$(EXESUF) \ MALLOC_PERTURB_=$${MALLOC_PERTURB_:-$$((RANDOM % 255 + 1))} \ gtester $(GTESTER_OPTIONS) -m=$(SPEED) $(check-qtest-$*-y) $(check-qtest-generic-y),"GTESTER $@") $(if $(CONFIG_GCOV),@for f in $(gcov-files-$*-y) $(gcov-files-generic-y); do \Signature · 1 line
Victor