diff mbox

[v3] linux-user/main.c: Set environments variables from command line options

Message ID 1441873959-4895-1-git-send-email-gang.chen.5i5j@gmail.com
State New
Headers show

Commit Message

Chen Gang Sept. 10, 2015, 8:32 a.m. UTC
From: Chen Gang <gang.chen.5i5j@gmail.com>

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 <gang.chen.5i5j@gmail.com>
---
 linux-user/main.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox

Patch

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;
             }
         }