18 Commits

Author SHA1 Message Date
Cyrill Gorcunov a28574790c kvm tools: Add BUG_ON() helper to make a run-time critical tests
Also drop useless assert.h inclusions.

Acked-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:50 +01:00
Sasha Levin 3c29e2aabd kvm tools: Add 'kvm sandbox'
This patch adds 'kvm sandbox' which is a wrapper on top of 'kvm run' which
allows the user to easily specify sandboxed command to run in a custom
rootfs guest.

Example usage:

	kvm sandbox -d test_guest -k some_kernel -- do_something_in_guest

Suggested-by: Pekka Enberg <penberg@cs.helsinki.fi>
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:49 +01:00
Pekka Enberg 282113fd51 kvm tools: Introduce 'kvm setup' command
This patch implements 'kvm setup' command that can be used to setup a guest
filesystem that shares system libraries and binaries from host filesystem in
read-only mode.

You can setup a new shared rootfs guest with:

  ./kvm setup -n default

and launch it with:

  ./kvm run --9p /,hostfs -p "init=virt/init" -d ~/.kvm-tools/default/

We want to teach 'kvm run' to be able to launch guest filesystems by name in
the future. Furthermore, 'kvm run' should setup a 'default' filesystem and use
it by default unless the user specifies otherwise.

Cc: Asias He <asias.hejun@gmail.com>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:47 +01:00
Sasha Levin bc10d2c1c8 kvm tools: Add 'kvm stat' command
This patch adds 'kvm stat' command that allows retrieving statistics out of
a running guest.

Currently the only supported statistics are memory statistics, available using the
'--memory' parameter.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:47 +01:00
Sasha Levin 0725673ad3 kvm tools: Connect existing command helpers to 'kvm help'
This patch connects usage helpers to 'kvm help' callbacks, allowing
to see help about a command by doing 'kvm help [command]'.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:47 +01:00
Sasha Levin 9abc695d91 kvm tools: Print version when running 'kvm --version'
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:47 +01:00
Liming Wang e81c0199f8 kvm tools: handle failure of command
handle failure of calling command function, especially, only handle
EPERM error now.

Signed-off-by: Liming Wang <walimisdev@gmail.com>
[ penberg@kernel.org: fix minor coding style issue ]
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:47 +01:00
Sasha Levin 02317b74e8 kvm tools: Split 'kvm pause' and add 'kvm resume'
This patch seperates 'kvm pause' into 'kvm pause' and 'kvm resume',
'kvm pause' no longer acts as a switch between running and paused state but
instead just switches the instance into paused and reume is handled by
the new 'kvm resume'.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:46 +01:00
Sasha Levin daf4cb5af4 kvm tools: Add 'kvm stop'
This command stops a running instance.

Syntax:
kvm stop [instance name]

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:46 +01:00
Sasha Levin 2a24f96d64 kvm tools: Rename command source files
Rename kvm-[command] into builtin-[command] to prevent
clashes with non-command files such as kvm-cpu.h

Suggested-by: Pekka Enberg <penberg@kernel.org>
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:46 +01:00
Sasha Levin 16b2bb87b9 kvm tools: Add 'kvm version' command
Add a 'kvm version' command which prints the version of the kernel
used to build kvm tools.

Part of the code is based on and was loaned from perf.

Suggested-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:46 +01:00
Sasha Levin 9dba6721a9 kvm tools: Add 'kvm list' command
Use 'kvm list' to list running virtual guest.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:45 +01:00
Sasha Levin 5cac5d9c43 kvm tools: Add 'kvm balloon' command
Add a command to allow easily inflate/deflate the balloon driver in running
instances.

Usage:
kvm balloon [command] [instance name] [size]

command is either inflate or deflate, and size is represented in MB.
Target instance must be named (started with '--name').

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:45 +01:00
Sasha Levin 2947270eaa kvm tools: Add 'kvm pause' command
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 <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:45 +01:00
Pekka Enberg ca379b8386 kvm tools: Add 'kvm debug' command
This patch adds a 'kvm debug' command that's currently an alias for

  kill -3 `pidof kvm`

which prints out debugging diagnostics for guests.

Suggested-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:44 +01:00
Amerigo Wang f6677a1dec kvm tools: implement "help xxx" command
'kvm run --help' works fine but 'kvm help run' shows nothing,
this patch implements it.

Acked-by: Prasad Joshi <prasadjoshi124@gmail.com>
Signed-off-by: WANG Cong <amwang@redhat.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:44 +01:00
Pekka Enberg 0ea58e5bbc kvm tools: Make code mostly checkpatch clean
This patch fixes code style issues pointed out by scripts/checkpatch. However,
some reported errors are false positives. In particular, the warning:

  WARNING: line over 80 characters

is too strict for our code and thus needs to action to be taken.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:42 +01:00
Prasad Joshi 0a936c5400 kvm tools: Provide the basic Gitish framework
- kvm-cmd.h: Adds a new structure cmd_struct to create a table of commands
  and callback function. The structure was copied from tools/perf

- kvm-cmd.c: implements two main functions for command processing.
  kvm_get_command(): searches table for specific command.
  handle_command(): invokes the callback function for a given command.

- kvm-help.[ch] Implements the kvm help command. The function
  list_common_cmds_help() is a copy of similar function in tools/perf.

[ penberg@kernel.org: Add CREDITS-Git file for proper attributions. ]
Signed-off-by: Prasad Joshi <prasadjoshi124@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:42 +01:00