[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC v4 PATCH 08/49] multi-process: add functions to synchronize proxy a
From: |
Jagannathan Raman |
Subject: |
[RFC v4 PATCH 08/49] multi-process: add functions to synchronize proxy and remote endpoints |
Date: |
Thu, 24 Oct 2019 05:08:49 -0400 |
In some cases, for example MMIO read, QEMU has to wait for the remote to
complete a command before proceeding. An eventfd based mechanism is
added to synchronize QEMU & remote process.
Signed-off-by: John G Johnson <address@hidden>
Signed-off-by: Jagannathan Raman <address@hidden>
Signed-off-by: Elena Ufimtseva <address@hidden>
---
v1 -> v2:
- Added timeout to synchronization functions
include/io/mpqemu-link.h | 9 +++++++++
io/mpqemu-link.c | 40 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 49 insertions(+)
diff --git a/include/io/mpqemu-link.h b/include/io/mpqemu-link.h
index 345c67e..dee2dd3 100644
--- a/include/io/mpqemu-link.h
+++ b/include/io/mpqemu-link.h
@@ -30,7 +30,9 @@
#include <stddef.h>
#include <stdint.h>
+#include <unistd.h>
#include <pthread.h>
+#include <sys/eventfd.h>
#include "qom/object.h"
#include "qemu/thread.h"
@@ -147,4 +149,11 @@ void mpqemu_destroy_channel(MPQemuChannel *chan);
void mpqemu_link_set_callback(MPQemuLinkState *s, mpqemu_link_callback
callback);
void mpqemu_start_coms(MPQemuLinkState *s);
+#define GET_REMOTE_WAIT eventfd(0, 0)
+#define PUT_REMOTE_WAIT(wait) close(wait)
+#define PROXY_LINK_WAIT_DONE 1
+
+uint64_t wait_for_remote(int efd);
+void notify_proxy(int fd, uint64_t val);
+
#endif
diff --git a/io/mpqemu-link.c b/io/mpqemu-link.c
index b39f4d0..696aeb1 100644
--- a/io/mpqemu-link.c
+++ b/io/mpqemu-link.c
@@ -231,6 +231,46 @@ int mpqemu_msg_recv(MPQemuLinkState *s, MPQemuMsg *msg,
MPQemuChannel *chan)
return rc;
}
+uint64_t wait_for_remote(int efd)
+{
+ struct pollfd pfd = { .fd = efd, .events = POLLIN };
+ uint64_t val;
+ int ret;
+
+ ret = poll(&pfd, 1, 1000);
+
+ switch (ret) {
+ case 0:
+ qemu_log_mask(LOG_REMOTE_DEBUG, "Error wait_for_remote: Timed out\n");
+ /* TODO: Kick-off error recovery */
+ return ULLONG_MAX;
+ case -1:
+ qemu_log_mask(LOG_REMOTE_DEBUG, "Poll error wait_for_remote: %s\n",
+ strerror(errno));
+ return ULLONG_MAX;
+ default:
+ if (read(efd, &val, sizeof(val)) == -1) {
+ qemu_log_mask(LOG_REMOTE_DEBUG, "Error wait_for_remote: %s\n",
+ strerror(errno));
+ return ULLONG_MAX;
+ }
+ }
+
+ val = (val == ULLONG_MAX) ? val : (val - 1);
+
+ return val;
+}
+
+void notify_proxy(int efd, uint64_t val)
+{
+ val = (val == ULLONG_MAX) ? val : (val + 1);
+
+ if (write(efd, &val, sizeof(val)) == -1) {
+ qemu_log_mask(LOG_REMOTE_DEBUG, "Error notify_proxy: %s\n",
+ strerror(errno));
+ }
+}
+
static gboolean mpqemu_link_handler_prepare(GSource *gsrc, gint *timeout)
{
g_assert(timeout);
--
1.8.3.1
- [RFC v4 PATCH 36/49] multi-process/mon: enable QMP module support in the remote process, (continued)
- [RFC v4 PATCH 36/49] multi-process/mon: enable QMP module support in the remote process, Jagannathan Raman, 2019/10/24
- [RFC v4 PATCH 38/49] multi-process/mon: Initialize QMP module for remote processes, Jagannathan Raman, 2019/10/24
- [RFC v4 PATCH 37/49] multi-process/mon: Refactor monitor/chardev functions out of vl.c, Jagannathan Raman, 2019/10/24
- [RFC v4 PATCH 39/49] multi-process: prevent duplicate memory initialization in remote, Jagannathan Raman, 2019/10/24
- [RFC v4 PATCH 40/49] multi-process/mig: build migration module in the remote process, Jagannathan Raman, 2019/10/24
- [RFC v4 PATCH 41/49] multi-process/mig: Enable VMSD save in the Proxy object, Jagannathan Raman, 2019/10/24
- [RFC v4 PATCH 42/49] multi-process/mig: Send VMSD of remote to the Proxy object, Jagannathan Raman, 2019/10/24
- [RFC v4 PATCH 44/49] multi-process/mig: refactor runstate_check into common file, Jagannathan Raman, 2019/10/24
- [RFC v4 PATCH 45/49] multi-process/mig: Synchronize runstate of remote process, Jagannathan Raman, 2019/10/24
- [RFC v4 PATCH 47/49] multi-process: Enable support for multiple devices in remote, Jagannathan Raman, 2019/10/24
- [RFC v4 PATCH 08/49] multi-process: add functions to synchronize proxy and remote endpoints,
Jagannathan Raman <=
- [RFC v4 PATCH 07/49] multi-process: define mpqemu-link object, Jagannathan Raman, 2019/10/24
- [RFC v4 PATCH 49/49] multi-process: add configure and usage information, Jagannathan Raman, 2019/10/24
- [RFC v4 PATCH 48/49] multi-process: add the concept description to docs/devel/qemu-multiprocess, Jagannathan Raman, 2019/10/24
- [RFC v4 PATCH 12/49] multi-process: remote process initialization, Jagannathan Raman, 2019/10/24
- [RFC v4 PATCH 17/49] multi-process: Synchronize remote memory, Jagannathan Raman, 2019/10/24
- [RFC v4 PATCH 25/49] multi-process: Introduce build flags to separate remote process code, Jagannathan Raman, 2019/10/24
- [RFC v4 PATCH 29/49] multi-process: add parse_cmdline in remote process, Jagannathan Raman, 2019/10/24
- [RFC v4 PATCH 33/49] multi-process: perform device reset in the remote process, Jagannathan Raman, 2019/10/24
- [RFC v4 PATCH 43/49] multi-process/mig: Load VMSD in the proxy object, Jagannathan Raman, 2019/10/24