All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] iov: don't touch iov in iov_send_recv()
@ 2015-05-21  1:50 Wen Congyang
  2015-05-27  8:00 ` Wen Congyang
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Wen Congyang @ 2015-05-21  1:50 UTC (permalink / raw)
  To: qemu-devl, Kevin Wolf, Paolo Bonzini; +Cc: Dr. David Alan Gilbert

Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
---
 include/qemu/iov.h |  2 +-
 util/iov.c         | 14 +++++++++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/include/qemu/iov.h b/include/qemu/iov.h
index 68d25f2..569b2c2 100644
--- a/include/qemu/iov.h
+++ b/include/qemu/iov.h
@@ -75,7 +75,7 @@ size_t iov_memset(const struct iovec *iov, const unsigned int iov_cnt,
  * For iov_send_recv() _whole_ area being sent or received
  * should be within the iovec, not only beginning of it.
  */
-ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt,
+ssize_t iov_send_recv(int sockfd, const struct iovec *iov, unsigned iov_cnt,
                       size_t offset, size_t bytes, bool do_send);
 #define iov_recv(sockfd, iov, iov_cnt, offset, bytes) \
   iov_send_recv(sockfd, iov, iov_cnt, offset, bytes, false)
diff --git a/util/iov.c b/util/iov.c
index 2fb18e6..a0d5934 100644
--- a/util/iov.c
+++ b/util/iov.c
@@ -133,7 +133,7 @@ do_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt, bool do_send)
 #endif
 }
 
-ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt,
+ssize_t iov_send_recv(int sockfd, const struct iovec *_iov, unsigned iov_cnt,
                       size_t offset, size_t bytes,
                       bool do_send)
 {
@@ -141,6 +141,16 @@ ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt,
     ssize_t ret;
     size_t orig_len, tail;
     unsigned niov;
+    struct iovec *local_iov, *iov;
+
+    if (bytes <= 0) {
+        return 0;
+    }
+
+    local_iov = g_new0(struct iovec, iov_cnt);
+    iov_copy(local_iov, iov_cnt, _iov, iov_cnt, offset, bytes);
+    offset = 0;
+    iov = local_iov;
 
     while (bytes > 0) {
         /* Find the start position, skipping `offset' bytes:
@@ -187,6 +197,7 @@ ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt,
 
         if (ret < 0) {
             assert(errno != EINTR);
+            g_free(local_iov);
             if (errno == EAGAIN && total > 0) {
                 return total;
             }
@@ -205,6 +216,7 @@ ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt,
         bytes -= ret;
     }
 
+    g_free(local_iov);
     return total;
 }
 
-- 
2.1.0

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

* Re: [Qemu-devel] [PATCH] iov: don't touch iov in iov_send_recv()
  2015-05-21  1:50 [Qemu-devel] [PATCH] iov: don't touch iov in iov_send_recv() Wen Congyang
@ 2015-05-27  8:00 ` Wen Congyang
  2015-05-28 18:38   ` Dr. David Alan Gilbert
  2015-06-23  3:43 ` Wen Congyang
  2015-06-23 15:06 ` Stefan Hajnoczi
  2 siblings, 1 reply; 5+ messages in thread
From: Wen Congyang @ 2015-05-27  8:00 UTC (permalink / raw)
  To: qemu-devl, Kevin Wolf, Paolo Bonzini; +Cc: Dr. David Alan Gilbert

Ping...

On 05/21/2015 09:50 AM, Wen Congyang wrote:
> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
> ---
>  include/qemu/iov.h |  2 +-
>  util/iov.c         | 14 +++++++++++++-
>  2 files changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/include/qemu/iov.h b/include/qemu/iov.h
> index 68d25f2..569b2c2 100644
> --- a/include/qemu/iov.h
> +++ b/include/qemu/iov.h
> @@ -75,7 +75,7 @@ size_t iov_memset(const struct iovec *iov, const unsigned int iov_cnt,
>   * For iov_send_recv() _whole_ area being sent or received
>   * should be within the iovec, not only beginning of it.
>   */
> -ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt,
> +ssize_t iov_send_recv(int sockfd, const struct iovec *iov, unsigned iov_cnt,
>                        size_t offset, size_t bytes, bool do_send);
>  #define iov_recv(sockfd, iov, iov_cnt, offset, bytes) \
>    iov_send_recv(sockfd, iov, iov_cnt, offset, bytes, false)
> diff --git a/util/iov.c b/util/iov.c
> index 2fb18e6..a0d5934 100644
> --- a/util/iov.c
> +++ b/util/iov.c
> @@ -133,7 +133,7 @@ do_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt, bool do_send)
>  #endif
>  }
>  
> -ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt,
> +ssize_t iov_send_recv(int sockfd, const struct iovec *_iov, unsigned iov_cnt,
>                        size_t offset, size_t bytes,
>                        bool do_send)
>  {
> @@ -141,6 +141,16 @@ ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt,
>      ssize_t ret;
>      size_t orig_len, tail;
>      unsigned niov;
> +    struct iovec *local_iov, *iov;
> +
> +    if (bytes <= 0) {
> +        return 0;
> +    }
> +
> +    local_iov = g_new0(struct iovec, iov_cnt);
> +    iov_copy(local_iov, iov_cnt, _iov, iov_cnt, offset, bytes);
> +    offset = 0;
> +    iov = local_iov;
>  
>      while (bytes > 0) {
>          /* Find the start position, skipping `offset' bytes:
> @@ -187,6 +197,7 @@ ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt,
>  
>          if (ret < 0) {
>              assert(errno != EINTR);
> +            g_free(local_iov);
>              if (errno == EAGAIN && total > 0) {
>                  return total;
>              }
> @@ -205,6 +216,7 @@ ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt,
>          bytes -= ret;
>      }
>  
> +    g_free(local_iov);
>      return total;
>  }
>  
> 

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

* Re: [Qemu-devel] [PATCH] iov: don't touch iov in iov_send_recv()
  2015-05-27  8:00 ` Wen Congyang
@ 2015-05-28 18:38   ` Dr. David Alan Gilbert
  0 siblings, 0 replies; 5+ messages in thread
From: Dr. David Alan Gilbert @ 2015-05-28 18:38 UTC (permalink / raw)
  To: Wen Congyang; +Cc: Kevin Wolf, Paolo Bonzini, qemu-devl, Dr. David Alan Gilbert

* Wen Congyang (wency@cn.fujitsu.com) wrote:
> Ping...

Hi Wen,
  I don't know the block side of stuff to review this stuff, so
I'll leave it to Kevin and Paolo.

Dave

> 
> On 05/21/2015 09:50 AM, Wen Congyang wrote:
> > Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
> > ---
> >  include/qemu/iov.h |  2 +-
> >  util/iov.c         | 14 +++++++++++++-
> >  2 files changed, 14 insertions(+), 2 deletions(-)
> > 
> > diff --git a/include/qemu/iov.h b/include/qemu/iov.h
> > index 68d25f2..569b2c2 100644
> > --- a/include/qemu/iov.h
> > +++ b/include/qemu/iov.h
> > @@ -75,7 +75,7 @@ size_t iov_memset(const struct iovec *iov, const unsigned int iov_cnt,
> >   * For iov_send_recv() _whole_ area being sent or received
> >   * should be within the iovec, not only beginning of it.
> >   */
> > -ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt,
> > +ssize_t iov_send_recv(int sockfd, const struct iovec *iov, unsigned iov_cnt,
> >                        size_t offset, size_t bytes, bool do_send);
> >  #define iov_recv(sockfd, iov, iov_cnt, offset, bytes) \
> >    iov_send_recv(sockfd, iov, iov_cnt, offset, bytes, false)
> > diff --git a/util/iov.c b/util/iov.c
> > index 2fb18e6..a0d5934 100644
> > --- a/util/iov.c
> > +++ b/util/iov.c
> > @@ -133,7 +133,7 @@ do_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt, bool do_send)
> >  #endif
> >  }
> >  
> > -ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt,
> > +ssize_t iov_send_recv(int sockfd, const struct iovec *_iov, unsigned iov_cnt,
> >                        size_t offset, size_t bytes,
> >                        bool do_send)
> >  {
> > @@ -141,6 +141,16 @@ ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt,
> >      ssize_t ret;
> >      size_t orig_len, tail;
> >      unsigned niov;
> > +    struct iovec *local_iov, *iov;
> > +
> > +    if (bytes <= 0) {
> > +        return 0;
> > +    }
> > +
> > +    local_iov = g_new0(struct iovec, iov_cnt);
> > +    iov_copy(local_iov, iov_cnt, _iov, iov_cnt, offset, bytes);
> > +    offset = 0;
> > +    iov = local_iov;
> >  
> >      while (bytes > 0) {
> >          /* Find the start position, skipping `offset' bytes:
> > @@ -187,6 +197,7 @@ ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt,
> >  
> >          if (ret < 0) {
> >              assert(errno != EINTR);
> > +            g_free(local_iov);
> >              if (errno == EAGAIN && total > 0) {
> >                  return total;
> >              }
> > @@ -205,6 +216,7 @@ ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt,
> >          bytes -= ret;
> >      }
> >  
> > +    g_free(local_iov);
> >      return total;
> >  }
> >  
> > 
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

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

* Re: [Qemu-devel] [PATCH] iov: don't touch iov in iov_send_recv()
  2015-05-21  1:50 [Qemu-devel] [PATCH] iov: don't touch iov in iov_send_recv() Wen Congyang
  2015-05-27  8:00 ` Wen Congyang
@ 2015-06-23  3:43 ` Wen Congyang
  2015-06-23 15:06 ` Stefan Hajnoczi
  2 siblings, 0 replies; 5+ messages in thread
From: Wen Congyang @ 2015-06-23  3:43 UTC (permalink / raw)
  To: qemu-devl, Kevin Wolf, Paolo Bonzini
  Cc: Dr. David Alan Gilbert, Stefan Hajnoczi

Ping again.

This patch is bugfix. The old discussion is here:
http://lists.nongnu.org/archive/html/qemu-devel/2015-02/msg00245.html

On 05/21/2015 09:50 AM, Wen Congyang wrote:
> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
> ---
>  include/qemu/iov.h |  2 +-
>  util/iov.c         | 14 +++++++++++++-
>  2 files changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/include/qemu/iov.h b/include/qemu/iov.h
> index 68d25f2..569b2c2 100644
> --- a/include/qemu/iov.h
> +++ b/include/qemu/iov.h
> @@ -75,7 +75,7 @@ size_t iov_memset(const struct iovec *iov, const unsigned int iov_cnt,
>   * For iov_send_recv() _whole_ area being sent or received
>   * should be within the iovec, not only beginning of it.
>   */
> -ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt,
> +ssize_t iov_send_recv(int sockfd, const struct iovec *iov, unsigned iov_cnt,
>                        size_t offset, size_t bytes, bool do_send);
>  #define iov_recv(sockfd, iov, iov_cnt, offset, bytes) \
>    iov_send_recv(sockfd, iov, iov_cnt, offset, bytes, false)
> diff --git a/util/iov.c b/util/iov.c
> index 2fb18e6..a0d5934 100644
> --- a/util/iov.c
> +++ b/util/iov.c
> @@ -133,7 +133,7 @@ do_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt, bool do_send)
>  #endif
>  }
>  
> -ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt,
> +ssize_t iov_send_recv(int sockfd, const struct iovec *_iov, unsigned iov_cnt,
>                        size_t offset, size_t bytes,
>                        bool do_send)
>  {
> @@ -141,6 +141,16 @@ ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt,
>      ssize_t ret;
>      size_t orig_len, tail;
>      unsigned niov;
> +    struct iovec *local_iov, *iov;
> +
> +    if (bytes <= 0) {
> +        return 0;
> +    }
> +
> +    local_iov = g_new0(struct iovec, iov_cnt);
> +    iov_copy(local_iov, iov_cnt, _iov, iov_cnt, offset, bytes);
> +    offset = 0;
> +    iov = local_iov;
>  
>      while (bytes > 0) {
>          /* Find the start position, skipping `offset' bytes:
> @@ -187,6 +197,7 @@ ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt,
>  
>          if (ret < 0) {
>              assert(errno != EINTR);
> +            g_free(local_iov);
>              if (errno == EAGAIN && total > 0) {
>                  return total;
>              }
> @@ -205,6 +216,7 @@ ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt,
>          bytes -= ret;
>      }
>  
> +    g_free(local_iov);
>      return total;
>  }
>  
> 

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

* Re: [Qemu-devel] [PATCH] iov: don't touch iov in iov_send_recv()
  2015-05-21  1:50 [Qemu-devel] [PATCH] iov: don't touch iov in iov_send_recv() Wen Congyang
  2015-05-27  8:00 ` Wen Congyang
  2015-06-23  3:43 ` Wen Congyang
@ 2015-06-23 15:06 ` Stefan Hajnoczi
  2 siblings, 0 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2015-06-23 15:06 UTC (permalink / raw)
  To: Wen Congyang; +Cc: Kevin Wolf, Paolo Bonzini, qemu-devl, Dr. David Alan Gilbert

[-- Attachment #1: Type: text/plain, Size: 336 bytes --]

On Thu, May 21, 2015 at 09:50:10AM +0800, Wen Congyang wrote:
> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
> ---
>  include/qemu/iov.h |  2 +-
>  util/iov.c         | 14 +++++++++++++-
>  2 files changed, 14 insertions(+), 2 deletions(-)

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan

[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]

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

end of thread, other threads:[~2015-06-23 15:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-21  1:50 [Qemu-devel] [PATCH] iov: don't touch iov in iov_send_recv() Wen Congyang
2015-05-27  8:00 ` Wen Congyang
2015-05-28 18:38   ` Dr. David Alan Gilbert
2015-06-23  3:43 ` Wen Congyang
2015-06-23 15:06 ` Stefan Hajnoczi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.