From patchwork Mon May 30 08:30:43 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 829432 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p4U8VqMn026511 for ; Mon, 30 May 2011 08:33:27 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753583Ab1E3Ibo (ORCPT ); Mon, 30 May 2011 04:31:44 -0400 Received: from mail-ww0-f44.google.com ([74.125.82.44]:35968 "EHLO mail-ww0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751147Ab1E3Ibm (ORCPT ); Mon, 30 May 2011 04:31:42 -0400 Received: by mail-ww0-f44.google.com with SMTP id 36so3676409wwa.1 for ; Mon, 30 May 2011 01:31:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=MOXA8wqap5/qlY74fKwbwXKPliYwgQXJJITAJfiAQg4=; b=ncEoQQVZujDzW4Lmt+nOtTqmP0cm/2Ne+tcIZ72PcQHCtLRhCF5129RibVvSRNr42N o02L4EqCyWoopetaQiCAT+7N2Ph5C4J0WO4kcev3zex350u/qkzXyaog9qU9TCXV2IB0 vA91T+1DdmephU3ly3by4jgPTDFIMYqbfcw+0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=aBTXddf4EUUKF+Ln72dl4K9Zx1p0eiINQ0Jbg4gve4Q4X8yLT9ld2e0zxTiJnbsh5j /5RnidvJgEiFAa3zTNTIS/MTWPXXd6JQ16GbcRt4crLd8HVVilrMCu3F80UIpmO8UvjC vbg7EgiZFr3DBK8YEc03QbQiB/jBWAGuhbPC4= Received: by 10.216.136.151 with SMTP id w23mr2159646wei.86.1306744302138; Mon, 30 May 2011 01:31:42 -0700 (PDT) Received: from localhost.localdomain (bzq-79-181-201-100.red.bezeqint.net [79.181.201.100]) by mx.google.com with ESMTPS id z66sm2331147weq.24.2011.05.30.01.31.40 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 30 May 2011 01:31:41 -0700 (PDT) From: Sasha Levin To: penberg@kernel.org Cc: kvm@vger.kernel.org, mingo@elte.hu, asias.hejun@gmail.com, gorcunov@gmail.com, prasadjoshi124@gmail.com, Sasha Levin Subject: [PATCH v2 4/8] kvm tools: Pause/resume guest using SIGUSR2 Date: Mon, 30 May 2011 11:30:43 +0300 Message-Id: <1306744247-26051-4-git-send-email-levinsasha928@gmail.com> X-Mailer: git-send-email 1.7.5.rc3 In-Reply-To: <1306744247-26051-1-git-send-email-levinsasha928@gmail.com> References: <1306744247-26051-1-git-send-email-levinsasha928@gmail.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Mon, 30 May 2011 08:33:27 +0000 (UTC) Make SIGUSR2 pause/resume a guest, this allows to easily test pausing a guest. Can be tested using cmdline 'kill -USR2 $(pidof kvm)'. Signed-off-by: Sasha Levin --- tools/kvm/kvm-run.c | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-) diff --git a/tools/kvm/kvm-run.c b/tools/kvm/kvm-run.c index 761ac0d..49cc0aa 100644 --- a/tools/kvm/kvm-run.c +++ b/tools/kvm/kvm-run.c @@ -165,6 +165,20 @@ static void handle_sigusr1(int sig) mb(); } +/* Pause/resume the guest using SIGUSR2 */ +static int is_paused; + +static void handle_sigusr2(int sig) +{ + if (is_paused) + kvm__continue(); + else + kvm__pause(); + + is_paused = !is_paused; + pr_info("Guest %s\n", is_paused?"paused":"resumed"); +} + static void handle_sigquit(int sig) { int i; @@ -422,6 +436,7 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix) signal(SIGALRM, handle_sigalrm); signal(SIGQUIT, handle_sigquit); signal(SIGUSR1, handle_sigusr1); + signal(SIGUSR2, handle_sigusr2); nr_online_cpus = sysconf(_SC_NPROCESSORS_ONLN);