]> git.proxmox.com Git - qemu.git/commitdiff
Introduce powerdown_notifiers
authorIgor Mammedov <imammedo@redhat.com>
Wed, 5 Sep 2012 21:06:21 +0000 (23:06 +0200)
committerAnthony Liguori <aliguori@us.ibm.com>
Tue, 25 Sep 2012 23:37:41 +0000 (18:37 -0500)
Notifier will be used for signaling powerdown request to guest in
a more general way and intended to replace very specific
qemu_irq_rise(qemu_system_powerdown) and will allow to remove global
variable qemu_system_powerdown.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
sysemu.h
vl.c

index 65552acee5618807e75c41fda6c07aa89c12ff1a..803c8588cff1d0baa28f1c86ee6ccf9205f49d31 100644 (file)
--- a/sysemu.h
+++ b/sysemu.h
@@ -52,6 +52,7 @@ void qemu_system_wakeup_enable(WakeupReason reason, bool enabled);
 void qemu_register_wakeup_notifier(Notifier *notifier);
 void qemu_system_shutdown_request(void);
 void qemu_system_powerdown_request(void);
+void qemu_register_powerdown_notifier(Notifier *notifier);
 void qemu_system_debug_request(void);
 void qemu_system_vmstop_request(RunState reason);
 int qemu_shutdown_requested_get(void);
diff --git a/vl.c b/vl.c
index 48049ef0b6a97080bd290216a5cf417b900ff0f0..a65759ad5af09683ce0ca7ba2037c0ecc16113cf 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -1355,6 +1355,8 @@ static int powerdown_requested;
 static int debug_requested;
 static int suspend_requested;
 static int wakeup_requested;
+static NotifierList powerdown_notifiers =
+    NOTIFIER_LIST_INITIALIZER(powerdown_notifiers);
 static NotifierList suspend_notifiers =
     NOTIFIER_LIST_INITIALIZER(suspend_notifiers);
 static NotifierList wakeup_notifiers =
@@ -1569,6 +1571,11 @@ void qemu_system_powerdown_request(void)
     qemu_notify_event();
 }
 
+void qemu_register_powerdown_notifier(Notifier *notifier)
+{
+    notifier_list_add(&powerdown_notifiers, notifier);
+}
+
 void qemu_system_debug_request(void)
 {
     debug_requested = 1;
@@ -1620,6 +1627,7 @@ static bool main_loop_should_exit(void)
     }
     if (qemu_powerdown_requested()) {
         monitor_protocol_event(QEVENT_POWERDOWN, NULL);
+        notifier_list_notify(&powerdown_notifiers, NULL);
         qemu_irq_raise(qemu_system_powerdown);
     }
     if (qemu_vmstop_requested(&r)) {