From patchwork Tue Jun 25 01:57:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: mrhines@linux.vnet.ibm.com X-Patchwork-Id: 254008 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 05E112C007E for ; Tue, 25 Jun 2013 12:02:13 +1000 (EST) Received: from localhost ([::1]:52877 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UrIaA-0007p0-TN for incoming@patchwork.ozlabs.org; Mon, 24 Jun 2013 22:02:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44518) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UrIXL-0003JK-BX for qemu-devel@nongnu.org; Mon, 24 Jun 2013 21:59:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UrIXI-0001HF-Dq for qemu-devel@nongnu.org; Mon, 24 Jun 2013 21:59:15 -0400 Received: from e7.ny.us.ibm.com ([32.97.182.137]:53745) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UrIXI-0001H8-Ah for qemu-devel@nongnu.org; Mon, 24 Jun 2013 21:59:12 -0400 Received: from /spool/local by e7.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 24 Jun 2013 21:59:12 -0400 Received: from d01dlp01.pok.ibm.com (9.56.250.166) by e7.ny.us.ibm.com (192.168.1.107) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 24 Jun 2013 21:59:10 -0400 Received: from d01relay02.pok.ibm.com (d01relay02.pok.ibm.com [9.56.227.234]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id 463F238C804D for ; Mon, 24 Jun 2013 21:59:09 -0400 (EDT) Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay02.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r5P1w9gf249368 for ; Mon, 24 Jun 2013 21:58:10 -0400 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r5P1w9DH029179 for ; Mon, 24 Jun 2013 22:58:09 -0300 Received: from mrhinesdev.klabtestbed.com (klinux.watson.ibm.com [9.2.208.21]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r5P1w8Br029131; Mon, 24 Jun 2013 22:58:09 -0300 From: mrhines@linux.vnet.ibm.com To: qemu-devel@nongnu.org Date: Mon, 24 Jun 2013 21:57:53 -0400 Message-Id: <1372125485-11795-4-git-send-email-mrhines@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1372125485-11795-1-git-send-email-mrhines@linux.vnet.ibm.com> References: <1372125485-11795-1-git-send-email-mrhines@linux.vnet.ibm.com> X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13062501-5806-0000-0000-000021DC3BAB X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 32.97.182.137 Cc: aliguori@us.ibm.com, quintela@redhat.com, knoel@redhat.com, owasserm@redhat.com, abali@us.ibm.com, mrhines@us.ibm.com, gokul@us.ibm.com, pbonzini@redhat.com, chegu_vinod@hp.com Subject: [Qemu-devel] [PATCH v11 03/15] rdma: export yield_until_fd_readable() 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: "Michael R. Hines" The RDMA event channel can be made non-blocking just like a TCP socket. Exporting this function allows us to yield so that the QEMU monitor remains available. Reviewed-by: Paolo Bonzini Reviewed-by: Chegu Vinod Tested-by: Chegu Vinod Tested-by: Michael R. Hines Signed-off-by: Michael R. Hines Reviewed-by: Juan Quintela --- include/block/coroutine.h | 6 ++++++ qemu-coroutine-io.c | 23 +++++++++++++++++++++++ savevm.c | 28 ---------------------------- 3 files changed, 29 insertions(+), 28 deletions(-) diff --git a/include/block/coroutine.h b/include/block/coroutine.h index a978162..377805a 100644 --- a/include/block/coroutine.h +++ b/include/block/coroutine.h @@ -209,4 +209,10 @@ void qemu_co_rwlock_unlock(CoRwlock *lock); */ void coroutine_fn co_sleep_ns(QEMUClock *clock, int64_t ns); +/** + * Yield until a file descriptor becomes readable + * + * Note that this function clobbers the handlers for the file descriptor. + */ +void coroutine_fn yield_until_fd_readable(int fd); #endif /* QEMU_COROUTINE_H */ diff --git a/qemu-coroutine-io.c b/qemu-coroutine-io.c index e8ad1a4..c4df35a 100644 --- a/qemu-coroutine-io.c +++ b/qemu-coroutine-io.c @@ -63,3 +63,26 @@ qemu_co_send_recv(int sockfd, void *buf, size_t bytes, bool do_send) struct iovec iov = { .iov_base = buf, .iov_len = bytes }; return qemu_co_sendv_recvv(sockfd, &iov, 1, 0, bytes, do_send); } + +typedef struct { + Coroutine *co; + int fd; +} FDYieldUntilData; + +static void fd_coroutine_enter(void *opaque) +{ + FDYieldUntilData *data = opaque; + qemu_set_fd_handler(data->fd, NULL, NULL, NULL); + qemu_coroutine_enter(data->co, NULL); +} + +void coroutine_fn yield_until_fd_readable(int fd) +{ + FDYieldUntilData data; + + assert(qemu_in_coroutine()); + data.co = qemu_coroutine_self(); + data.fd = fd; + qemu_set_fd_handler(fd, fd_coroutine_enter, NULL, &data); + qemu_coroutine_yield(); +} diff --git a/savevm.c b/savevm.c index 9b5577e..e35c7a4 100644 --- a/savevm.c +++ b/savevm.c @@ -149,34 +149,6 @@ typedef struct QEMUFileSocket QEMUFile *file; } QEMUFileSocket; -typedef struct { - Coroutine *co; - int fd; -} FDYieldUntilData; - -static void fd_coroutine_enter(void *opaque) -{ - FDYieldUntilData *data = opaque; - qemu_set_fd_handler(data->fd, NULL, NULL, NULL); - qemu_coroutine_enter(data->co, NULL); -} - -/** - * Yield until a file descriptor becomes readable - * - * Note that this function clobbers the handlers for the file descriptor. - */ -static void coroutine_fn yield_until_fd_readable(int fd) -{ - FDYieldUntilData data; - - assert(qemu_in_coroutine()); - data.co = qemu_coroutine_self(); - data.fd = fd; - qemu_set_fd_handler(fd, fd_coroutine_enter, NULL, &data); - qemu_coroutine_yield(); -} - static ssize_t socket_writev_buffer(void *opaque, struct iovec *iov, int iovcnt, int64_t pos) {