[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 02 of 13 RFC] libxl: allow libxl__exec to take a parameter containing the env variables
# HG changeset patch # User Roger Pau Monne <roger.pau@xxxxxxxxxxxxx> # Date 1324934702 -3600 # Node ID b9a79fd1b93d44cf7b9ccf288c9f5df169adeb4d # Parent 25752ced44427caec863c3e64185429c39b28c3a libxl: allow libxl__exec to take a parameter containing the env variables Add another parameter to libxl__exec call that contains the environment variables to use when performing the execvp call. Signed-off-by: Roger Pau Monne <roger.pau@xxxxxxxxxxxxx> diff -r 25752ced4442 -r b9a79fd1b93d tools/libxl/libxl.c --- a/tools/libxl/libxl.c Fri Sep 30 14:38:55 2011 +0200 +++ b/tools/libxl/libxl.c Mon Dec 26 22:25:02 2011 +0100 @@ -951,7 +951,7 @@ int libxl_vncviewer_exec(libxl_ctx *ctx, args[2] = "-autopass"; } - libxl__exec(autopass_fd, -1, -1, args[0], args); + libxl__exec(autopass_fd, -1, -1, args[0], args, NULL); abort(); x_fail: diff -r 25752ced4442 -r b9a79fd1b93d tools/libxl/libxl_bootloader.c --- a/tools/libxl/libxl_bootloader.c Fri Sep 30 14:38:55 2011 +0200 +++ b/tools/libxl/libxl_bootloader.c Mon Dec 26 22:25:02 2011 +0100 @@ -116,12 +116,12 @@ static int open_xenconsoled_pty(int *mas static pid_t fork_exec_bootloader(int *master, const char *arg0, char **args) { struct termios termattr; + char *env[] = {"TERM", "vt100", NULL}; pid_t pid = forkpty(master, NULL, NULL, NULL); if (pid == -1) return -1; else if (pid == 0) { - setenv("TERM", "vt100", 1); - libxl__exec(-1, -1, -1, arg0, args); + libxl__exec(-1, -1, -1, arg0, args, env); return -1; } diff -r 25752ced4442 -r b9a79fd1b93d tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Fri Sep 30 14:38:55 2011 +0200 +++ b/tools/libxl/libxl_dm.c Mon Dec 26 22:25:02 2011 +0100 @@ -884,7 +884,7 @@ retry_transaction: goto out_close; if (!rc) { /* inner child */ setsid(); - libxl__exec(null, logfile_w, logfile_w, dm, args); + libxl__exec(null, logfile_w, logfile_w, dm, args, NULL); } rc = 0; diff -r 25752ced4442 -r b9a79fd1b93d tools/libxl/libxl_exec.c --- a/tools/libxl/libxl_exec.c Fri Sep 30 14:38:55 2011 +0200 +++ b/tools/libxl/libxl_exec.c Mon Dec 26 22:25:02 2011 +0100 @@ -83,7 +83,7 @@ static void check_open_fds(const char *w } void libxl__exec(int stdinfd, int stdoutfd, int stderrfd, const char *arg0, - char **args) + char **args, char **env) /* call this in the child */ { if (stdinfd != -1) @@ -106,6 +106,11 @@ void libxl__exec(int stdinfd, int stdout /* in case our caller set it to IGN. subprocesses are entitled * to assume they got DFL. */ + if (env != NULL) { + for (int i = 0; env[i] != NULL && env[i+1] != NULL; i += 2) { + setenv(env[i], env[i+1], 1); + } + } execvp(arg0, args); fprintf(stderr, "libxl: cannot execute %s: %s\n", arg0, strerror(errno)); diff -r 25752ced4442 -r b9a79fd1b93d tools/libxl/libxl_internal.h --- a/tools/libxl/libxl_internal.h Fri Sep 30 14:38:55 2011 +0200 +++ b/tools/libxl/libxl_internal.h Mon Dec 26 22:25:02 2011 +0100 @@ -451,7 +451,7 @@ _hidden int libxl__spawn_check(libxl__gc /* low-level stuff, for synchronous subprocesses etc. */ _hidden void libxl__exec(int stdinfd, int stdoutfd, int stderrfd, - const char *arg0, char **args); // logs errors, never returns + const char *arg0, char **args, char **env); // logs errors, never returns /* from xl_create */ _hidden int libxl__domain_make(libxl__gc *gc, libxl_domain_create_info *info, uint32_t *domid); _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |