runstate-action.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright (c) 2020 Oracle and/or its affiliates.
  3. *
  4. * This work is licensed under the terms of the GNU GPL, version 2.
  5. * See the COPYING file in the top-level directory.
  6. *
  7. */
  8. #include "qemu/osdep.h"
  9. #include "system/runstate-action.h"
  10. #include "system/watchdog.h"
  11. #include "qemu/config-file.h"
  12. #include "qapi/error.h"
  13. #include "qemu/option_int.h"
  14. RebootAction reboot_action = REBOOT_ACTION_RESET;
  15. ShutdownAction shutdown_action = SHUTDOWN_ACTION_POWEROFF;
  16. PanicAction panic_action = PANIC_ACTION_SHUTDOWN;
  17. /*
  18. * Receives actions to be applied for specific guest events
  19. * and sets the internal state as requested.
  20. */
  21. void qmp_set_action(bool has_reboot, RebootAction reboot,
  22. bool has_shutdown, ShutdownAction shutdown,
  23. bool has_panic, PanicAction panic,
  24. bool has_watchdog, WatchdogAction watchdog,
  25. Error **errp)
  26. {
  27. if (has_reboot) {
  28. reboot_action = reboot;
  29. }
  30. if (has_panic) {
  31. panic_action = panic;
  32. }
  33. if (has_watchdog) {
  34. qmp_watchdog_set_action(watchdog, errp);
  35. }
  36. /* Process shutdown last, in case the panic action needs to be altered */
  37. if (has_shutdown) {
  38. shutdown_action = shutdown;
  39. }
  40. }