qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/3] linux-user: preadv and pwritev emulation support
@ 2016-10-06 13:59 Dejan Jovicevic
  2016-10-06 13:59 ` [Qemu-devel] [PATCH 1/3] linux-user: detect pwritev support on configure Dejan Jovicevic
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Dejan Jovicevic @ 2016-10-06 13:59 UTC (permalink / raw)
  To: qemu-devel; +Cc: riku.voipio, pbonzini, peter.maydell, kraxel, mjt, berrange

In this series the support for preadv and pwritev system call emulation
in linux-user mode is implemented. Also, the configure file is modified 
to check if both of these system calls are supported on the host.

Dejan Jovicevic (3):
  linux-user: detect pwritev support on configure
  linux-user: added support for preadv() system call.
  linux-user: added support for pwritev() system call.

 configure            | 17 +++++++++++++++++
 linux-user/syscall.c | 26 ++++++++++++++++++++++++++
 2 files changed, 43 insertions(+)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PATCH 1/3] linux-user: detect pwritev support on configure
  2016-10-06 13:59 [Qemu-devel] [PATCH 0/3] linux-user: preadv and pwritev emulation support Dejan Jovicevic
@ 2016-10-06 13:59 ` Dejan Jovicevic
  2016-10-07  7:17   ` Riku Voipio
  2016-10-06 13:59 ` [Qemu-devel] [PATCH 2/3] linux-user: added support for preadv() system call Dejan Jovicevic
  2016-10-06 13:59 ` [Qemu-devel] [PATCH 3/3] linux-user: added support for pwritev() " Dejan Jovicevic
  2 siblings, 1 reply; 6+ messages in thread
From: Dejan Jovicevic @ 2016-10-06 13:59 UTC (permalink / raw)
  To: qemu-devel; +Cc: riku.voipio, pbonzini, peter.maydell, kraxel, mjt, berrange

Modified the configure file so that, during configuration, a check
is performed to determine if the system call pwritev is supported
by the host. The check for preadv support already exists.               

Signed-off-by: Dejan Jovicevic <dejan.jovicevic@rt-rk.com>
---
 configure | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/configure b/configure
index 5751d8e..f834ac8 100755
--- a/configure
+++ b/configure
@@ -3318,6 +3318,19 @@ if compile_prog "" "" ; then
 fi
 
 ##########################################
+# pwritev probe
+cat > $TMPC <<EOF
+#include <sys/types.h>
+#include <sys/uio.h>
+#include <unistd.h>
+int main(void) { return pwritev(0, 0, 0, 0); }
+EOF
+pwritev=no
+if compile_prog "" "" ; then
+  pwritev=yes
+fi
+
+##########################################
 # fdt probe
 # fdt support is mandatory for at least some target architectures,
 # so insist on it if we're building those system emulators.
@@ -4902,6 +4915,7 @@ echo "RDMA support      $rdma"
 echo "TCG interpreter   $tcg_interpreter"
 echo "fdt support       $fdt"
 echo "preadv support    $preadv"
+echo "pwritev support   $pwritev"
 echo "fdatasync         $fdatasync"
 echo "madvise           $madvise"
 echo "posix_madvise     $posix_madvise"
@@ -5299,6 +5313,9 @@ fi
 if test "$preadv" = "yes" ; then
   echo "CONFIG_PREADV=y" >> $config_host_mak
 fi
+if test "$pwritev" = "yes" ; then
+  echo "CONFIG_PWRITEV=y" >> $config_host_mak
+fi
 if test "$fdt" = "yes" ; then
   echo "CONFIG_FDT=y" >> $config_host_mak
 fi
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PATCH 2/3] linux-user: added support for preadv() system call.
  2016-10-06 13:59 [Qemu-devel] [PATCH 0/3] linux-user: preadv and pwritev emulation support Dejan Jovicevic
  2016-10-06 13:59 ` [Qemu-devel] [PATCH 1/3] linux-user: detect pwritev support on configure Dejan Jovicevic
@ 2016-10-06 13:59 ` Dejan Jovicevic
  2016-10-06 14:14   ` Peter Maydell
  2016-10-06 13:59 ` [Qemu-devel] [PATCH 3/3] linux-user: added support for pwritev() " Dejan Jovicevic
  2 siblings, 1 reply; 6+ messages in thread
From: Dejan Jovicevic @ 2016-10-06 13:59 UTC (permalink / raw)
  To: qemu-devel; +Cc: riku.voipio, pbonzini, peter.maydell, kraxel, mjt, berrange

This system call performs the same task as the readv system call,
with the exception of having the fourth argument, offset, which 
specifes the file offset at which the input operation is to be performed.

This implementation is based on the existing readv implementation.

Signed-off-by: Dejan Jovicevic <dejan.jovicevic@rt-rk.com>
---
 linux-user/syscall.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 0815f30..10b2552 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -9894,6 +9894,19 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             }
         }
         break;
+#if defined(TARGET_NR_preadv) && defined(CONFIG_PREADV)
+    case TARGET_NR_preadv:
+        {
+            struct iovec *vec = lock_iovec(VERIFY_WRITE, arg2, arg3, 0);
+            if (vec != NULL) {
+                ret = get_errno(preadv(arg1, vec, arg3, arg4));
+                unlock_iovec(vec, arg2, arg3, 1);
+            } else {
+                ret = -host_to_target_errno(errno);
+           }
+        }
+        break;
+#endif
     case TARGET_NR_getsid:
         ret = get_errno(getsid(arg1));
         break;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PATCH 3/3] linux-user: added support for pwritev() system call.
  2016-10-06 13:59 [Qemu-devel] [PATCH 0/3] linux-user: preadv and pwritev emulation support Dejan Jovicevic
  2016-10-06 13:59 ` [Qemu-devel] [PATCH 1/3] linux-user: detect pwritev support on configure Dejan Jovicevic
  2016-10-06 13:59 ` [Qemu-devel] [PATCH 2/3] linux-user: added support for preadv() system call Dejan Jovicevic
@ 2016-10-06 13:59 ` Dejan Jovicevic
  2 siblings, 0 replies; 6+ messages in thread
From: Dejan Jovicevic @ 2016-10-06 13:59 UTC (permalink / raw)
  To: qemu-devel; +Cc: riku.voipio, pbonzini, peter.maydell, kraxel, mjt, berrange

This system call performs the same task as the writev system call,
with the exception of having the fourth argument, offset, which 
specifes the file offset at which the input operation is to be performed.

This implementation is based on the existing writev implementation.

Signed-off-by: Dejan Jovicevic <dejan.jovicevic@rt-rk.com>
---
 linux-user/syscall.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 10b2552..9f72a2c 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -9907,6 +9907,19 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
         }
         break;
 #endif
+#if defined(TARGET_NR_pwritev) && defined(CONFIG_PWRITEV)
+    case TARGET_NR_pwritev:
+        {
+            struct iovec *vec = lock_iovec(VERIFY_READ, arg2, arg3, 1);
+            if (vec != NULL) {
+                ret = get_errno(pwritev(arg1, vec, arg3, arg4));
+                unlock_iovec(vec, arg2, arg3, 0);
+            } else {
+                ret = -host_to_target_errno(errno);
+           }
+        }
+        break;
+#endif
     case TARGET_NR_getsid:
         ret = get_errno(getsid(arg1));
         break;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH 2/3] linux-user: added support for preadv() system call.
  2016-10-06 13:59 ` [Qemu-devel] [PATCH 2/3] linux-user: added support for preadv() system call Dejan Jovicevic
@ 2016-10-06 14:14   ` Peter Maydell
  0 siblings, 0 replies; 6+ messages in thread
From: Peter Maydell @ 2016-10-06 14:14 UTC (permalink / raw)
  To: Dejan Jovicevic
  Cc: QEMU Developers, Riku Voipio, Paolo Bonzini, Gerd Hoffmann,
	Michael Tokarev, Daniel P. Berrange

On 6 October 2016 at 14:59, Dejan Jovicevic <dejan.jovicevic@rt-rk.com> wrote:
> This system call performs the same task as the readv system call,
> with the exception of having the fourth argument, offset, which
> specifes the file offset at which the input operation is to be performed.
>
> This implementation is based on the existing readv implementation.
>
> Signed-off-by: Dejan Jovicevic <dejan.jovicevic@rt-rk.com>
> ---
>  linux-user/syscall.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 0815f30..10b2552 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -9894,6 +9894,19 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
>              }
>          }
>          break;
> +#if defined(TARGET_NR_preadv) && defined(CONFIG_PREADV)
> +    case TARGET_NR_preadv:
> +        {
> +            struct iovec *vec = lock_iovec(VERIFY_WRITE, arg2, arg3, 0);
> +            if (vec != NULL) {
> +                ret = get_errno(preadv(arg1, vec, arg3, arg4));
> +                unlock_iovec(vec, arg2, arg3, 1);
> +            } else {
> +                ret = -host_to_target_errno(errno);
> +           }
> +        }
> +        break;
> +#endif

preadv is an "interruptible syscall", meaning that it can
return EINTR if a signal occurs while it is blocking. This
means that in QEMU we need to implement it via the
safe_syscall() wrapper (see the long explanatory comment
in linux-user/qemu.h). The same applies to pwritev. See
the implementations of TARGET_NR_readv and TARGET_NR_writev
for an example of how to do this; basically you just need
a safe_syscall4() line to define safe_preadv(), and then
use it instead of direct preadv(). As a side-benefit you'll
then be able to drop the configure patch since we don't
go via libc.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH 1/3] linux-user: detect pwritev support on configure
  2016-10-06 13:59 ` [Qemu-devel] [PATCH 1/3] linux-user: detect pwritev support on configure Dejan Jovicevic
@ 2016-10-07  7:17   ` Riku Voipio
  0 siblings, 0 replies; 6+ messages in thread
From: Riku Voipio @ 2016-10-07  7:17 UTC (permalink / raw)
  To: Dejan Jovicevic
  Cc: qemu-devel, pbonzini, peter.maydell, kraxel, mjt, berrange

On Thu, Oct 06, 2016 at 03:59:29PM +0200, Dejan Jovicevic wrote:
> Modified the configure file so that, during configuration, a check
> is performed to determine if the system call pwritev is supported
> by the host. The check for preadv support already exists.               

Since preadv/pwritev appearead at the same time (glibc 2.10), using existing
CONFIG_PREADV ifdef guard is enough. Since the oldest distributions currently
being tested (SLES11, Ubuntu 10.04, RHEL6) all have glibc 2.11 or newer,
I'm not really sure we need this check at all.

Riku

 
> Signed-off-by: Dejan Jovicevic <dejan.jovicevic@rt-rk.com>
> ---
>  configure | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/configure b/configure
> index 5751d8e..f834ac8 100755
> --- a/configure
> +++ b/configure
> @@ -3318,6 +3318,19 @@ if compile_prog "" "" ; then
>  fi
>  
>  ##########################################
> +# pwritev probe
> +cat > $TMPC <<EOF
> +#include <sys/types.h>
> +#include <sys/uio.h>
> +#include <unistd.h>
> +int main(void) { return pwritev(0, 0, 0, 0); }
> +EOF
> +pwritev=no
> +if compile_prog "" "" ; then
> +  pwritev=yes
> +fi
> +
> +##########################################
>  # fdt probe
>  # fdt support is mandatory for at least some target architectures,
>  # so insist on it if we're building those system emulators.
> @@ -4902,6 +4915,7 @@ echo "RDMA support      $rdma"
>  echo "TCG interpreter   $tcg_interpreter"
>  echo "fdt support       $fdt"
>  echo "preadv support    $preadv"
> +echo "pwritev support   $pwritev"
>  echo "fdatasync         $fdatasync"
>  echo "madvise           $madvise"
>  echo "posix_madvise     $posix_madvise"
> @@ -5299,6 +5313,9 @@ fi
>  if test "$preadv" = "yes" ; then
>    echo "CONFIG_PREADV=y" >> $config_host_mak
>  fi
> +if test "$pwritev" = "yes" ; then
> +  echo "CONFIG_PWRITEV=y" >> $config_host_mak
> +fi
>  if test "$fdt" = "yes" ; then
>    echo "CONFIG_FDT=y" >> $config_host_mak
>  fi
> -- 
> 1.9.1
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-10-07  7:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-06 13:59 [Qemu-devel] [PATCH 0/3] linux-user: preadv and pwritev emulation support Dejan Jovicevic
2016-10-06 13:59 ` [Qemu-devel] [PATCH 1/3] linux-user: detect pwritev support on configure Dejan Jovicevic
2016-10-07  7:17   ` Riku Voipio
2016-10-06 13:59 ` [Qemu-devel] [PATCH 2/3] linux-user: added support for preadv() system call Dejan Jovicevic
2016-10-06 14:14   ` Peter Maydell
2016-10-06 13:59 ` [Qemu-devel] [PATCH 3/3] linux-user: added support for pwritev() " Dejan Jovicevic

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).