qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH stable-1.4 v2 0/4] monitor: do not rely on O_NONBLOCK for passed file descriptors
@ 2013-04-04 14:18 Stefan Hajnoczi
  2013-04-04 14:18 ` [Qemu-devel] [PATCH stable-1.4 v2 1/4] oslib-posix: rename socket_set_nonblock() to qemu_set_nonblock() Stefan Hajnoczi
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Stefan Hajnoczi @ 2013-04-04 14:18 UTC (permalink / raw)
  To: qemu-devel
  Cc: Markus Armbruster, Michael Roth, Stefan Hajnoczi, Luiz Capitulino

Backported to QEMU 1.4 stable branch.

Original series:
http://lists.nongnu.org/archive/html/qemu-devel/2013-03/msg04756.html

v2:
 * Use git cherry-pick -x and give rationale for conflict resolutions.

Stefan Hajnoczi (4):
  oslib-posix: rename socket_set_nonblock() to qemu_set_nonblock()
  net: ensure "socket" backend uses non-blocking fds
  qemu-socket: set passed fd non-blocking in socket_connect()
  chardev: clear O_NONBLOCK on SCM_RIGHTS file descriptors

 block/nbd.c            |  2 +-
 block/sheepdog.c       |  6 +++---
 include/qemu/sockets.h |  4 ++--
 migration-tcp.c        |  2 +-
 migration-unix.c       |  2 +-
 migration.c            |  2 +-
 nbd.c                  |  8 ++++----
 net/socket.c           | 13 +++++++++----
 qemu-char.c            | 11 +++++++----
 slirp/misc.c           |  2 +-
 slirp/tcp_subr.c       |  4 ++--
 ui/vnc.c               |  2 +-
 util/oslib-posix.c     |  4 ++--
 util/oslib-win32.c     |  4 ++--
 util/qemu-sockets.c    |  5 +++--
 15 files changed, 40 insertions(+), 31 deletions(-)

-- 
1.8.1.4

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

* [Qemu-devel] [PATCH stable-1.4 v2 1/4] oslib-posix: rename socket_set_nonblock() to qemu_set_nonblock()
  2013-04-04 14:18 [Qemu-devel] [PATCH stable-1.4 v2 0/4] monitor: do not rely on O_NONBLOCK for passed file descriptors Stefan Hajnoczi
@ 2013-04-04 14:18 ` Stefan Hajnoczi
  2013-04-04 14:18 ` [Qemu-devel] [PATCH stable-1.4 v2 2/4] net: ensure "socket" backend uses non-blocking fds Stefan Hajnoczi
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Stefan Hajnoczi @ 2013-04-04 14:18 UTC (permalink / raw)
  To: qemu-devel
  Cc: Markus Armbruster, Michael Roth, Stefan Hajnoczi, Luiz Capitulino

The fcntl(fd, F_SETFL, O_NONBLOCK) flag is not specific to sockets.
Rename to qemu_set_nonblock() just like qemu_set_cloexec().

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
(cherry picked from commit 399f1c8f8af1f6f8b18ef4e37169c6301264e467)

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>

Conflicts:
	block/sheepdog.c

socket_set_block()/socket_set_nonblock() calls in different locations

	include/qemu/sockets.h

socket_set_nodelay() does not exist in v1.4.0, messes up diff context

	qemu-char.c

glib G_IO_IN events are not used in v1.4.0, messes up diff context

	savevm.c

qemu_fopen_socket() only has read mode in v1.4.0, qemu_set_block() not
necessary.

	slirp/misc.c

unportable setsockopt() calls in v1.4.0 mess up diff context

	slirp/tcp_subr.c

file was reformatted, diff context is messed up

	ui/vnc.c

old dcl->idle instead of vd->dcl.idle messes up diff context

Added:
	migration-tcp.c, migration-unix.c

qemu_fopen_socket() write mode does not exist yet, qemu_set_block() call
is needed here.
---
 block/nbd.c            | 2 +-
 block/sheepdog.c       | 6 +++---
 include/qemu/sockets.h | 4 ++--
 migration-tcp.c        | 2 +-
 migration-unix.c       | 2 +-
 migration.c            | 2 +-
 nbd.c                  | 8 ++++----
 net/socket.c           | 6 +++---
 qemu-char.c            | 8 ++++----
 slirp/misc.c           | 2 +-
 slirp/tcp_subr.c       | 4 ++--
 ui/vnc.c               | 2 +-
 util/oslib-posix.c     | 4 ++--
 util/oslib-win32.c     | 4 ++--
 util/qemu-sockets.c    | 4 ++--
 15 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/block/nbd.c b/block/nbd.c
index a581294..6562fd3 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -350,7 +350,7 @@ static int nbd_establish_connection(BlockDriverState *bs)
 
     /* Now that we're connected, set the socket to be non-blocking and
      * kick the reply mechanism.  */
-    socket_set_nonblock(sock);
+    qemu_set_nonblock(sock);
     qemu_aio_set_fd_handler(sock, nbd_reply_ready, NULL,
                             nbd_have_request, s);
 
diff --git a/block/sheepdog.c b/block/sheepdog.c
index d466b23..b968b59 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -549,7 +549,7 @@ static coroutine_fn void do_co_req(void *opaque)
     co = qemu_coroutine_self();
     qemu_aio_set_fd_handler(sockfd, NULL, restart_co_req, NULL, co);
 
-    socket_set_block(sockfd);
+    qemu_set_block(sockfd);
     ret = send_co_req(sockfd, hdr, data, wlen);
     if (ret < 0) {
         goto out;
@@ -579,7 +579,7 @@ static coroutine_fn void do_co_req(void *opaque)
     ret = 0;
 out:
     qemu_aio_set_fd_handler(sockfd, NULL, NULL, NULL, NULL);
-    socket_set_nonblock(sockfd);
+    qemu_set_nonblock(sockfd);
 
     srco->ret = ret;
     srco->finished = true;
@@ -812,7 +812,7 @@ static int get_sheep_fd(BDRVSheepdogState *s)
         return fd;
     }
 
-    socket_set_nonblock(fd);
+    qemu_set_nonblock(fd);
 
     ret = set_nodelay(fd);
     if (ret) {
diff --git a/include/qemu/sockets.h b/include/qemu/sockets.h
index 803ae17..0ccf32f 100644
--- a/include/qemu/sockets.h
+++ b/include/qemu/sockets.h
@@ -34,8 +34,8 @@ int inet_aton(const char *cp, struct in_addr *ia);
 int qemu_socket(int domain, int type, int protocol);
 int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen);
 int socket_set_cork(int fd, int v);
-void socket_set_block(int fd);
-void socket_set_nonblock(int fd);
+void qemu_set_block(int fd);
+void qemu_set_nonblock(int fd);
 int send_all(int fd, const void *buf, int len1);
 
 /* callback function for nonblocking connect
diff --git a/migration-tcp.c b/migration-tcp.c
index e78a296..59e3b7e 100644
--- a/migration-tcp.c
+++ b/migration-tcp.c
@@ -60,7 +60,7 @@ static void tcp_wait_for_connect(int fd, void *opaque)
     } else {
         DPRINTF("migrate connect success\n");
         s->fd = fd;
-        socket_set_block(s->fd);
+        qemu_set_block(s->fd);
         migrate_fd_connect(s);
     }
 }
diff --git a/migration-unix.c b/migration-unix.c
index 218835a..0ca2a21 100644
--- a/migration-unix.c
+++ b/migration-unix.c
@@ -60,7 +60,7 @@ static void unix_wait_for_connect(int fd, void *opaque)
     } else {
         DPRINTF("migrate connect success\n");
         s->fd = fd;
-        socket_set_block(s->fd);
+        qemu_set_block(s->fd);
         migrate_fd_connect(s);
     }
 }
diff --git a/migration.c b/migration.c
index b1ebb01..98c7696 100644
--- a/migration.c
+++ b/migration.c
@@ -120,7 +120,7 @@ void process_incoming_migration(QEMUFile *f)
     int fd = qemu_get_fd(f);
 
     assert(fd != -1);
-    socket_set_nonblock(fd);
+    qemu_set_nonblock(fd);
     qemu_coroutine_enter(co, f);
 }
 
diff --git a/nbd.c b/nbd.c
index 0698a02..2eff5a2 100644
--- a/nbd.c
+++ b/nbd.c
@@ -393,7 +393,7 @@ static int nbd_send_negotiate(NBDClient *client)
         [28 .. 151]   reserved     (0)
      */
 
-    socket_set_block(csock);
+    qemu_set_block(csock);
     rc = -EINVAL;
 
     TRACE("Beginning negotiation.");
@@ -436,7 +436,7 @@ static int nbd_send_negotiate(NBDClient *client)
     TRACE("Negotiation succeeded.");
     rc = 0;
 fail:
-    socket_set_nonblock(csock);
+    qemu_set_nonblock(csock);
     return rc;
 }
 
@@ -450,7 +450,7 @@ int nbd_receive_negotiate(int csock, const char *name, uint32_t *flags,
 
     TRACE("Receiving negotiation.");
 
-    socket_set_block(csock);
+    qemu_set_block(csock);
     rc = -EINVAL;
 
     if (read_sync(csock, buf, 8) != 8) {
@@ -565,7 +565,7 @@ int nbd_receive_negotiate(int csock, const char *name, uint32_t *flags,
     rc = 0;
 
 fail:
-    socket_set_nonblock(csock);
+    qemu_set_nonblock(csock);
     return rc;
 }
 
diff --git a/net/socket.c b/net/socket.c
index 396dc8c..ea407c7 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -309,7 +309,7 @@ static int net_socket_mcast_create(struct sockaddr_in *mcastaddr, struct in_addr
         }
     }
 
-    socket_set_nonblock(fd);
+    qemu_set_nonblock(fd);
     return fd;
 fail:
     if (fd >= 0)
@@ -517,7 +517,7 @@ static int net_socket_listen_init(NetClientState *peer,
         perror("socket");
         return -1;
     }
-    socket_set_nonblock(fd);
+    qemu_set_nonblock(fd);
 
     /* allow fast reuse */
     val = 1;
@@ -563,7 +563,7 @@ static int net_socket_connect_init(NetClientState *peer,
         perror("socket");
         return -1;
     }
-    socket_set_nonblock(fd);
+    qemu_set_nonblock(fd);
 
     connected = 0;
     for(;;) {
diff --git a/qemu-char.c b/qemu-char.c
index e4b0f53..d685139 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -2377,7 +2377,7 @@ static int tcp_chr_add_client(CharDriverState *chr, int fd)
     if (s->fd != -1)
 	return -1;
 
-    socket_set_nonblock(fd);
+    qemu_set_nonblock(fd);
     if (s->do_nodelay)
         socket_set_nodelay(fd);
     s->fd = fd;
@@ -2512,7 +2512,7 @@ static CharDriverState *qemu_chr_open_socket_fd(int fd, bool do_nodelay,
         printf("QEMU waiting for connection on: %s\n",
                chr->filename);
         tcp_chr_accept(chr);
-        socket_set_nonblock(s->listen_fd);
+        qemu_set_nonblock(s->listen_fd);
     }
     return chr;
 }
@@ -2554,7 +2554,7 @@ static CharDriverState *qemu_chr_open_socket(QemuOpts *opts)
     }
 
     if (!is_waitconnect)
-        socket_set_nonblock(fd);
+        qemu_set_nonblock(fd);
 
     chr = qemu_chr_open_socket_fd(fd, do_nodelay, is_listen, is_telnet,
                                   is_waitconnect, &local_err);
@@ -3328,7 +3328,7 @@ static CharDriverState *qmp_chardev_open_serial(ChardevHostdev *serial,
     if (error_is_set(errp)) {
         return NULL;
     }
-    socket_set_nonblock(fd);
+    qemu_set_nonblock(fd);
     return qemu_chr_open_tty_fd(fd);
 #else
     error_setg(errp, "character device backend type 'serial' not supported");
diff --git a/slirp/misc.c b/slirp/misc.c
index d4df972..00f0140 100644
--- a/slirp/misc.c
+++ b/slirp/misc.c
@@ -215,7 +215,7 @@ fork_exec(struct socket *so, const char *ex, int do_pty)
                 setsockopt(so->s, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(int));
                 opt = 1;
                 setsockopt(so->s, SOL_SOCKET, SO_OOBINLINE, (char *)&opt, sizeof(int));
-		socket_set_nonblock(so->s);
+		qemu_set_nonblock(so->s);
 
 		/* Append the telnet options now */
                 if (so->so_m != NULL && do_pty == 1)  {
diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c
index 1542e43..8b7c2b5 100644
--- a/slirp/tcp_subr.c
+++ b/slirp/tcp_subr.c
@@ -336,7 +336,7 @@ int tcp_fconnect(struct socket *so)
     int opt, s=so->s;
     struct sockaddr_in addr;
 
-    socket_set_nonblock(s);
+    qemu_set_nonblock(s);
     opt = 1;
     setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(opt ));
     opt = 1;
@@ -424,7 +424,7 @@ tcp_connect(struct socket *inso)
 		tcp_close(sototcpcb(so)); /* This will sofree() as well */
 		return;
 	}
-	socket_set_nonblock(s);
+	qemu_set_nonblock(s);
 	opt = 1;
 	setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(int));
 	opt = 1;
diff --git a/ui/vnc.c b/ui/vnc.c
index ff4e2ae..9ba3794 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -2726,7 +2726,7 @@ static void vnc_connect(VncDisplay *vd, int csock, int skipauth, bool websocket)
 
     VNC_DEBUG("New client on socket %d\n", csock);
     dcl->idle = 0;
-    socket_set_nonblock(vs->csock);
+    qemu_set_nonblock(vs->csock);
 #ifdef CONFIG_VNC_WS
     if (websocket) {
         vs->websocket = 1;
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index b4152fb..42fbfed 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -134,14 +134,14 @@ void qemu_vfree(void *ptr)
     free(ptr);
 }
 
-void socket_set_block(int fd)
+void qemu_set_block(int fd)
 {
     int f;
     f = fcntl(fd, F_GETFL);
     fcntl(fd, F_SETFL, f & ~O_NONBLOCK);
 }
 
-void socket_set_nonblock(int fd)
+void qemu_set_nonblock(int fd)
 {
     int f;
     f = fcntl(fd, F_GETFL);
diff --git a/util/oslib-win32.c b/util/oslib-win32.c
index 640194c..dcfa0c2 100644
--- a/util/oslib-win32.c
+++ b/util/oslib-win32.c
@@ -100,14 +100,14 @@ struct tm *localtime_r(const time_t *timep, struct tm *result)
     return p;
 }
 
-void socket_set_block(int fd)
+void qemu_set_block(int fd)
 {
     unsigned long opt = 0;
     WSAEventSelect(fd, NULL, 0);
     ioctlsocket(fd, FIONBIO, &opt);
 }
 
-void socket_set_nonblock(int fd)
+void qemu_set_nonblock(int fd)
 {
     unsigned long opt = 1;
     ioctlsocket(fd, FIONBIO, &opt);
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index 1350ccc..e92e0d5 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -277,7 +277,7 @@ static int inet_connect_addr(struct addrinfo *addr, bool *in_progress,
     }
     qemu_setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
     if (connect_state != NULL) {
-        socket_set_nonblock(sock);
+        qemu_set_nonblock(sock);
     }
     /* connect to peer */
     do {
@@ -733,7 +733,7 @@ int unix_connect_opts(QemuOpts *opts, Error **errp,
         connect_state = g_malloc0(sizeof(*connect_state));
         connect_state->callback = callback;
         connect_state->opaque = opaque;
-        socket_set_nonblock(sock);
+        qemu_set_nonblock(sock);
     }
 
     memset(&un, 0, sizeof(un));
-- 
1.8.1.4

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

* [Qemu-devel] [PATCH stable-1.4 v2 2/4] net: ensure "socket" backend uses non-blocking fds
  2013-04-04 14:18 [Qemu-devel] [PATCH stable-1.4 v2 0/4] monitor: do not rely on O_NONBLOCK for passed file descriptors Stefan Hajnoczi
  2013-04-04 14:18 ` [Qemu-devel] [PATCH stable-1.4 v2 1/4] oslib-posix: rename socket_set_nonblock() to qemu_set_nonblock() Stefan Hajnoczi
@ 2013-04-04 14:18 ` Stefan Hajnoczi
  2013-04-04 14:18 ` [Qemu-devel] [PATCH stable-1.4 v2 3/4] qemu-socket: set passed fd non-blocking in socket_connect() Stefan Hajnoczi
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Stefan Hajnoczi @ 2013-04-04 14:18 UTC (permalink / raw)
  To: qemu-devel
  Cc: Markus Armbruster, Michael Roth, Stefan Hajnoczi, Luiz Capitulino

There are several code paths in net_init_socket() depending on how the
socket is created: file descriptor passing, UDP multicast, TCP, or UDP.
Some of these support both listen and connect.

Not all code paths set the socket to non-blocking.  This patch addresses
the file descriptor passing and UDP cases which were missing
socket_set_nonblock(fd) calls.

I considered moving socket_set_nonblock(fd) to a central location but it
turns out the code paths are different enough to require non-blocking at
different places.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
(cherry picked from commit f05b707279dc7c29ab10d9d13dbf413df6ec22f1)

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 net/socket.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/net/socket.c b/net/socket.c
index ea407c7..a2b94f4 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -672,6 +672,7 @@ static int net_socket_udp_init(NetClientState *peer,
         closesocket(fd);
         return -1;
     }
+    qemu_set_nonblock(fd);
 
     s = net_socket_fd_init(peer, model, name, fd, 0);
     if (!s) {
@@ -710,7 +711,11 @@ int net_init_socket(const NetClientOptions *opts, const char *name,
         int fd;
 
         fd = monitor_handle_fd_param(cur_mon, sock->fd);
-        if (fd == -1 || !net_socket_fd_init(peer, "socket", name, fd, 1)) {
+        if (fd == -1) {
+            return -1;
+        }
+        qemu_set_nonblock(fd);
+        if (!net_socket_fd_init(peer, "socket", name, fd, 1)) {
             return -1;
         }
         return 0;
-- 
1.8.1.4

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

* [Qemu-devel] [PATCH stable-1.4 v2 3/4] qemu-socket: set passed fd non-blocking in socket_connect()
  2013-04-04 14:18 [Qemu-devel] [PATCH stable-1.4 v2 0/4] monitor: do not rely on O_NONBLOCK for passed file descriptors Stefan Hajnoczi
  2013-04-04 14:18 ` [Qemu-devel] [PATCH stable-1.4 v2 1/4] oslib-posix: rename socket_set_nonblock() to qemu_set_nonblock() Stefan Hajnoczi
  2013-04-04 14:18 ` [Qemu-devel] [PATCH stable-1.4 v2 2/4] net: ensure "socket" backend uses non-blocking fds Stefan Hajnoczi
@ 2013-04-04 14:18 ` Stefan Hajnoczi
  2013-04-04 14:18 ` [Qemu-devel] [PATCH stable-1.4 v2 4/4] chardev: clear O_NONBLOCK on SCM_RIGHTS file descriptors Stefan Hajnoczi
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Stefan Hajnoczi @ 2013-04-04 14:18 UTC (permalink / raw)
  To: qemu-devel
  Cc: Markus Armbruster, Michael Roth, Stefan Hajnoczi, Luiz Capitulino

socket_connect() sets non-blocking on TCP or UNIX domain sockets if a
callback function is passed.  Do the same for file descriptor passing,
otherwise we could unexpectedly be using a blocking file descriptor.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
(cherry picked from commit 35fb94fa292173a3e1df0768433e06912a2a88e4)

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 util/qemu-sockets.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index e92e0d5..cd54fb4 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -906,6 +906,7 @@ int socket_connect(SocketAddress *addr, Error **errp,
     case SOCKET_ADDRESS_KIND_FD:
         fd = monitor_get_fd(cur_mon, addr->fd->str, errp);
         if (callback) {
+            qemu_set_nonblock(fd);
             callback(fd, opaque);
         }
         break;
-- 
1.8.1.4

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

* [Qemu-devel] [PATCH stable-1.4 v2 4/4] chardev: clear O_NONBLOCK on SCM_RIGHTS file descriptors
  2013-04-04 14:18 [Qemu-devel] [PATCH stable-1.4 v2 0/4] monitor: do not rely on O_NONBLOCK for passed file descriptors Stefan Hajnoczi
                   ` (2 preceding siblings ...)
  2013-04-04 14:18 ` [Qemu-devel] [PATCH stable-1.4 v2 3/4] qemu-socket: set passed fd non-blocking in socket_connect() Stefan Hajnoczi
@ 2013-04-04 14:18 ` Stefan Hajnoczi
  2013-04-04 14:54 ` [Qemu-devel] [PATCH stable-1.4 v2 0/4] monitor: do not rely on O_NONBLOCK for passed " Eric Blake
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Stefan Hajnoczi @ 2013-04-04 14:18 UTC (permalink / raw)
  To: qemu-devel
  Cc: Markus Armbruster, Michael Roth, Stefan Hajnoczi, Luiz Capitulino

When we receive a file descriptor over a UNIX domain socket the
O_NONBLOCK flag is preserved.  Clear the O_NONBLOCK flag and rely on
QEMU file descriptor users like migration, SPICE, VNC, block layer, and
others to set non-blocking only when necessary.

This change ensures we don't accidentally expose O_NONBLOCK in the QMP
API.  QMP clients should not need to get the non-blocking state
"correct".

A recent real-world example was when libvirt passed a non-blocking TCP
socket for migration where we expected a blocking socket.  The source
QEMU produced a corrupted migration stream since its code did not cope
with non-blocking sockets.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
(cherry picked from commit e374f7f816171f9783c1d9d00a041f26379f1ac6)

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 qemu-char.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/qemu-char.c b/qemu-char.c
index d685139..1efca64 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -2252,6 +2252,9 @@ static void unix_process_msgfd(CharDriverState *chr, struct msghdr *msg)
         if (fd < 0)
             continue;
 
+        /* O_NONBLOCK is preserved across SCM_RIGHTS so reset it */
+        qemu_set_block(fd);
+
 #ifndef MSG_CMSG_CLOEXEC
         qemu_set_cloexec(fd);
 #endif
-- 
1.8.1.4

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

* Re: [Qemu-devel] [PATCH stable-1.4 v2 0/4] monitor: do not rely on O_NONBLOCK for passed file descriptors
  2013-04-04 14:18 [Qemu-devel] [PATCH stable-1.4 v2 0/4] monitor: do not rely on O_NONBLOCK for passed file descriptors Stefan Hajnoczi
                   ` (3 preceding siblings ...)
  2013-04-04 14:18 ` [Qemu-devel] [PATCH stable-1.4 v2 4/4] chardev: clear O_NONBLOCK on SCM_RIGHTS file descriptors Stefan Hajnoczi
@ 2013-04-04 14:54 ` Eric Blake
  2013-04-04 14:59 ` Luiz Capitulino
  2013-04-04 22:48 ` mdroth
  6 siblings, 0 replies; 8+ messages in thread
From: Eric Blake @ 2013-04-04 14:54 UTC (permalink / raw)
  To: Stefan Hajnoczi
  Cc: Michael Roth, Luiz Capitulino, qemu-devel, Markus Armbruster

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

On 04/04/2013 08:18 AM, Stefan Hajnoczi wrote:
> Backported to QEMU 1.4 stable branch.
> 
> Original series:
> http://lists.nongnu.org/archive/html/qemu-devel/2013-03/msg04756.html
> 
> v2:
>  * Use git cherry-pick -x and give rationale for conflict resolutions.

Thanks.  My v1 series review still applies, since the only change is to
the commit message.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 621 bytes --]

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

* Re: [Qemu-devel] [PATCH stable-1.4 v2 0/4] monitor: do not rely on O_NONBLOCK for passed file descriptors
  2013-04-04 14:18 [Qemu-devel] [PATCH stable-1.4 v2 0/4] monitor: do not rely on O_NONBLOCK for passed file descriptors Stefan Hajnoczi
                   ` (4 preceding siblings ...)
  2013-04-04 14:54 ` [Qemu-devel] [PATCH stable-1.4 v2 0/4] monitor: do not rely on O_NONBLOCK for passed " Eric Blake
@ 2013-04-04 14:59 ` Luiz Capitulino
  2013-04-04 22:48 ` mdroth
  6 siblings, 0 replies; 8+ messages in thread
From: Luiz Capitulino @ 2013-04-04 14:59 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: Markus Armbruster, qemu-devel, Michael Roth

On Thu,  4 Apr 2013 16:18:27 +0200
Stefan Hajnoczi <stefanha@redhat.com> wrote:

> Backported to QEMU 1.4 stable branch.
> 
> Original series:
> http://lists.nongnu.org/archive/html/qemu-devel/2013-03/msg04756.html
> 
> v2:
>  * Use git cherry-pick -x and give rationale for conflict resolutions.
> 
> Stefan Hajnoczi (4):
>   oslib-posix: rename socket_set_nonblock() to qemu_set_nonblock()
>   net: ensure "socket" backend uses non-blocking fds
>   qemu-socket: set passed fd non-blocking in socket_connect()
>   chardev: clear O_NONBLOCK on SCM_RIGHTS file descriptors

Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>

> 
>  block/nbd.c            |  2 +-
>  block/sheepdog.c       |  6 +++---
>  include/qemu/sockets.h |  4 ++--
>  migration-tcp.c        |  2 +-
>  migration-unix.c       |  2 +-
>  migration.c            |  2 +-
>  nbd.c                  |  8 ++++----
>  net/socket.c           | 13 +++++++++----
>  qemu-char.c            | 11 +++++++----
>  slirp/misc.c           |  2 +-
>  slirp/tcp_subr.c       |  4 ++--
>  ui/vnc.c               |  2 +-
>  util/oslib-posix.c     |  4 ++--
>  util/oslib-win32.c     |  4 ++--
>  util/qemu-sockets.c    |  5 +++--
>  15 files changed, 40 insertions(+), 31 deletions(-)
> 

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

* Re: [Qemu-devel] [PATCH stable-1.4 v2 0/4] monitor: do not rely on O_NONBLOCK for passed file descriptors
  2013-04-04 14:18 [Qemu-devel] [PATCH stable-1.4 v2 0/4] monitor: do not rely on O_NONBLOCK for passed file descriptors Stefan Hajnoczi
                   ` (5 preceding siblings ...)
  2013-04-04 14:59 ` Luiz Capitulino
@ 2013-04-04 22:48 ` mdroth
  6 siblings, 0 replies; 8+ messages in thread
From: mdroth @ 2013-04-04 22:48 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: Markus Armbruster, qemu-devel, Luiz Capitulino

On Thu, Apr 04, 2013 at 04:18:27PM +0200, Stefan Hajnoczi wrote:
> Backported to QEMU 1.4 stable branch.
> 
> Original series:
> http://lists.nongnu.org/archive/html/qemu-devel/2013-03/msg04756.html
> 
> v2:
>  * Use git cherry-pick -x and give rationale for conflict resolutions.

Applied to the 1.4.1 staging tree:

https://github.com/mdroth/qemu/commits/stable-1.4-staging

Thanks for the backport!

> 
> Stefan Hajnoczi (4):
>   oslib-posix: rename socket_set_nonblock() to qemu_set_nonblock()
>   net: ensure "socket" backend uses non-blocking fds
>   qemu-socket: set passed fd non-blocking in socket_connect()
>   chardev: clear O_NONBLOCK on SCM_RIGHTS file descriptors
> 
>  block/nbd.c            |  2 +-
>  block/sheepdog.c       |  6 +++---
>  include/qemu/sockets.h |  4 ++--
>  migration-tcp.c        |  2 +-
>  migration-unix.c       |  2 +-
>  migration.c            |  2 +-
>  nbd.c                  |  8 ++++----
>  net/socket.c           | 13 +++++++++----
>  qemu-char.c            | 11 +++++++----
>  slirp/misc.c           |  2 +-
>  slirp/tcp_subr.c       |  4 ++--
>  ui/vnc.c               |  2 +-
>  util/oslib-posix.c     |  4 ++--
>  util/oslib-win32.c     |  4 ++--
>  util/qemu-sockets.c    |  5 +++--
>  15 files changed, 40 insertions(+), 31 deletions(-)
> 
> -- 
> 1.8.1.4
> 

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

end of thread, other threads:[~2013-04-04 22:50 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-04 14:18 [Qemu-devel] [PATCH stable-1.4 v2 0/4] monitor: do not rely on O_NONBLOCK for passed file descriptors Stefan Hajnoczi
2013-04-04 14:18 ` [Qemu-devel] [PATCH stable-1.4 v2 1/4] oslib-posix: rename socket_set_nonblock() to qemu_set_nonblock() Stefan Hajnoczi
2013-04-04 14:18 ` [Qemu-devel] [PATCH stable-1.4 v2 2/4] net: ensure "socket" backend uses non-blocking fds Stefan Hajnoczi
2013-04-04 14:18 ` [Qemu-devel] [PATCH stable-1.4 v2 3/4] qemu-socket: set passed fd non-blocking in socket_connect() Stefan Hajnoczi
2013-04-04 14:18 ` [Qemu-devel] [PATCH stable-1.4 v2 4/4] chardev: clear O_NONBLOCK on SCM_RIGHTS file descriptors Stefan Hajnoczi
2013-04-04 14:54 ` [Qemu-devel] [PATCH stable-1.4 v2 0/4] monitor: do not rely on O_NONBLOCK for passed " Eric Blake
2013-04-04 14:59 ` Luiz Capitulino
2013-04-04 22:48 ` mdroth

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