From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60761) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zu4Qm-0000Ai-5g for qemu-devel@nongnu.org; Wed, 04 Nov 2015 15:13:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zu4Qh-0003hm-5J for qemu-devel@nongnu.org; Wed, 04 Nov 2015 15:13:16 -0500 Received: from e19.ny.us.ibm.com ([129.33.205.209]:33766) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zu4Qh-0003hP-29 for qemu-devel@nongnu.org; Wed, 04 Nov 2015 15:13:11 -0500 Received: from localhost by e19.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 4 Nov 2015 15:13:10 -0500 Received: from b01cxnp23034.gho.pok.ibm.com (b01cxnp23034.gho.pok.ibm.com [9.57.198.29]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id 018AE6E803C for ; Wed, 4 Nov 2015 15:01:18 -0500 (EST) Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id tA4KD7WW63832156 for ; Wed, 4 Nov 2015 20:13:07 GMT Received: from d01av02.pok.ibm.com (localhost [127.0.0.1]) by d01av02.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id tA4KD6ES016410 for ; Wed, 4 Nov 2015 15:13:06 -0500 From: Michael Roth Date: Wed, 4 Nov 2015 14:12:15 -0600 Message-Id: <1446667937-12085-2-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1446667937-12085-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1446667937-12085-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [PULL 1/3] qga: drop hand-made guest_file_toggle_flags helper List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, Michael Roth , "Denis V. Lunev" From: "Denis V. Lunev" We'd better use generic qemu_set_nonblock directly. Signed-off-by: Denis V. Lunev Reviewed-by: Yuri Pudgorodskiy Reviewed-by: Eric Blake CC: Michael Roth Signed-off-by: Michael Roth --- qga/commands-posix.c | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 67a173a..0ebd473 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -28,6 +28,7 @@ #include "qapi/qmp/qerror.h" #include "qemu/queue.h" #include "qemu/host-utils.h" +#include "qemu/sockets.h" #ifndef CONFIG_HAS_ENVIRON #ifdef __APPLE__ @@ -385,27 +386,6 @@ safe_open_or_create(const char *path, const char *mode, Error **errp) return NULL; } -static int guest_file_toggle_flags(int fd, int flags, bool set, Error **err) -{ - int ret, old_flags; - - old_flags = fcntl(fd, F_GETFL); - if (old_flags == -1) { - error_setg_errno(err, errno, QERR_QGA_COMMAND_FAILED, - "failed to fetch filehandle flags"); - return -1; - } - - ret = fcntl(fd, F_SETFL, set ? (old_flags | flags) : (old_flags & ~flags)); - if (ret == -1) { - error_setg_errno(err, errno, QERR_QGA_COMMAND_FAILED, - "failed to set filehandle flags"); - return -1; - } - - return ret; -} - int64_t qmp_guest_file_open(const char *path, bool has_mode, const char *mode, Error **errp) { @@ -426,10 +406,7 @@ 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 */ - if (guest_file_toggle_flags(fileno(fh), O_NONBLOCK, true, errp) < 0) { - fclose(fh); - return -1; - } + qemu_set_nonblock(fileno(fh)); handle = guest_file_handle_add(fh, errp); if (handle < 0) { -- 1.9.1