Skip to contentSkip to conversation

minor fixes for guest-exec

PATCH Applied Denis V. Lunev 2 participants 4 messages Nov 12, 2015 – Nov 13, 2015

lore
Share & tools
lore
#2 lore raw

PATCH 2/2 qga: allow to lookup in PATH from the passed envp for guest-exec

From: Yuri Pudgorodskiy <[email protected]>

This was original behaviour before GLIB gspawn() rework and we rely on this behaviour.

---
 qga/commands.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
qga/commands.c +2 -1
index 7644ca0..559f18f 100644
@@ -400,7 +400,8 @@ GuestExec *qmp_guest_exec(const char *path,
     argv = guest_exec_get_args(&arglist, true);
     envp = has_env ? guest_exec_get_args(env, false) : NULL;
 
-    flags = G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD;
+    flags = G_SPAWN_SEARCH_PATH | G_SPAWN_SEARCH_PATH_FROM_ENVP |
+        G_SPAWN_DO_NOT_REAP_CHILD;
     if (!has_output) {
         flags |= G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL;
     }
Signature · 1 line
2.1.4
#1 lore raw

PATCH 1/2 qga: fix for default env processing for guest-exec

In reply to Denis V. Lunev

From: Yuri Pudgorodskiy <[email protected]>

envp == NULL must be passed inside gspawn() if it was not passed with the command line. Original code inherits environment from the QGA, which is wrong.

---
 qga/commands.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
qga/commands.c +1 -1
index 0f80ce6..7644ca0 100644
@@ -398,7 +398,7 @@ GuestExec *qmp_guest_exec(const char *path,
     arglist.next = has_arg ? arg : NULL;
 
     argv = guest_exec_get_args(&arglist, true);
-    envp = guest_exec_get_args(has_env ? env : NULL, false);
+    envp = has_env ? guest_exec_get_args(env, false) : NULL;
 
     flags = G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD;
     if (!has_output) {
Signature · 1 line
2.1.4
Applied
#3 lore raw
In reply to Denis V. Lunev

Quoting Denis V. Lunev (2015-11-12 07:36:19)

Quoted 7 lines

Yuri Pudgorodskiy (2):
[qga] Bugfix of default env processing for guest-exec. [qga] Enable lookup for the PATH from the passed envp for guest-exec.

Thanks, applied to qga tree and pull sent for 2.5:

https://github.com/mdroth/qemu/commits/qga

Confirmed on posix/w32 that we now properly inherit parent path by default, but don't use it if they're defined via user-specified env param.

Quoted 4 lines

qga/commands.c | 5 +++--

  1 file changed, 3 insertions(+), 2 deletions(-)