summaryrefslogtreecommitdiff
path: root/vl.c
diff options
context:
space:
mode:
authorGleb Natapov <gleb@redhat.com>2011-03-15 13:56:04 +0200
committerBlue Swirl <blauwirbel@gmail.com>2011-03-26 12:54:42 +0000
commitf64622c401d4975a56b8559e16286231a1d2cfb8 (patch)
tree20912e758f2b1a3be545af99215ef8a7276ac466 /vl.c
parentbf6b87a883f4067574764acb76024e34abba4aad (diff)
downloadqemu-f64622c401d4975a56b8559e16286231a1d2cfb8.zip
report that QEMU process was killed by a signal
Currently when rogue script kills QEMU process (using TERM/INT/HUP signal) it looks indistinguishable from system shutdown. Lets report that QEMU was killed and leave some clues about the killer identity. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'vl.c')
-rw-r--r--vl.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/vl.c b/vl.c
index c387f2b1ff..192a240b52 100644
--- a/vl.c
+++ b/vl.c
@@ -1215,7 +1215,8 @@ typedef struct QEMUResetEntry {
static QTAILQ_HEAD(reset_handlers, QEMUResetEntry) reset_handlers =
QTAILQ_HEAD_INITIALIZER(reset_handlers);
static int reset_requested;
-static int shutdown_requested;
+static int shutdown_requested, shutdown_signal = -1;
+static pid_t shutdown_pid;
static int powerdown_requested;
static int debug_requested;
static int vmstop_requested;
@@ -1227,6 +1228,15 @@ int qemu_shutdown_requested(void)
return r;
}
+void qemu_kill_report(void)
+{
+ if (shutdown_signal != -1) {
+ fprintf(stderr, "Got signal %d from pid %d\n",
+ shutdown_signal, shutdown_pid);
+ shutdown_signal = -1;
+ }
+}
+
int qemu_reset_requested(void)
{
int r = reset_requested;
@@ -1300,6 +1310,13 @@ void qemu_system_reset_request(void)
qemu_notify_event();
}
+void qemu_system_killed(int signal, pid_t pid)
+{
+ shutdown_signal = signal;
+ shutdown_pid = pid;
+ qemu_system_shutdown_request();
+}
+
void qemu_system_shutdown_request(void)
{
shutdown_requested = 1;
@@ -1443,6 +1460,7 @@ static void main_loop(void)
vm_stop(VMSTOP_DEBUG);
}
if (qemu_shutdown_requested()) {
+ qemu_kill_report();
monitor_protocol_event(QEVENT_SHUTDOWN, NULL);
if (no_shutdown) {
vm_stop(VMSTOP_SHUTDOWN);