qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] linux-user: pass correct host flags to eventfd2


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH] linux-user: pass correct host flags to eventfd2 call
Date: Mon, 8 Apr 2013 21:23:54 +0100

On 8 April 2013 19:26, Petar Jovanovic <address@hidden> wrote:
> This change makes conversion of TARGET_O_NONBLOCK and TARGET_O_CLOEXEC flags
> to host flags before calling eventfd for TARGET_NR_eventfd2.
>
> Signed-off-by: Petar Jovanovic <address@hidden>
> ---
>  linux-user/syscall.c |   11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index ee82a2d..1f07621 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -8823,8 +8823,17 @@ abi_long do_syscall(void *cpu_env, int num, abi_long 
> arg1,
>  #endif
>  #if defined(TARGET_NR_eventfd2)
>      case TARGET_NR_eventfd2:
> -        ret = get_errno(eventfd(arg1, arg2));
> +    {
> +        int host_flags = arg2 & (~(TARGET_O_NONBLOCK | TARGET_O_CLOEXEC));
> +        if (arg2 & TARGET_O_NONBLOCK) {
> +            host_flags |= O_NONBLOCK;
> +        }
> +        if (arg2 & TARGET_O_CLOEXEC) {
> +            host_flags |= O_CLOEXEC;
> +        }
> +        ret = get_errno(eventfd(arg1, host_flags));

I had to look it up, but this is OK because eventfd flags come
in two flavours: (a) those shared with the O_* fcntl flags, which
is just O_NONBLOCK and O_CLOEXEC at the moment and (b) those which
are not shared with the fcntl flags, which are the same value on
all targets. So it's correct to convert the two shared flags and
leave the rest alone.

Reviewed-by: Peter Maydell <address@hidden>

-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]