Skip to contentSkip to conversation

kvm tools: Add 'kvm memstat' command

PATCH In review Sasha Levin 4 participants 6 messages Aug 15, 2011 – Aug 19, 2011 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kvm tools: Add 'kvm memstat' command

This patch adds 'kvm memstat' command that allows retrieving memory statistics out of a running guest using the virtio-balloon stats vq interface.

---
 tools/kvm/Documentation/kvm-memstat.txt |   16 +++++
 tools/kvm/Makefile                      |    1 +
 tools/kvm/builtin-memstat.c             |   69 ++++++++++++++++++++
 tools/kvm/command-list.txt              |    1 +
 tools/kvm/include/kvm/builtin-memstat.h |    7 ++
 tools/kvm/include/kvm/kvm.h             |    1 +
 tools/kvm/kvm-cmd.c                     |    2 +
 tools/kvm/virtio/balloon.c              |  108 +++++++++++++++++++++++++++++-
 8 files changed, 201 insertions(+), 4 deletions(-)
 create mode 100644 tools/kvm/Documentation/kvm-memstat.txt
 create mode 100644 tools/kvm/builtin-memstat.c
 create mode 100644 tools/kvm/include/kvm/builtin-memstat.h
tools/kvm/Documentation/kvm-memstat.txt new file +16 -0
new file mode 100644
index 0000000..0562d33
@@ -0,0 +1,16 @@
+kvm-memstat(1)
+================
+
+NAME
+----
+kvm-memstat - Print memory statistics about a running instance
+
+SYNOPSIS
+--------
+[verse]
+'kvm memstat [-n instance] [-p instance pid] [--all]'
+
+DESCRIPTION
+-----------
+The command prints memory statistics about a running instance.
+For a list of running instances see 'kvm list'.
tools/kvm/Makefile +1 -0
index 3a06e10..ce68b8c 100644
@@ -24,6 +24,7 @@ OBJS	+= builtin-balloon.o
 OBJS	+= builtin-debug.o
 OBJS	+= builtin-help.o
 OBJS	+= builtin-list.o
+OBJS	+= builtin-memstat.o
 OBJS	+= builtin-pause.o
 OBJS	+= builtin-resume.o
 OBJS	+= builtin-run.o
tools/kvm/builtin-memstat.c new file +69 -0

69 lines not on this page · raw message

tools/kvm/command-list.txt +1 -0
index 6a49d0a..78f2dcf 100644
@@ -10,3 +10,4 @@ kvm-list			common
 kvm-debug			common
 kvm-balloon			common
 kvm-stop			common
+kvm-memstat			common
tools/kvm/include/kvm/builtin-memstat.h new file +7 -0
new file mode 100644
index 0000000..eb355ee
@@ -0,0 +1,7 @@
+#ifndef KVM__MEMSTAT_H
+#define KVM__MEMSTAT_H
+
+int kvm_cmd_memstat(int argc, const char **argv, const char *prefix);
+void kvm_memstat_help(void);
+
+#endif
tools/kvm/include/kvm/kvm.h +1 -0
index d4fe2a1..c2d815c 100644
@@ -22,6 +22,7 @@
 #define SIGKVMDELMEM		(SIGRTMIN + 3)
 #define SIGKVMSTOP		(SIGRTMIN + 4)
 #define SIGKVMRESUME		(SIGRTMIN + 5)
+#define SIGKVMMEMSTAT		(SIGRTMIN + 6)
 
 struct kvm {
 	int			sys_fd;		/* For system ioctls(), i.e. /dev/kvm */
tools/kvm/kvm-cmd.c +2 -0
index 4e3ea22..09e1825 100644
@@ -12,6 +12,7 @@
 #include "kvm/builtin-list.h"
 #include "kvm/builtin-version.h"
 #include "kvm/builtin-stop.h"
+#include "kvm/builtin-memstat.h"
 #include "kvm/builtin-help.h"
 #include "kvm/kvm-cmd.h"
 #include "kvm/builtin-run.h"
@@ -26,6 +27,7 @@ struct cmd_struct kvm_commands[] = {
 	{ "version",	kvm_cmd_version,	NULL,			0 },
 	{ "--version",	kvm_cmd_version,	NULL,			0 },
 	{ "stop",	kvm_cmd_stop,		kvm_stop_help,		0 },
+	{ "memstat",	kvm_cmd_memstat,	kvm_memstat_help,	0 },
 	{ "help",	kvm_cmd_help,		NULL,			0 },
 	{ "run",	kvm_cmd_run,		kvm_run_help,		0 },
 	{ NULL,		NULL,			NULL,			0 },
tools/kvm/virtio/balloon.c +104 -4

165 lines not on this page · raw message

Signature · 1 line
1.7.6
#1 lore raw
Quoted 4 lines · Sasha Levin

This patch adds 'kvm memstat' command that allows retrieving memory statistics out of a running guest using the virtio-balloon stats vq interface.

Shouldn't we just call this "kvm stat"? We can print out all statistics by default and add command line options like "--mem" to display individual stats?

Pekka

#2 lore raw
Quoted 9 lines · Pekka Enberg
Quoted 4 lines · Sasha Levin

This patch adds 'kvm memstat' command that allows retrieving memory statistics out of a running guest using the virtio-balloon stats vq interface.

Shouldn't we just call this "kvm stat"? We can print out all statistics by default and
add command line options like "--mem" to display individual stats?

Do we have any other statistics to print out at the moment?

Signature · 1 line
Sasha.
#3 lore raw
Quoted 10 lines · Sasha Levin
Quoted 8 lines · Pekka Enberg
Quoted 4 lines · Sasha Levin

This patch adds 'kvm memstat' command that allows retrieving memory statistics out of a running guest using the virtio-balloon stats vq interface.

Shouldn't we just call this "kvm stat"? We can print out all statistics by default and
add command line options like "--mem" to display individual stats?

Do we have any other statistics to print out at the moment?

Not right now but IIRC Asias talked about networking statistics. The 'kvm memstat' feels too specific to justify a separate builtin as opposed to an command line option in a 'kvm stat' command.

Pekka

#4 lore raw
Quoted 8 lines · Pekka Enberg
Quoted 7 lines · Sasha Levin
Quoted 6 lines · Pekka Enberg
Quoted 5 lines · Sasha Levin

This patch adds 'kvm memstat' command that allows retrieving memory statistics out of
a running guest using the virtio-balloon stats vq interface.

Quoted 8 lines
Quoted 4 lines
Quoted 3 lines

Shouldn't we just call this "kvm stat"? We can print out all statistics by default and
add command line options like "--mem" to display individual stats?

Do we have any other statistics to print out at the moment?

Not right now but IIRC Asias talked about networking statistics. The 'kvm memstat' feels too specific to justify a separate builtin as opposed to an command line option in a 'kvm stat' command.

Yes. the command I am proposing is 'kvm info'. We can have a lot of thing in 'kvm info', like register info, network info ,disk info. mem info. Actually, Pekka suggested to have kvm info for all the infos and if we are getting too much, we can split kvm info into sub command, like kvm info mem, kvm info reg.

Signature · 2 lines
Best Regards,
Asias He
#5 lore raw
Quoted 18 lines · Asias He
Quoted 8 lines · Pekka Enberg
Quoted 7 lines · Sasha Levin
Quoted 6 lines · Pekka Enberg
Quoted 5 lines · Sasha Levin

This patch adds 'kvm memstat' command that allows retrieving memory statistics out of
a running guest using the virtio-balloon stats vq interface.

Quoted 8 lines
Quoted 4 lines
Quoted 3 lines

Shouldn't we just call this "kvm stat"? We can print out all statistics by default and
add command line options like "--mem" to display individual stats?

Do we have any other statistics to print out at the moment?

Not right now but IIRC Asias talked about networking statistics. The 'kvm memstat' feels too specific to justify a separate builtin as opposed to an command line option in a 'kvm stat' command.

Quoted 5 lines

Yes. the command I am proposing is 'kvm info'. We can have a lot of thing in 'kvm info', like register info, network info ,disk info. mem info. Actually, Pekka suggested to have kvm info for all the infos and if we are getting too much, we can split kvm info into sub command, like kvm info mem, kvm info reg.

Should we already have something similar from QEMU already such as register and memory access?

Can we use this interface to write to guest physical address?

Thanks,
CJ

Quoted 8 lines
Signature · 7 lines
-- 
Best Regards,
Asias He
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html