Skip to contentSkip to conversation

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

PATCH Superseded [email protected] 2 participants 2 messages Sep 10, 2015

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 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 | 4 ++++
 1 file changed, 4 insertions(+)
linux-user/main.c +4 -0
index 06dd296..f1f5496 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,6 +3803,9 @@ static int parse_args(int argc, char **argv)
                     if (optind >= argc) {
                         usage();
                     }
+                    buf = g_strdup_printf("%s=%s", arginfo->env, argv[optind]);
+                    (void) envlist_setenv(envlist, buf);
+                    g_free(buf);
                     arginfo->handle_opt(argv[optind]);
                     optind++;
                 } else {
Signature · 1 line
1.9.1
#1 lore raw

Oh, very sorry! The patch v2 did not process simple options (e.g. -strace).

I should send patch v3 for it.

Thanks.

----------------------------------------

Quoted 43 lines

From: [email protected]
To: [email protected]
CC: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v2] linux-user/main.c: Set environments variables from command line options
Date: Thu, 10 Sep 2015 16:10:22 +0800

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 | 4 ++++

1 file changed, 4 insertions(+)
linux-user/main.c +4 -1
index 06dd296..f1f5496 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,6 +3803,9 @@ static int parse_args(int argc, char **argv)
 if (optind>= argc) {
 usage();
 }
+ buf = g_strdup_printf("%s=%s", arginfo->env, argv[optind]);
+ (void) envlist_setenv(envlist, buf);
+ g_free(buf);
 arginfo->handle_opt(argv[optind]);
 optind++;
 } else {
--

1.9.1