[Devel] [PATCH] vzctl enter: Forward error messages from child process

Dmitry V. Levin ldv at altlinux.org
Thu Aug 24 15:39:16 PDT 2006


vzctl: do_enter():
	- In child, redirect stdout and stderr to pipe.
	- In parent, read child's output from pipe even if enter failed.
Signed-off-by: Dmitry V. Levin <ldv at altlinux.org>
---

I need to obtain more information about vzctl enter failure.
For example, if dev/ptmx is not available inside container, vzctl enter
just fails with short "enter failed" message.
This patch forwards error messages issued by child process, e.g.
# vzctl enter 1234
enter into VPS 1234 failed
Unable to open pty: No such file or directory


 src/enter.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/src/enter.c b/src/enter.c
index 69cdd02..e0013df 100644
--- a/src/enter.c
+++ b/src/enter.c
@@ -231,6 +231,8 @@ int do_enter(vps_handler *h, envid_t vei
 		close(in[1]); close(out[0]); close(st[0]);
 		/* list of skipped fds -1 the end mark */
 		close_fds(1, in[0], out[1], st[1], h->vzfd, -1);
+		dup2(out[1], 1);
+		dup2(out[1], 2);
 		if ((ret = vz_chroot(root)))
 			goto err;
 		ret = vz_env_create_ioctl(h, veid, VE_ENTER);
@@ -297,7 +299,10 @@ err:
 		raw_on();
 		e_loop(fileno(stdin), in[1], out[0], fileno(stdout));
 	} else {
-		fprintf(stdout, "enter failed\n");
+		fprintf(stdout, "enter into VPS %d failed\n", veid);
+		set_not_blk(out[0]);
+		while (stdredir(out[0], fileno(stdout)) == 0)
+			;
 	}
 	while ((waitpid(pid, &status, 0)) == -1)
 		if (errno != EINTR)
-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.openvz.org/pipermail/devel/attachments/20060825/9750f1e9/attachment-0001.sig>


More information about the Devel mailing list