[tip:tools/kvm] kvm tools: pass kvm ptr directly to timer injection

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

 



Commit-ID:  49134d16d0e5e8f528360fe40d4610db0b1c4f50
Gitweb:     http://git.kernel.org/tip/49134d16d0e5e8f528360fe40d4610db0b1c4f50
Author:     Sasha Levin <levinsasha928@xxxxxxxxx>
AuthorDate: Mon, 17 Sep 2012 10:03:31 +0200
Committer:  Pekka Enberg <penberg@xxxxxxxxxx>
CommitDate: Tue, 18 Sep 2012 10:30:42 +0300

kvm tools: pass kvm ptr directly to timer injection

This will help us get rid of the global kvm object.

Signed-off-by: Sasha Levin <levinsasha928@xxxxxxxxx>
Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxx>
---
 tools/kvm/builtin-run.c |   10 ++++++++--
 tools/kvm/kvm.c         |    1 +
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/tools/kvm/builtin-run.c b/tools/kvm/builtin-run.c
index bca9122..ee59d1c 100644
--- a/tools/kvm/builtin-run.c
+++ b/tools/kvm/builtin-run.c
@@ -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";
diff --git a/tools/kvm/kvm.c b/tools/kvm/kvm.c
index 20322a3..d107931 100644
--- a/tools/kvm/kvm.c
+++ b/tools/kvm/kvm.c
@@ -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);
--
To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux