Skip to content

Commit

Permalink
io: replace qemu_set{_non}block()
Browse files Browse the repository at this point in the history
Those calls are non-socket fd, or are POSIX-specific. Use the dedicated
GLib API. (qemu_set_nonblock() is for socket-like)

(this is a preliminary patch before renaming qemu_set_nonblock())

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
  • Loading branch information
elmarco committed May 3, 2022
1 parent b84bb4d commit 17fc124
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
16 changes: 9 additions & 7 deletions io/channel-command.c
Expand Up @@ -301,16 +301,18 @@ static int qio_channel_command_set_blocking(QIOChannel *ioc,
bool enabled,
Error **errp)
{
#ifdef WIN32
/* command spawn is not supported on win32 */
g_assert_not_reached();
#else
QIOChannelCommand *cioc = QIO_CHANNEL_COMMAND(ioc);

if (enabled) {
qemu_set_block(cioc->writefd);
qemu_set_block(cioc->readfd);
} else {
qemu_set_nonblock(cioc->writefd);
qemu_set_nonblock(cioc->readfd);
if (!g_unix_set_fd_nonblocking(cioc->writefd, !enabled, NULL) ||
!g_unix_set_fd_nonblocking(cioc->readfd, !enabled, NULL)) {
error_setg_errno(errp, errno, "Failed to set FD nonblocking");
return -1;
}

#endif
return 0;
}

Expand Down
13 changes: 9 additions & 4 deletions io/channel-file.c
Expand Up @@ -139,14 +139,19 @@ static int qio_channel_file_set_blocking(QIOChannel *ioc,
bool enabled,
Error **errp)
{
#ifdef WIN32
/* not implemented */
error_setg_errno(errp, errno, "Failed to set FD nonblocking");
return -1;
#else
QIOChannelFile *fioc = QIO_CHANNEL_FILE(ioc);

if (enabled) {
qemu_set_block(fioc->fd);
} else {
qemu_set_nonblock(fioc->fd);
if (!g_unix_set_fd_nonblocking(fioc->fd, !enabled, NULL)) {
error_setg_errno(errp, errno, "Failed to set FD nonblocking");
return -1;
}
return 0;
#endif
}


Expand Down

0 comments on commit 17fc124

Please sign in to comment.