|
|
0a122b |
From 5134b54a7e8941d6e6c112e03b7e85b578606fc0 Mon Sep 17 00:00:00 2001
|
|
|
0a122b |
Message-Id: <5134b54a7e8941d6e6c112e03b7e85b578606fc0.1387382496.git.minovotn@redhat.com>
|
|
|
0a122b |
In-Reply-To: <c5386144fbf09f628148101bc674e2421cdd16e3.1387382496.git.minovotn@redhat.com>
|
|
|
0a122b |
References: <c5386144fbf09f628148101bc674e2421cdd16e3.1387382496.git.minovotn@redhat.com>
|
|
|
0a122b |
From: Nigel Croxon <ncroxon@redhat.com>
|
|
|
0a122b |
Date: Thu, 14 Nov 2013 22:52:42 +0100
|
|
|
0a122b |
Subject: [PATCH 06/46] rdma: export yield_until_fd_readable()
|
|
|
0a122b |
|
|
|
0a122b |
RH-Author: Nigel Croxon <ncroxon@redhat.com>
|
|
|
0a122b |
Message-id: <1384469598-13137-7-git-send-email-ncroxon@redhat.com>
|
|
|
0a122b |
Patchwork-id: 55691
|
|
|
0a122b |
O-Subject: [RHEL7.0 PATCH 06/42] rdma: export yield_until_fd_readable()
|
|
|
0a122b |
Bugzilla: 1011720
|
|
|
0a122b |
RH-Acked-by: Orit Wasserman <owasserm@redhat.com>
|
|
|
0a122b |
RH-Acked-by: Amit Shah <amit.shah@redhat.com>
|
|
|
0a122b |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
0a122b |
|
|
|
0a122b |
Bugzilla: 1011720
|
|
|
0a122b |
https://bugzilla.redhat.com/show_bug.cgi?id=1011720
|
|
|
0a122b |
|
|
|
0a122b |
>From commit ID:
|
|
|
0a122b |
commit 9f05d0c3a4f9e8fcb13ed09cc350af45a627809a
|
|
|
0a122b |
Author: Michael R. Hines <mrhines@us.ibm.com>
|
|
|
0a122b |
Date: Tue Jun 25 21:35:29 2013 -0400
|
|
|
0a122b |
|
|
|
0a122b |
rdma: export yield_until_fd_readable()
|
|
|
0a122b |
|
|
|
0a122b |
The RDMA event channel can be made non-blocking just like a TCP
|
|
|
0a122b |
socket. Exporting this function allows us to yield so that the
|
|
|
0a122b |
QEMU monitor remains available.
|
|
|
0a122b |
|
|
|
0a122b |
Reviewed-by: Juan Quintela <quintela@redhat.com>
|
|
|
0a122b |
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
0a122b |
Reviewed-by: Chegu Vinod <chegu_vinod@hp.com>
|
|
|
0a122b |
Tested-by: Chegu Vinod <chegu_vinod@hp.com>
|
|
|
0a122b |
Tested-by: Michael R. Hines <mrhines@us.ibm.com>
|
|
|
0a122b |
Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
|
|
|
0a122b |
Signed-off-by: Juan Quintela <quintela@redhat.com>
|
|
|
0a122b |
---
|
|
|
0a122b |
include/block/coroutine.h | 6 ++++++
|
|
|
0a122b |
qemu-coroutine-io.c | 23 +++++++++++++++++++++++
|
|
|
0a122b |
savevm.c | 28 ----------------------------
|
|
|
0a122b |
3 files changed, 29 insertions(+), 28 deletions(-)
|
|
|
0a122b |
|
|
|
0a122b |
Signed-off-by: Michal Novotny <minovotn@redhat.com>
|
|
|
0a122b |
---
|
|
|
0a122b |
include/block/coroutine.h | 6 ++++++
|
|
|
0a122b |
qemu-coroutine-io.c | 23 +++++++++++++++++++++++
|
|
|
0a122b |
savevm.c | 28 ----------------------------
|
|
|
0a122b |
3 files changed, 29 insertions(+), 28 deletions(-)
|
|
|
0a122b |
|
|
|
0a122b |
diff --git a/include/block/coroutine.h b/include/block/coroutine.h
|
|
|
0a122b |
index a978162..377805a 100644
|
|
|
0a122b |
--- a/include/block/coroutine.h
|
|
|
0a122b |
+++ b/include/block/coroutine.h
|
|
|
0a122b |
@@ -209,4 +209,10 @@ void qemu_co_rwlock_unlock(CoRwlock *lock);
|
|
|
0a122b |
*/
|
|
|
0a122b |
void coroutine_fn co_sleep_ns(QEMUClock *clock, int64_t ns);
|
|
|
0a122b |
|
|
|
0a122b |
+/**
|
|
|
0a122b |
+ * Yield until a file descriptor becomes readable
|
|
|
0a122b |
+ *
|
|
|
0a122b |
+ * Note that this function clobbers the handlers for the file descriptor.
|
|
|
0a122b |
+ */
|
|
|
0a122b |
+void coroutine_fn yield_until_fd_readable(int fd);
|
|
|
0a122b |
#endif /* QEMU_COROUTINE_H */
|
|
|
0a122b |
diff --git a/qemu-coroutine-io.c b/qemu-coroutine-io.c
|
|
|
0a122b |
index e8ad1a4..c4df35a 100644
|
|
|
0a122b |
--- a/qemu-coroutine-io.c
|
|
|
0a122b |
+++ b/qemu-coroutine-io.c
|
|
|
0a122b |
@@ -63,3 +63,26 @@ qemu_co_send_recv(int sockfd, void *buf, size_t bytes, bool do_send)
|
|
|
0a122b |
struct iovec iov = { .iov_base = buf, .iov_len = bytes };
|
|
|
0a122b |
return qemu_co_sendv_recvv(sockfd, &iov, 1, 0, bytes, do_send);
|
|
|
0a122b |
}
|
|
|
0a122b |
+
|
|
|
0a122b |
+typedef struct {
|
|
|
0a122b |
+ Coroutine *co;
|
|
|
0a122b |
+ int fd;
|
|
|
0a122b |
+} FDYieldUntilData;
|
|
|
0a122b |
+
|
|
|
0a122b |
+static void fd_coroutine_enter(void *opaque)
|
|
|
0a122b |
+{
|
|
|
0a122b |
+ FDYieldUntilData *data = opaque;
|
|
|
0a122b |
+ qemu_set_fd_handler(data->fd, NULL, NULL, NULL);
|
|
|
0a122b |
+ qemu_coroutine_enter(data->co, NULL);
|
|
|
0a122b |
+}
|
|
|
0a122b |
+
|
|
|
0a122b |
+void coroutine_fn yield_until_fd_readable(int fd)
|
|
|
0a122b |
+{
|
|
|
0a122b |
+ FDYieldUntilData data;
|
|
|
0a122b |
+
|
|
|
0a122b |
+ assert(qemu_in_coroutine());
|
|
|
0a122b |
+ data.co = qemu_coroutine_self();
|
|
|
0a122b |
+ data.fd = fd;
|
|
|
0a122b |
+ qemu_set_fd_handler(fd, fd_coroutine_enter, NULL, &data);
|
|
|
0a122b |
+ qemu_coroutine_yield();
|
|
|
0a122b |
+}
|
|
|
0a122b |
diff --git a/savevm.c b/savevm.c
|
|
|
0a122b |
index f68f7f2..9304788 100644
|
|
|
0a122b |
--- a/savevm.c
|
|
|
0a122b |
+++ b/savevm.c
|
|
|
0a122b |
@@ -149,34 +149,6 @@ typedef struct QEMUFileSocket
|
|
|
0a122b |
QEMUFile *file;
|
|
|
0a122b |
} QEMUFileSocket;
|
|
|
0a122b |
|
|
|
0a122b |
-typedef struct {
|
|
|
0a122b |
- Coroutine *co;
|
|
|
0a122b |
- int fd;
|
|
|
0a122b |
-} FDYieldUntilData;
|
|
|
0a122b |
-
|
|
|
0a122b |
-static void fd_coroutine_enter(void *opaque)
|
|
|
0a122b |
-{
|
|
|
0a122b |
- FDYieldUntilData *data = opaque;
|
|
|
0a122b |
- qemu_set_fd_handler(data->fd, NULL, NULL, NULL);
|
|
|
0a122b |
- qemu_coroutine_enter(data->co, NULL);
|
|
|
0a122b |
-}
|
|
|
0a122b |
-
|
|
|
0a122b |
-/**
|
|
|
0a122b |
- * Yield until a file descriptor becomes readable
|
|
|
0a122b |
- *
|
|
|
0a122b |
- * Note that this function clobbers the handlers for the file descriptor.
|
|
|
0a122b |
- */
|
|
|
0a122b |
-static void coroutine_fn yield_until_fd_readable(int fd)
|
|
|
0a122b |
-{
|
|
|
0a122b |
- FDYieldUntilData data;
|
|
|
0a122b |
-
|
|
|
0a122b |
- assert(qemu_in_coroutine());
|
|
|
0a122b |
- data.co = qemu_coroutine_self();
|
|
|
0a122b |
- data.fd = fd;
|
|
|
0a122b |
- qemu_set_fd_handler(fd, fd_coroutine_enter, NULL, &data);
|
|
|
0a122b |
- qemu_coroutine_yield();
|
|
|
0a122b |
-}
|
|
|
0a122b |
-
|
|
|
0a122b |
static ssize_t socket_writev_buffer(void *opaque, struct iovec *iov, int iovcnt,
|
|
|
0a122b |
int64_t pos)
|
|
|
0a122b |
{
|
|
|
0a122b |
--
|
|
|
0a122b |
1.7.11.7
|
|
|
0a122b |
|