From patchwork Mon May 30 17:27:54 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 830662 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 p4UHTG2N018765 for ; Mon, 30 May 2011 17:29:48 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757592Ab1E3R3Q (ORCPT ); Mon, 30 May 2011 13:29:16 -0400 Received: from mail-wy0-f174.google.com ([74.125.82.174]:46736 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757501Ab1E3R3O (ORCPT ); Mon, 30 May 2011 13:29:14 -0400 Received: by mail-wy0-f174.google.com with SMTP id 21so2766739wya.19 for ; Mon, 30 May 2011 10:29:13 -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=CS88S6E6bZcIRpO+53EYgCx5YLJKb13aNEt72OawFRU=; b=JCCcw3YEqi13gqkrlbFkoOGOrBo+clM/nj8nZhsq0d1RH0aq1UfljJ2eAcr20214iK wQw5XdmYW1Qq4D5uDHEoaG+URgUZZ71uXFl5kSLY0LwNYSBvzOhsfmqYzwdYNr0ByKkd eyn2I2LdeNk61hSueHGJeW50JjLxT5DwQB0S0= 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=mXPUZQIBaJEweOjgvk0W3Z1Uj4Be4spqEN453j2j97fjPDmnEKWa1fdEHTw+odyyBc WTGtmLinmhFLa7Y1QRdDCy0HWU2wqsRTaYYTG/Uk/T7T5oc3zFOBWmRKiawqaMQxj1fY HTfYMP/MulnhS7RMRyYCCzw6/jLqnfUnU/g3M= Received: by 10.216.230.153 with SMTP id j25mr2777324weq.22.1306776553823; Mon, 30 May 2011 10:29:13 -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 gb6sm3194848wbb.17.2011.05.30.10.29.12 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 30 May 2011 10:29:13 -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 v3 4/8] kvm tools: Pause/resume guest using SIGUSR2 Date: Mon, 30 May 2011 20:27:54 +0300 Message-Id: <1306776478-29613-5-git-send-email-levinsasha928@gmail.com> X-Mailer: git-send-email 1.7.5.3 In-Reply-To: <1306776478-29613-1-git-send-email-levinsasha928@gmail.com> References: <1306776478-29613-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 17:29:49 +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..b0ef333 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);