From: Jan Kiszka <jan.kiszka-kv7WeFo6aLtBDgjK7y7TUQ@public.gmane.org>
To: Guido Guenther
<public-agx-wGvLLbajjwFAfugRpC6u6w-1dZseelyfdZg9hUCZPvPmw@public.gmane.org>
Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
Jun Koi
<public-public-junkoi2004-Re5JQEeQqe8AvxtiuMwx3w-z5DuStaUktnZ+VzJOa5vwg-1dZseelyfdZg9hUCZPvPmw@public.gmane.org>
Subject: Re: [PATCH] add acpi powerbutton support
Date: Mon, 21 Jan 2008 11:00:42 +0100 [thread overview]
Message-ID: <47946D4A.5000808@siemens.com> (raw)
In-Reply-To: <20080120115617.GA31618-DVvpyRRQz99DDGxTMhc9XQ@public.gmane.org>
Hi Guido,
[posting via gmane sucks, just re-enabled mail delivery in this account...]
Guido Guenther wrote:
> Hi Jan,
> On Sat, Jan 19, 2008 at 04:40:06PM +0100, Jan Kiszka wrote:
>> What about additionally listening on signals? If you run qemu from the
>> console, you can then just press ctrl-c to shut the guest down (instead
> Catching ctrl-c sounds like a good idea but "ctrl-c, ctrl-c" should
> probably kill qemu then, since the machine might have no acpid running -
> in that case hitting ctrl-c would have no effect.
Good idea.
>
>> of killing it that way). The same happens on host shutdown (if the guest
>> is faster than the host's grace period before SIGKILL...).
>
>> + signal(SIGINT, qemu_powerdown_sighand);
>> + signal(SIGTERM, qemu_powerdown_sighand);
> We shouldn't catch SIGTERM here since libvirt uses it for
> domainDestroy() (in contrast to domainShutdown() which uses
> system_powerdown).
Something like this? I also included the SDL window this time, and at
least I like it this way now :->
Jan
--
Siemens AG, Corporate Technology, CT SE 2
Corporate Competence Center Embedded Linux
---
qemu/sdl.c | 2 +-
qemu/sysemu.h | 2 +-
qemu/vl.c | 21 ++++++++++++++++++++-
3 files changed, 22 insertions(+), 3 deletions(-)
Index: b/qemu/vl.c
===================================================================
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -7653,9 +7653,21 @@ void qemu_system_shutdown_request(void)
cpu_interrupt(cpu_single_env, CPU_INTERRUPT_EXIT);
}
+/* more than one requests within 2 s => hard powerdown */
+#define HARD_POWERDOWN_WINDOW 2
+
void qemu_system_powerdown_request(void)
{
- powerdown_requested = 1;
+ static time_t last_request;
+ time_t now, delta;
+
+ now = time(NULL);
+ delta = now-last_request;
+ last_request = now;
+ if (delta < 0 || delta > HARD_POWERDOWN_WINDOW)
+ powerdown_requested = 1;
+ else
+ shutdown_requested = 1;
if (cpu_single_env)
cpu_interrupt(cpu_single_env, CPU_INTERRUPT_EXIT);
}
@@ -8501,6 +8513,11 @@ void qemu_get_launch_info(int *argc, cha
*opt_incoming = incoming;
}
+void qemu_powerdown_sighand(int signal)
+{
+ qemu_system_powerdown_request();
+}
+
int main(int argc, char **argv)
{
#ifdef CONFIG_GDBSTUB
@@ -9475,6 +9492,8 @@ int main(int argc, char **argv)
}
}
+ signal(SIGINT, qemu_powerdown_sighand);
+
machine->init(ram_size, vga_ram_size, boot_devices, ds,
kernel_filename, kernel_cmdline, initrd_filename, cpu_model);
Index: b/qemu/sysemu.h
===================================================================
--- a/qemu/sysemu.h
+++ b/qemu/sysemu.h
@@ -35,7 +35,7 @@ int qemu_reset_requested(void);
int qemu_powerdown_requested(void);
#if !defined(TARGET_SPARC) && !defined(TARGET_I386)
// Please implement a power failure function to signal the OS
-#define qemu_system_powerdown() do{}while(0)
+#define qemu_system_powerdown() exit(0)
#else
void qemu_system_powerdown(void);
#endif
Index: b/qemu/sdl.c
===================================================================
--- a/qemu/sdl.c
+++ b/qemu/sdl.c
@@ -469,7 +469,7 @@ static void sdl_refresh(DisplayState *ds
break;
case SDL_QUIT:
if (!no_quit) {
- qemu_system_shutdown_request();
+ qemu_system_powerdown_request();
vm_start(); /* In case we're paused */
}
break;
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
next prev parent reply other threads:[~2008-01-21 10:00 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-03 18:11 [PATCH] system_powerdown via acpi power button Guido Guenther
[not found] ` <20080103181132.GA1077-DVvpyRRQz99DDGxTMhc9XQ@public.gmane.org>
2008-01-03 18:14 ` acpi sci polarity Guido Guenther
[not found] ` <20080103181415.GB1077-DVvpyRRQz99DDGxTMhc9XQ@public.gmane.org>
2008-01-03 21:17 ` Avi Kivity
[not found] ` <477D50FE.4040104-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2008-01-04 18:31 ` Guido Guenther
[not found] ` <20080104183158.GA14002-DVvpyRRQz99DDGxTMhc9XQ@public.gmane.org>
2008-01-06 9:08 ` Avi Kivity
[not found] ` <47809A8F.5090803-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2008-01-07 11:59 ` Guido Guenther
[not found] ` <20080107115916.GA24050-DVvpyRRQz99DDGxTMhc9XQ@public.gmane.org>
2008-01-07 12:02 ` [PATCH] add acpi powerbutton support Guido Guenther
[not found] ` <20080107120223.GB24050-DVvpyRRQz99DDGxTMhc9XQ@public.gmane.org>
2008-01-07 12:44 ` Avi Kivity
[not found] ` <47821EC8.4020308-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2008-01-08 4:34 ` Jun Koi
[not found] ` <fdaac4d50801072034p7f047495jd4be276c20623be3-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-01-08 8:09 ` Guido Guenther
[not found] ` <20080108080928.GA9823-DVvpyRRQz99DDGxTMhc9XQ@public.gmane.org>
2008-01-19 15:40 ` Jan Kiszka
[not found] ` <479219D6.1000707-S0/GAf8tV78@public.gmane.org>
2008-01-20 11:56 ` Guido Guenther
[not found] ` <20080120115617.GA31618-DVvpyRRQz99DDGxTMhc9XQ@public.gmane.org>
2008-01-21 10:00 ` Jan Kiszka [this message]
[not found] ` <47946D4A.5000808-kv7WeFo6aLtBDgjK7y7TUQ@public.gmane.org>
2008-01-21 10:47 ` Avi Kivity
[not found] ` <47947857.4020004-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2008-01-21 11:35 ` Jan Kiszka
[not found] ` <47948376.9000105-kv7WeFo6aLtBDgjK7y7TUQ@public.gmane.org>
2008-01-21 12:52 ` Avi Kivity
2008-01-22 9:48 ` Gerd Hoffmann
[not found] ` <4795BBE3.5060609-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2008-01-22 10:06 ` Jan Kiszka
2008-01-08 8:50 ` Avi Kivity
[not found] ` <47833938.1020609-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2008-01-09 18:00 ` Guido Guenther
[not found] ` <20080109180001.GA11240-DVvpyRRQz99DDGxTMhc9XQ@public.gmane.org>
2008-01-13 9:35 ` Avi Kivity
[not found] ` <4789DB74.5070901-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2008-01-13 13:48 ` Avi Kivity
[not found] ` <478A1694.1010307-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2008-01-14 10:23 ` Guido Guenther
[not found] ` <20080114102326.GB8987-DVvpyRRQz99DDGxTMhc9XQ@public.gmane.org>
2008-01-14 17:34 ` Avi Kivity
2008-01-18 22:20 ` Avi Kivity
[not found] ` <47912648.4030101-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2008-01-19 14:04 ` Guido Guenther
2008-01-14 10:21 ` Guido Guenther
2008-01-14 12:41 ` Alexey Eremenko
[not found] ` <64F9B87B6B770947A9F8391472E032160C95C641-yEcIvxbTEBqsx+V+t5oei8rau4O3wl8o3fe8/T/H7NteoWH0uzbU5w@public.gmane.org>
2008-01-14 13:30 ` Guido Guenther
2008-01-22 10:11 ` [PATCH] system_powerdown via acpi power button Jan Kiszka
[not found] ` <4795C134.7030400-kv7WeFo6aLtBDgjK7y7TUQ@public.gmane.org>
2008-01-22 11:49 ` Guido Guenther
[not found] ` <20080122114955.GA28335-DVvpyRRQz99DDGxTMhc9XQ@public.gmane.org>
2008-01-22 12:12 ` Jan Kiszka
[not found] ` <4795DD9C.3040804-kv7WeFo6aLtBDgjK7y7TUQ@public.gmane.org>
2008-01-24 12:37 ` Guido Guenther
[not found] ` <20080124123730.GA4527-DVvpyRRQz99DDGxTMhc9XQ@public.gmane.org>
2008-01-24 12:41 ` Avi Kivity
[not found] ` <47988797.8040208-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2008-01-24 12:50 ` Gerd Hoffmann
[not found] ` <479889B1.6030403-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2008-01-24 12:54 ` Avi Kivity
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=47946D4A.5000808@siemens.com \
--to=jan.kiszka-kv7wefo6altbdgjk7y7tuq@public.gmane.org \
--cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
--cc=public-agx-wGvLLbajjwFAfugRpC6u6w-1dZseelyfdZg9hUCZPvPmw@public.gmane.org \
--cc=public-public-junkoi2004-Re5JQEeQqe8AvxtiuMwx3w-z5DuStaUktnZ+VzJOa5vwg-1dZseelyfdZg9hUCZPvPmw@public.gmane.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