From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Andreas Faerber <afaerber@suse.de>,
Markus Armbruster <armbru@redhat.com>
Subject: [Qemu-devel] [PATCH v2 1/4] vl: add qemu_system_shutdown_force()
Date: Fri, 25 Jul 2014 14:16:43 +0100 [thread overview]
Message-ID: <1406294206-26679-2-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1406294206-26679-1-git-send-email-stefanha@redhat.com>
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 <stefanha@redhat.com>
---
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
next prev parent reply other threads:[~2014-07-25 13:17 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-25 13:16 [Qemu-devel] [PATCH v2 0/4] libqtest: solve QEMU process cleanup problem Stefan Hajnoczi
2014-07-25 13:16 ` Stefan Hajnoczi [this message]
2014-07-25 13:16 ` [Qemu-devel] [PATCH v2 2/4] libqemustub: add qemu_system_shutdown_force() Stefan Hajnoczi
2014-07-25 13:16 ` [Qemu-devel] [PATCH v2 3/4] qemu-char: add -chardev exit-on-eof option Stefan Hajnoczi
2014-07-28 21:21 ` Eric Blake
2014-07-25 13:16 ` [Qemu-devel] [PATCH v2 4/4] libqtest: use -chardev exit-on-eof to clean up QEMU Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1406294206-26679-2-git-send-email-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=afaerber@suse.de \
--cc=armbru@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).