]> git.karo-electronics.de Git - karo-tx-linux.git/log
karo-tx-linux.git
12 years agokvm tools: Use kernel error check functions
Lan Tianyu [Thu, 15 Dec 2011 13:40:14 +0000 (21:40 +0800)]
kvm tools: Use kernel error check functions

Add compiler.h file to support using kernel error check funciotns(e.g
ERR_PTR, PTR_ERR and so on).

Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Fix rootfs name resolving when specified with image
Sasha Levin [Thu, 15 Dec 2011 12:15:10 +0000 (14:15 +0200)]
kvm tools: Fix rootfs name resolving when specified with image

Fix the case when using a rootfs combined with a virtio-blk disk.

Also, simplify custon rootfs name lookup.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Fix running with --initrd and no real discs/rootfs
Matt Evans [Thu, 15 Dec 2011 07:13:41 +0000 (18:13 +1100)]
kvm tools: Fix running with --initrd and no real discs/rootfs

It's useful to boot with no -d and no implicit 9p root, with --initrd.
Since commit eaf720b285947a6f4e29174d0eba1899de31d8ab, we die() failing
to create the 2nd stage custom rootfs.  This patch doesn't try to set up
a custom rootfs by default if user specifies an initrd on the commandline.

Signed-off-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Get correct 64-bit types on PPC64 and link appropriately
Matt Evans [Fri, 9 Dec 2011 06:53:50 +0000 (17:53 +1100)]
kvm tools: Get correct 64-bit types on PPC64 and link appropriately

kvmtool's types.h includes <asm/types.h>, which by default on PPC64 brings in
int-l64.h; define __SANE_USERSPACE_TYPES__ to get LL64 types.

This patch also adds CFLAGS to the final link, so that any -m64 is obeyed
when linking, too.

Signed-off-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agoPPC: Add __SANE_USERSPACE_TYPES__ to asm/types.h for LL64
Matt Evans [Thu, 8 Dec 2011 06:57:09 +0000 (17:57 +1100)]
PPC: Add __SANE_USERSPACE_TYPES__ to asm/types.h for LL64

PPC64 uses long long for u64 in the kernel, but powerpc's asm/types.h
prevents 64-bit userland from seeing this definition, instead defaulting
to u64 == long in userspace.  Some user programs (e.g. kvmtool) may actually
want LL64, so this patch adds a check for __SANE_USERSPACE_TYPES__ so that,
if defined, int-ll64.h is included instead.

Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Fix alaising errors in LINT assignment
Matt Evans [Wed, 14 Dec 2011 02:06:44 +0000 (13:06 +1100)]
kvm tools: Fix alaising errors in LINT assignment

I'm getting this on x86-32, gcc 4.4.3:

  CC       x86/kvm-cpu.o
cc1: warnings being treated as errors
x86/kvm-cpu.c: In function ‘kvm_cpu__set_lint’:
x86/kvm-cpu.c:89: error: dereferencing pointer ‘lapic’ does break strict-aliasing rules
x86/kvm-cpu.c:88: error: dereferencing pointer ‘lapic’ does break strict-aliasing rules
x86/kvm-cpu.c:83: note: initialized from here
make: *** [x86/kvm-cpu.o] Error 1

Removing the nasty aliasing seems to be a good way to go.

Acked-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agoRevert "kvm tools: Add kvm__has_cap() to check whether a cap is available on the...
Sasha Levin [Thu, 15 Dec 2011 06:02:55 +0000 (08:02 +0200)]
Revert "kvm tools: Add kvm__has_cap() to check whether a cap is available on the host"

We already had kvm__has_extension, no need for two functions that do the
same.

This reverts commit 42efb1abf4ebebeedd14af34c073e673923e2898.

Conflicts:

tools/kvm/include/kvm/kvm.h

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Use kvm__supports_extension instead of kvm__has_cap
Sasha Levin [Thu, 15 Dec 2011 06:02:54 +0000 (08:02 +0200)]
kvm tools: Use kvm__supports_extension instead of kvm__has_cap

kvm__supports_extension has been there before, and it's does it's job right
unlike kvm__has_cap.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Remove KVM_NR_CPUS
Matt Evans [Thu, 15 Dec 2011 05:06:57 +0000 (16:06 +1100)]
kvm tools: Remove KVM_NR_CPUS

The KVM_NR_CPUS define is only really used to statically size the global
kvm_cpus array, which can just as easily be allocated on startup.  There is
some checking of the -c <nr cpus> value given against NR_CPUs but this is
later again checked against a dynamically-determined limit from
KVM_CAP_MAX_VCPUS anyway.  The hardwired limit is arbitrary and not strictly
necessary.

This patch removes the #define, replacing the statically-sized array with
a malloc; the array is kvm->nrcpus+1 in size so that any iterator can halt
at the end (this is done in kvm_cpu__reboot, which doesn't have access to
a struct kvm* and therefore kvm->nrcpus).

An unused #define in x86/mptable.c is also removed.

Signed-off-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Don't use ioeventfds if no KVM_CAP_IOEVENTFD
Sasha Levin [Wed, 14 Dec 2011 06:37:26 +0000 (08:37 +0200)]
kvm tools: Don't use ioeventfds if no KVM_CAP_IOEVENTFD

Check KVM_CAP_IOEVENTFD before using ioeventfds.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Add kvm__has_cap() to check whether a cap is available on the host
Sasha Levin [Wed, 14 Dec 2011 06:37:25 +0000 (08:37 +0200)]
kvm tools: Add kvm__has_cap() to check whether a cap is available on the host

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Fix MMIO ordering problem cause due to coalescing
Sasha Levin [Wed, 14 Dec 2011 13:11:22 +0000 (15:11 +0200)]
kvm tools: Fix MMIO ordering problem cause due to coalescing

If we took a MMIO exit, the data in the coalesced ring should be processes
before the data in the exit itself is processed.

Doing it wrong (like we did so far) will cause ordering issues.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Don't always coalesce MMIOs
Sasha Levin [Wed, 14 Dec 2011 13:11:21 +0000 (15:11 +0200)]
kvm tools: Don't always coalesce MMIOs

Coalescing MMIOs is only required when we really want avoid having to exit
to userspace for every MMIO write, usually it's not the case so no reason
to coalesce every MMIO zone (I was also pretty sure it didn't always coalesce
zones)..

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Add initial SPAPR PPC64 architecture support
Matt Evans [Tue, 13 Dec 2011 07:00:26 +0000 (18:00 +1100)]
kvm tools: Add initial SPAPR PPC64 architecture support

This patch adds a new arch directory, powerpc, basic file structure, register
setup and where necessary stubs out arch-specific functions (e.g. interrupts,
runloop exits) that later patches will provide.  The target is an
SPAPR-compliant PPC64 machine (i.e. pSeries); there is no support for PPC32 or
'bare metal' PPC64 guests as yet.  Subsequent patches implement the hcalls and
RTAS required to boot SPAPR pSeries kernels.

Memory is mapped from hugetlbfs (as that is currently required by upstream PPC64
HV-mode KVM).  The mapping of a VRMA region is yet to be implemented; this is
only necessary on processors that don't support VRMA, e.g. <= P6.  Work is
therefore needed to get this going on pre-P7 CPUs.

Processor state is set up as a guest kernel would expect (both primary and
secondaries), and SMP is fully supported.

Finally, support is added for simply loading flat binary kernels (plus initrd).
(bzImages are not used on PPC, and this series does not add zImage support or an
ELF loader.)  The intention is to later support loading firmware such as SLOF.

Signed-off-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Fix build of util.c on 32bit machines
Matt Evans [Wed, 14 Dec 2011 01:10:03 +0000 (12:10 +1100)]
kvm tools: Fix build of util.c on 32bit machines

commit 378ee7e6dd301347c6bf2c740cb1fb40174bcb8b broke the -Werror build
on 32bit targets due to some variable typing in struct statfs:

On 14/12/11 11:03, David Evensky wrote:
> On an x86 32bit system (and using the 32bit CodeSourcery toolchain on
> a x86_64 system) I get:
>
> evensky@machine:~/.../linux-kvm/tools/kvm$ make
>   CC       util/util.o
> util/util.c: In function 'mmap_hugetlbfs':
> util/util.c:93:17: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
> util/util.c:99:7: error: format '%ld' expects argument of type 'long int', but argument 2 has type 'int' [-Werror=format]
> cc1: all warnings being treated as errors
>
> make: *** [util/util.o] Error 1

Fixes the build.

Reported-by: David Evensky <evensky@dancer.ca.sandia.gov>
Signed-off-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Create arch-specific kvm_cpu__emulate_{mm}io()
Matt Evans [Tue, 13 Dec 2011 06:21:47 +0000 (17:21 +1100)]
kvm tools: Create arch-specific kvm_cpu__emulate_{mm}io()

Different architectures will deal with MMIO exits differently.  For example,
KVM_EXIT_IO is x86-specific, and I/O cycles are often synthesised by steering
into windows in PCI bridges on other architectures.

This patch calls arch-specific kvm_cpu__emulate_io() and kvm_cpu__emulate_mmio()
from the main runloop's IO and MMIO exit handlers.  For x86, these directly
call kvm__emulate_io() and kvm__emulate_mmio() but other architectures will
perform some address munging before passing on the call.

Signed-off-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Add ability to map guest RAM from hugetlbfs
Matt Evans [Tue, 13 Dec 2011 06:21:46 +0000 (17:21 +1100)]
kvm tools: Add ability to map guest RAM from hugetlbfs

Add a --hugetlbfs commandline option to give a path to hugetlbfs-map guest
memory (down in kvm__arch_init()).  For x86, guest memory is a normal
ANON mmap() if this option is not provided, otherwise a hugetlbfs mmap.

This maps directly from a hugetlbfs temp file rather than using something
like MADV_HUGEPAGES so that, if the user asks for hugepages, we definitely
are using hugepages.  (This is particularly useful for architectures that
don't yet support KVM without hugepages, so we definitely need to use
them for the whole of guest RAM.)

Signed-off-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: remove duplicated code
Lai Jiangshan [Mon, 12 Dec 2011 07:15:55 +0000 (15:15 +0800)]
kvm tools: remove duplicated code

Simple cleanup.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: protect shared global id in compat_mtx C.S.
Lai Jiangshan [Mon, 12 Dec 2011 07:15:54 +0000 (15:15 +0800)]
kvm tools: protect shared global id in compat_mtx C.S.

The global id is shared, protect it when access it.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: narrow the C.S. of compat_mtx
Lai Jiangshan [Mon, 12 Dec 2011 07:15:53 +0000 (15:15 +0800)]
kvm tools: narrow the C.S. of compat_mtx

The allocation and the copy are not required in the C.S.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: move strlcat() to util/strbuf.c
Lai Jiangshan [Mon, 12 Dec 2011 07:15:52 +0000 (15:15 +0800)]
kvm tools: move strlcat() to util/strbuf.c

strlcat() is a string related function.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: move util.c to util/
Lai Jiangshan [Mon, 12 Dec 2011 07:15:51 +0000 (15:15 +0800)]
kvm tools: move util.c to util/

util.c is a lib for kvm.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: move read-write.c to util/
Lai Jiangshan [Mon, 12 Dec 2011 07:15:50 +0000 (15:15 +0800)]
kvm tools: move read-write.c to util/

read-write.c contains no kvm related code, it is just a lib.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: add missing build output
Lai Jiangshan [Mon, 12 Dec 2011 07:15:49 +0000 (15:15 +0800)]
kvm tools: add missing build output

The missing "CC       util/rbtree.o" will be output when building.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: move rbtree.o to util/
Lai Jiangshan [Mon, 12 Dec 2011 07:15:48 +0000 (15:15 +0800)]
kvm tools: move rbtree.o to util/

rbtree.o is just a lib for kvm.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: move threadpool.c to util/
Lai Jiangshan [Mon, 12 Dec 2011 07:15:47 +0000 (15:15 +0800)]
kvm tools: move threadpool.c to util/

threadpool.c contains no kvm related code, it is just a lib.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: fix function name
Lai Jiangshan [Mon, 12 Dec 2011 07:15:46 +0000 (15:15 +0800)]
kvm tools: fix function name

In here, xxx_locked() should means "called with job_mutex locked",
the original funtion are opposite, fix them.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: check condition before wait
Lai Jiangshan [Mon, 12 Dec 2011 07:15:45 +0000 (15:15 +0800)]
kvm tools: check condition before wait

We should check the condition before wait it,
otherewise we may get deadlock.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Clean up 'kvm debug'
Sasha Levin [Mon, 12 Dec 2011 09:19:49 +0000 (11:19 +0200)]
kvm tools: Clean up 'kvm debug'

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Clean up LINT assignment code
Sasha Levin [Sun, 11 Dec 2011 19:50:19 +0000 (21:50 +0200)]
kvm tools: Clean up LINT assignment code

Just set delivery mode directly without going through ugly casting.

This cleans up and simplifies the code.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Add NMI ability to 'kvm debug'
Sasha Levin [Sun, 11 Dec 2011 10:51:13 +0000 (12:51 +0200)]
kvm tools: Add NMI ability to 'kvm debug'

This allows triggering NMI on guests using 'kvm debug -m [cpu]'.

Please note that the default behaviour of 'kvm debug' dumping guest's cpu
state has been modified to require a '-d'/--dump.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Call executable 'lkvm' and add 'vm' alias
Pekka Enberg [Sun, 11 Dec 2011 19:27:16 +0000 (21:27 +0200)]
kvm tools: Call executable 'lkvm' and add 'vm' alias

Several people have raised up the issue with our 'kvm' executable name. Rusty
came up with 'lkvm' which even Ingo is reasonably happy with:

  I could live with:

   - keeping 'tools/kvm/' as the tool project name

   - 'lkvm' as the binary

   - a command alias binary (hardlink) to 'vm'. I just checked,
     it's not used by any other package.

  ... and be done with it?

  'lkvm' rhymes nicely to 'lkml' as well, so it's not a 100% bad
  name.

Suggested-by: Rusty Russell <rusty@rustcorp.com.au>
Suggested-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agoMerge branch 'kvmtool/sandbox' into kvmtool/next
Pekka Enberg [Sun, 11 Dec 2011 09:17:42 +0000 (11:17 +0200)]
Merge branch 'kvmtool/sandbox' into kvmtool/next

Conflicts:
tools/kvm/Makefile

12 years agokvm tools: Add 'kvm sandbox'
Sasha Levin [Mon, 5 Dec 2011 14:16:36 +0000 (16:16 +0200)]
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>
12 years agokvm tools: Ignore parameters after dashdash in 'kvm run'
Sasha Levin [Mon, 5 Dec 2011 14:16:35 +0000 (16:16 +0200)]
kvm tools: Ignore parameters after dashdash in 'kvm run'

This allows other commands to wrap 'kvm run' and use the parameters user
provides after a dash-dash for it's own use.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Allow easily sandboxing applications within a guest
Sasha Levin [Mon, 5 Dec 2011 14:16:34 +0000 (16:16 +0200)]
kvm tools: Allow easily sandboxing applications within a guest

This patch adds a '--sandbox' argument when used in conjuction with a custom
rootfs, it allows running a script or an executable in the guest environment
by using executables and other files from the host.

This is useful when testing code that might cause problems on the host, or
to automate kernel testing since it's now easy to link a kvm tools test
script with 'git bisect run'.

Suggested-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Split custom rootfs init into two stages
Sasha Levin [Mon, 5 Dec 2011 14:16:32 +0000 (16:16 +0200)]
kvm tools: Split custom rootfs init into two stages

Currently custom rootfs init is built along with the main KVM tools executable
and is copied into custom rootfs directories when they are created with
'kvm setup'. The problem there is that if the init code changes, they have
to be manually copied to custom rootfs directories.

Instead, this patch splits init process into two parts. One part that simply
handles mounts, and passes it to stage 2 of the init.

Stage 2 really sits along in the code tree, and does all the heavy lifting.

This allows us to make init changes in the code tree and have it automatically
be updated in custom rootfs guests without having to copy files over manua

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
[ penberg@kernel.org: fix 'make check' breakage in Makefile ]
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Free up the MSI-X PBA BAR
Sasha Levin [Sat, 10 Dec 2011 20:40:43 +0000 (22:40 +0200)]
kvm tools: Free up the MSI-X PBA BAR

Free up the BAR to make space for the new virtio BARs. It isn't required
to have the PBA and the table in the separate BARs, and uniting them will
just give us extra BARs to play with.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Don't use 64bit BARs
Sasha Levin [Sat, 10 Dec 2011 20:40:42 +0000 (22:40 +0200)]
kvm tools: Don't use 64bit BARs

We don't really support that, so no point in using 64bit BARs.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: serial: Make it work with non rt guests as well
Thomas Gleixner [Sat, 10 Dec 2011 20:27:26 +0000 (21:27 +0100)]
kvm tools: serial: Make it work with non rt guests as well

Sasha reported, that a non RT guest reports "too much work for irq 4"
with the previous serial overhaul.

The reason is, that the new code allows unlimited tx transfers, which
triggers the sanity check in the 8250.c interrupt handler.

Limit the consecutive TX chars to 16 and let the guest kernel escape
from the 8250 interrupt handler. Set the TEMT/THRE bits in the
periodic serial console update.

Reported-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tool: serial: Fix interrupt handling
Thomas Gleixner [Sat, 10 Dec 2011 13:27:57 +0000 (13:27 +0000)]
kvm tool: serial: Fix interrupt handling

The interrupt injection of the serial emulation is completely
broken. It's just doing random toggling of the interrupt line, which
can lead to complete console hangs.

The real hardware asserts the interrupt line when a condition
(RX/TX/Status) is met and the corresponding interrupt is enabled in
the IER. It's deasserted when the condition is cleared or the
corresponding interrupt is disabled in the IER.

So the correct emulation just needs to check after each state change
in the LSR or the IER which bits in the IIR need to be set and update
the interrupt line accordingly. To avoid setting the same state over
and over keep an internal state of the last set interrupt line state
and only update via the kvm ioctl when the new state differs.

Rename serial8250__inject_interrupts() to serial8250__update_consoles()
which reflects what the function really is about.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tool: serial: Simplify switch cases
Thomas Gleixner [Sat, 10 Dec 2011 13:27:57 +0000 (13:27 +0000)]
kvm tool: serial: Simplify switch cases

There is no point to have the same switch case construct for all the
registers, just to take care of the oddball case of DLL/DLM.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tool: serial: Cleanup coding style
Thomas Gleixner [Sat, 10 Dec 2011 13:27:56 +0000 (13:27 +0000)]
kvm tool: serial: Cleanup coding style

It's nice to align struct initializers, but random tab insertion into
the code flow is a horrible idea.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Arch-specific define for PCI MMIO allocation area
Matt Evans [Fri, 9 Dec 2011 06:55:54 +0000 (17:55 +1100)]
kvm tools: Arch-specific define for PCI MMIO allocation area

pci_get_io_space_block() used to grab addresses from
KVM_32BIT_GAP_START + 0x1000000, which is x86-specific.  Create a new define,
KVM_PCI_MMIO_AREA, to specify a bus address these allocations can come from.

Signed-off-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Add pci__config_{rd,wr}(), pci__find_dev()
Matt Evans [Fri, 9 Dec 2011 06:55:45 +0000 (17:55 +1100)]
kvm tools: Add pci__config_{rd,wr}(), pci__find_dev()

This allows config space access in a more natural manner than clunky x86 IO ports,
and is useful for other architectures.  Internally, the x86 IO port access uses
these new config space interfaces.

Signed-off-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Correctly set virtio-pci bar_size and remove hardwired address
Matt Evans [Fri, 9 Dec 2011 06:55:41 +0000 (17:55 +1100)]
kvm tools: Correctly set virtio-pci bar_size and remove hardwired address

The BAR addresses are set up fine, but missed the bar_size[] array which is now
updated correspondingly.

Use PCI_IO_SIZE instead of '0x100'.

Signed-off-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Endian-sanitise pci.h and PCI device setup
Matt Evans [Fri, 9 Dec 2011 06:55:36 +0000 (17:55 +1100)]
kvm tools: Endian-sanitise pci.h and PCI device setup

vesa, pci-shmem and virtio-pci devices need to set up config space with
little-endian conversions (as config space is LE).  The pci_config_address
bitfield also needs to be reversed when building on BE systems.

Signed-off-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Move PCI_MAX_DEVICES to pci.h
Matt Evans [Fri, 9 Dec 2011 06:55:30 +0000 (17:55 +1100)]
kvm tools: Move PCI_MAX_DEVICES to pci.h

Other pieces of kvmtool may be interested in PCI_MAX_DEVICES.

Signed-off-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Init IRQs after determining nrcpus
Matt Evans [Fri, 9 Dec 2011 06:55:21 +0000 (17:55 +1100)]
kvm tools: Init IRQs after determining nrcpus

IRQ init may involve per-CPU setup/allocation of resources, so make sure
kvm->nrcpus is initialised before calling irq__init().

Signed-off-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Perform CPU and firmware setup after devices are added
Matt Evans [Fri, 9 Dec 2011 06:55:16 +0000 (17:55 +1100)]
kvm tools: Perform CPU and firmware setup after devices are added

Currently some devices (in this case kbd, fb, vesa) are initialised after
CPU/firmware setup.  On some platforms (e.g. PPC) kvm__arch_setup_firmware() may
be making a device tree.  Any devices added after this point will be missed!

Tiny refactor of builtin-run.c, moving timer start, firmware setup, cpu init
to occur last.

Signed-off-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Initialise PCI before devices start getting registered with PCI
Matt Evans [Fri, 9 Dec 2011 06:55:11 +0000 (17:55 +1100)]
kvm tools: Initialise PCI before devices start getting registered with PCI

Re-arrange pci__init() in builtin-run such that it comes before devices are
initialised.

Signed-off-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Allow load_flat_binary() to load an initrd alongside
Matt Evans [Fri, 9 Dec 2011 06:54:43 +0000 (17:54 +1100)]
kvm tools: Allow load_flat_binary() to load an initrd alongside

This patch passes the initrd fd and commandline to load_flat_binary(), which may
be used to load both the kernel & an initrd (stashing or inserting the
commandline as appropriate) in the same way that load_bzimage() does.  This is
especially useful when load_bzimage() is unused for a particular
architecture. :-)

Signed-off-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Allow initrd_check() to match a cpio
Matt Evans [Fri, 9 Dec 2011 06:54:37 +0000 (17:54 +1100)]
kvm tools: Allow initrd_check() to match a cpio

cpios are valid as initrds too, so allow them through the check.

Signed-off-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Fix term_getc(), term_getc_iov() endian bugs
Matt Evans [Fri, 9 Dec 2011 06:54:32 +0000 (17:54 +1100)]
kvm tools: Fix term_getc(), term_getc_iov() endian bugs

term_getc()'s int c has one byte written into it (at its lowest address) by
read_in_full().  This is expected to be the least significant byte, but that
isn't the case on BE!  Use correct type, unsigned char.  A similar issue exists
in term_getc_iov(), which needs to write a char to the iov rather than an int.

Signed-off-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Add CONSOLE_HV term type and allow it to be selected
Matt Evans [Fri, 9 Dec 2011 06:54:20 +0000 (17:54 +1100)]
kvm tools: Add CONSOLE_HV term type and allow it to be selected

This patch paves the way for adding a hypervisor console, useful on systems that
support one out of the box yet don't have either serial port or virtio console
support (e.g. kernels expecting POWER SPAPR).

Signed-off-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Move arch-specific cmdline init into kvm__arch_set_cmdline()
Matt Evans [Fri, 9 Dec 2011 06:54:15 +0000 (17:54 +1100)]
kvm tools: Move arch-specific cmdline init into kvm__arch_set_cmdline()

Different systems will want different base kernel commandlines, e.g. non-x86
systems probably don't need noapic, i8042.* etc., so set the commandline up in
arch-specific code.  Then, if the resulting commandline is empty, don't strcat a
space onto the front.

Signed-off-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Add kvm__arch_periodic_poll()
Matt Evans [Fri, 9 Dec 2011 06:54:11 +0000 (17:54 +1100)]
kvm tools: Add kvm__arch_periodic_poll()

Currently, the SIGALRM handler calls device poll functions (for serial, virtio
console) directly.  Which devices are present and which require polling is a
system-specific decision, so create a new function called from common code &
move the x86-specific poll calls into it.

Signed-off-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Fix KVM_RUN exit code check
Matt Evans [Fri, 9 Dec 2011 06:54:06 +0000 (17:54 +1100)]
kvm tools: Fix KVM_RUN exit code check

kvm_cpu__run() currently die()s if KVM_RUN returns non-zero.  Some architectures
may return positive values in non-error cases, whereas real errors are always
negative return values.  Check for those instead.

Signed-off-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Don't die if KVM_CAP_NR_VCPUS isn't available
Matt Evans [Fri, 9 Dec 2011 06:54:01 +0000 (17:54 +1100)]
kvm tools: Don't die if KVM_CAP_NR_VCPUS isn't available

We die() if we can't read KVM_CAP_NR_VCPUS, but the API docs suggest to assume
the value 4 in this case.  This is pertinent to PPC KVM, which currently
does not support this CAP.

Signed-off-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Add arch-specific KVM_RUN exit handling via kvm_cpu__handle_exit()
Matt Evans [Fri, 9 Dec 2011 06:53:56 +0000 (17:53 +1100)]
kvm tools: Add arch-specific KVM_RUN exit handling via kvm_cpu__handle_exit()

This patch creates a new function in x86/kvm-cpu.c, kvm_cpu__handle_exit(), in
which arch-specific exit reasons can be handled outside of the common runloop.

Signed-off-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Re-arrange Makefile to heed CFLAGS before checking for optional libs
Matt Evans [Fri, 9 Dec 2011 06:52:45 +0000 (17:52 +1100)]
kvm tools: Re-arrange Makefile to heed CFLAGS before checking for optional libs

The checks for optional libraries build code to perform the tests, so should
respect certain CFLAGS -- in particular, -m64 so we check for 64bit libraries if
they're required.

Signed-off-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Add Makefile parameter for kernel include path
Matt Evans [Fri, 9 Dec 2011 06:53:29 +0000 (17:53 +1100)]
kvm tools: Add Makefile parameter for kernel include path

This patch adds an 'I' parameter to override the default kernel include path of
'../../include'.

Signed-off-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Only build/init i8042 on x86
Matt Evans [Fri, 9 Dec 2011 06:52:35 +0000 (17:52 +1100)]
kvm tools: Only build/init i8042 on x86

Not every architecture has an i8042 kbd controller, so only use this when
building for x86.

Signed-off-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Fix serial port probing
Sasha Levin [Fri, 9 Dec 2011 11:16:17 +0000 (13:16 +0200)]
kvm tools: Fix serial port probing

The process of probing the 8250 serial port is as follows:

1. Start detecting IRQs

2. Enable the IER register [At this point, the port is supposed to light
   the INTR].

3. Stop detecting IRQs [At this point, the driver detects which IRQ
   belongs to that port].

4. Disable IER register.

Since we weren't enabling and disabling the IRQ based on IER writes, we
would often fail the probing since the driver couldn't detect which IRQ
is used by the port, and would just default that to 0.

This would cause slowness and may have caused hangs. For me there is a
significant increase in speed of the terminal after this patch.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
[ penberg@kernel.org: whitspace cleanup ]
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Correctly limit nrcpus to max_cpus
Matt Evans [Thu, 8 Dec 2011 02:47:06 +0000 (13:47 +1100)]
kvm tools: Correctly limit nrcpus to max_cpus

Fix a typo where kvm->nrcpus was set, then immediately overwritten with
older value.

Signed-off-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Allow the user to pass a FD to use as a TAP device
Sasha Levin [Wed, 7 Dec 2011 09:37:53 +0000 (11:37 +0200)]
kvm tools: Allow the user to pass a FD to use as a TAP device

This allows users to pass a pre-configured fd to use for the network
interface.

For example:
        kvm run -n mode=tap,fd=3 3<>/dev/net/tap3

Acked-by: Daniel P. Berrange <berrange@redhat.com>
Cc: Osier Yang <jyang@redhat.com>
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Document virtio-console usage
Sasha Levin [Tue, 6 Dec 2011 14:31:25 +0000 (16:31 +0200)]
kvm tools: Document virtio-console usage

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Fix kvm/barrier.h build breakage
Pekka Enberg [Tue, 6 Dec 2011 13:54:29 +0000 (15:54 +0200)]
kvm tools: Fix kvm/barrier.h build breakage

Ingo Molnar writes:

  On Tue, 6 Dec 2011, Ingo Molnar wrote:
  > > FYI, today's version fails to build:
  > >
  > > In file included from x86/include/kvm/barrier.h:13:0,
  > >                 from virtio/core.c:5:
  > > ../../arch/x86/include/asm/system.h:404:1: error: unknown type
  > > name ‘bool’
  > > make: *** [virtio/core.o] Error 1
  > > make: *** Waiting for unfinished jobs....
  > >
  > > latest Fedora Rawhide.
  >
  > There's no 'bool' in system.h for 3.2-rc4. Is this something that's
  > changed in -tip?

  It got introduced by a post-rc4 fix:

  e5fd47bfab2d: xen/pm_idle: Make pm_idle be default_idle under Xen.

Fix it by include <stdbool.h> in kvm/barrier.h

Reported-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Link ld.so.conf to the file on the host
Sasha Levin [Tue, 6 Dec 2011 13:01:23 +0000 (15:01 +0200)]
kvm tools: Link ld.so.conf to the file on the host

This enables the custom rootfs to run executables which have dylibs located
in non standard paths by taking these settings from the host.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Initialize irq_routing before using it
Sasha Levin [Tue, 6 Dec 2011 12:15:31 +0000 (14:15 +0200)]
kvm tools: Initialize irq_routing before using it

Initialize irq_routing, and specifically irq_routing->nr before using it.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Zero out event before calling epoll_ctl()
Sasha Levin [Tue, 6 Dec 2011 12:15:30 +0000 (14:15 +0200)]
kvm tools: Zero out event before calling epoll_ctl()

Zero out struct epoll_event before calling epoll_ctl(). This isn't really
required, but is done to avoid warnings.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Fix virtio-pci endian bug when reading VIRTIO_PCI_QUEUE_NUM
Matt Evans [Tue, 6 Dec 2011 03:42:29 +0000 (14:42 +1100)]
kvm tools: Fix virtio-pci endian bug when reading VIRTIO_PCI_QUEUE_NUM

The field size is currently wrong, read into a 32bit word instead of 16.  This
casues trouble when BE.

Acked-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Split x86 arch-specific bits into x86/
Matt Evans [Tue, 6 Dec 2011 03:37:17 +0000 (14:37 +1100)]
kvm tools: Split x86 arch-specific bits into x86/

Create a new arch-specific subdirectory to contain architecture-specific code
and includes.

The Makefile now adds various arch-specific objects based on detected
architecture.  That aside, this patch should only contain code moves.  These
include:

- x86-specific kvm_cpu setup, kernel loading, memory setup etc. now in
  x86/kvm{-cpu}.c
- BIOS now lives in x86/bios/
- ioport setup
- KVM extensions are asserted in arch-specific kvm.c now, so each architecture
  can manage its own dependencies.
- Various architecture-specific #defines are moved into $(ARCH)/include/kvm{-cpu}.h
  such as struct kvm_cpu, KVM_NR_CPUS, KVM_32BIT_GAP_SIZE.

Signed-off-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: kvm.c needs to include sys/stat.h for mkdir
Matt Evans [Tue, 6 Dec 2011 03:40:17 +0000 (14:40 +1100)]
kvm tools: kvm.c needs to include sys/stat.h for mkdir

Fix a missing include.

Signed-off-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: term.h needs to include stdbool.h
Matt Evans [Tue, 6 Dec 2011 03:40:09 +0000 (14:40 +1100)]
kvm tools: term.h needs to include stdbool.h

Fix a missing include.

Signed-off-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Ninja out support for VIRTIO_F_FEATURES_HIGH
Sasha Levin [Tue, 6 Dec 2011 08:45:21 +0000 (10:45 +0200)]
kvm tools: Ninja out support for VIRTIO_F_FEATURES_HIGH

Rusty has just removed it out of the spec. Since we probably the only ones
who implemented support for it, we should remove it out of our code as well.

There is no issue with breaking anything since nothing else worked with it,
so it's fully backwards compatible.

Cc: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Remove double 'init=' kernel param
Sasha Levin [Fri, 2 Dec 2011 07:16:54 +0000 (09:16 +0200)]
kvm tools: Remove double 'init=' kernel param

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Drop write operation in ro_ops_nowrite
Asias He [Tue, 29 Nov 2011 13:04:06 +0000 (21:04 +0800)]
kvm tools: Drop write operation in ro_ops_nowrite

It is supposed to have no write ops in ro_ops_nowrite disk operation.
However, there is one. Let's remove it.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Remove unnecessary assignment in disk/raw.c
Asias He [Tue, 29 Nov 2011 13:04:05 +0000 (21:04 +0800)]
kvm tools: Remove unnecessary assignment in disk/raw.c

ro_ops is never used after the assignment, so no need to do the
assignment.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Get multiple io events at a time
Asias He [Tue, 29 Nov 2011 13:04:04 +0000 (21:04 +0800)]
kvm tools: Get multiple io events at a time

This patch reduces the number of calls to io_getevents() by getting
multiple io events at a time instead of one in disk image thread.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools, qcow: Add the support for copy-on-write cluster
Lan Tianyu [Tue, 29 Nov 2011 07:30:26 +0000 (15:30 +0800)]
kvm tools, qcow: Add the support for copy-on-write cluster

When meeting request to write the cluster without copied flag,
allocate a new cluster and write original data with modification
to the new cluster. This also adds support for the writing operation
of the qcow2 compressed image. After testing, image file can pass
through "qemu-img check". The performance is needed to be improved.

Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Support virtio indirect buffers
Sasha Levin [Mon, 28 Nov 2011 17:54:27 +0000 (19:54 +0200)]
kvm tools: Support virtio indirect buffers

Indirect buffers are ring descriptors which point to more (even more)
descriptors.

This can be used to increase the effective ring capacity, which helps the
guest to batch large requests - very useful for blk devices.

This patch also enables indirect buffers for virtio-net and virtio-blk.

The patch is based on the lguest's code which does the same.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Improve virtio blk request processing
Asias He [Mon, 28 Nov 2011 05:34:11 +0000 (13:34 +0800)]
kvm tools: Improve virtio blk request processing

There are at most bdev->reqs[VIRTIO_BLK_QUEUE_SIZE] outstanding requests
at any time.  We can simply use the head of each request to fetch the
right 'struct blk_dev_req' in bdev->reqs[].

So, we can eliminate the list and lock operations which introduced by
virtio_blk_req_{pop, push}.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools, rtc: Nonvolatile BIOS memory support
Pekka Enberg [Mon, 28 Nov 2011 19:02:19 +0000 (21:02 +0200)]
kvm tools, rtc: Nonvolatile BIOS memory support

This adds a ->cmos_data array to 'struct rtc_device' that is used to emulate
nonvolatile BIOS memory and the RTC registers.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools, rtc: Implement RTC_DAY_OF_WEEK
Pekka Enberg [Mon, 28 Nov 2011 19:02:19 +0000 (21:02 +0200)]
kvm tools, rtc: Implement RTC_DAY_OF_WEEK

This patch implements support for RTC_DAY_OF_WEEK RTC register.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools, rtc: Add RTC register names
Pekka Enberg [Mon, 28 Nov 2011 19:02:19 +0000 (21:02 +0200)]
kvm tools, rtc: Add RTC register names

Add missing RTC register names to hw/rtc.c and rename the current ones to
follow <linux/mc146818rtc.h> naming. It would be nice to use the header
directly but unfortunately it includes <linux/spinlock.h>.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools, rtc: Introduce 'struct rtc_device'
Pekka Enberg [Mon, 28 Nov 2011 19:02:19 +0000 (21:02 +0200)]
kvm tools, rtc: Introduce 'struct rtc_device'

This patch introduces a 'struct rtc_device' in preparation for implementing
missing RTC features like alarms which need auxiliary data structures.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Use vring_need_event() to determine if interrupt is needed
Asias He [Fri, 25 Nov 2011 15:47:07 +0000 (23:47 +0800)]
kvm tools: Use vring_need_event() to determine if interrupt is needed

This patch also fixes fio seq-read hang problem.

   root@guest-kvm:~# cat seq-read.fio
   [seq-read]
   rw=read
   bs=4096
   size=512m
   direct=1
   filename=/dev/vdb

   root@guest-kvm:~# fio seq-read.fio
   random-read: (g=0): rw=read, bs=4K-4K/4K-4K, ioengine=sync, iodepth=1
   Starting 1 process
   Jobs: 1 (f=1): [R] [50.0% done] [0K/0K /s] [0/0 iops] [eta 00m:27s]

Acked-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Fix build in virtio/net.c
Asias He [Fri, 25 Nov 2011 11:59:56 +0000 (19:59 +0800)]
kvm tools: Fix build in virtio/net.c

virtio/net.c: In function ???virtio_net__vhost_init???:
virtio/net.c:476:22: error: cast from pointer to integer of different
size [-Werror=pointer-to-int-cast]
cc1: all warnings being treated as errors

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Add event idx support to virtio-blk
Sasha Levin [Thu, 17 Nov 2011 13:53:26 +0000 (15:53 +0200)]
kvm tools: Add event idx support to virtio-blk

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Support event idx in virtio-net
Sasha Levin [Thu, 17 Nov 2011 13:53:25 +0000 (15:53 +0200)]
kvm tools: Support event idx in virtio-net

Support event idx both when using vhost and when using simple TAP mode.

I did simple TCP stream performance test with vhost, and it showed another 9%
increase over regular vhost mode.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Prepare support for VIRTIO_RING_F_EVENT_IDX
Sasha Levin [Thu, 17 Nov 2011 13:53:24 +0000 (15:53 +0200)]
kvm tools: Prepare support for VIRTIO_RING_F_EVENT_IDX

This patch is the base for enabling support for event index feature in the virtio spec.
We do so by updating and evaluating the used/avail event idx in the virtio ring functions.

Actual usage of this flag is in the following patches.

The results are less notifications between the guest and host, and in
result faster operation of the virt queues.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Add '--no-dhcp' to disable kernel DHCP
Sasha Levin [Thu, 17 Nov 2011 13:53:23 +0000 (15:53 +0200)]
kvm tools: Add '--no-dhcp' to disable kernel DHCP

This new option disables the kernel DHCP which runs when starting
a custom rootfs.

This is useful when we want to start a rootfs but are using a network
other than the usermode IP proxy (a network which doesn't provide DHCP).

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Add vhost-net support
Sasha Levin [Wed, 16 Nov 2011 12:24:36 +0000 (14:24 +0200)]
kvm tools: Add vhost-net support

This patch adds support to using the vhost-net device when using a tap backed
virtio-net device.

Activating vhost-net is done by appending a 'vhost=1' flag to the net device
configuration. For example:

'kvm run -n mode=tap,vhost=1'

This improves performance as follows:

  Short version
  ------------------

  TCP Throughput: +29%
  UDP Throughput: +10%
  TCP Latency: -15%
  UDP Latency: -12%

  Long version
  ------------------

  MIGRATED TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to
  192.168.33.4 (192.168.33.4) port 0 AF_INET
  Recv   Send    Send
  Socket Socket  Message  Elapsed
  Size   Size    Size     Time     Throughput
  bytes  bytes   bytes    secs.    10^6bits/sec

   87380  16384  16384    10.00    4895.04

  MIGRATED UDP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to
  192.168.33.4 (192.168.33.4) port 0 AF_INET
  Socket  Message  Elapsed      Messages
  Size    Size     Time         Okay Errors   Throughput
  bytes   bytes    secs            #      #   10^6bits/sec

  229376   65507   10.00      125287      0    6565.60
  229376           10.00      106910           5602.57

  MIGRATED TCP REQUEST/RESPONSE TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET
  to 192.168.33.4 (192.168.33.4) port 0 AF_INET : first burst 0
  Local /Remote
  Socket Size   Request  Resp.   Elapsed  Trans.
  Send   Recv   Size     Size    Time     Rate
  bytes  Bytes  bytes    bytes   secs.    per sec

  16384  87380  1        1       10.00    14811.55

  MIGRATED UDP REQUEST/RESPONSE TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET
  to 192.168.33.4 (192.168.33.4) port 0 AF_INET : first burst 0
  Local /Remote
  Socket Size   Request  Resp.   Elapsed  Trans.
  Send   Recv   Size     Size    Time     Rate
  bytes  Bytes  bytes    bytes   secs.    per sec

  229376 229376 1        1       10.00    16000.44
  229376 229376

  After:

  MIGRATED TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to
  192.168.33.4 (192.168.33.4) port 0 AF_INET
  Recv   Send    Send
  Socket Socket  Message  Elapsed
  Size   Size    Size     Time     Throughput
  bytes  bytes   bytes    secs.    10^6bits/sec

   87380  16384  16384    10.00    6340.74

  MIGRATED UDP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to
  192.168.33.4 (192.168.33.4) port 0 AF_INET
  Socket  Message  Elapsed      Messages
  Size    Size     Time         Okay Errors   Throughput
  bytes   bytes    secs            #      #   10^6bits/sec

  229376   65507   10.00      131478      0    6890.09
  229376           10.00      118136           6190.90

  MIGRATED TCP REQUEST/RESPONSE TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET
  to 192.168.33.4 (192.168.33.4) port 0 AF_INET : first burst 0
  Local /Remote
  Socket Size   Request  Resp.   Elapsed  Trans.
  Send   Recv   Size     Size    Time     Rate
  bytes  Bytes  bytes    bytes   secs.    per sec

  16384  87380  1        1       10.00    17126.10

  MIGRATED UDP REQUEST/RESPONSE TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET
  to 192.168.33.4 (192.168.33.4) port 0 AF_INET : first burst 0
  Local /Remote
  Socket Size   Request  Resp.   Elapsed  Trans.
  Send   Recv   Size     Size    Time     Rate
  bytes  Bytes  bytes    bytes   secs.    per sec

229376 229376 1        1       10.00    17944.51
Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Add optional callbacks for VQs
Sasha Levin [Wed, 16 Nov 2011 12:24:35 +0000 (14:24 +0200)]
kvm tools: Add optional callbacks for VQs

This patch adds optional callbacks which get called when the VQ gets assigned
an eventfd for notifications, and when it gets assigned with a GSI.

This allows the device to pass the eventfds to 3rd parties which can use
them to notify and get notifications regarding the VQ.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Use IRQ line 5+ for devices
Sasha Levin [Tue, 15 Nov 2011 16:20:25 +0000 (18:20 +0200)]
kvm tools: Use IRQ line 5+ for devices

IRQ lines 3 and 4 are used by the serial device, assigning them to other
devices as well hurts performance. We should avoid shared IRQs if possible.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Don't add the -Wunused-result flag
Wanlong Gao [Sun, 13 Nov 2011 06:19:36 +0000 (14:19 +0800)]
kvm tools: Don't add the -Wunused-result flag

The -Wunused-result is the default option of gcc, so no need to add it
to the FLAGS.

And the previous version of gcc can't support this flag, it may cause a
compile error.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Fix parameter to virtio device features config
Sasha Levin [Fri, 11 Nov 2011 22:02:21 +0000 (00:02 +0200)]
kvm tools: Fix parameter to virtio device features config

Commit ef10d0b ("kvm tools: Add abstract virtio transport layer") config
updates by passing wrong argument to set_config(), this patch fixes it.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Add abstract virtio transport layer
Sasha Levin [Wed, 9 Nov 2011 20:01:52 +0000 (22:01 +0200)]
kvm tools: Add abstract virtio transport layer

Since virtio-mmio was introduced in 3.2, virtio-pci isn't the only transport
layer between the kernel and virtio devices.

This patch adds an abstract virtio-transport layer which allows to easily
use different transports while making it transparent to the device.

This is the first step in adding virtio-mmio support.

Cc: Pawel Moll <pawel.moll@arm.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
12 years agokvm tools: Create /etc/passwd in shared rootfs
Sasha Levin [Mon, 7 Nov 2011 21:36:21 +0000 (23:36 +0200)]
kvm tools: Create /etc/passwd in shared rootfs

This patch creates a dummy /etc/passwd on guest creation.

This is done because some applications (read: git) get angry when they
can't find current user in /etc/passwd.

Reported-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>