[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH RESEND v6 16/36] multi-process: remote process initialization
From: |
elena . ufimtseva |
Subject: |
[PATCH RESEND v6 16/36] multi-process: remote process initialization |
Date: |
Wed, 22 Apr 2020 21:13:51 -0700 |
From: Jagannathan Raman <address@hidden>
Adds the handler to process message from QEMU,
Initialize remote process main loop, handles SYNC_SYSMEM
message by updating its "system_memory" container using
shared file descriptors received from QEMU.
Signed-off-by: John G Johnson <address@hidden>
Signed-off-by: Elena Ufimtseva <address@hidden>
Signed-off-by: Jagannathan Raman <address@hidden>
---
MAINTAINERS | 1 +
remote/remote-common.h | 21 +++++++++
remote/remote-main.c | 104 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 126 insertions(+)
create mode 100644 remote/remote-common.h
diff --git a/MAINTAINERS b/MAINTAINERS
index 98237fff62..96f8d7ff19 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2857,6 +2857,7 @@ M: John G Johnson <address@hidden>
S: Maintained
F: remote/Makefile.objs
F: remote/remote-main.c
+F: remote/remote-common.h
F: include/io/mpqemu-link.h
F: io/mpqemu-link.c
F: include/remote/pcihost.h
diff --git a/remote/remote-common.h b/remote/remote-common.h
new file mode 100644
index 0000000000..12c8d066cf
--- /dev/null
+++ b/remote/remote-common.h
@@ -0,0 +1,21 @@
+/*
+ * Remote device initialization
+ *
+ * Copyright © 2018, 2020 Oracle and/or its affiliates.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+#ifndef REMOTE_COMMON_H
+#define REMOTE_COMMON_H
+
+extern const char *__progname;
+
+#define PROC_INFO_LENGTH 1024
+gchar *print_pid_exec(gchar *str);
+
+#endif /* REMOTE_COMMON_H */
+
+
+
diff --git a/remote/remote-main.c b/remote/remote-main.c
index ecf30e0cba..dbd6ad2529 100644
--- a/remote/remote-main.c
+++ b/remote/remote-main.c
@@ -12,6 +12,7 @@
#include "qemu-common.h"
#include <stdio.h>
+#include <unistd.h>
#include "qemu/module.h"
#include "remote/pcihost.h"
@@ -19,12 +20,115 @@
#include "hw/boards.h"
#include "hw/qdev-core.h"
#include "qemu/main-loop.h"
+#include "remote/memory.h"
+#include "io/mpqemu-link.h"
+#include "qapi/error.h"
+#include "qemu/main-loop.h"
+#include "sysemu/cpus.h"
+#include "qemu-common.h"
+#include "hw/pci/pci.h"
+#include "qemu/thread.h"
+#include "qemu/main-loop.h"
+#include "qemu/config-file.h"
+#include "sysemu/sysemu.h"
+#include "block/block.h"
+#include "exec/ramlist.h"
+#include "remote/remote-common.h"
+
+static MPQemuLinkState *mpqemu_link;
+
+gchar *print_pid_exec(gchar *str)
+{
+ if (!str) {
+ return NULL;
+ }
+ memset(str, 0, PROC_INFO_LENGTH);
+ g_snprintf(str, PROC_INFO_LENGTH, "pid %d, exec name %s ",
+ getpid(), __progname);
+ return str;
+}
+
+static void process_msg(GIOCondition cond, MPQemuLinkState *link,
+ MPQemuChannel *chan)
+{
+ MPQemuMsg *msg = NULL;
+ Error *err = NULL;
+ g_autofree gchar *pid_exec = NULL;
+
+ pid_exec = g_malloc(PROC_INFO_LENGTH);
+
+ if ((cond & G_IO_HUP) || (cond & G_IO_ERR)) {
+ goto finalize_loop;
+ }
+
+ msg = g_malloc0(sizeof(MPQemuMsg));
+
+ if (mpqemu_msg_recv(msg, chan) < 0) {
+ error_setg(&err, "Failed to receive message in remote process %s",
+ print_pid_exec(pid_exec));
+ goto finalize_loop;
+ }
+
+ switch (msg->cmd) {
+ case INIT:
+ break;
+ default:
+ error_setg(&err, "Unknown command in %s", print_pid_exec(pid_exec));
+ goto finalize_loop;
+ }
+
+ g_free(msg->data2);
+ g_free(msg);
+
+ return;
+
+finalize_loop:
+ if (err) {
+ error_report_err(err);
+ }
+ g_free(msg);
+ mpqemu_link_finalize(mpqemu_link);
+ mpqemu_link = NULL;
+}
int main(int argc, char *argv[])
{
+ Error *err = NULL;
+
module_call_init(MODULE_INIT_QOM);
+ bdrv_init_with_whitelist();
+
+ if (qemu_init_main_loop(&err)) {
+ error_report_err(err);
+ return -EBUSY;
+ }
+
+ qemu_init_cpu_loop();
+
+ page_size_init();
+
+ qemu_mutex_init(&ram_list.mutex);
+
current_machine = MACHINE(REMOTE_MACHINE(object_new(TYPE_REMOTE_MACHINE)));
+ mpqemu_link = mpqemu_link_create();
+ if (!mpqemu_link) {
+ printf("Could not create MPQemu link pid %d, exec_name %s",
+ getpid(), __progname);
+ return -1;
+ }
+
+ mpqemu_init_channel(mpqemu_link, &mpqemu_link->com, STDIN_FILENO);
+
+ mpqemu_link_set_callback(mpqemu_link, process_msg);
+
+ qdev_machine_creation_done();
+ qemu_mutex_lock_iothread();
+ qemu_run_machine_init_done_notifiers();
+ qemu_mutex_unlock_iothread();
+
+ mpqemu_start_coms(mpqemu_link, mpqemu_link->com);
+
return 0;
}
--
2.25.GIT
- [PATCH RESEND v6 00/36] Initial support for multi-process qemu, elena . ufimtseva, 2020/04/23
- [PATCH RESEND v6 04/36] multi-process: Refactor chardev functions out of vl.c, elena . ufimtseva, 2020/04/23
- [PATCH RESEND v6 03/36] command-line: refractor parser code, elena . ufimtseva, 2020/04/23
- [PATCH RESEND v6 05/36] multi-process: Refactor monitor functions out of vl.c, elena . ufimtseva, 2020/04/23
- [PATCH RESEND v6 01/36] memory: alloc RAM from file at offset, elena . ufimtseva, 2020/04/23
- [PATCH RESEND v6 06/36] monitor: destaticize HMP commands, elena . ufimtseva, 2020/04/23
- [PATCH RESEND v6 09/36] multi-process: Add config option for multi-process QEMU, elena . ufimtseva, 2020/04/23
- [PATCH RESEND v6 07/36] multi-process: add a command line option for debug file, elena . ufimtseva, 2020/04/23
- [PATCH RESEND v6 13/36] multi-process: setup PCI host bridge for remote device, elena . ufimtseva, 2020/04/23
- [PATCH RESEND v6 15/36] multi-process: setup memory manager for remote device, elena . ufimtseva, 2020/04/23
- [PATCH RESEND v6 16/36] multi-process: remote process initialization,
elena . ufimtseva <=
- [PATCH RESEND v6 18/36] multi-process: Initialize Proxy Object's communication channel, elena . ufimtseva, 2020/04/23
- [PATCH RESEND v6 19/36] multi-process: Connect Proxy Object with device in the remote process, elena . ufimtseva, 2020/04/23
- [PATCH RESEND v6 21/36] multi-process: PCI BAR read/write handling for proxy & remote endpoints, elena . ufimtseva, 2020/04/23
- [PATCH RESEND v6 22/36] multi-process: Synchronize remote memory, elena . ufimtseva, 2020/04/23
- [PATCH RESEND v6 20/36] multi-process: Forward PCI config space acceses to the remote process, elena . ufimtseva, 2020/04/23
- [PATCH RESEND v6 23/36] multi-process: create IOHUB object to handle irq, elena . ufimtseva, 2020/04/23
- [PATCH RESEND v6 25/36] multi-process: Introduce build flags to separate remote process code, elena . ufimtseva, 2020/04/23
- [PATCH RESEND v6 27/36] multi-process: add support to parse device option, elena . ufimtseva, 2020/04/23
- [PATCH RESEND v6 29/36] multi-process: handle heartbeat messages in remote process, elena . ufimtseva, 2020/04/23
- [PATCH RESEND v6 30/36] multi-process: perform device reset in the remote process, elena . ufimtseva, 2020/04/23