- 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>
kvm tools: Generate list of common kvm tool commands
- The Documentation/ directory will have a text file for each commmand. The
text file should contain the information about the command in manpage format.
- command-list.txt: is a list of common commands used with the kvm tool.
- util/generate-cmdlist.sh: is a shell script that uses command-list.txt and
text files in Documentation/ directory to generate the common-cmds.h file in
the include directory. The header file is furthur used to display a usage
messgae. Almost the entire script is copied from the tools/perf.
Signed-off-by: Prasad Joshi <prasadjoshi124@gmail.com> Signed-off-by: Pekka Enberg <penberg@kernel.org>
Right now when a KVM session ends with an incomplete line printk'd
without a newline, kvm exits in an ugly way:
[ 4.638016] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
[ 4.641668] Rebooting in 1 seconds..spirit:~/tip/tools/kvm>
spirit:~/tip/tools/kvm>
See the shell prompt intermixed with the last line of kernel output.
There's also no indication to the user that everything is fine on the
kvm tool side.
This is somewhat of a beauty wart and also a bit confusing to users.
To clarify and clean up things, add a final printout on normal exits:
[ 4.654814] Please append a correct "root=" boot option; here are the available partitions:
[ 4.584390] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
[ 4.662243] Rebooting in 1 seconds..
# KVM session ended normally.
spirit:~/tip/tools/kvm>
This delimits the kernel output properly and gives feedback to the user
that (despite the scary kernel messages) all fine from the KVM POV.
Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Pekka Enberg <penberg@kernel.org>
kvm tools: Fix segfault when running 'kvm' without a disk image
When running a simple, diskless 'kvm ./bzImage' KVM session we currently
segfault at the end of the session:
[ 4.895488] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
[ 4.899371] Rebooting in 1 seconds..
Program received signal SIGSEGV, Segmentation fault.
disk_image__close (self=0x0) at disk-image.c:93
93 if (self->ops->close)
(gdb)
Because disk_image__close() assumes that 'self' is never NULL.
Add a NULL check to allow a clean exit.
Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Pekka Enberg <penberg@kernel.org>
kvm tools: Emit a more informative error message when /dev/kvm does not open
When for some reason virtualization is not available on a box, the user
gets this cryptic error message:
open: No such device
The user has no idea what happened - what is being opened and why is
there no such device?
This happens on one of my boxes, where there's VMX support indicated
in the CPU feature flags but where modules do not load because the
BIOS has virtualization disabled. The KVM kernel subsystem emits a
warning into the syslog:
kvm: disabled by bios
But unfortunatey tools cannot really recover that error reason in any sane,
programmatic way when accessing /dev/kvm.
So do the best we can, we suggest to the user to look into the syslog for
the reason of the error:
Fatal: '/dev/kvm' KVM driver not available.
# (If the KVM module is loaded then 'dmesg' may offer further clues about the failure.)
Also improve the fallback error message from 'open: No such device' to:
Fatal, could not open /dev/kvm: No such device
... should there be any future error returns that are neither -ENOENT,
nor -ENODEV.
Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Pekka Enberg <penberg@kernel.org>
This option enables virtio console and disables serial console.
At this time, the virtio and serial console can not work simultaneously.
Becasue we can not put both console's output to user at the same time.
However, once we redirect the virtio console to a pipe or socket. We can
use both console simultaneously.
Signed-off-by: Asias He <asias.hejun@gmail.com> Signed-off-by: Pekka Enberg <penberg@kernel.org>
David Ahern [Tue, 5 Apr 2011 16:04:13 +0000 (10:04 -0600)]
kvm tools: do not append root=/dev/vda if passed via command line
Hardcoding the root= option prevents an existing qemu-kvm based disk
image using LVM from booting. It fails to find the root filesystem.
By making the root parameter optional if given on the command line, the
image boots correctly. For example,
Got following errors while compiling the native kvm tool on my supervisor's
machine.
oswaldo@sir61a:~/linux-kvm/tools/kvm> make
In file included from /usr/include/asm/types.h:4,
from /usr/include/asm/kvm.h:9,
from ../../include/linux/kvm.h:13,
from include/kvm/kvm.h:6,
from mmio.c:1:
../../include/asm-generic/int-ll64.h:11:29: error: asm/bitsperlong.h: No such file or directory
In file included from /usr/include/asm/types.h:4,
from /usr/include/asm/kvm.h:9,
from ../../include/linux/kvm.h:13,
from include/kvm/kvm.h:6,
from main.c:1:
[snip]
../../include/asm-generic/int-ll64.h:11:29: error: asm/bitsperlong.h: No such file or directory
make: *** No rule to make target `8250-serial.d', needed by `kvm'. Stop.
Following patch adds architecture specific include path to resolve this error.
Signed-off-by: Prasad Joshi <prasadjoshi124@gmail.com> Signed-off-by: Pekka Enberg <penberg@kernel.org>
Pekka Enberg [Sun, 3 Apr 2011 09:42:12 +0000 (12:42 +0300)]
kvm tools: Fix required boot protocol version
Cyrill has an old bzImage that SIGSEGVs when running under KVM because
'cmdline_size' is bogus. Reading Documentation/x86/boot.txt, it turns out
32-bit 'cmdline_size' requires boot protocol 2.06 or later so fix up
BOOT_PROTOCOL_REQUIRED.
Reported-by: Cyrill Gorcunov <gorcunov@gmail.com> Signed-off-by: Pekka Enberg <penberg@kernel.org>
Pekka Enberg [Sun, 3 Apr 2011 08:25:14 +0000 (11:25 +0300)]
kvm tools: Fix E820 map on x86-64
We must not define '-D__x86_64__' for all the code because the BIOS emulation
code is actually real mode 16-bite code. This fixes E820 map regression on
x86-64 caused by commit e227ea5 ("kvm tools: Fix compilation on x86_64").
Paul Bolle [Thu, 31 Mar 2011 20:33:02 +0000 (22:33 +0200)]
kvm tools: Fix compilation on x86_64
Compilation on x86_64 failed with:
[...]
In file included from /usr/include/features.h:386:0,
from /usr/include/stdint.h:26,
from
/usr/lib/gcc/x86_64-redhat-linux/4.5.1/include/stdint.h:3,
from include/kvm/e820.h:4,
from bios/e820.c:1:
/usr/include/gnu/stubs.h:7:27: fatal error: gnu/stubs-32.h: No such file
or directory
compilation terminated.
make: *** [bios/bios-rom.bin] Error 1
This is caused by a typo in the Makefile and because gnu/stubs.h (and
friends) expect to see __x86_64__. That's trivial to fix.
Acked-by: Cyrill Gorcunov <gorcunov@gmail.com> Signed-off-by: Paul Bolle <pebolle@tiscali.nl> Signed-off-by: Pekka Enberg <penberg@kernel.org>
Pekka Enberg [Thu, 24 Mar 2011 16:56:02 +0000 (18:56 +0200)]
kvm tools, 8250: Don't set the UART_LSR_OE bit
User input is buffered anyway, so it's pointless to set the UART_LSR_OE bit.
Instead, wait for the guest kernel to consume the current input and send a new
character when the guest is ready.
This fixes the following warnings in guest kernels:
[ 207.485000] ttyS0: 1 input overrun(s)
Reported-by: Asias He <asias.hejun@gmail.com> Signed-off-by: Pekka Enberg <penberg@kernel.org>
Asias He [Sat, 26 Feb 2011 02:11:52 +0000 (10:11 +0800)]
kvm,virtio: add scatter-gather support v2
The size of the virtqueue(16) was smaller than scatter-gather(128)
which hypervisor tells the guest. Under some circumstances,
if the guest uses scatter-gather which larger than 16 - 2, kernel panics.
That is why the scatter-gather support v1 breaks Cyrill's kernel boot.
Two descriptors are used as the header and status descriptors.
The remaining descriptors can be used as the real disk data descriptors.
So DISK_SEG_MAX should be VIRTIO_BLK_QUEUE_SIZE - 2.
VIRTIO_BLK_QUEUE_SIZE is 128 and DISK_SEG_MAX is 126 in this patch.
Tested-by: Cyrill Gorcunov <gorcunov@gmail.com> Signed-off-by: Asias He <asias.hejun@gmail.com> Signed-off-by: Pekka Enberg <penberg@kernel.org>
Pekka Enberg [Tue, 11 Jan 2011 18:52:06 +0000 (20:52 +0200)]
kvm,serial: Implement 16550A FIFO support
This patch implements 16550A FIFO support to the serial console emulation
layer. There's still a bug lurking somewhere which the hypervisor in some busy
loop taking up 100% of CPU. However, this patch is a definite improvement over
the previous hacks.
Pekka Enberg [Mon, 10 Jan 2011 22:06:28 +0000 (00:06 +0200)]
kvm,8250: Cleanup receive emulation
This patch cleans up receive emulation by separating the stdin polling and
reading logic from the interrupt logic. The patch also fixes the interrupt
injection code to inject one type of interrupt at a time.
Pekka Enberg [Mon, 10 Jan 2011 19:46:37 +0000 (21:46 +0200)]
kvm,8250: Fix "too much work for irq4" problems
This patch fixes the "too much work for irq4" problems caused by the fact that
we never set the UART_IIR_NO_INT flag in the emulation layer. This makes the
interrupt handler in the guest kernel process as much as possible which
triggers a warning.
Pekka Enberg [Sun, 9 Jan 2011 20:15:04 +0000 (22:15 +0200)]
kvm: Put terminal in canonical mode
As suggested by Ingo Molnar, put terminal in canonical mode. This makes poll()
on stdin to react to keystrokes insted of return key and fixes the double
echo'd character problem for input.
Pekka Enberg [Sat, 8 Jan 2011 20:56:25 +0000 (22:56 +0200)]
kvm,serial: Enable THRI bit in IIR register
This patch enables the THRI ("transmission holding register empty") bit in the
IIR register to make sure the guest doesn't think we have data waiting for it.
Pekka Enberg [Sat, 8 Jan 2011 10:18:44 +0000 (12:18 +0200)]
kvm: Fix virtqueue ring index check
This patch fixes the virtqueu ring index check that was totally wrong. The
->last_avail_idx is the index we've last seen but it doesn't need to match with
avail->idx.
Pekka Enberg [Wed, 5 Jan 2011 17:54:48 +0000 (19:54 +0200)]
kvm: Add support for disk images
This patch implements "--image" command line option that can be used to specify
a disk image. It supports raw images and it needs to be integrated to the
hypervisor block layer.