qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/2] migration: fixes for 2.10
@ 2017-08-02  3:25 Peter Xu
  2017-08-02  3:25 ` [Qemu-devel] [PATCH 1/2] migration: fix comment disorder in RAMState Peter Xu
  2017-08-02  3:25 ` [Qemu-devel] [PATCH 2/2] io: fix qio_channel_socket_accept err handling Peter Xu
  0 siblings, 2 replies; 7+ messages in thread
From: Peter Xu @ 2017-08-02  3:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Juan Quintela, Daniel P . Berrange, peterx,
	Dr . David Alan Gilbert

Two patches isolated from the postcopy recovery series, which may be
good for 2.10.

Peter Xu (2):
  migration: fix comment disorder in RAMState
  io: fix qio_channel_socket_accept err handling

 io/channel-socket.c | 3 ++-
 migration/ram.c     | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

-- 
2.7.4

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

* [Qemu-devel] [PATCH 1/2] migration: fix comment disorder in RAMState
  2017-08-02  3:25 [Qemu-devel] [PATCH 0/2] migration: fixes for 2.10 Peter Xu
@ 2017-08-02  3:25 ` Peter Xu
  2017-08-02  8:23   ` Juan Quintela
  2017-08-02  3:25 ` [Qemu-devel] [PATCH 2/2] io: fix qio_channel_socket_accept err handling Peter Xu
  1 sibling, 1 reply; 7+ messages in thread
From: Peter Xu @ 2017-08-02  3:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Juan Quintela, Daniel P . Berrange, peterx,
	Dr . David Alan Gilbert

Comments for "migration_dirty_pages" and "bitmap_mutex" are switched.
Fix it.

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Peter Xu <peterx@redhat.com>
---
 migration/ram.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/migration/ram.c b/migration/ram.c
index 1b08296..e18b3e2 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -188,9 +188,9 @@ struct RAMState {
     uint64_t iterations_prev;
     /* Iterations since start */
     uint64_t iterations;
-    /* protects modification of the bitmap */
-    uint64_t migration_dirty_pages;
     /* number of dirty bits in the bitmap */
+    uint64_t migration_dirty_pages;
+    /* protects modification of the bitmap */
     QemuMutex bitmap_mutex;
     /* The RAMBlock used in the last src_page_requests */
     RAMBlock *last_req_rb;
-- 
2.7.4

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

* [Qemu-devel] [PATCH 2/2] io: fix qio_channel_socket_accept err handling
  2017-08-02  3:25 [Qemu-devel] [PATCH 0/2] migration: fixes for 2.10 Peter Xu
  2017-08-02  3:25 ` [Qemu-devel] [PATCH 1/2] migration: fix comment disorder in RAMState Peter Xu
@ 2017-08-02  3:25 ` Peter Xu
  2017-08-02  8:26   ` Juan Quintela
  2017-08-02  9:30   ` Daniel P. Berrange
  1 sibling, 2 replies; 7+ messages in thread
From: Peter Xu @ 2017-08-02  3:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Juan Quintela, Daniel P . Berrange, peterx,
	Dr . David Alan Gilbert

When accept failed, we should setup errp with the reason. More
importantly, the caller may assume errp be non-NULL when error happens,
and not setting the errp may crash QEMU.

At the same time, move the trace_qio_channel_socket_accept_fail() after
the if check on EINTR. Two reasons:

1. when EINTR happened, it's not really a fault (we should just try
   again), so we should not log with an "accept failure".

2. trace_*() functions may overwrite errno, then the old errno will be
   missing. We need to either check errno before trace_*() calls, or
   reserve the errno.

Signed-off-by: Peter Xu <peterx@redhat.com>
---
 io/channel-socket.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/io/channel-socket.c b/io/channel-socket.c
index 53386b7..442f230 100644
--- a/io/channel-socket.c
+++ b/io/channel-socket.c
@@ -340,10 +340,11 @@ qio_channel_socket_accept(QIOChannelSocket *ioc,
     cioc->fd = qemu_accept(ioc->fd, (struct sockaddr *)&cioc->remoteAddr,
                            &cioc->remoteAddrLen);
     if (cioc->fd < 0) {
-        trace_qio_channel_socket_accept_fail(ioc);
         if (errno == EINTR) {
             goto retry;
         }
+        trace_qio_channel_socket_accept_fail(ioc);
+        error_setg_errno(errp, errno, "Unable to accept connection");
         goto error;
     }
 
-- 
2.7.4

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

* Re: [Qemu-devel] [PATCH 1/2] migration: fix comment disorder in RAMState
  2017-08-02  3:25 ` [Qemu-devel] [PATCH 1/2] migration: fix comment disorder in RAMState Peter Xu
@ 2017-08-02  8:23   ` Juan Quintela
  0 siblings, 0 replies; 7+ messages in thread
From: Juan Quintela @ 2017-08-02  8:23 UTC (permalink / raw)
  To: Peter Xu
  Cc: qemu-devel, Laurent Vivier, Daniel P . Berrange,
	Dr . David Alan Gilbert

Peter Xu <peterx@redhat.com> wrote:
> Comments for "migration_dirty_pages" and "bitmap_mutex" are switched.
> Fix it.
>
> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> Signed-off-by: Peter Xu <peterx@redhat.com>

Reviewed-by: Juan Quintela <quintela@redhat.com>

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

* Re: [Qemu-devel] [PATCH 2/2] io: fix qio_channel_socket_accept err handling
  2017-08-02  3:25 ` [Qemu-devel] [PATCH 2/2] io: fix qio_channel_socket_accept err handling Peter Xu
@ 2017-08-02  8:26   ` Juan Quintela
  2017-08-02  9:30   ` Daniel P. Berrange
  1 sibling, 0 replies; 7+ messages in thread
From: Juan Quintela @ 2017-08-02  8:26 UTC (permalink / raw)
  To: Peter Xu
  Cc: qemu-devel, Laurent Vivier, Daniel P . Berrange,
	Dr . David Alan Gilbert

Peter Xu <peterx@redhat.com> wrote:
> When accept failed, we should setup errp with the reason. More
> importantly, the caller may assume errp be non-NULL when error happens,
> and not setting the errp may crash QEMU.
>
> At the same time, move the trace_qio_channel_socket_accept_fail() after
> the if check on EINTR. Two reasons:
>
> 1. when EINTR happened, it's not really a fault (we should just try
>    again), so we should not log with an "accept failure".
>
> 2. trace_*() functions may overwrite errno, then the old errno will be
>    missing. We need to either check errno before trace_*() calls, or
>    reserve the errno.
>
> Signed-off-by: Peter Xu <peterx@redhat.com>

Reviewed-by: Juan Quintela <quintela@redhat.com>

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

* Re: [Qemu-devel] [PATCH 2/2] io: fix qio_channel_socket_accept err handling
  2017-08-02  3:25 ` [Qemu-devel] [PATCH 2/2] io: fix qio_channel_socket_accept err handling Peter Xu
  2017-08-02  8:26   ` Juan Quintela
@ 2017-08-02  9:30   ` Daniel P. Berrange
  2017-08-02  9:37     ` Peter Xu
  1 sibling, 1 reply; 7+ messages in thread
From: Daniel P. Berrange @ 2017-08-02  9:30 UTC (permalink / raw)
  To: Peter Xu; +Cc: qemu-devel, Laurent Vivier, Juan Quintela,
	Dr . David Alan Gilbert

On Wed, Aug 02, 2017 at 11:25:21AM +0800, Peter Xu wrote:
> When accept failed, we should setup errp with the reason. More
> importantly, the caller may assume errp be non-NULL when error happens,
> and not setting the errp may crash QEMU.
> 
> At the same time, move the trace_qio_channel_socket_accept_fail() after
> the if check on EINTR. Two reasons:
> 
> 1. when EINTR happened, it's not really a fault (we should just try
>    again), so we should not log with an "accept failure".
> 
> 2. trace_*() functions may overwrite errno, then the old errno will be
>    missing. We need to either check errno before trace_*() calls, or
>    reserve the errno.
> 
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
>  io/channel-socket.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/io/channel-socket.c b/io/channel-socket.c
> index 53386b7..442f230 100644
> --- a/io/channel-socket.c
> +++ b/io/channel-socket.c
> @@ -340,10 +340,11 @@ qio_channel_socket_accept(QIOChannelSocket *ioc,
>      cioc->fd = qemu_accept(ioc->fd, (struct sockaddr *)&cioc->remoteAddr,
>                             &cioc->remoteAddrLen);
>      if (cioc->fd < 0) {
> -        trace_qio_channel_socket_accept_fail(ioc);
>          if (errno == EINTR) {
>              goto retry;
>          }
> +        trace_qio_channel_socket_accept_fail(ioc);
> +        error_setg_errno(errp, errno, "Unable to accept connection");

Err, you're still clobbering errno in trace_qio_channel_socket_accept_fail
before calling error_setg_errno


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

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

* Re: [Qemu-devel] [PATCH 2/2] io: fix qio_channel_socket_accept err handling
  2017-08-02  9:30   ` Daniel P. Berrange
@ 2017-08-02  9:37     ` Peter Xu
  0 siblings, 0 replies; 7+ messages in thread
From: Peter Xu @ 2017-08-02  9:37 UTC (permalink / raw)
  To: Daniel P. Berrange
  Cc: qemu-devel, Laurent Vivier, Juan Quintela,
	Dr . David Alan Gilbert

On Wed, Aug 02, 2017 at 10:30:20AM +0100, Daniel P. Berrange wrote:
> On Wed, Aug 02, 2017 at 11:25:21AM +0800, Peter Xu wrote:
> > When accept failed, we should setup errp with the reason. More
> > importantly, the caller may assume errp be non-NULL when error happens,
> > and not setting the errp may crash QEMU.
> > 
> > At the same time, move the trace_qio_channel_socket_accept_fail() after
> > the if check on EINTR. Two reasons:
> > 
> > 1. when EINTR happened, it's not really a fault (we should just try
> >    again), so we should not log with an "accept failure".
> > 
> > 2. trace_*() functions may overwrite errno, then the old errno will be
> >    missing. We need to either check errno before trace_*() calls, or
> >    reserve the errno.
> > 
> > Signed-off-by: Peter Xu <peterx@redhat.com>
> > ---
> >  io/channel-socket.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/io/channel-socket.c b/io/channel-socket.c
> > index 53386b7..442f230 100644
> > --- a/io/channel-socket.c
> > +++ b/io/channel-socket.c
> > @@ -340,10 +340,11 @@ qio_channel_socket_accept(QIOChannelSocket *ioc,
> >      cioc->fd = qemu_accept(ioc->fd, (struct sockaddr *)&cioc->remoteAddr,
> >                             &cioc->remoteAddrLen);
> >      if (cioc->fd < 0) {
> > -        trace_qio_channel_socket_accept_fail(ioc);
> >          if (errno == EINTR) {
> >              goto retry;
> >          }
> > +        trace_qio_channel_socket_accept_fail(ioc);
> > +        error_setg_errno(errp, errno, "Unable to accept connection");
> 
> Err, you're still clobbering errno in trace_qio_channel_socket_accept_fail
> before calling error_setg_errno

Oops! I'll do a quick respin.  Thanks for pointing out.

-- 
Peter Xu

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

end of thread, other threads:[~2017-08-02  9:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-02  3:25 [Qemu-devel] [PATCH 0/2] migration: fixes for 2.10 Peter Xu
2017-08-02  3:25 ` [Qemu-devel] [PATCH 1/2] migration: fix comment disorder in RAMState Peter Xu
2017-08-02  8:23   ` Juan Quintela
2017-08-02  3:25 ` [Qemu-devel] [PATCH 2/2] io: fix qio_channel_socket_accept err handling Peter Xu
2017-08-02  8:26   ` Juan Quintela
2017-08-02  9:30   ` Daniel P. Berrange
2017-08-02  9:37     ` Peter Xu

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).