From patchwork Wed Sep 5 08:32:06 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 1406711 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id D30103FC71 for ; Wed, 5 Sep 2012 08:37:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750990Ab2IEIgo (ORCPT ); Wed, 5 Sep 2012 04:36:44 -0400 Received: from mail-we0-f174.google.com ([74.125.82.174]:40454 "EHLO mail-we0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758207Ab2IEIgl (ORCPT ); Wed, 5 Sep 2012 04:36:41 -0400 Received: by mail-we0-f174.google.com with SMTP id x8so223930wey.19 for ; Wed, 05 Sep 2012 01:36:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=MVjWKVy0DnU9JD7LpavNtio6VVOBYii/dVzBcscFSyI=; b=qnZAfzlXa2HTSADESxf+NlIi80gM3b9EMTekHQHp+l96EJA4aYuVl+HffG27zric5B i95/B18I9FuPeXfTvVKjhkskUw7YcyBN5vLUregmSu4qTigLY0JnRQ3DR3oKLlghT7hq nc+S5n0p/dQW/lQGUQE7bGUClb7+4vjTIQXoLOYAnws9l1DdFd/4fOxcU1F7STvuMkZJ dQD+l41KHyfR0exNtOmIznsizY01jtboeXlh6ollKMu3BJ3LGBovNBN0pFQyEx0uzUU/ p8k/uPEFs0FnQz4eT5mubGQn8ZGsoz/sd1fRaFoN/HvfYpan/UBwYNPAB/x5pkSsoPuu XGGg== Received: by 10.216.132.135 with SMTP id o7mr12271382wei.6.1346834200410; Wed, 05 Sep 2012 01:36:40 -0700 (PDT) Received: from lappy.capriciverd.com (20.Red-80-59-140.staticIP.rima-tde.net. [80.59.140.20]) by mx.google.com with ESMTPS id q4sm27971068wix.9.2012.09.05.01.36.37 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 05 Sep 2012 01:36:39 -0700 (PDT) From: Sasha Levin To: penberg@kernel.org Cc: asias.hejun@gmail.com, mingo@elte.hu, gorcunov@openvz.org, kvm@vger.kernel.org, Sasha Levin Subject: [PATCH 32/33] kvm tools: pass kvm ptr directly to timer injection Date: Wed, 5 Sep 2012 10:32:06 +0200 Message-Id: <1346833927-15740-33-git-send-email-levinsasha928@gmail.com> X-Mailer: git-send-email 1.7.12 In-Reply-To: <1346833927-15740-1-git-send-email-levinsasha928@gmail.com> References: <1346833927-15740-1-git-send-email-levinsasha928@gmail.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This will help us get rid of the global kvm object. Signed-off-by: Sasha Levin --- 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..0ad49c1 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 = uc; + 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);