[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v11 07/19] multi-process: Initialize message handler in remote de
From: |
Jagannathan Raman |
Subject: |
[PATCH v11 07/19] multi-process: Initialize message handler in remote device |
Date: |
Thu, 15 Oct 2020 14:05:00 -0400 |
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>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.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 42b5da5..7314536 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3106,6 +3106,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 d9d4f40..3a2aa6e 100644
--- a/hw/i386/meson.build
+++ b/hw/i386/meson.build
@@ -25,6 +25,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 0000000..83fd7bd
--- /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 d312972..3073db6 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 "x-remote-machine"
#define REMOTE_MACHINE(obj) \
OBJECT_CHECK(RemoteMachineState, (obj), TYPE_REMOTE_MACHINE)
+void coroutine_fn mpqemu_remote_msg_loop_co(void *data);
+
#endif
--
1.8.3.1
- [PATCH v11 13/19] multi-process: PCI BAR read/write handling for proxy & remote endpoints, (continued)
- [PATCH v11 13/19] multi-process: PCI BAR read/write handling for proxy & remote endpoints, Jagannathan Raman, 2020/10/15
- [PATCH v11 05/19] multi-process: add qio channel function to transmit, Jagannathan Raman, 2020/10/15
- [PATCH v11 16/19] multi-process: Retrieve PCI info from remote process, Jagannathan Raman, 2020/10/15
- [PATCH v11 17/19] multi-process: perform device reset in the remote process, Jagannathan Raman, 2020/10/15
- [PATCH v11 14/19] multi-process: Synchronize remote memory, Jagannathan Raman, 2020/10/15
- [PATCH v11 19/19] multi-process: add configure and usage information, Jagannathan Raman, 2020/10/15
- [PATCH v11 15/19] multi-process: create IOHUB object to handle irq, Jagannathan Raman, 2020/10/15
- [PATCH v11 06/19] multi-process: define MPQemuMsg format and transmission functions, Jagannathan Raman, 2020/10/15
- [PATCH v11 07/19] multi-process: Initialize message handler in remote device,
Jagannathan Raman <=
- [PATCH v11 18/19] multi-process: add the concept description to docs/devel/qemu-multiprocess, Jagannathan Raman, 2020/10/15
- Re: [PATCH v11 00/19] Initial support for multi-process Qemu, Stefan Hajnoczi, 2020/10/23