aboutsummaryrefslogtreecommitdiff
path: root/softmmu/vl.c
diff options
context:
space:
mode:
authorAlexander Bulekov <alxndr@bu.edu>2020-02-19 23:10:58 -0500
committerStefan Hajnoczi <stefanha@redhat.com>2020-02-22 08:26:47 +0000
commit7b73386222626608f843ca4773426dce4ebcc73a (patch)
tree7022e65b90e98517f546c0b9b019c89a785f149f /softmmu/vl.c
parentbac068e0648c1f5c37f6a0a9423b8aa55e8c09c2 (diff)
softmmu: split off vl.c:main() into main.c
A program might rely on functions implemented in vl.c, but implement its own main(). By placing main into a separate source file, there are no complaints about duplicate main()s when linking against vl.o. For example, the virtual-device fuzzer uses a main() provided by libfuzzer, and needs to perform some initialization before running the softmmu initialization. Now, main simply calls three vl.c functions which handle the guest initialization, main loop and cleanup. Signed-off-by: Alexander Bulekov <alxndr@bu.edu> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Darren Kenny <darren.kenny@oracle.com> Message-id: 20200220041118.23264-3-alxndr@bu.edu Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'softmmu/vl.c')
-rw-r--r--softmmu/vl.c36
1 files changed, 9 insertions, 27 deletions
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 794f2e5733..080d3b5106 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -36,25 +36,6 @@
#include "sysemu/seccomp.h"
#include "sysemu/tcg.h"
-#ifdef CONFIG_SDL
-#if defined(__APPLE__) || defined(main)
-#include <SDL.h>
-int qemu_main(int argc, char **argv, char **envp);
-int main(int argc, char **argv)
-{
- return qemu_main(argc, argv, NULL);
-}
-#undef main
-#define main qemu_main
-#endif
-#endif /* CONFIG_SDL */
-
-#ifdef CONFIG_COCOA
-#undef main
-#define main qemu_main
-#endif /* CONFIG_COCOA */
-
-
#include "qemu/error-report.h"
#include "qemu/sockets.h"
#include "sysemu/accel.h"
@@ -1670,7 +1651,7 @@ static bool main_loop_should_exit(void)
return false;
}
-static void main_loop(void)
+void qemu_main_loop(void)
{
#ifdef CONFIG_PROFILER
int64_t ti;
@@ -2805,7 +2786,7 @@ static void configure_accelerators(const char *progname)
}
}
-int main(int argc, char **argv, char **envp)
+void qemu_init(int argc, char **argv, char **envp)
{
int i;
int snapshot, linux_boot;
@@ -3357,7 +3338,7 @@ int main(int argc, char **argv, char **envp)
case QEMU_OPTION_watchdog:
if (watchdog) {
error_report("only one watchdog option may be given");
- return 1;
+ exit(1);
}
watchdog = optarg;
break;
@@ -4269,7 +4250,7 @@ int main(int argc, char **argv, char **envp)
parse_numa_opts(current_machine);
/* do monitor/qmp handling at preconfig state if requested */
- main_loop();
+ qemu_main_loop();
audio_init_audiodevs();
@@ -4387,7 +4368,7 @@ int main(int argc, char **argv, char **envp)
if (vmstate_dump_file) {
/* dump and exit */
dump_vmstate_json_to_file(vmstate_dump_file);
- return 0;
+ exit(0);
}
if (incoming) {
@@ -4404,8 +4385,11 @@ int main(int argc, char **argv, char **envp)
accel_setup_post(current_machine);
os_setup_post();
- main_loop();
+ return;
+}
+void qemu_cleanup(void)
+{
gdbserver_cleanup();
/*
@@ -4442,6 +4426,4 @@ int main(int argc, char **argv, char **envp)
qemu_chr_cleanup();
user_creatable_cleanup();
/* TODO: unref root container, check all devices are ok */
-
- return 0;
}