From f6e8648c7a5d4c38d8b7c32b1ab07316ae307701 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Tue, 20 Sep 2016 00:32:48 +0200 Subject: [PATCH] add option to open an additional port for the application with the environment variable HERMIT_APP_PORT an additional port can be open for the application --- hermit/tools/proxy.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/hermit/tools/proxy.c b/hermit/tools/proxy.c index e77cb491d..9c4de1c10 100644 --- a/hermit/tools/proxy.c +++ b/hermit/tools/proxy.c @@ -220,8 +220,9 @@ static int init_qemu(char *path) char hostfwd[MAX_PATH]; char monitor_str[MAX_PATH]; char chardev_file[MAX_PATH]; + char port_str[MAX_PATH]; char* qemu_str = "qemu-system-x86_64"; - char* qemu_argv[] = {qemu_str, "-nographic", "-smp", "1", "-m", "2G", "-net", "nic,model=rtl8139", "-net", hostfwd, "-chardev", chardev_file, "-device", "pci-serial,chardev=gnc0", "-monitor", monitor_str, "-kernel", loader_path, "-initrd", path, "-s", NULL, NULL, NULL, NULL, NULL, NULL, NULL}; + char* qemu_argv[] = {qemu_str, "-nographic", "-smp", "1", "-m", "2G", "-net", "nic,model=rtl8139", "-net", hostfwd, "-chardev", chardev_file, "-device", "pci-serial,chardev=gnc0", "-monitor", monitor_str, "-kernel", loader_path, "-initrd", path, "-s", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; str = getenv("HERMIT_CPUS"); if (str) @@ -245,6 +246,22 @@ static int init_qemu(char *path) str = strstr(loader_path, "proxy"); strncpy(str, "../arch/x86/loader/ldhermit.elf", MAX_PATH-strlen(loader_path)+5); + str = getenv("HERMIT_APP_PORT"); + if (str) + { + int app_port = atoi(str); + + if (app_port > 0) { + for(i=0; qemu_argv[i] != NULL; i++) + ; + + snprintf(port_str, MAX_PATH, "tcp:%u::%u", app_port, app_port); + + qemu_argv[i] = "-redir"; + qemu_argv[i+1] = port_str; + } + } + str = getenv("HERMIT_KVM"); if (str && (strcmp(str, "0") == 0)) kvm = 0;