diff mbox

qemu-kvm guest shutdown on signal -- patch

Message ID 233e0fa20912100333s38992cb0w2f956016049b5b3@mail.gmail.com
State New
Headers show

Commit Message

Jan Psota Dec. 10, 2009, 11:33 a.m. UTC
It would be useful if you include this addition to qemu code.
I often use Windows on virtual qemu machines and I think that there is
no more elegant way to shut them down (any other OS too!), than by
killing qemu with signal it does not use for other purposes.

// termsig_handler() is not consistent with other _handler names,
// it would look better as sigterm_handler()

--
Jan Psota
diff mbox

Patch

--- vl.c.orig	2009-09-23 09:30:02.000000000 +0200
+++ vl.c	2009-12-08 21:31:57.275033029 +0100
@@ -4742,6 +4742,11 @@ 
     qemu_system_shutdown_request();
 }
 
+static void sigquit_handler(int signal)
+{
+    qemu_system_powerdown_request();
+}
+
 static void sigchld_handler(int signal)
 {
     waitpid(-1, NULL, WNOHANG);
@@ -4757,6 +4762,9 @@ 
     sigaction(SIGHUP,  &act, NULL);
     sigaction(SIGTERM, &act, NULL);
 
+    act.sa_handler = sigquit_handler;
+    sigaction(SIGQUIT, &act, NULL);
+
     act.sa_handler = sigchld_handler;
     act.sa_flags = SA_NOCLDSTOP;
     sigaction(SIGCHLD, &act, NULL);