The action variables are now used only within system/runstate.c. Move them and qmp_set_action() there, make the variables static, and remove runstate-action.c and its header.
Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]> --- MAINTAINERS | 1 - include/system/runstate-action.h | 19 ------------- monitor/qmp-cmds.c | 1 - system/meson.build | 1 - system/runstate-action.c | 46 -------------------------------- system/runstate.c | 34 ++++++++++++++++++++++- system/vl.c | 2 +- ui/cocoa.m | 1 - ui/sdl2.c | 1 - 9 files changed, 34 insertions(+), 72 deletions(-) delete mode 100644 include/system/runstate-action.h delete mode 100644 system/runstate-action.c diff --git a/MAINTAINERS b/MAINTAINERS index 7183babd6aa..2cee4c71b7a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3514,7 +3514,6 @@ M: Paolo Bonzini <[email protected]> S: Maintained F: include/qemu/main-loop.h F: include/system/runstate.h -F: include/system/runstate-action.h F: util/main-loop.c F: util/qemu-timer*.c F: system/vl.c diff --git a/include/system/runstate-action.h b/include/system/runstate-action.h deleted file mode 100644 index db4e3099ae5..00000000000 --- a/include/system/runstate-action.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2020 Oracle and/or its affiliates. - * - * This work is licensed under the terms of the GNU GPL, version 2. - * See the COPYING file in the top-level directory. - * - */ - -#ifndef RUNSTATE_ACTION_H -#define RUNSTATE_ACTION_H - -#include "qapi/qapi-commands-run-state.h" - -/* in system/runstate-action.c */ -extern RebootAction reboot_action; -extern ShutdownAction shutdown_action; -extern PanicAction panic_action; - -#endif /* RUNSTATE_ACTION_H */ diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index 6d0ba75ff16..f89237eb238 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -22,7 +22,6 @@ #include "system/system.h" #include "system/kvm.h" #include "system/runstate.h" -#include "system/runstate-action.h" #include "system/block-backend.h" #include "qapi/error.h" #include "qapi/qapi-init-commands.h" diff --git a/system/meson.build b/system/meson.build index 41e2e4a292d..dd4622ae08c 100644 --- a/system/meson.build +++ b/system/meson.build @@ -22,7 +22,6 @@ system_ss.add(files( 'qdev-monitor.c', 'qtest.c', 'rtc.c', - 'runstate-action.c', 'runstate.c', 'watchpoint.c', )) diff --git a/system/runstate-action.c b/system/runstate-action.c deleted file mode 100644 index f912bc837f2..00000000000 --- a/system/runstate-action.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Oracle and/or its affiliates. - * - * This work is licensed under the terms of the GNU GPL, version 2. - * See the COPYING file in the top-level directory. - * - */ - -#include "qemu/osdep.h" -#include "system/runstate-action.h" -#include "system/watchdog.h" -#include "qemu/config-file.h" -#include "qapi/error.h" -#include "qemu/option_int.h" - -RebootAction reboot_action = REBOOT_ACTION_RESET; -ShutdownAction shutdown_action = SHUTDOWN_ACTION_POWEROFF; -PanicAction panic_action = PANIC_ACTION_SHUTDOWN; - -/* - * Receives actions to be applied for specific guest events - * and sets the internal state as requested. - */ -void qmp_set_action(bool has_reboot, RebootAction reboot, - bool has_shutdown, ShutdownAction shutdown, - bool has_panic, PanicAction panic, - bool has_watchdog, WatchdogAction watchdog, - Error **errp) -{ - if (has_reboot) { - reboot_action = reboot; - } - - if (has_panic) { - panic_action = panic; - } - - if (has_watchdog) { - qmp_watchdog_set_action(watchdog, errp); - } - - /* Process shutdown last, in case the panic action needs to be altered */ - if (has_shutdown) { - shutdown_action = shutdown; - } -} diff --git a/system/runstate.c b/system/runstate.c index 5d10ff0df99..a5f16da975e 100644 --- a/system/runstate.c +++ b/system/runstate.c @@ -2,6 +2,7 @@ * QEMU main system emulation loop * * Copyright (c) 2003-2020 QEMU contributors + * Copyright (c) 2020 Oracle and/or its affiliates. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -58,7 +59,6 @@ #include "system/replay.h" #include "system/reset.h" #include "system/runstate.h" -#include "system/runstate-action.h" #include "system/confidential-guest-support.h" #include "system/system.h" #include "system/tpm.h" @@ -75,6 +75,10 @@ static RunState current_run_state = RUN_STATE_PRELAUNCH; static RunState vmstop_requested = RUN_STATE__MAX; static QemuMutex vmstop_lock; +static RebootAction reboot_action = REBOOT_ACTION_RESET; +static ShutdownAction shutdown_action = SHUTDOWN_ACTION_POWEROFF; +static PanicAction panic_action = PANIC_ACTION_SHUTDOWN; + typedef struct { RunState from; RunState to; @@ -277,6 +281,34 @@ StatusInfo *qmp_query_status(Error **errp) return info; } +/* + * Receives actions to be applied for specific guest events + * and sets the internal state as requested. + */ +void qmp_set_action(bool has_reboot, RebootAction reboot, + bool has_shutdown, ShutdownAction shutdown, + bool has_panic, PanicAction panic, + bool has_watchdog, WatchdogAction watchdog, + Error **errp) +{ + if (has_reboot) { + reboot_action = reboot; + } + + if (has_panic) { + panic_action = panic; + } + + if (has_watchdog) { + qmp_watchdog_set_action(watchdog, errp); + } + + /* Process shutdown last, in case the panic action needs to be altered */ + if (has_shutdown) { + shutdown_action = shutdown; + } +} + bool qemu_vmstop_requested(RunState *r) { qemu_mutex_lock(&vmstop_lock); diff --git a/system/vl.c b/system/vl.c index 9bd7664b85c..e1bb105514f 100644 --- a/system/vl.c +++ b/system/vl.c @@ -44,7 +44,6 @@ #include "qemu/uuid.h" #include "system/reset.h" #include "system/runstate.h" -#include "system/runstate-action.h" #include "system/seccomp.h" #include "system/tcg.h" #include "system/xen.h" @@ -136,6 +135,7 @@ #include "qapi/qapi-commands-block-core.h" #include "qapi/qapi-commands-migration.h" #include "qapi/qapi-commands-misc.h" +#include "qapi/qapi-commands-run-state.h" #include "qapi/qapi-visit-qom.h" #include "qapi/qapi-commands-ui.h" #include "block/qdict.h" diff --git a/ui/cocoa.m b/ui/cocoa.m index 5447fb637ad..94bb094ff13 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -37,7 +37,6 @@ #include "ui/kbd-state.h" #include "system/system.h" #include "system/runstate.h" -#include "system/runstate-action.h" #include "system/cpu-throttle.h" #include "qapi/error.h" #include "qapi/qapi-commands-block.h" diff --git a/ui/sdl2.c b/ui/sdl2.c index d647905a379..72ec8819fb1 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -30,7 +30,6 @@ #include "ui/input.h" #include "ui/sdl2.h" #include "system/runstate.h" -#include "system/runstate-action.h" #include "system/system.h" #include "qemu/log.h" #include "qemu-main.h" -- 2.43.0
