[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v10 07/19] multi-process: Initialize message handler in remote de
From: |
elena . ufimtseva |
Subject: |
[PATCH v10 07/19] multi-process: Initialize message handler in remote device |
Date: |
Mon, 5 Oct 2020 11:50:55 -0700 |
From: Jagannathan Raman <jag.raman@oracle.com>
Initializes the message handler function in the remote process. It is
called whenever there's an event pending on QIOChannel that registers
this function.
Signed-off-by: Elena Ufimtseva <elena.ufimtseva@oracle.com>
Signed-off-by: John G Johnson <john.g.johnson@oracle.com>
Signed-off-by: Jagannathan Raman <jag.raman@oracle.com>
---
MAINTAINERS | 1 +
hw/i386/meson.build | 1 +
hw/i386/remote-msg.c | 61 ++++++++++++++++++++++++++++++++++++++++
include/hw/i386/remote.h | 9 ++++++
4 files changed, 72 insertions(+)
create mode 100644 hw/i386/remote-msg.c
diff --git a/MAINTAINERS b/MAINTAINERS
index 1ca1f8ccff..9885c9499f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3047,6 +3047,7 @@ F: hw/i386/remote.c
F: include/hw/i386/remote.h
F: io/mpqemu-link.c
F: include/io/mpqemu-link.h
+F: hw/i386/remote-msg.c
Build and test automation
-------------------------
diff --git a/hw/i386/meson.build b/hw/i386/meson.build
index 1c1668c5db..238ae0879d 100644
--- a/hw/i386/meson.build
+++ b/hw/i386/meson.build
@@ -24,6 +24,7 @@ i386_ss.add(when: 'CONFIG_PC', if_true: files(
'acpi-build.c',
'port92.c'))
i386_ss.add(when: 'CONFIG_MPQEMU', if_true: files('remote.c'))
+i386_ss.add(when: 'CONFIG_MPQEMU', if_true: files('remote-msg.c'))
subdir('kvm')
subdir('xen')
diff --git a/hw/i386/remote-msg.c b/hw/i386/remote-msg.c
new file mode 100644
index 0000000000..83fd7bd852
--- /dev/null
+++ b/hw/i386/remote-msg.c
@@ -0,0 +1,61 @@
+/*
+ * Copyright © 2020 Oracle and/or its affiliates.
+ *
+ * This work is licensed under the terms of the GNU GPL-v2, version 2 or later.
+ *
+ * See the COPYING file in the top-level directory.
+ *
+ */
+
+#include "qemu/osdep.h"
+#include "qemu-common.h"
+
+#include "hw/i386/remote.h"
+#include "io/channel.h"
+#include "io/mpqemu-link.h"
+#include "qapi/error.h"
+#include "sysemu/runstate.h"
+
+void coroutine_fn mpqemu_remote_msg_loop_co(void *data)
+{
+ RemoteCommDev *com = (RemoteCommDev *)data;
+ PCIDevice *pci_dev = NULL;
+
+ pci_dev = com->dev;
+ for (;;) {
+ MPQemuMsg msg = {0};
+ Error *local_err = NULL;
+
+ if (!com->ioc) {
+ error_report("ERROR: No channel available");
+ break;
+ }
+ mpqemu_msg_recv(&msg, com->ioc, &local_err);
+ if (local_err) {
+ error_report_err(local_err);
+ break;
+ }
+
+ if (!mpqemu_msg_valid(&msg)) {
+ error_report("Received invalid message from proxy"
+ "in remote process pid=%d", getpid());
+ break;
+ }
+
+ switch (msg.cmd) {
+ default:
+ error_setg(&local_err,
+ "Unknown command (%d) received for device %s (pid=%d)",
+ msg.cmd, DEVICE(pci_dev)->id, getpid());
+ }
+
+ if (local_err) {
+ error_report_err(local_err);
+ qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
+ break;
+ }
+ }
+ qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
+
+ return;
+}
diff --git a/include/hw/i386/remote.h b/include/hw/i386/remote.h
index 5b36b25ca1..e21bd5f68f 100644
--- a/include/hw/i386/remote.h
+++ b/include/hw/i386/remote.h
@@ -14,6 +14,7 @@
#include "qom/object.h"
#include "hw/boards.h"
#include "hw/pci-host/remote.h"
+#include "io/channel.h"
typedef struct RemoteMachineState {
MachineState parent_obj;
@@ -21,8 +22,16 @@ typedef struct RemoteMachineState {
RemotePCIHost *host;
} RemoteMachineState;
+/* Used to pass to co-routine device and ioc. */
+typedef struct RemoteCommDev {
+ PCIDevice *dev;
+ QIOChannel *ioc;
+} RemoteCommDev;
+
#define TYPE_REMOTE_MACHINE "remote-machine"
#define REMOTE_MACHINE(obj) \
OBJECT_CHECK(RemoteMachineState, (obj), TYPE_REMOTE_MACHINE)
+void coroutine_fn mpqemu_remote_msg_loop_co(void *data);
+
#endif
--
2.25.GIT
- [PATCH v10 00/19] Initial support for multi-process Qemu, elena . ufimtseva, 2020/10/05
- [PATCH v10 06/19] multi-process: define MPQemuMsg format and transmission functions, elena . ufimtseva, 2020/10/05
- [PATCH v10 02/19] multi-process: Add config option for multi-process QEMU, elena . ufimtseva, 2020/10/05
- [PATCH v10 01/19] memory: alloc RAM from file at offset, elena . ufimtseva, 2020/10/05
- [PATCH v10 07/19] multi-process: Initialize message handler in remote device,
elena . ufimtseva <=
- [PATCH v10 03/19] multi-process: setup PCI host bridge for remote device, elena . ufimtseva, 2020/10/05
- [PATCH v10 05/19] multi-process: add qio channel function to transmit, elena . ufimtseva, 2020/10/05
- [PATCH v10 08/19] multi-process: Associate fd of a PCIDevice with its object, elena . ufimtseva, 2020/10/05
- [PATCH v10 09/19] multi-process: setup memory manager for remote device, elena . ufimtseva, 2020/10/05
- [PATCH v10 12/19] multi-process: Forward PCI config space acceses to the remote process, elena . ufimtseva, 2020/10/05
- [PATCH v10 10/19] multi-process: introduce proxy object, elena . ufimtseva, 2020/10/05
- [PATCH v10 14/19] multi-process: Synchronize remote memory, elena . ufimtseva, 2020/10/05