* [Qemu-devel] [v3 0/2] tests/pxe-test: add testcase using vhost-user-bridge
@ 2017-10-26 12:44 Jens Freimann
2017-10-26 12:44 ` [Qemu-devel] [v3 1/2] tests/vhost-user-bridge: disable debug output by default Jens Freimann
2017-10-26 12:44 ` [Qemu-devel] [v3 2/2] tests/pxe-test: add testcase using vhost-user-bridge Jens Freimann
0 siblings, 2 replies; 5+ messages in thread
From: Jens Freimann @ 2017-10-26 12:44 UTC (permalink / raw)
To: qemu-devel; +Cc: mst, victork, maxime.coquelin, jasowang, stefanha
This implements a testcase for pxe-test using the vhost-user interface. Spawn a
vhost-user-bridge process and connect it to the qemu process
v2->v3:
* rebase to current master
* run test with slow test cases, as it takes a bit of time
Jens Freimann (2):
tests/vhost-user-bridge: disable debug output by default
tests/pxe-test: add testcase using vhost-user-bridge
tests/Makefile.include | 4 +-
tests/pxe-test.c | 111 ++++++++++++++++++++++++++++++++++++++++++++++
tests/vhost-user-bridge.c | 2 +-
3 files changed, 115 insertions(+), 2 deletions(-)
--
2.13.6
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Qemu-devel] [v3 1/2] tests/vhost-user-bridge: disable debug output by default
2017-10-26 12:44 [Qemu-devel] [v3 0/2] tests/pxe-test: add testcase using vhost-user-bridge Jens Freimann
@ 2017-10-26 12:44 ` Jens Freimann
2017-10-26 12:44 ` [Qemu-devel] [v3 2/2] tests/pxe-test: add testcase using vhost-user-bridge Jens Freimann
1 sibling, 0 replies; 5+ messages in thread
From: Jens Freimann @ 2017-10-26 12:44 UTC (permalink / raw)
To: qemu-devel; +Cc: mst, victork, maxime.coquelin, jasowang, stefanha
From: Jens Freimann <jfreiman@redhat.com>
vhost-user-bridge prints out a lot of information, including dumps
of all transmitted data. When called from a testcase this output
clutters the actual test results, so let's make the default no debug
output.
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Signed-off-by: Jens Freimann <jfreiman@redhat.com>
---
tests/vhost-user-bridge.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/vhost-user-bridge.c b/tests/vhost-user-bridge.c
index d820033a72..4b18e84b42 100644
--- a/tests/vhost-user-bridge.c
+++ b/tests/vhost-user-bridge.c
@@ -34,7 +34,7 @@
#include "standard-headers/linux/virtio_net.h"
#include "contrib/libvhost-user/libvhost-user.h"
-#define VHOST_USER_BRIDGE_DEBUG 1
+#define VHOST_USER_BRIDGE_DEBUG 0
#define DPRINT(...) \
do { \
--
2.13.6
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [v3 2/2] tests/pxe-test: add testcase using vhost-user-bridge
2017-10-26 12:44 [Qemu-devel] [v3 0/2] tests/pxe-test: add testcase using vhost-user-bridge Jens Freimann
2017-10-26 12:44 ` [Qemu-devel] [v3 1/2] tests/vhost-user-bridge: disable debug output by default Jens Freimann
@ 2017-10-26 12:44 ` Jens Freimann
2017-10-26 14:53 ` Michael S. Tsirkin
1 sibling, 1 reply; 5+ messages in thread
From: Jens Freimann @ 2017-10-26 12:44 UTC (permalink / raw)
To: qemu-devel; +Cc: mst, victork, maxime.coquelin, jasowang, stefanha
From: Jens Freimann <jfreiman@redhat.com>
Add a PXE testcase tunneling traffic through vhost-user-bridge process.
Create a vhost-user-bridge process and connect it to qemu via a socket.
Signed-off-by: Jens Freimann <jfreimann@redhat.com>
---
tests/Makefile.include | 4 +-
tests/pxe-test.c | 111 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 114 insertions(+), 1 deletion(-)
diff --git a/tests/Makefile.include b/tests/Makefile.include
index 70dc711bca..6cdb783753 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -740,7 +740,8 @@ tests/boot-order-test$(EXESUF): tests/boot-order-test.o $(libqos-obj-y)
tests/boot-serial-test$(EXESUF): tests/boot-serial-test.o $(libqos-obj-y)
tests/bios-tables-test$(EXESUF): tests/bios-tables-test.o \
tests/boot-sector.o tests/acpi-utils.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/m25p80-test$(EXESUF): tests/m25p80-test.o
@@ -849,6 +850,7 @@ $(patsubst %, check-qtest-%, $(QTEST_TARGETS)): check-qtest-%: subdir-%-softmmu
$(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:-0} % 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 \
diff --git a/tests/pxe-test.c b/tests/pxe-test.c
index 937f29e631..d2646ee86d 100644
--- a/tests/pxe-test.c
+++ b/tests/pxe-test.c
@@ -7,6 +7,7 @@
* Michael S. Tsirkin <mst@redhat.com>,
* Victor Kaplansky <victork@redhat.com>
* Thomas Huth <thuth@redhat.com>
+ * Jens Freimann <jfreiman@redhat.com>
*
* This work is licensed under the terms of the GNU GPL, version 2 or later.
* See the COPYING file in the top-level directory.
@@ -14,14 +15,123 @@
#include "qemu/osdep.h"
#include <glib/gstdio.h>
+#include <glib.h>
#include "qemu-common.h"
#include "libqtest.h"
#include "boot-sector.h"
+#define LPORT 5555
+#define RPORT 4444
#define NETNAME "net0"
+#define QEMU_CMD_MEM "--enable-kvm -m %d "\
+ "-object memory-backend-file,id=mem,size=%dM,"\
+ "mem-path=%s,share=on -numa node,memdev=mem -mem-prealloc "
+#define QEMU_CMD_CHR " -chardev socket,id=%s,path=%s"
+#define QEMU_CMD_NETDEV " -device virtio-net-pci,netdev=net0 "\
+ " -netdev vhost-user,id=net0,chardev=%s,vhostforce "\
+ " -netdev user,id=n0,tftp=./,bootfile=%s "\
+ " -netdev socket,id=n1,fd=%d"
+#define QEMU_CMD_NET " -device virtio-net-pci,netdev=n0 "\
+ " -device virtio-net-pci,netdev=n1 "
+
+#define QEMU_CMD QEMU_CMD_MEM QEMU_CMD_CHR \
+ QEMU_CMD_NETDEV QEMU_CMD_NET
+
+#define VUBR_SOCK "vubr.sock"
+#define MEMSZ 1024
static char disk[] = "tests/pxe-test-disk-XXXXXX";
+static int vubr_create_socket(struct sockaddr_in *si_remote, int rport)
+{
+ int sock;
+
+ si_remote->sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+ sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+ if (sock == -1) {
+ g_test_message("socket creation failed\n");
+ return -1;
+ }
+ if (connect(sock, (struct sockaddr *) si_remote, sizeof(*si_remote))) {
+ g_test_message("connect failed: %s", strerror(errno));
+ return -1;
+ }
+
+ return sock;
+}
+
+static void vubr_watch(GPid pid, gint status, gpointer data)
+{
+ g_assert_cmpint(status, ==, 0);
+ g_spawn_close_pid(pid);
+}
+
+static void abrt_handler(void *data)
+{
+ int *pid = data;
+
+ g_spawn_close_pid(*pid);
+ kill(*pid, SIGTERM);
+ waitpid(*pid, NULL, 0);
+}
+
+static void test_pxe_vhost_user(void)
+{
+ char template[] = "/tmp/vhost-user-bridge-XXXXXX";
+ gchar * vubr_args[] = {NULL, NULL, NULL, NULL};
+ struct sockaddr_in si_remote = {
+ .sin_family = AF_INET,
+ .sin_port = htons(RPORT),
+ };
+ const char *hugefs = NULL;
+ const char *tmpfs = NULL;
+ GError *error = NULL;
+ char *vubr_binary;
+ char *qemu_args;
+ GPid vubr_pid;
+ int sock = -1;
+
+ qtest_add_abrt_handler(abrt_handler, &vubr_pid);
+ tmpfs = mkdtemp(template);
+ if (!tmpfs) {
+ g_test_message("mkdtemp on path(%s): %s\n",
+ template, strerror(errno));
+ }
+ vubr_binary = getenv("QTEST_VUBR_BINARY");
+ g_assert(vubr_binary);
+ vubr_args[0] = g_strdup_printf("%s", vubr_binary);
+ vubr_args[1] = g_strdup_printf("-u");
+ vubr_args[2] = g_strdup_printf("%s/%s", tmpfs, VUBR_SOCK);
+ g_spawn_async(NULL, vubr_args, NULL,
+ G_SPAWN_SEARCH_PATH |
+ G_SPAWN_DO_NOT_REAP_CHILD,
+ NULL, NULL, &vubr_pid, &error);
+ g_assert_no_error(error);
+ g_child_watch_add(vubr_pid, vubr_watch, NULL);
+
+ hugefs = getenv("QTEST_HUGETLBFS_PATH");
+ if (!hugefs) {
+ hugefs = tmpfs;
+ }
+ sock = vubr_create_socket(&si_remote, RPORT);
+ g_assert_cmpint(sock, !=, -1);
+ qemu_args = g_strdup_printf(QEMU_CMD, MEMSZ, MEMSZ, (hugefs),
+ "char0", vubr_args[2], "char0",
+ disk, sock);
+ qtest_start(qemu_args);
+ boot_sector_test();
+ qtest_quit(global_qtest);
+ g_free(qemu_args);
+ g_free(vubr_args[0]);
+ g_free(vubr_args[1]);
+ g_free(vubr_args[2]);
+ g_assert_cmpint(g_remove(g_strdup_printf("%s/%s", tmpfs, VUBR_SOCK)),
+ ==, 0);
+ g_assert_cmpint(g_remove(g_strdup_printf("%s", disk)), ==, 0);
+ g_assert_cmpint(g_rmdir(tmpfs), ==, 0);
+ g_assert_cmpint(kill(vubr_pid, SIGTERM), ==, 0);
+}
+
static void test_pxe_one(const char *params, bool ipv6)
{
char *args;
@@ -77,6 +187,7 @@ int main(int argc, char *argv[])
qtest_add_data_func("pxe/pcnet", "pcnet", test_pxe_ipv4);
qtest_add_data_func("pxe/rtl8139", "rtl8139", test_pxe_ipv4);
qtest_add_data_func("pxe/vmxnet3", "vmxnet3", test_pxe_ipv4);
+ qtest_add_func("pxe/vhost-user", test_pxe_vhost_user);
}
} else if (strcmp(arch, "ppc64") == 0) {
qtest_add_func("pxe/spapr-vlan", test_pxe_spapr_vlan);
--
2.13.6
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [v3 2/2] tests/pxe-test: add testcase using vhost-user-bridge
2017-10-26 12:44 ` [Qemu-devel] [v3 2/2] tests/pxe-test: add testcase using vhost-user-bridge Jens Freimann
@ 2017-10-26 14:53 ` Michael S. Tsirkin
2017-10-27 9:40 ` Jens Freimann
0 siblings, 1 reply; 5+ messages in thread
From: Michael S. Tsirkin @ 2017-10-26 14:53 UTC (permalink / raw)
To: Jens Freimann; +Cc: qemu-devel, victork, maxime.coquelin, jasowang, stefanha
On Thu, Oct 26, 2017 at 02:44:25PM +0200, Jens Freimann wrote:
> From: Jens Freimann <jfreiman@redhat.com>
>
> Add a PXE testcase tunneling traffic through vhost-user-bridge process.
> Create a vhost-user-bridge process and connect it to qemu via a socket.
>
> Signed-off-by: Jens Freimann <jfreimann@redhat.com>
> ---
> tests/Makefile.include | 4 +-
> tests/pxe-test.c | 111 +++++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 114 insertions(+), 1 deletion(-)
>
> diff --git a/tests/Makefile.include b/tests/Makefile.include
> index 70dc711bca..6cdb783753 100644
> --- a/tests/Makefile.include
> +++ b/tests/Makefile.include
> @@ -740,7 +740,8 @@ tests/boot-order-test$(EXESUF): tests/boot-order-test.o $(libqos-obj-y)
> tests/boot-serial-test$(EXESUF): tests/boot-serial-test.o $(libqos-obj-y)
> tests/bios-tables-test$(EXESUF): tests/bios-tables-test.o \
> tests/boot-sector.o tests/acpi-utils.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/m25p80-test$(EXESUF): tests/m25p80-test.o
> @@ -849,6 +850,7 @@ $(patsubst %, check-qtest-%, $(QTEST_TARGETS)): check-qtest-%: subdir-%-softmmu
> $(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:-0} % 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 \
> diff --git a/tests/pxe-test.c b/tests/pxe-test.c
> index 937f29e631..d2646ee86d 100644
> --- a/tests/pxe-test.c
> +++ b/tests/pxe-test.c
> @@ -7,6 +7,7 @@
> * Michael S. Tsirkin <mst@redhat.com>,
> * Victor Kaplansky <victork@redhat.com>
> * Thomas Huth <thuth@redhat.com>
> + * Jens Freimann <jfreiman@redhat.com>
> *
> * This work is licensed under the terms of the GNU GPL, version 2 or later.
> * See the COPYING file in the top-level directory.
> @@ -14,14 +15,123 @@
>
> #include "qemu/osdep.h"
> #include <glib/gstdio.h>
> +#include <glib.h>
> #include "qemu-common.h"
> #include "libqtest.h"
> #include "boot-sector.h"
>
> +#define LPORT 5555
Is this used anywhere?
> +#define RPORT 4444
Using a known port is problematic as you can't run
many instances of the test then. I think you want an option
to bind in the parent.
> #define NETNAME "net0"
> +#define QEMU_CMD_MEM "--enable-kvm -m %d "\
enable-kvm won't work on boxes without kvm.
Pls use same technique as other tests to only use kvm
when available.
> + "-object memory-backend-file,id=mem,size=%dM,"\
> + "mem-path=%s,share=on -numa node,memdev=mem -mem-prealloc "
Do we really need prealloc? And why?
> +#define QEMU_CMD_CHR " -chardev socket,id=%s,path=%s"
> +#define QEMU_CMD_NETDEV " -device virtio-net-pci,netdev=net0 "\
> + " -netdev vhost-user,id=net0,chardev=%s,vhostforce "\
> + " -netdev user,id=n0,tftp=./,bootfile=%s "\
> + " -netdev socket,id=n1,fd=%d"
> +#define QEMU_CMD_NET " -device virtio-net-pci,netdev=n0 "\
> + " -device virtio-net-pci,netdev=n1 "
> +
> +#define QEMU_CMD QEMU_CMD_MEM QEMU_CMD_CHR \
> + QEMU_CMD_NETDEV QEMU_CMD_NET
> +
> +#define VUBR_SOCK "vubr.sock"
> +#define MEMSZ 1024
>
> static char disk[] = "tests/pxe-test-disk-XXXXXX";
>
> +static int vubr_create_socket(struct sockaddr_in *si_remote, int rport)
> +{
> + int sock;
> +
> + si_remote->sin_addr.s_addr = htonl(INADDR_LOOPBACK);
> + sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
> + if (sock == -1) {
> + g_test_message("socket creation failed\n");
> + return -1;
> + }
> + if (connect(sock, (struct sockaddr *) si_remote, sizeof(*si_remote))) {
> + g_test_message("connect failed: %s", strerror(errno));
> + return -1;
> + }
> +
> + return sock;
> +}
> +
> +static void vubr_watch(GPid pid, gint status, gpointer data)
> +{
> + g_assert_cmpint(status, ==, 0);
> + g_spawn_close_pid(pid);
> +}
> +
> +static void abrt_handler(void *data)
> +{
> + int *pid = data;
> +
> + g_spawn_close_pid(*pid);
> + kill(*pid, SIGTERM);
> + waitpid(*pid, NULL, 0);
> +}
> +
> +static void test_pxe_vhost_user(void)
> +{
> + char template[] = "/tmp/vhost-user-bridge-XXXXXX";
> + gchar * vubr_args[] = {NULL, NULL, NULL, NULL};
> + struct sockaddr_in si_remote = {
> + .sin_family = AF_INET,
> + .sin_port = htons(RPORT),
> + };
> + const char *hugefs = NULL;
> + const char *tmpfs = NULL;
> + GError *error = NULL;
> + char *vubr_binary;
> + char *qemu_args;
> + GPid vubr_pid;
> + int sock = -1;
> +
> + qtest_add_abrt_handler(abrt_handler, &vubr_pid);
> + tmpfs = mkdtemp(template);
> + if (!tmpfs) {
> + g_test_message("mkdtemp on path(%s): %s\n",
> + template, strerror(errno));
> + }
defer above until we know it's used (no hugetlbfs?)
> + vubr_binary = getenv("QTEST_VUBR_BINARY");
> + g_assert(vubr_binary);
> + vubr_args[0] = g_strdup_printf("%s", vubr_binary);
> + vubr_args[1] = g_strdup_printf("-u");
> + vubr_args[2] = g_strdup_printf("%s/%s", tmpfs, VUBR_SOCK);
> + g_spawn_async(NULL, vubr_args, NULL,
> + G_SPAWN_SEARCH_PATH |
> + G_SPAWN_DO_NOT_REAP_CHILD,
> + NULL, NULL, &vubr_pid, &error);
> + g_assert_no_error(error);
> + g_child_watch_add(vubr_pid, vubr_watch, NULL);
> +
> + hugefs = getenv("QTEST_HUGETLBFS_PATH");
> + if (!hugefs) {
> + hugefs = tmpfs;
> + }
> + sock = vubr_create_socket(&si_remote, RPORT);
> + g_assert_cmpint(sock, !=, -1);
> + qemu_args = g_strdup_printf(QEMU_CMD, MEMSZ, MEMSZ, (hugefs),
> + "char0", vubr_args[2], "char0",
> + disk, sock);
> + qtest_start(qemu_args);
> + boot_sector_test();
> + qtest_quit(global_qtest);
> + g_free(qemu_args);
> + g_free(vubr_args[0]);
> + g_free(vubr_args[1]);
> + g_free(vubr_args[2]);
> + g_assert_cmpint(g_remove(g_strdup_printf("%s/%s", tmpfs, VUBR_SOCK)),
> + ==, 0);
> + g_assert_cmpint(g_remove(g_strdup_printf("%s", disk)), ==, 0);
> + g_assert_cmpint(g_rmdir(tmpfs), ==, 0);
> + g_assert_cmpint(kill(vubr_pid, SIGTERM), ==, 0);
> +}
> +
> static void test_pxe_one(const char *params, bool ipv6)
> {
> char *args;
> @@ -77,6 +187,7 @@ int main(int argc, char *argv[])
> qtest_add_data_func("pxe/pcnet", "pcnet", test_pxe_ipv4);
> qtest_add_data_func("pxe/rtl8139", "rtl8139", test_pxe_ipv4);
> qtest_add_data_func("pxe/vmxnet3", "vmxnet3", test_pxe_ipv4);
> + qtest_add_func("pxe/vhost-user", test_pxe_vhost_user);
> }
> } else if (strcmp(arch, "ppc64") == 0) {
> qtest_add_func("pxe/spapr-vlan", test_pxe_spapr_vlan);
> --
> 2.13.6
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [v3 2/2] tests/pxe-test: add testcase using vhost-user-bridge
2017-10-26 14:53 ` Michael S. Tsirkin
@ 2017-10-27 9:40 ` Jens Freimann
0 siblings, 0 replies; 5+ messages in thread
From: Jens Freimann @ 2017-10-27 9:40 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: qemu-devel, victork, maxime.coquelin, jasowang, stefanha
On Thu, Oct 26, 2017 at 02:53:12PM +0000, Michael S. Tsirkin wrote:
>On Thu, Oct 26, 2017 at 02:44:25PM +0200, Jens Freimann wrote:
>> From: Jens Freimann <jfreiman@redhat.com>
>>
>> Add a PXE testcase tunneling traffic through vhost-user-bridge process.
>> Create a vhost-user-bridge process and connect it to qemu via a socket.
>>
>> Signed-off-by: Jens Freimann <jfreimann@redhat.com>
>> ---
>> tests/Makefile.include | 4 +-
>> tests/pxe-test.c | 111 +++++++++++++++++++++++++++++++++++++++++++++++++
>> 2 files changed, 114 insertions(+), 1 deletion(-)
>>
>> diff --git a/tests/Makefile.include b/tests/Makefile.include
>> index 70dc711bca..6cdb783753 100644
>> --- a/tests/Makefile.include
>> +++ b/tests/Makefile.include
>> @@ -740,7 +740,8 @@ tests/boot-order-test$(EXESUF): tests/boot-order-test.o $(libqos-obj-y)
>> tests/boot-serial-test$(EXESUF): tests/boot-serial-test.o $(libqos-obj-y)
>> tests/bios-tables-test$(EXESUF): tests/bios-tables-test.o \
>> tests/boot-sector.o tests/acpi-utils.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/m25p80-test$(EXESUF): tests/m25p80-test.o
>> @@ -849,6 +850,7 @@ $(patsubst %, check-qtest-%, $(QTEST_TARGETS)): check-qtest-%: subdir-%-softmmu
>> $(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:-0} % 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 \
>> diff --git a/tests/pxe-test.c b/tests/pxe-test.c
>> index 937f29e631..d2646ee86d 100644
>> --- a/tests/pxe-test.c
>> +++ b/tests/pxe-test.c
>> @@ -7,6 +7,7 @@
>> * Michael S. Tsirkin <mst@redhat.com>,
>> * Victor Kaplansky <victork@redhat.com>
>> * Thomas Huth <thuth@redhat.com>
>> + * Jens Freimann <jfreiman@redhat.com>
>> *
>> * This work is licensed under the terms of the GNU GPL, version 2 or later.
>> * See the COPYING file in the top-level directory.
>> @@ -14,14 +15,123 @@
>>
>> #include "qemu/osdep.h"
>> #include <glib/gstdio.h>
>> +#include <glib.h>
>> #include "qemu-common.h"
>> #include "libqtest.h"
>> #include "boot-sector.h"
>>
>> +#define LPORT 5555
>
>Is this used anywhere?
>
>> +#define RPORT 4444
>
>Using a known port is problematic as you can't run
>many instances of the test then. I think you want an option
>to bind in the parent.
ok
>> #define NETNAME "net0"
>> +#define QEMU_CMD_MEM "--enable-kvm -m %d "\
>
>enable-kvm won't work on boxes without kvm.
>Pls use same technique as other tests to only use kvm
>when available.
ok
>> + "-object memory-backend-file,id=mem,size=%dM,"\
>> + "mem-path=%s,share=on -numa node,memdev=mem -mem-prealloc "
>
>Do we really need prealloc? And why?
We don't need it, I'll remove it.
>> +#define QEMU_CMD_CHR " -chardev socket,id=%s,path=%s"
>> +#define QEMU_CMD_NETDEV " -device virtio-net-pci,netdev=net0 "\
>> + " -netdev vhost-user,id=net0,chardev=%s,vhostforce "\
>> + " -netdev user,id=n0,tftp=./,bootfile=%s "\
>> + " -netdev socket,id=n1,fd=%d"
>> +#define QEMU_CMD_NET " -device virtio-net-pci,netdev=n0 "\
>> + " -device virtio-net-pci,netdev=n1 "
>> +
>> +#define QEMU_CMD QEMU_CMD_MEM QEMU_CMD_CHR \
>> + QEMU_CMD_NETDEV QEMU_CMD_NET
>> +
>> +#define VUBR_SOCK "vubr.sock"
>> +#define MEMSZ 1024
>>
>> static char disk[] = "tests/pxe-test-disk-XXXXXX";
>>
>> +static int vubr_create_socket(struct sockaddr_in *si_remote, int rport)
>> +{
>> + int sock;
>> +
>> + si_remote->sin_addr.s_addr = htonl(INADDR_LOOPBACK);
>> + sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
>> + if (sock == -1) {
>> + g_test_message("socket creation failed\n");
>> + return -1;
>> + }
>> + if (connect(sock, (struct sockaddr *) si_remote, sizeof(*si_remote))) {
>> + g_test_message("connect failed: %s", strerror(errno));
>> + return -1;
>> + }
>> +
>> + return sock;
>> +}
>> +
>> +static void vubr_watch(GPid pid, gint status, gpointer data)
>> +{
>> + g_assert_cmpint(status, ==, 0);
>> + g_spawn_close_pid(pid);
>> +}
>> +
>> +static void abrt_handler(void *data)
>> +{
>> + int *pid = data;
>> +
>> + g_spawn_close_pid(*pid);
>> + kill(*pid, SIGTERM);
>> + waitpid(*pid, NULL, 0);
>> +}
>> +
>> +static void test_pxe_vhost_user(void)
>> +{
>> + char template[] = "/tmp/vhost-user-bridge-XXXXXX";
>> + gchar * vubr_args[] = {NULL, NULL, NULL, NULL};
>> + struct sockaddr_in si_remote = {
>> + .sin_family = AF_INET,
>> + .sin_port = htons(RPORT),
>> + };
>> + const char *hugefs = NULL;
>> + const char *tmpfs = NULL;
>> + GError *error = NULL;
>> + char *vubr_binary;
>> + char *qemu_args;
>> + GPid vubr_pid;
>> + int sock = -1;
>> +
>> + qtest_add_abrt_handler(abrt_handler, &vubr_pid);
>> + tmpfs = mkdtemp(template);
>> + if (!tmpfs) {
>> + g_test_message("mkdtemp on path(%s): %s\n",
>> + template, strerror(errno));
>> + }
>
>defer above until we know it's used (no hugetlbfs?)
yes, will do. Thanks for the review!
regards,
Jens
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-10-27 9:41 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-26 12:44 [Qemu-devel] [v3 0/2] tests/pxe-test: add testcase using vhost-user-bridge Jens Freimann
2017-10-26 12:44 ` [Qemu-devel] [v3 1/2] tests/vhost-user-bridge: disable debug output by default Jens Freimann
2017-10-26 12:44 ` [Qemu-devel] [v3 2/2] tests/pxe-test: add testcase using vhost-user-bridge Jens Freimann
2017-10-26 14:53 ` Michael S. Tsirkin
2017-10-27 9:40 ` Jens Freimann
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.