Skip to contentSkip to conversation

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

PATCH New [email protected] 1 participant 1 message Sep 10, 2015

lore
Share & tools
lore
#0 lore raw

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

From: Chen Gang <[email protected]>

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.

---
 linux-user/main.c | 5 +++++
 1 file changed, 5 insertions(+)
linux-user/main.c +5 -0
index 06dd296..dfbccbe 100644
@@ -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;
             }
         }
Signature · 1 line
1.9.1