From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56681) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XAfMs-0001h8-EP for qemu-devel@nongnu.org; Fri, 25 Jul 2014 09:17:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XAfMk-00064C-OB for qemu-devel@nongnu.org; Fri, 25 Jul 2014 09:17:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:2104) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XAfMk-00063t-Dq for qemu-devel@nongnu.org; Fri, 25 Jul 2014 09:16:54 -0400 From: Stefan Hajnoczi Date: Fri, 25 Jul 2014 14:16:43 +0100 Message-Id: <1406294206-26679-2-git-send-email-stefanha@redhat.com> In-Reply-To: <1406294206-26679-1-git-send-email-stefanha@redhat.com> References: <1406294206-26679-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PATCH v2 1/4] vl: add qemu_system_shutdown_force() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Andreas Faerber , Markus Armbruster The QEMU --no-shutdown option prevents guests from shutting down. There are several cases where shutdown should be forced, even if --no-shutdown was given. This patch adds an API for forcing shutdown. This cleans up the code and hides the extern int no_shutdown variable which is currently being touched in various files. Signed-off-by: Stefan Hajnoczi --- include/sysemu/sysemu.h | 2 +- qmp.c | 3 +-- ui/sdl.c | 3 +-- ui/sdl2.c | 6 ++---- vl.c | 11 ++++++++--- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index d8539fd..171d7d3 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -58,6 +58,7 @@ void qemu_system_wakeup_request(WakeupReason reason); 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_shutdown_force(void); void qemu_system_powerdown_request(void); void qemu_register_powerdown_notifier(Notifier *notifier); void qemu_system_debug_request(void); @@ -126,7 +127,6 @@ extern int max_cpus; extern int cursor_hide; extern int graphic_rotate; extern int no_quit; -extern int no_shutdown; extern int semihosting_enabled; extern int old_param; extern int boot_menu; diff --git a/qmp.c b/qmp.c index 0d2553a..cd4d6a7 100644 --- a/qmp.c +++ b/qmp.c @@ -86,8 +86,7 @@ UuidInfo *qmp_query_uuid(Error **errp) void qmp_quit(Error **errp) { - no_shutdown = 0; - qemu_system_shutdown_request(); + qemu_system_shutdown_force(); } void qmp_stop(Error **errp) diff --git a/ui/sdl.c b/ui/sdl.c index 4e7f920..7c3d91c 100644 --- a/ui/sdl.c +++ b/ui/sdl.c @@ -791,8 +791,7 @@ static void sdl_refresh(DisplayChangeListener *dcl) break; case SDL_QUIT: if (!no_quit) { - no_shutdown = 0; - qemu_system_shutdown_request(); + qemu_system_shutdown_force(); } break; case SDL_MOUSEMOTION: diff --git a/ui/sdl2.c b/ui/sdl2.c index fcac87b..f392528 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -711,8 +711,7 @@ static void handle_windowevent(DisplayChangeListener *dcl, SDL_Event *ev) break; case SDL_WINDOWEVENT_CLOSE: if (!no_quit) { - no_shutdown = 0; - qemu_system_shutdown_request(); + qemu_system_shutdown_force(); } break; } @@ -743,8 +742,7 @@ static void sdl_refresh(DisplayChangeListener *dcl) break; case SDL_QUIT: if (!no_quit) { - no_shutdown = 0; - qemu_system_shutdown_request(); + qemu_system_shutdown_force(); } break; case SDL_MOUSEMOTION: diff --git a/vl.c b/vl.c index fe451aa..c733e04 100644 --- a/vl.c +++ b/vl.c @@ -164,7 +164,7 @@ int acpi_enabled = 1; int no_hpet = 0; int fd_bootchk = 1; static int no_reboot; -int no_shutdown = 0; +static int no_shutdown = 0; int cursor_hide = 1; int graphic_rotate = 0; const char *watchdog; @@ -1915,8 +1915,7 @@ void qemu_system_killed(int signal, pid_t pid) { shutdown_signal = signal; shutdown_pid = pid; - no_shutdown = 0; - qemu_system_shutdown_request(); + qemu_system_shutdown_force(); } void qemu_system_shutdown_request(void) @@ -1926,6 +1925,12 @@ void qemu_system_shutdown_request(void) qemu_notify_event(); } +void qemu_system_shutdown_force(void) +{ + no_shutdown = 0; + qemu_system_shutdown_request(); +} + static void qemu_system_powerdown(void) { qapi_event_send_powerdown(&error_abort); -- 1.9.3