aboutsummaryrefslogtreecommitdiffstats
path: root/vl.c
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2010-03-17 17:44:48 -0500
committerAnthony Liguori <aliguori@us.ibm.com>2010-03-19 15:27:38 -0500
commit3b6304f706ef7eebc0b3b3f3a5093ec75448ee19 (patch)
tree963d3fe64dab594aacd2b89c1cb92315d836fc3f /vl.c
parent3af12c86d9db42c826dc9a7577b657543baf7fab (diff)
Add exit notifiers
Like atexit() but with state Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'vl.c')
-rw-r--r--vl.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/vl.c b/vl.c
index d69250ca2..183ec32a9 100644
--- a/vl.c
+++ b/vl.c
@@ -150,6 +150,7 @@ int main(int argc, char **argv)
#include "qemu-option.h"
#include "qemu-config.h"
#include "qemu-objects.h"
+#include "notify.h"
#include "disas.h"
@@ -553,6 +554,32 @@ static int socket_init(void)
}
#endif
+/*********************/
+/* Exit notifiers */
+/*********************/
+
+static NotifierList exit_notifiers = NOTIFIER_LIST_INITIALIZER(exit_notifiers);
+
+void exit_notifier_add(Notifier *notifier)
+{
+ notifier_list_add(&exit_notifiers, notifier);
+}
+
+void exit_notifier_remove(Notifier *notifier)
+{
+ notifier_list_remove(&exit_notifiers, notifier);
+}
+
+static void exit_notifier_notify(void)
+{
+ notifier_list_notify(&exit_notifiers);
+}
+
+static void exit_notifier_init(void)
+{
+ atexit(exit_notifier_notify);
+}
+
/***********************************************************/
/* Bluetooth support */
static int nb_hcis;