qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] Use SIGALRM even for timers delivered over a fd


From: Anders Melchiorsen
Subject: [Qemu-devel] [PATCH] Use SIGALRM even for timers delivered over a fd
Date: Sun, 20 Apr 2008 11:20:28 +0200

This ensures that all timers use the same signal, no
matter how the underlying timer is implemented. It also
frees up SIGIO for real I/O events.

The patch is only relevant for Linux, hpet and rtc timers.

Signed-off-by: Anders Melchiorsen <address@hidden>

diff --git a/vl.c b/vl.c
index 78486cf..ad4f6ef 100644
--- a/vl.c
+++ b/vl.c
@@ -1241,7 +1241,7 @@ static uint64_t qemu_next_deadline(void)
 
 #define RTC_FREQ 1024
 
-static void enable_sigio_timer(int fd)
+static void enable_sigalrm(int fd)
 {
     struct sigaction act;
 
@@ -1250,8 +1250,9 @@ static void enable_sigio_timer(int fd)
     act.sa_flags = 0;
     act.sa_handler = host_alarm_handler;
 
-    sigaction(SIGIO, &act, NULL);
+    sigaction(SIGALRM, &act, NULL);
     fcntl(fd, F_SETFL, O_ASYNC);
+    fcntl(fd, F_SETSIG, SIGALRM);
     fcntl(fd, F_SETOWN, getpid());
 }
 
@@ -1288,7 +1289,7 @@ static int hpet_start_timer(struct qemu_alarm_timer *t)
     if (r < 0)
         goto fail;
 
-    enable_sigio_timer(fd);
+    enable_sigalrm(fd);
     t->priv = (void *)(long)fd;
 
     return 0;
@@ -1326,7 +1327,7 @@ static int rtc_start_timer(struct qemu_alarm_timer *t)
         return -1;
     }
 
-    enable_sigio_timer(rtc_fd);
+    enable_sigalrm(rtc_fd);
 
     t->priv = (void *)(long)rtc_fd;
 
-- 
1.5.2.5





reply via email to

[Prev in Thread] Current Thread [Next in Thread]