From patchwork Tue Jun 16 10:26:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dr. David Alan Gilbert" X-Patchwork-Id: 484915 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 5C8E31401B5 for ; Tue, 16 Jun 2015 20:32:29 +1000 (AEST) Received: from localhost ([::1]:39141 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4oAN-0006Qa-F2 for incoming@patchwork.ozlabs.org; Tue, 16 Jun 2015 06:32:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53175) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4o5M-0005kO-PM for qemu-devel@nongnu.org; Tue, 16 Jun 2015 06:27:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z4o5L-0000ej-97 for qemu-devel@nongnu.org; Tue, 16 Jun 2015 06:27:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54815) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4o5L-0000ed-4C for qemu-devel@nongnu.org; Tue, 16 Jun 2015 06:27:15 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id C34998F28E; Tue, 16 Jun 2015 10:27:14 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-116-112.ams2.redhat.com [10.36.116.112]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t5GAQtZp017611; Tue, 16 Jun 2015 06:27:12 -0400 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org Date: Tue, 16 Jun 2015 11:26:19 +0100 Message-Id: <1434450415-11339-7-git-send-email-dgilbert@redhat.com> In-Reply-To: <1434450415-11339-1-git-send-email-dgilbert@redhat.com> References: <1434450415-11339-1-git-send-email-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: aarcange@redhat.com, yamahata@private.email.ne.jp, quintela@redhat.com, liang.z.li@intel.com, luis@cs.umu.se, amit.shah@redhat.com, pbonzini@redhat.com, david@gibson.dropbear.id.au Subject: [Qemu-devel] [PATCH v7 06/42] Add wrapper for setting blocking status on a QEMUFile X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- 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 29a9d69..d43c835 100644 --- a/include/migration/qemu-file.h +++ b/include/migration/qemu-file.h @@ -193,6 +193,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_change_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 c111a6b..c746129 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -651,3 +651,18 @@ size_t qemu_get_counted_string(QEMUFile *f, char buf[256]) return res == len ? res : 0; } + +/* + * Change 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_change_blocking(QEMUFile *f, bool block) +{ + if (block) { + qemu_set_block(qemu_get_fd(f)); + } else { + qemu_set_nonblock(qemu_get_fd(f)); + } +}