#define QIO_CHANNEL_READ_FLAG_MSG_PEEK 0x1
#define QIO_CHANNEL_READ_FLAG_RELAXED_EOF 0x2
+#define QIO_CHANNEL_READ_FLAG_FD_PRESERVE_BLOCKING 0x4
typedef enum QIOChannelFeature QIOChannelFeature;
#ifndef WIN32
static void qio_channel_socket_copy_fds(struct msghdr *msg,
- int **fds, size_t *nfds)
+ int **fds, size_t *nfds,
+ bool preserve_blocking)
{
struct cmsghdr *cmsg;
continue;
}
- /* O_NONBLOCK is preserved across SCM_RIGHTS so reset it */
- qemu_socket_set_block(fd);
+ if (!preserve_blocking) {
+ /* O_NONBLOCK is preserved across SCM_RIGHTS so reset it */
+ qemu_socket_set_block(fd);
+ }
#ifndef MSG_CMSG_CLOEXEC
qemu_set_cloexec(fd);
}
if (fds && nfds) {
- qio_channel_socket_copy_fds(&msg, fds, nfds);
+ qio_channel_socket_copy_fds(
+ &msg, fds, nfds,
+ flags & QIO_CHANNEL_READ_FLAG_FD_PRESERVE_BLOCKING);
}
return ret;
do {
struct iovec iov = { f->buf + pending, IO_BUF_SIZE - pending };
- len = qio_channel_readv_full(f->ioc, &iov, 1, pfds, pnfd, 0,
+ len = qio_channel_readv_full(f->ioc, &iov, 1, pfds, pnfd,
+ QIO_CHANNEL_READ_FLAG_FD_PRESERVE_BLOCKING,
&local_error);
if (len == QIO_CHANNEL_ERR_BLOCK) {
if (qemu_in_coroutine()) {