io: replace qemu_set{_non}block()

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>
This commit is contained in:
Marc-André Lureau 2022-04-25 17:39:06 +04:00
parent b84bb4dfe5
commit 17fc124529
2 changed files with 18 additions and 11 deletions

View File

@ -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;
}

View File

@ -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
}