qga: replace qemu_set_nonblock()
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Mon, 25 Apr 2022 13:39:06 +0000 (17:39 +0400)
committerMarc-André Lureau <marcandre.lureau@redhat.com>
Tue, 3 May 2022 11:52:29 +0000 (15:52 +0400)
The call is POSIX-specific. Use the dedicated GLib API.

(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>
qga/commands-posix.c

index 094487c2c395cbe45c8d842c7c469b73f31486d9..78f2f210015dc22be386db5735ea1175d368929d 100644 (file)
@@ -404,7 +404,11 @@ int64_t qmp_guest_file_open(const char *path, bool has_mode, const char *mode,
     /* set fd non-blocking to avoid common use cases (like reading from a
      * named pipe) from hanging the agent
      */
-    qemu_set_nonblock(fileno(fh));
+    if (!g_unix_set_fd_nonblocking(fileno(fh), true, NULL)) {
+        fclose(fh);
+        error_setg_errno(errp, errno, "Failed to set FD nonblocking");
+        return -1;
+    }
 
     handle = guest_file_handle_add(fh, errp);
     if (handle < 0) {