* [PATCH] kvm tools: Add 'kvm pause' command
@ 2011-06-02 20:22 Sasha Levin
2011-06-02 22:59 ` Prasad Joshi
2011-06-03 6:29 ` Pekka Enberg
0 siblings, 2 replies; 5+ messages in thread
From: Sasha Levin @ 2011-06-02 20:22 UTC (permalink / raw)
To: penberg; +Cc: kvm, mingo, asias.hejun, gorcunov, prasadjoshi124, Sasha Levin
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 <levinsasha928@gmail.com>
---
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 <stdio.h>
+#include <string.h>
+#include <signal.h>
+
+#include <kvm/util.h>
+#include <kvm/kvm-cmd.h>
+#include <kvm/kvm-pause.h>
+
+int kvm_cmd_pause(int argc, const char **argv, const char *prefix)
+{
+ signal(SIGUSR2, SIG_IGN);
+ return system("kill -USR2 $(pidof kvm)");
+}
--
1.7.5.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] kvm tools: Add 'kvm pause' command
2011-06-02 20:22 [PATCH] kvm tools: Add 'kvm pause' command Sasha Levin
@ 2011-06-02 22:59 ` Prasad Joshi
2011-06-03 7:02 ` Ingo Molnar
2011-06-03 6:29 ` Pekka Enberg
1 sibling, 1 reply; 5+ messages in thread
From: Prasad Joshi @ 2011-06-02 22:59 UTC (permalink / raw)
To: Sasha Levin; +Cc: penberg, kvm, mingo, asias.hejun, gorcunov
On Thu, Jun 2, 2011 at 9:22 PM, Sasha Levin <levinsasha928@gmail.com> wrote:
> 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 <levinsasha928@gmail.com>
> ---
> 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 },
We automatically generate <include/common-cmds.h> header file that
lists the command options with kvm. Should we ensure 'pause' is added
to the file? I think then './kvm help' will display 'pause' as one of
the possible command.
I think we should ensure 'pause' is added to the file during compilation.
> { "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 <stdio.h>
> +#include <string.h>
> +#include <signal.h>
> +
> +#include <kvm/util.h>
> +#include <kvm/kvm-cmd.h>
> +#include <kvm/kvm-pause.h>
> +
> +int kvm_cmd_pause(int argc, const char **argv, const char *prefix)
> +{
> + signal(SIGUSR2, SIG_IGN);
> + return system("kill -USR2 $(pidof kvm)");
> +}
> --
> 1.7.5.3
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] kvm tools: Add 'kvm pause' command
2011-06-02 20:22 [PATCH] kvm tools: Add 'kvm pause' command Sasha Levin
2011-06-02 22:59 ` Prasad Joshi
@ 2011-06-03 6:29 ` Pekka Enberg
2011-06-03 6:34 ` Sasha Levin
1 sibling, 1 reply; 5+ messages in thread
From: Pekka Enberg @ 2011-06-03 6:29 UTC (permalink / raw)
To: Sasha Levin; +Cc: kvm, mingo, asias.hejun, gorcunov, prasadjoshi124
On Thu, Jun 2, 2011 at 11:22 PM, Sasha Levin <levinsasha928@gmail.com> wrote:
> 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 <levinsasha928@gmail.com>
What is this useful for? Debugging? Don't we need a command to
unfreeze the guest as well?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] kvm tools: Add 'kvm pause' command
2011-06-03 6:29 ` Pekka Enberg
@ 2011-06-03 6:34 ` Sasha Levin
0 siblings, 0 replies; 5+ messages in thread
From: Sasha Levin @ 2011-06-03 6:34 UTC (permalink / raw)
To: Pekka Enberg; +Cc: kvm, mingo, asias.hejun, gorcunov, prasadjoshi124
On Fri, 2011-06-03 at 09:29 +0300, Pekka Enberg wrote:
> On Thu, Jun 2, 2011 at 11:22 PM, Sasha Levin <levinsasha928@gmail.com> wrote:
> > 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 <levinsasha928@gmail.com>
>
> What is this useful for? Debugging? Don't we need a command to
> unfreeze the guest as well?
It unfreezes the guest if it's paused. I should have mentioned that in
the commit message.
--
Sasha.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] kvm tools: Add 'kvm pause' command
2011-06-02 22:59 ` Prasad Joshi
@ 2011-06-03 7:02 ` Ingo Molnar
0 siblings, 0 replies; 5+ messages in thread
From: Ingo Molnar @ 2011-06-03 7:02 UTC (permalink / raw)
To: Prasad Joshi; +Cc: Sasha Levin, penberg, kvm, asias.hejun, gorcunov
* Prasad Joshi <prasadjoshi124@gmail.com> wrote:
> > struct cmd_struct kvm_commands[] = {
> > + { "pause", kvm_cmd_pause, NULL, 0 },
>
> We automatically generate <include/common-cmds.h> header file that
> lists the command options with kvm. Should we ensure 'pause' is
> added to the file? I think then './kvm help' will display 'pause'
> as one of the possible command.
That is done by adding the new command to command-list.txt - then the
Makefile will generate everything correctly.
Thanks,
Ingo
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-06-03 7:02 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-02 20:22 [PATCH] kvm tools: Add 'kvm pause' command Sasha Levin
2011-06-02 22:59 ` Prasad Joshi
2011-06-03 7:02 ` Ingo Molnar
2011-06-03 6:29 ` Pekka Enberg
2011-06-03 6:34 ` Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox