]> git.kernelconcepts.de Git - karo-tx-linux.git/log
karo-tx-linux.git
13 years agokvm tools: Fix a possible segfault if raw_image__probe returns NULL
Prasad Joshi [Fri, 8 Apr 2011 18:29:15 +0000 (19:29 +0100)]
kvm tools: Fix a possible segfault if raw_image__probe returns NULL

raw_image__probe() might return NULL therefore, using self->fd will segment.
Instead use the local fd variable to close the file.

Signed-off-by: Prasad Joshi <prasadjoshi124@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Use static assignment for default RAM size
Cyrill Gorcunov [Fri, 8 Apr 2011 17:54:34 +0000 (21:54 +0400)]
kvm tools: Use static assignment for default RAM size

No need to make an additional check-and-set.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Cleanup virtio_blk_do_io_request I/O error handling
Pekka Enberg [Fri, 8 Apr 2011 17:18:14 +0000 (20:18 +0300)]
kvm tools: Cleanup virtio_blk_do_io_request I/O error handling

There's no point in keeping track of I/O error count when a simple boolean flag
is all we need.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Fix .gitignore after Gitification merge
Pekka Enberg [Fri, 8 Apr 2011 16:57:28 +0000 (19:57 +0300)]
kvm tools: Fix .gitignore after Gitification merge

We now generate include/common-cmds.h header file so put that into the
.gitignore file so it's excluded from 'git status'.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agoMerge branch 'kvm/gitish' into kvm/core
Pekka Enberg [Fri, 8 Apr 2011 16:57:11 +0000 (19:57 +0300)]
Merge branch 'kvm/gitish' into kvm/core

Conflicts:
tools/kvm/Makefile
tools/kvm/main.c

13 years agokvm tools: Use the Gitish freamwork to run the virtual machine
Prasad Joshi [Fri, 8 Apr 2011 16:43:09 +0000 (17:43 +0100)]
kvm tools: Use the Gitish freamwork to run the virtual machine

- kvm-run.[ch] Adds a new kvm command called 'run'. The most of the code is
  copied from main.c.

- main.c is modified to use the functionality provided by framework.
  The old code from main.c is moved to kvm-run.c.

Signed-off-by: Prasad Joshi <prasadjoshi124@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Provide the basic Gitish framework
Prasad Joshi [Fri, 8 Apr 2011 16:43:08 +0000 (17:43 +0100)]
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>
13 years agokvm tools: Use code from perf for argument processing
Prasad Joshi [Fri, 8 Apr 2011 16:43:07 +0000 (17:43 +0100)]
kvm tools: Use code from perf for argument processing

- parse-options.[ch] has argument processing code.

- types.h: Additional types for argument processing.

- strbuf.[ch]: Added a function prefixcmp to compare string prefix

Signed-off-by: Prasad Joshi <prasadjoshi124@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Generate list of common kvm tool commands
Prasad Joshi [Fri, 8 Apr 2011 16:43:06 +0000 (17:43 +0100)]
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>
13 years agokvm tools: Use virt_queue__get_iov to simpify virtio blk IO handler
Asias He [Fri, 8 Apr 2011 16:10:07 +0000 (00:10 +0800)]
kvm tools: Use virt_queue__get_iov to simpify virtio blk IO handler

This really makes my life much easier!

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Drop virt_queue__get_used_elem virtio helper
Asias He [Fri, 8 Apr 2011 16:10:06 +0000 (00:10 +0800)]
kvm tools: Drop virt_queue__get_used_elem virtio helper

Use virt_queue__set_used_elem instead.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Unify virtio code file names
Asias He [Fri, 8 Apr 2011 16:10:05 +0000 (00:10 +0800)]
kvm tools: Unify virtio code file names

- rename {blk,console}-virtio.* to virtio-{blk,console}.*
- change the virtio block device PCI io space operation callback names

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Introduce virtio.c and virtio.h
Asias He [Fri, 8 Apr 2011 16:10:04 +0000 (00:10 +0800)]
kvm tools: Introduce virtio.c and virtio.h

This patch moves common virtio code to virtio.c and virtio.h.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Rename struct device to struct blk_device for block devices
Asias He [Fri, 8 Apr 2011 16:10:03 +0000 (00:10 +0800)]
kvm tools: Rename struct device to struct blk_device for block devices

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Indicate the end of a KVM session
Ingo Molnar [Fri, 8 Apr 2011 15:17:20 +0000 (17:17 +0200)]
kvm tools: Indicate the end of a KVM session

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>
13 years agokvm tools: Fix segfault when running 'kvm' without a disk image
Ingo Molnar [Fri, 8 Apr 2011 15:12:38 +0000 (17:12 +0200)]
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>
13 years agokvm tools: Emit a more informative error message when /dev/kvm does not open
Ingo Molnar [Fri, 8 Apr 2011 14:55:33 +0000 (16:55 +0200)]
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>
13 years agokvm tools: Send SysRq-P to guest kernel on SIGQUIT
Pekka Enberg [Fri, 8 Apr 2011 12:21:36 +0000 (15:21 +0300)]
kvm tools: Send SysRq-P to guest kernel on SIGQUIT

This patch makes SIGQUIT to the host hypervisor send 'SysRq-P' to the guest
kernel via 8250 serial console to make debugging stuck guests easier.

Cc: Asias He <asias.hejun@gmail.com>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Don't exit() on SIGQUIT
Pekka Enberg [Fri, 8 Apr 2011 12:14:33 +0000 (15:14 +0300)]
kvm tools: Don't exit() on SIGQUIT

The point of SIGQUIT is to dump relevant information of a running guest, not to
stop it.

Cc: Asias He <asias.hejun@gmail.com>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Use pread() and pwrite() in disk-image.c
Pekka Enberg [Fri, 8 Apr 2011 11:53:26 +0000 (14:53 +0300)]
kvm tools: Use pread() and pwrite() in disk-image.c

This patch convert lseek() + read()/write() pairs with pread()/pwrite(). The
performance of running the following command

  dd if=/dev/vda of=/dev/null

in the guest does not show significant performance differences but should be a
net win because of the reduction in system calls.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Introduce --enable-virtio-console option
Asias He [Fri, 8 Apr 2011 14:12:53 +0000 (22:12 +0800)]
kvm tools: Introduce --enable-virtio-console option

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>
13 years agokvm tools: Virtio console support
Asias He [Fri, 8 Apr 2011 14:12:52 +0000 (22:12 +0800)]
kvm tools: Virtio console support

This patch adds simple virtio console support to the hypervisor.

NOTE, NOTE, NOTE: Please add something like this to your /etc/inittab file:

    T2:23:respawn:/sbin/getty -L hvc0 9600 vt100

to get a virtio console login.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Make 8250 serial use infrastructure provided by term.c
Asias He [Fri, 8 Apr 2011 14:12:51 +0000 (22:12 +0800)]
kvm tools: Make 8250 serial use infrastructure provided by term.c

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Move terminal related code to a new file term.c
Asias He [Fri, 8 Apr 2011 14:12:50 +0000 (22:12 +0800)]
kvm tools: Move terminal related code to a new file term.c

This patch is a preparational step for virtio console and 8250 serial console
code consolidation.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Add helper functions for virtqueue code
Asias He [Fri, 8 Apr 2011 14:12:49 +0000 (22:12 +0800)]
kvm tools: Add helper functions for virtqueue code

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Cleanup IO space and PCI magic numbers
Asias He [Fri, 8 Apr 2011 14:12:48 +0000 (22:12 +0800)]
kvm tools: Cleanup IO space and PCI magic numbers

This patch define macros for virtio device IO space size and PCI device
numbering.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Fix input hang when compiling without optimization
Sasha Levin [Wed, 6 Apr 2011 18:47:27 +0000 (21:47 +0300)]
kvm tools: Fix input hang when compiling without optimization

When compiling without optimizations (-O0) input would hang.
This was caused by poll() returning there was data to read but read()
failing.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Use STDIN_FILENO instead of fileno(stdin)
Pekka Enberg [Wed, 6 Apr 2011 18:09:14 +0000 (21:09 +0300)]
kvm tools: Use STDIN_FILENO instead of fileno(stdin)

To cleanup the serial console emulation code, use STDIN_FILENO which is POSIX
API instead of fileno(stdin) which is libc API.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools, bios: Introduce bioscall specificator
Cyrill Gorcunov [Wed, 6 Apr 2011 17:19:08 +0000 (21:19 +0400)]
kvm tools, bios: Introduce bioscall specificator

We are to be sure how arguments are passed from
bios assembler code to C code. Just for sure.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Free memory and FDs on exit
Sasha Levin [Wed, 6 Apr 2011 16:07:43 +0000 (19:07 +0300)]
kvm tools: Free memory and FDs on exit

Following patch adds more cleanup code when exiting.
Close disk image, free msrs array and destroy the timer fd.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Drop hard-coded 'nosmp' kernel parameter
Pekka Enberg [Wed, 6 Apr 2011 15:46:29 +0000 (18:46 +0300)]
kvm tools: Drop hard-coded 'nosmp' kernel parameter

As noted by Cyrill, there's no need to pass 'nosmp' to the guest kernel because
it'll switch to PIC after noticing APIC is not available.

Cc: Asias He <asias.hejun@gmail.com>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Cleanup disk image code
Pekka Enberg [Wed, 6 Apr 2011 13:25:17 +0000 (16:25 +0300)]
kvm tools: Cleanup disk image code

This patch cleans up disk image in preparation for supporting other disk
format.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Cleanup virtio block device configuration
Pekka Enberg [Wed, 6 Apr 2011 13:25:17 +0000 (16:25 +0300)]
kvm tools: Cleanup virtio block device configuration

This patch removes obsolete virtio block device configuration bits that are no
longer used.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: remove KVM_EXIT_INTERNAL_ERROR
Asias He [Thu, 7 Apr 2011 08:33:41 +0000 (16:33 +0800)]
kvm tools: remove KVM_EXIT_INTERNAL_ERROR

Since we are in tools/kvm, remove the compatibility define

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Separate BIOS specifics into own file
Cyrill Gorcunov [Tue, 5 Apr 2011 17:44:57 +0000 (20:44 +0300)]
kvm tools: Separate BIOS specifics into own file

Instead of calling various BIOS routines from kvm.c better to have all BIOS
specifics sit in bios.c.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Remove useless empty lines for a call series in kvm__reset_vcpu
Cyrill Gorcunov [Tue, 5 Apr 2011 17:44:30 +0000 (20:44 +0300)]
kvm tools: Remove useless empty lines for a call series in kvm__reset_vcpu

Also add a comment on function in kernel-doc style.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Setup BIOS for both bzImage and flat image
Cyrill Gorcunov [Tue, 5 Apr 2011 17:43:39 +0000 (20:43 +0300)]
kvm tools: Setup BIOS for both bzImage and flat image

There is no differences in terms of BIOS what kind of kernel is loaded so we
have to setup BIOS for both bzImage and flat image.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Cleanup strstr() in expression
Pekka Enberg [Tue, 5 Apr 2011 16:48:40 +0000 (19:48 +0300)]
kvm tools: Cleanup strstr() in expression

Cleanup use of strstr() in an expression in main() function.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: do not append root=/dev/vda if passed via command line
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,

  ./kvm --kernel=/tmp/vmlinuz-2.6.38 \
        --initrd=/tmp/initramfs-2.6.38.img \
        --image=/home/dsa/vm/images/f14/nkvm-f14.img \
        --mem=1024
        --params="ro root=/dev/mapper/vg_f14vm-lv_root"

works now.

Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agotools kvm: Fix missing ARCH define on 32-bit in Makefile
Pekka Enberg [Mon, 4 Apr 2011 15:23:47 +0000 (18:23 +0300)]
tools kvm: Fix missing ARCH define on 32-bit in Makefile

Commit daf68ae ("kvm tools: Fix KVM problem on SuSe 2.6.37 kernel") missed a
hunk that's needed on 32 bit x86.

Reported-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Fix KVM problem on SuSe 2.6.37 kernel
Prasad Joshi [Mon, 4 Apr 2011 15:03:21 +0000 (16:03 +0100)]
kvm tools: Fix KVM problem on SuSe 2.6.37 kernel

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>
13 years agokvm tools: add README
Asias He [Sun, 3 Apr 2011 10:50:51 +0000 (18:50 +0800)]
kvm tools: add README

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Fix required boot protocol version
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>
13 years agokvm tools: Fix E820 map on x86-64
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").

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm 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>
13 years agokvm tools: Fix large disk images on 32-bit
Pekka Enberg [Thu, 31 Mar 2011 08:50:09 +0000 (11:50 +0300)]
kvm tools: Fix large disk images on 32-bit

Use read()/write() instead of mmap() for virtio block device emulation to
support large disk images on 32-bit.

Reported-and-tested-by: Asias He <asias.hejun@gmail.com>
Tested-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools, 8250: Don't set the UART_LSR_OE bit
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>
13 years agotools/kvm: Exit gracefully upon KVM_EXIT_SHUTDOWN
Pekka Enberg [Tue, 22 Mar 2011 19:32:46 +0000 (21:32 +0200)]
tools/kvm: Exit gracefully upon KVM_EXIT_SHUTDOWN

This patch changes the userspace hypervisor to exit gracefully upon
KVM_EXIT_SHUTDOWN which is triggered when guest userspace is shut down.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm,virtio: add scatter-gather support v2
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>
13 years agokvm tools: Cleanup virtqueue handling
Pekka Enberg [Sun, 23 Jan 2011 19:21:58 +0000 (21:21 +0200)]
kvm tools: Cleanup virtqueue handling

This patch introduces some virtqueue handling helper functions and converts the
blk virtio device to use them.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm,8250: Fix device initial state
Pekka Enberg [Sun, 23 Jan 2011 09:49:39 +0000 (11:49 +0200)]
kvm,8250: Fix device initial state

This patch fixes 8250 device initial state for registers and IRQ based on what
Qemu does.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Cleanup termios handling
Pekka Enberg [Tue, 18 Jan 2011 21:05:06 +0000 (23:05 +0200)]
kvm tools: Cleanup termios handling

This patch cleans up the confused termios handling to do what Lguest does.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm: Remove duplicate headers
Pekka Enberg [Sun, 16 Jan 2011 21:09:01 +0000 (23:09 +0200)]
kvm: Remove duplicate headers

We're in the kernel source tree now so remove duplicate headers.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agoRevert "kvm,virtio: add scatter-gather support"
Pekka Enberg [Sun, 16 Jan 2011 21:06:42 +0000 (23:06 +0200)]
Revert "kvm,virtio: add scatter-gather support"

This reverts commit 87a53e99dad8b70decbc4d9744c3d272e51c3ceb.  It breaks
Cyrill's kernel boot.

13 years agovirtio, block: Rename IOPORT_VIRTIO to IOPORT_VIRTIO_BLK
Cyrill Gorcunov [Thu, 13 Jan 2011 16:56:17 +0000 (18:56 +0200)]
virtio, block: Rename IOPORT_VIRTIO to IOPORT_VIRTIO_BLK

Since that is its only purpose, not the whole virtio
stuff.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm,virtio: add scatter-gather support
Asias He [Thu, 13 Jan 2011 11:56:05 +0000 (19:56 +0800)]
kvm,virtio: add scatter-gather support

Publish VIRTIO_BLK_F_SEG_MAX feature to guest.

In disk I/O request, guest can use multiple buffers which are not physicall
contiguousy as the I/O request buffer.

[ penberg@kernel.org: cleanups ]
Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm: Cleanup interrupt timer logic
Pekka Enberg [Tue, 11 Jan 2011 21:56:22 +0000 (23:56 +0200)]
kvm: Cleanup interrupt timer logic

This patch moves the interrupt timer logic to kvm.c and cleans it up.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm,serial: Implement 16550A FIFO support
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.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm,8250: Implement missing register emulation
Pekka Enberg [Tue, 11 Jan 2011 15:52:22 +0000 (17:52 +0200)]
kvm,8250: Implement missing register emulation

This patch implements missing register emulation as per "UART register to port
conversion table" here:

  http://www.lammertbies.nl/comm/info/serial-uart.html

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years ago8250-serial: Emulate 8250 behaviour on autoprobing
Cyrill Gorcunov [Tue, 11 Jan 2011 06:08:15 +0000 (08:08 +0200)]
8250-serial: Emulate 8250 behaviour on autoprobing

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm,8250: Cleanup receive emulation
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.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm,8250: Fix ->counter clearing
Pekka Enberg [Mon, 10 Jan 2011 20:20:06 +0000 (22:20 +0200)]
kvm,8250: Fix ->counter clearing

We need to reset the counter to zero before we inject an interrupt to the
guest.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm,8250: Fix "too much work for irq4" problems
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.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm,8250: Make ttyS1 and ttyS2 disabled
Pekka Enberg [Mon, 10 Jan 2011 19:21:06 +0000 (21:21 +0200)]
kvm,8250: Make ttyS1 and ttyS2 disabled

This patch fixes the 8250 serial emulation to not have undefined ioports but
rather make them explicitly disabled.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm: Support for more than one serial ttys
Pekka Enberg [Mon, 10 Jan 2011 19:12:03 +0000 (21:12 +0200)]
kvm: Support for more than one serial ttys

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm: Improve 8250 serial console interrupt handling
Pekka Enberg [Mon, 10 Jan 2011 18:28:37 +0000 (20:28 +0200)]
kvm: Improve 8250 serial console interrupt handling

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm: Use disk name for mounting root
Pekka Enberg [Mon, 10 Jan 2011 17:44:50 +0000 (19:44 +0200)]
kvm: Use disk name for mounting root

Use disk name for kernel "root=" parameter rather than the dynamic major and
minor numbers that vary from system to system.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agoMerge branch 'master' of /home/penberg/kvm into kvm/core
Pekka Enberg [Tue, 11 Jan 2011 14:49:41 +0000 (16:49 +0200)]
Merge branch 'master' of /home/penberg/kvm into kvm/core

13 years ago8250-serial: Make transmitter being always ready to send data
Cyrill Gorcunov [Mon, 10 Jan 2011 13:22:27 +0000 (16:22 +0300)]
8250-serial: Make transmitter being always ready to send data

Otherwise it causes kernel to do additional timeout
waiting for THR being empty.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
13 years ago8250-serial: Use linux/serial-reg.h with predefined constants
Cyrill Gorcunov [Mon, 10 Jan 2011 13:20:10 +0000 (16:20 +0300)]
8250-serial: Use linux/serial-reg.h with predefined constants

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
13 years ago8250-serial: Simplify is_readable function
Cyrill Gorcunov [Sun, 9 Jan 2011 23:06:10 +0000 (02:06 +0300)]
8250-serial: Simplify is_readable function

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
13 years agokvm: save/restore std ttys
Cyrill Gorcunov [Sun, 9 Jan 2011 21:30:32 +0000 (00:30 +0300)]
kvm: save/restore std ttys

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
13 years agokvm: Put terminal in canonical mode
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.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm,8250: Implement serial input support
Pekka Enberg [Sun, 9 Jan 2011 19:26:48 +0000 (21:26 +0200)]
kvm,8250: Implement serial input support

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agomake: Add TAGS, tags targets and tune cscope
Cyrill Gorcunov [Sun, 9 Jan 2011 17:12:43 +0000 (20:12 +0300)]
make: Add TAGS, tags targets and tune cscope

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
13 years agokvm: Use serial console by default
Pekka Enberg [Sun, 9 Jan 2011 16:32:38 +0000 (18:32 +0200)]
kvm: Use serial console by default

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm,8250: Inject interrupts to guest
Pekka Enberg [Sun, 9 Jan 2011 16:28:03 +0000 (18:28 +0200)]
kvm,8250: Inject interrupts to guest

This patch fixes 8250 emulation to inject interrupts to guest so we actually
see what's sent to the serial console.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm: Rename early_printk.c to 8250-serial.c
Pekka Enberg [Sun, 9 Jan 2011 11:02:04 +0000 (13:02 +0200)]
kvm: Rename early_printk.c to 8250-serial.c

The 8250 emulation is no longer there to just support early_printk() so rename
the source file to reflect that.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm: Implement support interrupt injection
Pekka Enberg [Sat, 8 Jan 2011 22:46:07 +0000 (00:46 +0200)]
kvm: Implement support interrupt injection

This patch implement support for injecting interrupts from the userspace
hypervisor to the guest.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm: Add rw to default kernel command line parameters
Asias He [Sun, 9 Jan 2011 08:48:40 +0000 (16:48 +0800)]
kvm: Add rw to default kernel command line parameters

As reported by Asias He, guest kernels mount filesystems as readonly under our
hypervisor:

  without rw:
  [    0.909000] EXT3-fs: mounted filesystem with writeback data mode.
  [    0.909000] VFS: Mounted root (ext3 filesystem) readonly on device 253:1.

  /dev/root on / type ext3 (ro,relatime,errors=continue,data=writeback)

by passing the "rw" kernel parameter, guest kernels are able to mount as
read-write:

  [    0.891000] EXT3 FS on vda1, internal journal
  [    0.891000] EXT3-fs: recovery complete.
  [    0.892000] EXT3-fs: mounted filesystem with writeback data mode.
  [    0.892000] VFS: Mounted root (ext3 filesystem) on device 253:1.

  /dev/root on / type ext3 (rw,relatime,errors=continue,data=writeback)

There's some real problem hiding here but as we've done with other parts of the
kernel (PCI, SMP), just bypass the problem for now.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm,virtio: do not publish read only feature to guest
Asias He [Sun, 9 Jan 2011 08:48:39 +0000 (16:48 +0800)]
kvm,virtio: do not publish read only feature to guest

We support write operations now.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm,virtio: move SECTOR_SHIFT and SECTOR_SIZE to disk-image.h
Asias He [Sun, 9 Jan 2011 08:01:40 +0000 (16:01 +0800)]
kvm,virtio: move SECTOR_SHIFT and SECTOR_SIZE to disk-image.h

Suggested-by: Pekka Enberg <penberg@kernel.org>
Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm,serial: Enable THRI bit in IIR register
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.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm: Fix magic numbers in 8250 support
Pekka Enberg [Sat, 8 Jan 2011 20:51:10 +0000 (22:51 +0200)]
kvm: Fix magic numbers in 8250 support

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm: Improve 8250 serial console support
Pekka Enberg [Sat, 8 Jan 2011 17:29:23 +0000 (19:29 +0200)]
kvm: Improve 8250 serial console support

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm: Redirect serial console to stdout, not stderr
Pekka Enberg [Sat, 8 Jan 2011 12:50:32 +0000 (14:50 +0200)]
kvm: Redirect serial console to stdout, not stderr

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm: Implement virtio block device write support
Pekka Enberg [Sat, 8 Jan 2011 12:28:59 +0000 (14:28 +0200)]
kvm: Implement virtio block device write support

This patch implement virtio block device write support. The writes are not
persistent because we map the disk image with MAP_PRIVATE.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm: Kill debug logging from blk-virtio.c
Pekka Enberg [Sat, 8 Jan 2011 11:24:49 +0000 (13:24 +0200)]
kvm: Kill debug logging from blk-virtio.c

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm: Support MSR register for serial console
Pekka Enberg [Sat, 8 Jan 2011 11:20:56 +0000 (13:20 +0200)]
kvm: Support MSR register for serial console

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm: Fix virtio block device support some more
Pekka Enberg [Sat, 8 Jan 2011 10:06:47 +0000 (12:06 +0200)]
kvm: Fix virtio block device support some more

This patch fixes the following issues in virtio block device support:

- Handle all requests in the virtqueue before signaling an interrupt.

- Initialize ->used vring elements properly.

- Handle non-read requests by injecting an I/O error to the guest.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm: Fix virtqueue ring index check
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.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agovirtio: capacity should be in 512-byte sectors
Asias He [Sat, 8 Jan 2011 02:28:26 +0000 (10:28 +0800)]
virtio: capacity should be in 512-byte sectors

struct virtio_blk_config {
        /* The capacity (in 512-byte sectors). */
        uint64_t capacity;
...
}

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm: Fail if user specifies a QCOW disk image
Pekka Enberg [Fri, 7 Jan 2011 19:25:24 +0000 (21:25 +0200)]
kvm: Fail if user specifies a QCOW disk image

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm: Improve kvm__init() error message
Pekka Enberg [Fri, 7 Jan 2011 19:17:59 +0000 (21:17 +0200)]
kvm: Improve kvm__init() error message

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm: Enable virtio block device if disk image specified
Pekka Enberg [Fri, 7 Jan 2011 19:06:27 +0000 (21:06 +0200)]
kvm: Enable virtio block device if disk image specified

This patch removes the "--enable-virtion" command line option and enable virtio
block device when a disk image is specified.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agoMerge branch 'master' of git://github.com/cyrillos/vm
Pekka Enberg [Thu, 6 Jan 2011 09:58:36 +0000 (11:58 +0200)]
Merge branch 'master' of git://github.com/cyrillos/vm

13 years agovirtio-blk: Leave disk geometry to compute in kernel
Cyrill Gorcunov [Thu, 6 Jan 2011 09:55:32 +0000 (12:55 +0300)]
virtio-blk: Leave disk geometry to compute in kernel

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
13 years agokvm: Introduce a list of known BUGS
Pekka Enberg [Thu, 6 Jan 2011 09:48:45 +0000 (11:48 +0200)]
kvm: Introduce a list of known BUGS

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm: Cleanup disk geometry setup code
Pekka Enberg [Thu, 6 Jan 2011 08:22:09 +0000 (10:22 +0200)]
kvm: Cleanup disk geometry setup code

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm: Setup disk geometry if needed
Cyrill Gorcunov [Wed, 5 Jan 2011 22:37:29 +0000 (01:37 +0300)]
kvm: Setup disk geometry if needed

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>