From patchwork Fri Jun 3 14:22:29 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 847022 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p53EMjlm012082 for ; Fri, 3 Jun 2011 14:22:45 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755708Ab1FCOWk (ORCPT ); Fri, 3 Jun 2011 10:22:40 -0400 Received: from mail-wy0-f174.google.com ([74.125.82.174]:52641 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755704Ab1FCOWi (ORCPT ); Fri, 3 Jun 2011 10:22:38 -0400 Received: by mail-wy0-f174.google.com with SMTP id 21so1426709wya.19 for ; Fri, 03 Jun 2011 07:22:38 -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; bh=gccEg4pWlmqKdH1l4hx2Fvb8CufKnL/HV+HBnWrxeF0=; b=bVgeQUvNJ9DGSz7XTVvpg8C2/PVEjuU+c4tC8qZDy+etjXHRMBg1QrVEb1g7/bnQwc H2fv2PUn7YhnHkFoLf+d3YJPqldP3/b/kXYpqxLcJKWbmwwGESoAWm3fhIr0KBIzq5GD zUdw62IzkdVr6l8goVVTjZop3gaDaVTT69/qg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=Rl4Ve0etOUzSKOawuul6BcX/6WwQoegxw0as8RTIBW4SWHrIuh68irbMwX85nzCGBQ SkdgYvMOpCgcdZ7Jxxm/djoYoivnoF/3rNwWDLcL4b1hjV6XpcQQ031pHykv6IDW4U8t aq46TSACyB9wpMI8QlZzFFryWj2gNSoMiMwEM= Received: by 10.227.6.219 with SMTP id a27mr2011622wba.46.1307110957975; Fri, 03 Jun 2011 07:22:37 -0700 (PDT) Received: from localhost.localdomain ([109.67.207.42]) by mx.google.com with ESMTPS id fm14sm1076887wbb.58.2011.06.03.07.22.36 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 03 Jun 2011 07:22:37 -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] kvm tools: Add 'kvm pause' command Date: Fri, 3 Jun 2011 17:22:29 +0300 Message-Id: <1307110949-7851-1-git-send-email-levinsasha928@gmail.com> X-Mailer: git-send-email 1.7.5.3 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 (demeter2.kernel.org [140.211.167.43]); Fri, 03 Jun 2011 14:22:45 +0000 (UTC) This patch adds a 'kvm debug' command that's currently an alias for kill -USR2 `pidof kvm` Which pauses a guest (freezes all VCPU threads) or resumes a paused guest. Signed-off-by: Sasha Levin --- tools/kvm/Documentation/kvm-pause.txt | 15 +++++++++++++++ tools/kvm/Makefile | 1 + tools/kvm/command-list.txt | 1 + tools/kvm/include/kvm/kvm-pause.h | 6 ++++++ tools/kvm/kvm-cmd.c | 2 ++ tools/kvm/kvm-pause.c | 13 +++++++++++++ 6 files changed, 38 insertions(+), 0 deletions(-) create mode 100644 tools/kvm/Documentation/kvm-pause.txt create mode 100644 tools/kvm/include/kvm/kvm-pause.h create mode 100644 tools/kvm/kvm-pause.c diff --git a/tools/kvm/Documentation/kvm-pause.txt b/tools/kvm/Documentation/kvm-pause.txt new file mode 100644 index 0000000..ddf3d8f --- /dev/null +++ b/tools/kvm/Documentation/kvm-pause.txt @@ -0,0 +1,15 @@ +kvm-pause(1) +================ + +NAME +---- +kvm-pause - Pause/resume the virtual machine + +SYNOPSIS +-------- +[verse] +'kvm pause' + +DESCRIPTION +----------- +The command pauses and resumes a virtual machine. diff --git a/tools/kvm/Makefile b/tools/kvm/Makefile index a05a6b1..ed82cdf 100644 --- a/tools/kvm/Makefile +++ b/tools/kvm/Makefile @@ -42,6 +42,7 @@ OBJS += irq.o OBJS += kvm-cmd.o OBJS += kvm-debug.o OBJS += kvm-help.o +OBJS += kvm-pause.o OBJS += kvm-run.o OBJS += mptable.o OBJS += rbtree.o diff --git a/tools/kvm/command-list.txt b/tools/kvm/command-list.txt index 4eaf399..36dcd67b 100644 --- a/tools/kvm/command-list.txt +++ b/tools/kvm/command-list.txt @@ -3,3 +3,4 @@ # command name category [deprecated] [common] # kvm-run mainporcelain common +kvm-pause common diff --git a/tools/kvm/include/kvm/kvm-pause.h b/tools/kvm/include/kvm/kvm-pause.h new file mode 100644 index 0000000..0f8e96b --- /dev/null +++ b/tools/kvm/include/kvm/kvm-pause.h @@ -0,0 +1,6 @@ +#ifndef KVM__PAUSE_H +#define KVM__PAUSE_H + +int kvm_cmd_pause(int argc, const char **argv, const char *prefix); + +#endif diff --git a/tools/kvm/kvm-cmd.c b/tools/kvm/kvm-cmd.c index 2ea51a5..ffbc4ff 100644 --- a/tools/kvm/kvm-cmd.c +++ b/tools/kvm/kvm-cmd.c @@ -6,11 +6,13 @@ /* user defined header files */ #include "kvm/kvm-debug.h" +#include "kvm/kvm-pause.h" #include "kvm/kvm-help.h" #include "kvm/kvm-cmd.h" #include "kvm/kvm-run.h" struct cmd_struct kvm_commands[] = { + { "pause", kvm_cmd_pause, NULL, 0 }, { "debug", kvm_cmd_debug, NULL, 0 }, { "help", kvm_cmd_help, NULL, 0 }, { "run", kvm_cmd_run, kvm_run_help, 0 }, diff --git a/tools/kvm/kvm-pause.c b/tools/kvm/kvm-pause.c new file mode 100644 index 0000000..fdf8714 --- /dev/null +++ b/tools/kvm/kvm-pause.c @@ -0,0 +1,13 @@ +#include +#include +#include + +#include +#include +#include + +int kvm_cmd_pause(int argc, const char **argv, const char *prefix) +{ + signal(SIGUSR2, SIG_IGN); + return system("kill -USR2 $(pidof kvm)"); +}