[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 08/50] multi-process: add functions to synchronize proxy and r
From: |
Jagannathan Raman |
Subject: |
[PATCH v5 08/50] multi-process: add functions to synchronize proxy and remote endpoints |
Date: |
Mon, 24 Feb 2020 15:54:59 -0500 |
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>
---
include/io/mpqemu-link.h | 7 +++++++
io/mpqemu-link.c | 41 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 48 insertions(+)
diff --git a/include/io/mpqemu-link.h b/include/io/mpqemu-link.h
index 2f2dd83..ae04fca 100644
--- a/include/io/mpqemu-link.h
+++ b/include/io/mpqemu-link.h
@@ -135,4 +135,11 @@ void mpqemu_link_set_callback(MPQemuLinkState *s,
mpqemu_link_callback callback);
void mpqemu_start_coms(MPQemuLinkState *s);
+#define GET_REMOTE_WAIT eventfd(0, EFD_CLOEXEC)
+#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 bac120b..73b7032 100644
--- a/io/mpqemu-link.c
+++ b/io/mpqemu-link.c
@@ -10,6 +10,7 @@
#include "qemu/osdep.h"
#include "qemu-common.h"
+#include <poll.h>
#include "qemu/module.h"
#include "io/mpqemu-link.h"
@@ -216,6 +217,46 @@ int mpqemu_msg_recv(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
- [PATCH v5 00/50] Initial support for multi-process qemu, Jagannathan Raman, 2020/02/24
- [PATCH v5 02/50] multi-process: Refactor machine_init and exit notifiers, Jagannathan Raman, 2020/02/24
- [PATCH v5 03/50] multi-process: add a command line option for debug file, Jagannathan Raman, 2020/02/24
- [PATCH v5 01/50] multi-process: memory: alloc RAM from file at offset, Jagannathan Raman, 2020/02/24
- [PATCH v5 05/50] multi-process: Add config option for multi-process QEMU, Jagannathan Raman, 2020/02/24
- [PATCH v5 07/50] multi-process: define mpqemu-link object, Jagannathan Raman, 2020/02/24
- [PATCH v5 09/50] multi-process: setup PCI host bridge for remote device, Jagannathan Raman, 2020/02/24
- [PATCH v5 06/50] multi-process: build system for remote device process, Jagannathan Raman, 2020/02/24
- [PATCH v5 08/50] multi-process: add functions to synchronize proxy and remote endpoints,
Jagannathan Raman <=
- [PATCH v5 11/50] multi-process: setup memory manager for remote device, Jagannathan Raman, 2020/02/24
- [PATCH v5 10/50] multi-process: setup a machine object for remote device process, Jagannathan Raman, 2020/02/24
- [PATCH v5 12/50] multi-process: remote process initialization, Jagannathan Raman, 2020/02/24
- [PATCH v5 14/50] mutli-process: build remote command line args, Jagannathan Raman, 2020/02/24
- [PATCH v5 13/50] multi-process: introduce proxy object, Jagannathan Raman, 2020/02/24
- [PATCH v5 15/50] multi-process: PCI BAR read/write handling for proxy & remote endpoints, Jagannathan Raman, 2020/02/24
- [PATCH v5 16/50] multi-process: Synchronize remote memory, Jagannathan Raman, 2020/02/24
- [PATCH v5 18/50] multi-process: configure remote side devices, Jagannathan Raman, 2020/02/24
- [PATCH v5 17/50] multi-process: create IOHUB object to handle irq, Jagannathan Raman, 2020/02/24
- [PATCH v5 20/50] multi-process: add qdev_proxy_add to create proxy devices, Jagannathan Raman, 2020/02/24