qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] Use SIGALRM for all timers


From: Anders Melchiorsen
Subject: [Qemu-devel] Use SIGALRM for all timers
Date: Wed, 13 Feb 2008 15:30:23 +0100
User-agent: Gnus/5.1008 (Gnus v5.10.8) XEmacs/21.4.20 (linux)

I wonder if this patch makes sense, using SIGALRM for all kinds of
timers, even those expiring through a file descriptor?

It seems more clean to me to always use SIGALRM for alarms, but the
actual trigger for this change was to free up SIGIO for KVM.

Unfortunately, I have been unable to test it myself yet, as the HPET
and RTC timers both do not work on my system. If I get feedback that
this approach is not good, I will not spend the time on getting those
timers to behave.


Best regards,
Anders.


diff --git a/vl.c b/vl.c
index c87e8bc..d94302d 100644
--- a/vl.c
+++ b/vl.c
@@ -1240,7 +1240,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;
 
@@ -1249,8 +1249,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());
 }
 
@@ -1287,7 +1288,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;
@@ -1325,7 +1326,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;
 




reply via email to

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