Signed-off-by: Paolo Bonzini <[email protected]>
---
meson.build | 16 +++--
softmmu/{vl.c => climain.c} | 2 +-
softmmu/meson.build | 1 -
softmmu/qmpmain.c | 120 ++++++++++++++++++++++++++++++++++++
4 files changed, 133 insertions(+), 6 deletions(-)
rename softmmu/{vl.c => climain.c} (99%)
create mode 100644 softmmu/qmpmain.c
diff --git a/meson.build b/meson.build
index 5f43355071..eed85d3d1a 100644
--- a/meson.build
+++ b/meson.build
@@ -3003,14 +3003,21 @@ foreach target : target_dirs
execs = [{
'name': 'qemu-system-' + target_name,
'win_subsystem': 'console',
- 'sources': files('softmmu/main.c'),
+ 'sources': [files('softmmu/climain.c', 'softmmu/main.c')],
'dependencies': []
}]
- if targetos == 'windows' and (sdl.found() or gtk.found())
+ if targetos != 'windows'
+ execs += [{
+ 'name': 'qemu-qmp-' + target_name,
+ 'win_subsystem': 'console',
+ 'sources': [files('softmmu/qmpmain.c', 'softmmu/main.c')],
+ 'dependencies': []
+ }]
+ elif sdl.found() or gtk.found()
execs += [{
'name': 'qemu-system-' + target_name + 'w',
'win_subsystem': 'windows',
- 'sources': files('softmmu/main.c'),
+ 'sources': [files('softmmu/climain.c', 'softmmu/main.c')],
'dependencies': []
}]
endif
@@ -3019,7 +3026,7 @@ foreach target : target_dirs
execs += [{
'name': 'qemu-fuzz-' + target_name,
'win_subsystem': 'console',
- 'sources': specific_fuzz.sources(),
+ 'sources': [files('softmmu/climain.c'), specific_fuzz.sources()],
'dependencies': specific_fuzz.dependencies(),
}]
endif
@@ -3040,6 +3047,7 @@ foreach target : target_dirs
emulator = executable(exe_name, exe['sources'],
install: true,
c_args: c_args,
+ include_directories: target_inc,
dependencies: arch_deps + deps + exe['dependencies'],
objects: lib.extract_all_objects(recursive: true),
link_language: link_language,
diff --git a/softmmu/vl.c b/softmmu/climain.c
similarity index 99%
rename from softmmu/vl.c
rename to softmmu/climain.c
index 5e1b35ba48..0489850415 100644
--- a/softmmu/vl.c
+++ b/softmmu/climain.c
@@ -1,5 +1,5 @@
/*
- * QEMU System Emulator
+ * QEMU System Emulator command-line interface
*
* Copyright (c) 2003-2008 Fabrice Bellard
*
diff --git a/softmmu/meson.build b/softmmu/meson.build
index d8e03018ab..d53673f8d2 100644
--- a/softmmu/meson.build
+++ b/softmmu/meson.build
@@ -12,7 +12,6 @@ specific_ss.add(when: 'CONFIG_SOFTMMU', if_true: [files(
'memory.c',
'memory_mapping.c',
'qtest.c',
- 'vl.c',
'cpu-timers.c',
'runstate-action.c',
)])
diff --git a/softmmu/qmpmain.c b/softmmu/qmpmain.c
new file mode 100644
index 0000000000..d976736ed9
--- /dev/null
+++ b/softmmu/qmpmain.c
@@ -0,0 +1,120 @@
+/*
+ * QEMU System Emulator machine interface
+ *
+ * Copyright (c) 2020 Red Hat, Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "qemu/rcu.h"
+#include "qemu-common.h"
+#include "chardev/char.h"
+#include "monitor/monitor.h"
+#include "qapi/error.h"
+#include "qapi/qapi-commands-misc.h"
+#include "qapi/qapi-commands-ui.h"
+#include "qapi/qapi-types-sockets.h"
+#include "qemu/systemd.h"
+#include "sysemu/cpu-timers.h"
+#include "sysemu/sysemu.h"
+#include "ui/console.h"
+#include "hw/qdev-core.h"
+
+static void open_socket_and_monitor(void)
+{
+ int nfds = check_socket_activation();
+ Chardev *chardev;
+ if (nfds > 1) {
+ error_report("QEMU only supports listening on one socket");
+ exit(1);
+ }
+ if (!nfds) {
+ ChardevBackend backend = {
+ .type = CHARDEV_BACKEND_KIND_STDIO,
+ .u.stdio.data = &(ChardevStdio) {
+ .has_signal = true,
+ .signal = false
+ }
+ };
+ chardev = qemu_chardev_new("#qmp0", TYPE_CHARDEV_STDIO, &backend,
NULL, &error_fatal);
+ } else {
+ ChardevBackend backend = {
+ .type = CHARDEV_BACKEND_KIND_SOCKET,
+ .u.socket.data = &(ChardevSocket) {
+ .addr = &(SocketAddressLegacy) {
+ .type = SOCKET_ADDRESS_TYPE_FD,
+ .u.fd.data = &(String){
+ .str = (char *) stringify(FIRST_SOCKET_ACTIVATION_FD)
+ }
+ }
+ }
+ };
+ chardev = qemu_chardev_new("#qmp0", TYPE_CHARDEV_SOCKET, &backend,
NULL, &error_fatal);
+ }
+ monitor_init_qmp(chardev, true, &error_fatal);
+}
+
+bool defaults_enabled(void)
+{
+ return false;
+}
+
+DisplayOptions *qmp_query_display_options(Error **errp)
+{
+ error_setg(errp, "You're running too fast!");
+ return NULL;
+}
+
+Chardev *serial_hd(int i)
+{
+ return NULL;
+}
+
+void qmp_x_exit_preconfig(Error **errp)
+{
+ error_setg(errp, "You're running too fast!");
+}
+
+void qemu_init(int argc, char **argv, char **envp)
+{
+ error_init(argv[0]);
+ qemu_init_exec_dir(argv[0]);
+
+ qemu_init_subsystems();
+
+ /* Missing: parse -name, -sandbox, -trace, -L */
+
+ /*
+ * Clear error location left behind by the loop.
+ * Best done right after the loop. Do not insert code here!
+ */
+ loc_set_none();
+
+ /* Missing: process -name, -sandbox, -trace, -L */
+
+ rcu_disable_atfork();
+ qemu_init_main_loop(&error_fatal);
+ cpu_timers_init();
+ open_socket_and_monitor();
+
+ /* Missing: replay_configure, configure_rtc */
+
+ /* machine-set:
+ * qemu_create_machine();
+ * qemu_apply_machine_options();
+ * phase_advance(PHASE_MACHINE_CREATED);
+ *
+ * accel-set:
+ * configure_accelerators(argv[0]);
+ * phase_advance(PHASE_ACCEL_CREATED);
+ * machine type deprecation
+ * migration_object_init();
+ * cpu_type...
+ * accel_setup_post(current_machine);
+ * machine_run_board_init(current_machine, errp);
+ */
+
+ init_displaystate();
+ os_setup_signal_handling();
+}
--
2.31.1