On 10/05/13 22:07, Osier Yang wrote:
On 10/05/13 21:51, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange(a)redhat.com>
>
> In b2878ed860ceceec3cd6481424fed0b543b687cd we added the O_NOCTTY
> flag when opening files in the stream code. Unfortunately a later
> piece of code was comparing the flags == O_RDONLY, without masking
> out the non-access mode flags. This broke the iohelper when used
> with streams for read, since it caused us to attach the stream
> output pipe to the stream input FD instead of output FD :-(
>
> Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
> ---
> src/fdstream.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/fdstream.c b/src/fdstream.c
> index 6f8ce53..a9a4851 100644
> --- a/src/fdstream.c
> +++ b/src/fdstream.c
> @@ -641,7 +641,7 @@ virFDStreamOpenFileInternal(virStreamPtr st,
> virCommandTransferFD(cmd, fd);
> virCommandAddArgFormat(cmd, "%d", fd);
> - if (oflags == O_RDONLY) {
> + if ((oflags & O_ACCMODE) == O_RDONLY) {
> childfd = fds[1];
> fd = fds[0];
> virCommandSetOutputFD(cmd, &childfd);
ACK. I went a bit far away to find the cause.. :-(
This patch should be pushed to maint branch as well, as it existed since
v1.0.4.