]> Git Repo - qemu.git/blobdiff - hw/watchdog/watchdog.c
util: move declarations out of qemu-common.h
[qemu.git] / hw / watchdog / watchdog.c
index c307f9b57e31b725f7f49b77fc2286305c47ff57..bbf3646bae9e5947ffe32b722e23436f66da6c5d 100644 (file)
@@ -19,7 +19,7 @@
  * By Richard W.M. Jones ([email protected]).
  */
 
-#include "qemu-common.h"
+#include "qemu/osdep.h"
 #include "qemu/option.h"
 #include "qemu/config-file.h"
 #include "qemu/queue.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/watchdog.h"
 #include "qapi-event.h"
-
-/* Possible values for action parameter. */
-#define WDT_RESET        1     /* Hard reset. */
-#define WDT_SHUTDOWN     2     /* Shutdown. */
-#define WDT_POWEROFF     3     /* Quit. */
-#define WDT_PAUSE        4     /* Pause. */
-#define WDT_DEBUG        5     /* Prints a message and continues running. */
-#define WDT_NONE         6     /* Do nothing. */
+#include "hw/nmi.h"
+#include "qemu/help_option.h"
 
 static int watchdog_action = WDT_RESET;
 static QLIST_HEAD(watchdog_list, WatchdogTimerModel) watchdog_list;
@@ -68,7 +62,7 @@ int select_watchdog(const char *p)
             /* add the device */
             opts = qemu_opts_create(qemu_find_opts("device"), NULL, 0,
                                     &error_abort);
-            qemu_opt_set(opts, "driver", p);
+            qemu_opt_set(opts, "driver", p, &error_abort);
             return 0;
         }
     }
@@ -95,12 +89,19 @@ int select_watchdog_action(const char *p)
         watchdog_action = WDT_DEBUG;
     else if (strcasecmp(p, "none") == 0)
         watchdog_action = WDT_NONE;
+    else if (strcasecmp(p, "inject-nmi") == 0)
+        watchdog_action = WDT_NMI;
     else
         return -1;
 
     return 0;
 }
 
+int get_watchdog_action(void)
+{
+    return watchdog_action;
+}
+
 /* This actually performs the "action" once a watchdog has expired,
  * ie. reboot, shutdown, exit, etc.
  */
@@ -138,5 +139,11 @@ void watchdog_perform_action(void)
     case WDT_NONE:
         qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_NONE, &error_abort);
         break;
+
+    case WDT_NMI:
+        qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_INJECT_NMI,
+                                 &error_abort);
+        inject_nmi();
+        break;
     }
 }
This page took 0.022859 seconds and 4 git commands to generate.