From patchwork Mon Sep 17 08:03:31 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 1465821 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 6FC80E0012 for ; Mon, 17 Sep 2012 08:03:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754775Ab2IQIDa (ORCPT ); Mon, 17 Sep 2012 04:03:30 -0400 Received: from mail-we0-f174.google.com ([74.125.82.174]:53609 "EHLO mail-we0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754748Ab2IQIDW (ORCPT ); Mon, 17 Sep 2012 04:03:22 -0400 Received: by mail-we0-f174.google.com with SMTP id x8so3701159wey.19 for ; Mon, 17 Sep 2012 01:03:22 -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=AZiaVfT0KGPKGDpOxFj6tt3RkUFvV3/zJUIgijTOxRc=; b=vWnD5e1R70QshMzc2CUdM85BpoRq15jxXU6GXld9OdGNoOgLUypUL2JIgmGsElp9ok K8d6dpJGMGAXnIhUGBBA9ssVWxLn3FjCbCJQUe3BLz/nKscTAoy5QRDef1fl9RwPz3U6 vMYtByCIqKcHZ+m/0lggMOebWGqCwCZyv2HU7R4vUEaN7DEukCd8Bp3VrJ51YQOecDaT lIJeEbddiiP0ky0dN+QmYllnXmxebDDXKEmWebaIcBKvtHXfHYQ6hgSijeyuXtj+aksd +WKc0V9zCxy76sOYWzXzLo29Mqzai6G2ueJ+Y6vFGAOk+2o0O1GaI1lnHouvfSs53SCB rrSw== Received: by 10.216.71.82 with SMTP id q60mr5973152wed.64.1347869002112; Mon, 17 Sep 2012 01:03:22 -0700 (PDT) Received: from localhost.localdomain ([37.46.33.122]) by mx.google.com with ESMTPS id v3sm16632604wiw.7.2012.09.17.01.03.19 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 17 Sep 2012 01:03:21 -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 3/8] kvm tools: pass kvm ptr directly to timer injection Date: Mon, 17 Sep 2012 10:03:31 +0200 Message-Id: <1347869016-17204-3-git-send-email-levinsasha928@gmail.com> X-Mailer: git-send-email 1.7.12 In-Reply-To: <1347869016-17204-1-git-send-email-levinsasha928@gmail.com> References: <1347869016-17204-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..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);