From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34187) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zw9s4-00035c-EI for qemu-devel@nongnu.org; Tue, 10 Nov 2015 09:26:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zw9s3-0000kf-MB for qemu-devel@nongnu.org; Tue, 10 Nov 2015 09:26:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35728) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zw9s3-0000kX-Hp for qemu-devel@nongnu.org; Tue, 10 Nov 2015 09:26:03 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 452B5C0AED53 for ; Tue, 10 Nov 2015 14:26:03 +0000 (UTC) From: Juan Quintela Date: Tue, 10 Nov 2015 15:24:58 +0100 Message-Id: <1447165546-27784-10-git-send-email-quintela@redhat.com> In-Reply-To: <1447165546-27784-1-git-send-email-quintela@redhat.com> References: <1447165546-27784-1-git-send-email-quintela@redhat.com> Subject: [Qemu-devel] [PULL 09/57] Add wrapper for setting blocking status on a QEMUFile List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: amit.shah@redhat.com, dgilbert@redhat.com From: "Dr. David Alan Gilbert" Add a wrapper to change the blocking status on a QEMUFile rather than having to use qemu_set_block(qemu_get_fd(f)); it seems best to avoid exposing the fd since not all QEMUFile's really have one. With this wrapper we could move the implementation down to be different on different transports. Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Amit Shah Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- include/migration/qemu-file.h | 1 + migration/qemu-file.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/migration/qemu-file.h b/include/migration/qemu-file.h index 86bb972..66e741f 100644 --- a/include/migration/qemu-file.h +++ b/include/migration/qemu-file.h @@ -197,6 +197,7 @@ int qemu_file_get_error(QEMUFile *f); void qemu_file_set_error(QEMUFile *f, int ret); int qemu_file_shutdown(QEMUFile *f); void qemu_fflush(QEMUFile *f); +void qemu_file_set_blocking(QEMUFile *f, bool block); static inline void qemu_put_be64s(QEMUFile *f, const uint64_t *pv) { diff --git a/migration/qemu-file.c b/migration/qemu-file.c index e41a677..9ec2267 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -648,3 +648,18 @@ size_t qemu_get_counted_string(QEMUFile *f, char buf[256]) return res == len ? res : 0; } + +/* + * Set the blocking state of the QEMUFile. + * Note: On some transports the OS only keeps a single blocking state for + * both directions, and thus changing the blocking on the main + * QEMUFile can also affect the return path. + */ +void qemu_file_set_blocking(QEMUFile *f, bool block) +{ + if (block) { + qemu_set_block(qemu_get_fd(f)); + } else { + qemu_set_nonblock(qemu_get_fd(f)); + } +} -- 2.5.0