Skip to contentSkip to conversation

migration: fixes for 2.10

PATCH Superseded Peter Xu 3 participants 7 messages Aug 2, 2017

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Peter Xu

author
#0 lore raw

cover migration: fixes for 2.10

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(-)
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH 1/2 migration: fix comment disorder in RAMState

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

---
 migration/ram.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
migration/ram.c +2 -2
index 1b08296..e18b3e2 100644
@@ -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;
Signature · 1 line
2.7.4
author
#3 lore raw

PATCH 2/2 io: fix qio_channel_socket_accept err handling

In reply to Peter Xu

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.

---
 io/channel-socket.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
io/channel-socket.c +2 -1
index 53386b7..442f230 100644
@@ -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;
     }
 
Signature · 1 line
2.7.4
Reviewed-by on v1 2/2
#4 lore raw

Re: [Qemu-devel] [PATCH 2/2] io: fix qio_channel_socket_accept err handling

Quoted 7 lines · Peter Xu

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:

Quoted 8 lines

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.

#5 lore raw

Re: [Qemu-devel] [PATCH 2/2] io: fix qio_channel_socket_accept err handling

In reply to Peter Xu
Quoted 24 lines · Peter Xu

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.

---
 io/channel-socket.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
io/channel-socket.c +0 -0
index 53386b7..442f230 100644

io/channel-socket.c qio_channel_socket_accept(QIOChannelSocket *ioc, · line 347

Quoted 9 lines
io/channel-socket.c +2 -1
@@ -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

Signature · 3 lines
|: 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 :|
author
#6 lore raw

Re: [Qemu-devel] [PATCH 2/2] io: fix qio_channel_socket_accept err handling

Quoted 29 lines · Daniel P. Berrange
Quoted 28 lines · Peter Xu

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.

---
 io/channel-socket.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
io/channel-socket.c +0 -1
index 53386b7..442f230 100644
@@ -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);
Quoted 8 lines

io/channel-socket.c qio_channel_socket_accept(QIOChannelSocket *ioc, · line 347

Quoted 5 lines
io/channel-socket.c +2 -0
         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.

Signature · 1 line
Peter Xu