]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm tools: pass kvm ptr directly to timer injection
authorSasha Levin <levinsasha928@gmail.com>
Mon, 17 Sep 2012 08:03:31 +0000 (10:03 +0200)
committerPekka Enberg <penberg@kernel.org>
Tue, 18 Sep 2012 07:30:42 +0000 (10:30 +0300)
This will help us get rid of the global kvm object.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
tools/kvm/builtin-run.c
tools/kvm/kvm.c

index bca91220523524911dcffaf66d367b36a5aeeb9d..ee59d1cfa102b730f384b080536b138b925af2aa 100644 (file)
@@ -163,8 +163,10 @@ void kvm_run_set_wrapper_sandbox(void)
        OPT_END()                                                       \
        };
 
-static void handle_sigalrm(int sig)
+static void handle_sigalrm(int sig, siginfo_t *si, void *uc)
 {
+       struct kvm *kvm = si->si_value.sival_ptr;
+
        kvm__arch_periodic_poll(kvm);
 }
 
@@ -476,12 +478,16 @@ static int kvm_cmd_run_init(int argc, const char **argv)
 {
        static char real_cmdline[2048], default_name[20];
        unsigned int nr_online_cpus;
+       struct sigaction sa;
 
        kvm = kvm__new();
        if (IS_ERR(kvm))
                return PTR_ERR(kvm);
 
-       signal(SIGALRM, handle_sigalrm);
+       sa.sa_flags = SA_SIGINFO;
+       sa.sa_sigaction = handle_sigalrm;
+       sigemptyset(&sa.sa_mask);
+       sigaction(SIGALRM, &sa, NULL);
 
        nr_online_cpus = sysconf(_SC_NPROCESSORS_ONLN);
        kvm->cfg.custom_rootfs_name = "default";
index 20322a3375b23d1d005a101ffc92a81915c7ec62..d107931c688feedae12e69d7d575c337265fd00f 100644 (file)
@@ -358,6 +358,7 @@ int kvm_timer__init(struct kvm *kvm)
        sev.sigev_value.sival_int       = 0;
        sev.sigev_notify                = SIGEV_THREAD_ID;
        sev.sigev_signo                 = SIGALRM;
+       sev.sigev_value.sival_ptr       = kvm;
        sev._sigev_un._tid              = syscall(__NR_gettid);
 
        r = timer_create(CLOCK_REALTIME, &sev, &kvm->timerid);