Skip to contentSkip to conversation

qemu-kvm guest shutdown on signal -- patch

Qemu-devel Jan Psota 1 participant 1 message Dec 10, 2009

lore
Share & tools
lore

Jan Psota

author
#0 lore raw

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

vl.c renamed from vl.c.orig +8 -0
@@ -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);