Received: from eggs.gnu.org ([2001:4830:134:3::10]:48599) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZxHw-0001li-OJ for qemu-devel@nongnu.org; Thu, 10 Sep 2015 04:33:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZxHt-0006GJ-FI for qemu-devel@nongnu.org; Thu, 10 Sep 2015 04:33:00 -0400 Received: from smtpbg62.qq.com ([103.7.29.139]:24128 helo=smtpbg64.qq.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZxHs-0006FS-Rt for qemu-devel@nongnu.org; Thu, 10 Sep 2015 04:32:57 -0400 Sender: gang.chen.5i5j@qq.com From: gang.chen.5i5j@gmail.com Date: Thu, 10 Sep 2015 16:32:39 +0800 Message-Id: <1441873959-4895-1-git-send-email-gang.chen.5i5j@gmail.com> Subject: [Qemu-devel] [PATCH v3] linux-user/main.c: Set environments variables from command line options List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: riku.voipio@iki.fi Cc: peter.maydell@linaro.org, Chen Gang , qemu-devel@nongnu.org, xili_gchen_5257@hotmail.com, rth@twiddle.net From: Chen Gang When qemu execute execve() system call, the related command line options can not be passed to the second qemu process, which causes the second process fail. Signed-off-by: Chen Gang --- linux-user/main.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/linux-user/main.c b/linux-user/main.c index 06dd296..dfbccbe 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -3767,6 +3767,7 @@ static void usage(void) static int parse_args(int argc, char **argv) { const char *r; + char *buf; int optind; const struct qemu_argument *arginfo; @@ -3802,11 +3803,15 @@ static int parse_args(int argc, char **argv) if (optind >= argc) { usage(); } + buf = g_strdup_printf("%s=%s", arginfo->env, argv[optind]); arginfo->handle_opt(argv[optind]); optind++; } else { + buf = g_strdup_printf("%s=", arginfo->env); arginfo->handle_opt(NULL); } + (void) envlist_setenv(envlist, buf); + g_free(buf); break; } } -- 1.9.1