From patchwork Thu Jun 2 20:22:56 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 844822 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 p52KNDtM029665 for ; Thu, 2 Jun 2011 20:23:14 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752400Ab1FBUXK (ORCPT ); Thu, 2 Jun 2011 16:23:10 -0400 Received: from mail-ey0-f174.google.com ([209.85.215.174]:56943 "EHLO mail-ey0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752286Ab1FBUXJ (ORCPT ); Thu, 2 Jun 2011 16:23:09 -0400 Received: by eyx24 with SMTP id 24so451673eyx.19 for ; Thu, 02 Jun 2011 13:23:07 -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=JSPLmWyV1lgwkVKZR1i5smDqGMAwMmI4Ogz+lsdKDaI=; b=SbnX9mI6jGUN8UmyfmUxz1qIvfT31rCw9qK2k3KghCZ8g6k9HdeUo3hPaB5oNmNg/p ThPf009stMPMQ4x6Rr720LjAL9kuz2a4meXKqqhf9BrJrh7CsSLDHxxTEASlagxPkKkg Kklhgxxx1du0C7dRrHMkh+pvEQsAhkiaXWdtM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=oiqGn+DECCndu+CIDngEW7a5MHVJDICPh2JoAOBtFGIufcDb0tMO6tIucXtcg4bhwF yRrmVmtfbJGg4cBC7KpCcZCEO+UeaTXmLhQgFehDWa//sz8ZNsQbZRfzp08y48x+vg7H vOdc7+mGdEdE+5JfzE0cLqQ7NeUJtdDToeeec= Received: by 10.216.230.105 with SMTP id i83mr2442381weq.43.1307046187558; Thu, 02 Jun 2011 13:23:07 -0700 (PDT) Received: from localhost.localdomain (bzq-79-183-205-152.red.bezeqint.net [79.183.205.152]) by mx.google.com with ESMTPS id 14sm603016wbw.32.2011.06.02.13.23.05 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 02 Jun 2011 13:23:06 -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] kvm tools: Add 'kvm pause' command Date: Thu, 2 Jun 2011 23:22:56 +0300 Message-Id: <1307046176-13906-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]); Thu, 02 Jun 2011 20:23:14 +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). Signed-off-by: Sasha Levin --- tools/kvm/Makefile | 1 + tools/kvm/include/kvm/kvm-pause.h | 6 ++++++ tools/kvm/kvm-cmd.c | 2 ++ tools/kvm/kvm-pause.c | 13 +++++++++++++ 4 files changed, 22 insertions(+), 0 deletions(-) create mode 100644 tools/kvm/include/kvm/kvm-pause.h create mode 100644 tools/kvm/kvm-pause.c 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/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)"); +}