From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:38973) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T9Mo2-0007qC-2b for qemu-devel@nongnu.org; Wed, 05 Sep 2012 17:06:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T9Mo0-0001hi-VJ for qemu-devel@nongnu.org; Wed, 05 Sep 2012 17:06:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:62869) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T9Mo0-0001he-MC for qemu-devel@nongnu.org; Wed, 05 Sep 2012 17:06:36 -0400 From: Igor Mammedov Date: Wed, 5 Sep 2012 23:06:21 +0200 Message-Id: <1346879185-19299-2-git-send-email-imammedo@redhat.com> In-Reply-To: <1346879185-19299-1-git-send-email-imammedo@redhat.com> References: <1346879185-19299-1-git-send-email-imammedo@redhat.com> Subject: [Qemu-devel] [PATCH 1/5] Introduce powerdown_notifiers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: peter.maydell@linaro.org, qemu-devel@nongnu.org Cc: aliguori@us.ibm.com, mst@redhat.com, jan.kiszka@siemens.com, lcapitulino@redhat.com, blauwirbel@gmail.com, alex.williamson@redhat.com, kraxel@redhat.com, pbonzini@redhat.com 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 --- sysemu.h | 1 + vl.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/sysemu.h b/sysemu.h index 65552ac..803c858 100644 --- 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 7c577fa..4893192 100644 --- 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)) { -- 1.7.11.4