]> git.karo-electronics.de Git - karo-tx-linux.git/log
karo-tx-linux.git
13 years agokvm tools: Stop guest if SDL window is closed
Pekka Enberg [Wed, 10 Aug 2011 18:48:11 +0000 (21:48 +0300)]
kvm tools: Stop guest if SDL window is closed

Send SIGKVMSTOP signal to the process if the SDL window is closed. This fixes
an annoying problem where closing the window makes the guest seem like it froze
although it's really running in the background but the UI is unusable.

Cc: Asias He <asias.hejun@gmail.com>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Prasad Joshi <prasadjoshi124@gmail.com>
Cc: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Improve 'kvm version' output
Pekka Enberg [Wed, 10 Aug 2011 18:38:40 +0000 (21:38 +0300)]
kvm tools: Improve 'kvm version' output

This patch improves 'kvm version' output as follows as suggested by Ingo
Molnar:

  $ ./kvm version
  kvm tool 3.0.rc5.763.ga6c998

Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tool: Fix builtin command usage printouts
Pekka Enberg [Wed, 10 Aug 2011 18:32:58 +0000 (21:32 +0300)]
kvm tool: Fix builtin command usage printouts

This patch fixes builtin commands to use usage_with_options() instead of die().
The latter prefixes messages with "Fatal" which makes the usage text ugly.

Cc: Asias He <asias.hejun@gmail.com>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Prasad Joshi <prasadjoshi124@gmail.com>
Cc: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Improve 'kvm list' output
Pekka Enberg [Wed, 10 Aug 2011 18:20:22 +0000 (21:20 +0300)]
kvm tools: Improve 'kvm list' output

This patch improves 'kvm list' output to look more like 'ps':

  $ ./kvm list
    PID GUEST
   2820 guest-2820

Cc: Ingo Molnar <mingo@elte.hu>
Cc: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agoRevert "kvm tools: Enable kernel DHCP autoconf by default"
Pekka Enberg [Wed, 10 Aug 2011 04:59:11 +0000 (07:59 +0300)]
Revert "kvm tools: Enable kernel DHCP autoconf by default"

This reverts commit f0aec23a91368e916a53e6072f2173bb481b1544.

Asias He writes:

  'ip=dhcp' makes kernel try to use nfs as root fs which results in a long
  time 'wait and fail' and finally fallback to 9p as root fs.

  [    1.688000] Sending DHCP requests ., OK
  [    1.695000] IP-Config: Got DHCP answer from 192.168.33.1, my address
  is 192.168.33.15
  [    1.699000] IP-Config: Complete:
  [    1.700000]      device=eth0, addr=192.168.33.15, mask=255.255.255.0,
  gw=192.168.33.1,
  [    1.703000]      host=192.168.33.15, domain=stu.buaa.edu.cn,
  nis-domain=(none),
  [    1.706000]      bootserver=192.168.33.1, rootserver=192.168.33.1,
  rootpath=
  [   36.769000] VFS: Unable to mount root fs via NFS, trying floppy.
  [   36.771000] VFS: Mounted root (9p filesystem) on device 0:14.

13 years agokvm tools: handle failure of command
Liming Wang [Wed, 10 Aug 2011 02:44:09 +0000 (10:44 +0800)]
kvm tools: handle failure of command

handle failure of calling command function, especially, only handle
EPERM error now.

Signed-off-by: Liming Wang <walimisdev@gmail.com>
[ penberg@kernel.org: fix minor coding style issue ]
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: convert callback to int and deal with the return value
Liming Wang [Wed, 10 Aug 2011 02:44:08 +0000 (10:44 +0800)]
kvm tools: convert callback to int and deal with the return value

callback function maybe fail, so we should deal with the return value.

Signed-off-by: Liming Wang <walimisdev@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Enable kernel DHCP autoconf by default
Pekka Enberg [Tue, 9 Aug 2011 17:46:08 +0000 (20:46 +0300)]
kvm tools: Enable kernel DHCP autoconf by default

As we boot to '/bin/sh' by default, enable kernel DHCP autoconfiguration too.
The guest kernel needs to be configured with the following configuration
options:

  CONFIG_IP_PNP=y
  CONFIG_IP_PNP_DHCP=y

Cc: Asias He <asias.hejun@gmail.com>
Cc: Avi Kivity <avi@redhat.com>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Prasad Joshi <prasadjoshi124@gmail.com>
Cc: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Boot to host /bin/sh via 9p by default
Pekka Enberg [Tue, 9 Aug 2011 15:25:57 +0000 (18:25 +0300)]
kvm tools: Boot to host /bin/sh via 9p by default

This patch updates 'kvm run' to boot to host filesystem via 9p '/bin/sh' by
default:

  $ ./kvm run
    # kvm run -k ../../arch/x86/boot/bzImage -m 320 -c 2 --name guest-3462
  [    0.000000] Linux version 3.1.0-rc1+ (penberg@tiger) (gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) ) #7 SMP PREEMPT Tue Aug 9 16:39:20 EEST 2011
  [    0.000000] Command line: notsc noapic noacpi pci=conf1 reboot=k panic=1 console=ttyS0 earlyprintk=serial  init=/bin/sh  root=/dev/vda rw  root=/dev/root rootflags=rw,trans=virtio,version=9p2000.u rootfstype=9p

  [snip]

  [    1.803261] VFS: Mounted root (9p filesystem) on device 0:13.
  [    1.805153] devtmpfs: mounted
  [    1.808353] Freeing unused kernel memory: 924k freed
  [    1.810592] Write protecting the kernel read-only data: 12288k
  [    1.816268] Freeing unused kernel memory: 632k freed
  [    1.826030] Freeing unused kernel memory: 1448k freed
  sh: cannot set terminal process group (-1): Inappropriate ioctl for device
  sh: no job control in this shell
  sh-4.1#

Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Asias He <asias.hejun@gmail.com>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Prasad Joshi <prasadjoshi124@gmail.com>
Cc: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools, 9p: handler should be called in case of not supported operation
Aneesh Kumar K.V [Tue, 9 Aug 2011 15:13:46 +0000 (20:43 +0530)]
kvm tools, 9p: handler should be called in case of not supported operation

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: remove unused options
Liming Wang [Tue, 9 Aug 2011 14:56:54 +0000 (22:56 +0800)]
kvm tools: remove unused options

kvm "--help" and "--version" are not implemented, so remove them to
avoid ambiguous.

Signed-off-by: Liming Wang <walimisdev@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Change method of retrieving process name
Sasha Levin [Tue, 9 Aug 2011 10:17:39 +0000 (13:17 +0300)]
kvm tools: Change method of retrieving process name

This patch changes './kvm list' to retrieve process name from
'/proc/<pid>/stat' instead of '/proc/<pid>/comm' as it appears the latter
does not exist by default on several systems.

Reported-by: Pradeep Kumar Surisetty <psuriset@linux.vnet.ibm.com>
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Tune --disk option usage information
Asias He [Mon, 8 Aug 2011 00:58:12 +0000 (08:58 +0800)]
kvm tools: Tune --disk option usage information

This patch makes --disk option usage information include rootfs
directory, since --disk supports both images and rootfs dir.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Sort options of kvm run command
Asias He [Mon, 8 Aug 2011 00:58:11 +0000 (08:58 +0800)]
kvm tools: Sort options of kvm run command

This patch sort options of kvm run command to make it look tidier and
cleaner.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Make --virtio-9p option shorter
Asias He [Mon, 8 Aug 2011 00:58:10 +0000 (08:58 +0800)]
kvm tools: Make --virtio-9p option shorter

This patch changes --virtio-9p to --9p because:

1. It's shorter
2. No need to add virtio prior to 9p since we use virtio by default

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Make --kvm-dev option shorter
Asias He [Mon, 8 Aug 2011 00:58:09 +0000 (08:58 +0800)]
kvm tools: Make --kvm-dev option shorter

This patch changes --kvm-dev to --dev.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Split 'kvm pause' and add 'kvm resume'
Sasha Levin [Sun, 7 Aug 2011 19:23:06 +0000 (22:23 +0300)]
kvm tools: Split 'kvm pause' and add 'kvm resume'

This patch seperates 'kvm pause' into 'kvm pause' and 'kvm resume',
'kvm pause' no longer acts as a switch between running and paused state but
instead just switches the instance into paused and reume is handled by
the new 'kvm resume'.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Tune 'kvm balloon' option
Asias He [Sun, 7 Aug 2011 06:57:15 +0000 (14:57 +0800)]
kvm tools: Tune 'kvm balloon' option

This patch changes the option
from:

   kvm balloon [command] [instance name] [amount]

to:

   kvm balloon [inflate/deflate] [size in MiB] [instance name]

Acked-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Support xAPIC
Cyrill Gorcunov [Sun, 7 Aug 2011 09:40:42 +0000 (13:40 +0400)]
kvm tools: Support xAPIC

Since we rely on in-kernel kvm-apic implementation
it's fine to set apic version as xAPIC which allows
kernel to run in bigsmp mode.

Without it the kernel will not support more than 8 cpus,
complaining as

 | [    0.362000] Initializing CPU#8
 | [    0.363000] ------------[ cut here ]------------
 | [    0.363000] WARNING: at arch/x86/kernel/apic/apic.c:1238 setup_local_APIC+0xeb/0x2e1()
 | [    0.364000] Modules linked in:
 | [    0.364000] Pid: 0, comm: kworker/0:1 Not tainted 3.0.0+ #70
 | [    0.364000] Call Trace:
 | [    0.364000]  [<c1060c7e>] warn_slowpath_common+0x63/0x78
 | [    0.365000]  [<c16612a8>] ? setup_local_APIC+0xeb/0x2e1
 | [    0.365000]  [<c1060ca2>] warn_slowpath_null+0xf/0x13
 | [    0.365000]  [<c16612a8>] setup_local_APIC+0xeb/0x2e1
 | [    0.366000]  [<c165c684>] ? fpu_init+0x6b/0x88
 | [    0.366000]  [<c1047fd7>] ? default_get_apic_id+0x17/0x32
 | [    0.366000]  [<c16607d3>] start_secondary+0xab/0x18e
 | [    0.367000] ---[ end trace 4eaa2a86a8e2da22 ]---

Note the kernel needs "apic=bigsmp" parameter passed to
enable physical destination mode.

Reported-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Fix PCI masking on probes
Sasha Levin [Sat, 6 Aug 2011 07:28:04 +0000 (10:28 +0300)]
kvm tools: Fix PCI masking on probes

This patch adds a missing check of mask during probing of PCI BARs.

The missing check manifested in wrong address values for the BARs after the
initial probe.

Reported-by: David Evensky <evensky@dancer.ca.sandia.gov>
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Remove version file on 'make clean'
Sasha Levin [Fri, 5 Aug 2011 15:21:33 +0000 (18:21 +0300)]
kvm tools: Remove version file on 'make clean'

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Add 'kvm stop'
Sasha Levin [Fri, 5 Aug 2011 15:21:10 +0000 (18:21 +0300)]
kvm tools: Add 'kvm stop'

This command stops a running instance.

Syntax:
kvm stop [instance name]

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Use '-d' to boot a directory as a rootfs
Sasha Levin [Fri, 5 Aug 2011 13:43:13 +0000 (16:43 +0300)]
kvm tools: Use '-d' to boot a directory as a rootfs

Pointing to a directory when specifying an image ('-d') will attempt to boot
the directory as if it was a root device using virtio-9p.

Tested-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Add support for 9p2000.u
Sasha Levin [Tue, 2 Aug 2011 18:46:28 +0000 (21:46 +0300)]
kvm tools: Add support for 9p2000.u

This patch adds support for the UNIX extensions to 9p2000.

Supporting thses extensions allow us to transperantly mount UNIX directories
without missing features such as symlinks.

Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools, qcow: Add support for writing to zero refcount clusters
Pekka Enberg [Thu, 21 Jul 2011 09:04:39 +0000 (12:04 +0300)]
kvm tools, qcow: Add support for writing to zero refcount clusters

This patch adds support for writing to zero refcount clusters. Refcount blocks
are cached in like L2 tables and flushed upon VIRTIO_BLK_T_FLUSH and when
evicted from the LRU cache.

With this patch applied, 'qemu-img check' no longer complains about referenced
clusters with zero reference count after

  dd if=/dev/zero of=/mnt/tmp

where '/mnt' is freshly generated QCOW2 image.

Cc: Asias He <asias.hejun@gmail.com>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Prasad Joshi <prasadjoshi124@gmail.com>
Cc: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Implement MSI-X for virtio-rng
Sasha Levin [Thu, 28 Jul 2011 17:56:21 +0000 (20:56 +0300)]
kvm tools: Implement MSI-X for virtio-rng

This patch implements basic MSI-X support for virtio-rng.

The device uses the virtio preferred method of working with MSI-X by
creating one vector for configuration and one vector for each vq in the
device.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Add a void ptr to be passed to mmio callback
Sasha Levin [Thu, 28 Jul 2011 17:56:20 +0000 (20:56 +0300)]
kvm tools: Add a void ptr to be passed to mmio callback

This makes MMIO callback similar to it's PIO counterpart by passing
a void* value provided in the registration to the callback function.

This allows to keep context within the MMIO callback function.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Fix PCI probing
Sasha Levin [Thu, 28 Jul 2011 17:56:19 +0000 (20:56 +0300)]
kvm tools: Fix PCI probing

PCI BAR probing is done in four steps:

 1. Read address (and flags).
 2. Mask BAR.
 3. Read BAR again - Now the expected result is the size of the BAR.
 4. Mask BAR with address.

So far, we have only took care of the first step. This means that the kernel
was using address as the size, causing a PCI allocation blunder.

This patch fixes the issue by passing a proper size after masking.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Use GSI routing
Sasha Levin [Thu, 28 Jul 2011 17:56:18 +0000 (20:56 +0300)]
kvm tools: Use GSI routing

Map GSIs manually when starting the guest.
This will allow us mapping new GSIs for MSIX in the future.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools, 9p: Fix init error handling
Pekka Enberg [Thu, 28 Jul 2011 16:10:24 +0000 (19:10 +0300)]
kvm tools, 9p: Fix init error handling

Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Cc: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Fix absence of notrace definition
Cyrill Gorcunov [Mon, 25 Jul 2011 08:32:03 +0000 (12:32 +0400)]
kvm tools: Fix absence of notrace definition

Ingo reported a build breakage caused by absence of 'notrace' definition. Fix
it by adding compiler.h into own headers set.

Reported-by: Ingo Molnar <mingo@elte.hu>
Tested-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools, qcow: Force read-only mode for QCOW images
Pekka Enberg [Sun, 24 Jul 2011 20:19:10 +0000 (23:19 +0300)]
kvm tools, qcow: Force read-only mode for QCOW images

The QCOW write support isn't stable enough for wide-spread use so force
read-only mode for QCOW images.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools, qcow: Rename L2 table lookup functions
Pekka Enberg [Sun, 24 Jul 2011 19:04:01 +0000 (22:04 +0300)]
kvm tools, qcow: Rename L2 table lookup functions

In preparation for refcount block caching, rename L2 table lookup functions to
use less generic names.

Cc: Prasad Joshi <prasadjoshi124@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools, qcow: Move L2 cache to 'struct qcow_l1_table'
Pekka Enberg [Sun, 24 Jul 2011 16:27:20 +0000 (19:27 +0300)]
kvm tools, qcow: Move L2 cache to 'struct qcow_l1_table'

In preparation for refcount block cache, move L2 cache data structures to
'struct qcow_l1_table'.

Cc: Prasad Joshi <prasadjoshi124@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Fix formatting in include/kvm/qcow.h
Pekka Enberg [Sun, 24 Jul 2011 09:13:49 +0000 (12:13 +0300)]
kvm tools: Fix formatting in include/kvm/qcow.h

The include/kvm/qcow.h has mixed tabs and spaces. Fix that up.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools, qcow: Unify L1 and L2 variable names
Pekka Enberg [Sun, 24 Jul 2011 09:10:12 +0000 (12:10 +0300)]
kvm tools, qcow: Unify L1 and L2 variable names

This patch unifies qcow_read_cluster() and qcow_write_cluster() L1 and L2 table
variable names to make the code more readable.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Rename 'struct qcow_table' to 'struct qcow_l1_table'
Pekka Enberg [Sun, 24 Jul 2011 09:02:34 +0000 (12:02 +0300)]
kvm tools: Rename 'struct qcow_table' to 'struct qcow_l1_table'

This patch renames the ambiguous 'struct qcow_table' to 'struct qcow_l1_table'
in preparation for introducing 'struct qcow_refcount_table'.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Set hardcoded MAC to local administered
Sasha Levin [Sun, 24 Jul 2011 07:42:31 +0000 (10:42 +0300)]
kvm tools: Set hardcoded MAC to local administered

This sets bit one in the first octet to 1, which means that the hardcoded
MAC we use is locally administered and wasn't assigned to us.

Acked-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Fix warning on 32bit
Sasha Levin [Fri, 22 Jul 2011 13:21:19 +0000 (16:21 +0300)]
kvm tools: Fix warning on 32bit

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools, qcow: Fix copy-on-write image corruption
Pekka Enberg [Wed, 20 Jul 2011 13:28:31 +0000 (16:28 +0300)]
kvm tools, qcow: Fix copy-on-write image corruption

We don't handle refcount table properly so make sure we only write to clusters
that have the "copied" flag set.

Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Update max VCPU limit
Sasha Levin [Wed, 20 Jul 2011 11:21:12 +0000 (14:21 +0300)]
kvm tools: Update max VCPU limit

Use the newly introduced KVM_CAP_MAX_VCPUS to determine max VCPU count
the kernel side supports.

Using more VCPUs than the recommended limit will issue a warning, using more
than the absolute maximum will limit it down to the absolute maximum.

Note this patch contains a hack to define KVM_CAP_MAX_VCPUS and should be
removed when the kernel patch is merged with mainline.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agotools/kvm: Use kernel header version of net/9p/9p.h
Aneesh Kumar K.V [Thu, 7 Jul 2011 08:44:04 +0000 (14:14 +0530)]
tools/kvm: Use kernel header version of net/9p/9p.h

don't do a copy of the kernel header

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agonet/9p: Remove structure not used in the code
Aneesh Kumar K.V [Thu, 7 Jul 2011 08:44:03 +0000 (14:14 +0530)]
net/9p: Remove structure not used in the code

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Add '-Wunused-result' to WARNINGS
Asias He [Mon, 18 Jul 2011 10:59:19 +0000 (18:59 +0800)]
kvm tools: Add '-Wunused-result' to WARNINGS

This makes GCC catch warn_unused_result explicitly.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Initialize MAC and IP address for uip properly
Asias He [Sun, 17 Jul 2011 08:57:04 +0000 (16:57 +0800)]
kvm tools: Initialize MAC and IP address for uip properly

- Drop static initialization

- Use {host,guet}_{ip,mac} to initialize

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Initialize MAC address for virtio net properly
Asias He [Sun, 17 Jul 2011 08:57:03 +0000 (16:57 +0800)]
kvm tools: Initialize MAC address for virtio net properly

- Drop static initialization

- Move the initializtion out of tap init

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Rename --host-ip-addr to --host-ip
Asias He [Sun, 17 Jul 2011 08:57:02 +0000 (16:57 +0800)]
kvm tools: Rename --host-ip-addr to --host-ip

This patch makes the network options more consistent.

We are having:

   --host-ip
   --host-mac
   --guest-ip
   --guest-mac

now.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Introduce --host-mac option
Asias He [Sun, 17 Jul 2011 08:57:01 +0000 (16:57 +0800)]
kvm tools: Introduce --host-mac option

The --host-mac option sets up MAC address of host.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Introduce --guest-ip option
Asias He [Sun, 17 Jul 2011 08:57:00 +0000 (16:57 +0800)]
kvm tools: Introduce --guest-ip option

The --guest-ip option tells which IP address to give guest through DHCP.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Handle DHCP package in gernal UDP processing path
Asias He [Sun, 17 Jul 2011 08:56:59 +0000 (16:56 +0800)]
kvm tools: Handle DHCP package in gernal UDP processing path

DHCP packages are handled by the hypervisor, they are not sent to remote
servers. In contrast, all other non-DHCP UDP packages are sent to remote
servers.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Get DNS information from host in uip_init()
Asias He [Sun, 17 Jul 2011 08:56:58 +0000 (16:56 +0800)]
kvm tools: Get DNS information from host in uip_init()

Use uip_dhcp_get_dns() in uip_init() to get DNS information from host
for DHCP.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Introduce uip_tx_do_ipv4_udp_dhcp()
Asias He [Sun, 17 Jul 2011 08:56:57 +0000 (16:56 +0800)]
kvm tools: Introduce uip_tx_do_ipv4_udp_dhcp()

uip_tx_do_ipv4_udp_dhcp() is used to handle DHCP packages from guest.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Introduce uip_dhcp_make_pkg()
Asias He [Sun, 17 Jul 2011 08:56:56 +0000 (16:56 +0800)]
kvm tools: Introduce uip_dhcp_make_pkg()

This patch cooks a DHCP package.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Fill all DHCP options
Asias He [Sun, 17 Jul 2011 08:56:55 +0000 (16:56 +0800)]
kvm tools: Fill all DHCP options

The following DHCP options are filled.

   - MSG_TYPE

   - SERVER_ID

   - LEASE_TIME

   - SUBMASK

   - ROUTER

   - DNS_SERVER

   - DOMAIN_NAME

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Fill DHCP options with domain name and DNS server IP
Asias He [Sun, 17 Jul 2011 08:56:54 +0000 (16:56 +0800)]
kvm tools: Fill DHCP options with domain name and DNS server IP

Domain name and DNS server IP address are filled.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Get domain name and nameserver from host
Asias He [Sun, 17 Jul 2011 08:56:53 +0000 (16:56 +0800)]
kvm tools: Get domain name and nameserver from host

This patch get domain name and nameserver information from host config
file /etc/resolv.conf.

Guest can obtain DNS information through DHCP.

Signed-off-by: Asias He <asias.hejun@gmail.com>
[ penberg@kernel.org: check fscanf() for errors ]
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Add helpers to tell the type of a DHCP message
Asias He [Sun, 17 Jul 2011 08:56:52 +0000 (16:56 +0800)]
kvm tools: Add helpers to tell the type of a DHCP message

If DHCP DISCOVER or DHCP REQUEST is found, reply with DHCP OFFER or DHCP
ACK respectively.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Add helper to tell if a UDP package is a DHCP package
Asias He [Sun, 17 Jul 2011 08:56:51 +0000 (16:56 +0800)]
kvm tools: Add helper to tell if a UDP package is a DHCP package

This patch checks:

   - sport and dport

   - magic cookie

to detemine whether a UDP package is a DHCP package.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Introduce struct uip_dhcp
Asias He [Sun, 17 Jul 2011 08:56:50 +0000 (16:56 +0800)]
kvm tools: Introduce struct uip_dhcp

struct uip_dhcp is used to present DHCP package

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Introduce uip_udp_make_pkg()
Asias He [Sun, 17 Jul 2011 08:56:49 +0000 (16:56 +0800)]
kvm tools: Introduce uip_udp_make_pkg()

This helper cooks a ethernet package and virtio header for UDP.
This patch also makes uip_udp_socket_thread() shorter.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Implement VIRTIO_BLK_T_GET_ID
Sasha Levin [Sat, 16 Jul 2011 09:28:23 +0000 (12:28 +0300)]
kvm tools: Implement VIRTIO_BLK_T_GET_ID

Return device id when requested by virtio-blk.
Device id is currently based on the device information and the inode
number of the underlying disk image.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Use writev() in xwritev()
Pekka Enberg [Tue, 12 Jul 2011 18:42:21 +0000 (21:42 +0300)]
kvm tools: Use writev() in xwritev()

This patch fixes a typo in xwritev(). Luckily the function is not used so the
problem is only latent. Spotted during code review.

Cc: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Update README
Sasha Levin [Tue, 12 Jul 2011 14:34:33 +0000 (17:34 +0300)]
kvm tools: Update README

Update required kernel config options and git info.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools, bios: Make sure IRQ handlers segment is properly set
Cyrill Gorcunov [Sun, 10 Jul 2011 21:52:53 +0000 (01:52 +0400)]
kvm tools, bios: Make sure IRQ handlers segment is properly set

The mini bios is copied at predefined place and should have
constant segment address.

Without this patch cs value varies depending on which code
is compiled and how big bios is, it's kinda flowing error
which is not triggered yet by a pure luck.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools, 9p: WSTAT don't use open fid
Aneesh Kumar K.V [Sun, 10 Jul 2011 18:23:21 +0000 (23:53 +0530)]
kvm tools, 9p: WSTAT don't use open fid

We should use full path instead of fd. WSTAT can operate on
unopen fid.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools, 9p: Add error handling to protocol handlers
Aneesh Kumar K.V [Sun, 10 Jul 2011 17:59:16 +0000 (23:29 +0530)]
kvm tools, 9p: Add error handling to protocol handlers

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Fix leaked descriptors
Sasha Levin [Sun, 10 Jul 2011 12:41:55 +0000 (15:41 +0300)]
kvm tools: Fix leaked descriptors

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools, qcow: I/O error on compressed sectors
Pekka Enberg [Sun, 10 Jul 2011 12:36:11 +0000 (15:36 +0300)]
kvm tools, qcow: I/O error on compressed sectors

We currently don't support compressed sectors in QCOW images so warn the user
about it and return a I/O error.

Cc: Asias He <asias.hejun@gmail.com>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Prasad Joshi <prasadjoshi124@gmail.com>
Cc: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools, qcow: Flush only dirty L2 tables
Pekka Enberg [Sat, 9 Jul 2011 12:15:52 +0000 (15:15 +0300)]
kvm tools, qcow: Flush only dirty L2 tables

This patch improves qcow_l2_cache_write() to only flush dirty L2 tables.

Cc: Asias He <asias.hejun@gmail.com>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Prasad Joshi <prasadjoshi124@gmail.com>
Cc: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools, qcow: Delayed L2 table writeout
Pekka Enberg [Sat, 9 Jul 2011 07:58:37 +0000 (10:58 +0300)]
kvm tools, qcow: Delayed L2 table writeout

This patch delays writeout for new L2 tables like we do for L1 tables. If a L2
table has non-allocated clusters, we mark that in the in-memory L2 table but
don't actually write it to disk until the L2 table is thrown out of LRU cache
or when qcow_disk_flush() is called. That makes writes to new clusters volatile
before VIRTIO_BLK_T_FLUSH is issued without corrupting the QCOW image on I/O
error.

Cc: Asias He <asias.hejun@gmail.com>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Prasad Joshi <prasadjoshi124@gmail.com>
Cc: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools, qcow: Use big endian order for L2 table entries
Pekka Enberg [Sat, 9 Jul 2011 07:49:16 +0000 (10:49 +0300)]
kvm tools, qcow: Use big endian order for L2 table entries

Don't keep the in-memory array in CPU byte order to simplify delayed L2 table
writeout.

Cc: Asias He <asias.hejun@gmail.com>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Prasad Joshi <prasadjoshi124@gmail.com>
Cc: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools, qcow: Don't fdatasync() L2 table writeout
Pekka Enberg [Sat, 9 Jul 2011 07:37:58 +0000 (10:37 +0300)]
kvm tools, qcow: Don't fdatasync() L2 table writeout

There's now now point in making sure new L2 tables actually hit the disk before
we write out data to clusters because they are not visible on-disk until
qcow_disk_flush() is called which flushes the L1 table.

Cc: Asias He <asias.hejun@gmail.com>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Prasad Joshi <prasadjoshi124@gmail.com>
Cc: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools, qcow: Delayed L1 table writeout
Pekka Enberg [Sat, 9 Jul 2011 07:23:07 +0000 (10:23 +0300)]
kvm tools, qcow: Delayed L1 table writeout

This patch moves L1 table writeout to qcow_disk_flush(). The rationale here is
that while writes to clusters that don't have L2 table allocated on-disk are
volatile until VIRTIO_BLK_T_FLUSH is issued, we never corrupt the disk image.

Cc: Asias He <asias.hejun@gmail.com>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Prasad Joshi <prasadjoshi124@gmail.com>
Cc: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools, qcow: Introduce qcow_disk_flush()
Pekka Enberg [Sat, 9 Jul 2011 07:15:12 +0000 (10:15 +0300)]
kvm tools, qcow: Introduce qcow_disk_flush()

This patch introduces a QCOW specific qcow_disk_flush() in preparation for
delaying QCOW metadata writeout until VIRTIO_BLK_T_FLUSH time.

Cc: Asias He <asias.hejun@gmail.com>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Prasad Joshi <prasadjoshi124@gmail.com>
Cc: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools, qcow: Fix locking issues
Pekka Enberg [Sat, 9 Jul 2011 11:04:12 +0000 (14:04 +0300)]
kvm tools, qcow: Fix locking issues

The virtio_blk_do_io() function can enter the QCOW code through
disk_image__{read,write,flush}() from multiple threads because it uses a thread
pool for I/O requests. Thus, use locking to make the QCOW2 code thread-safe.

Cc: Asias He <asias.hejun@gmail.com>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Prasad Joshi <prasadjoshi124@gmail.com>
Cc: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools, qcow: Use 'struct qcow_l2_table' instead of untyped array
Pekka Enberg [Sat, 9 Jul 2011 11:23:47 +0000 (14:23 +0300)]
kvm tools, qcow: Use 'struct qcow_l2_table' instead of untyped array

This patch converts disk/qcow.c to use 'struct qcow_l2_table' for tracking
dirty L2 tables later on in this series.

Cc: Asias He <asias.hejun@gmail.com>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Prasad Joshi <prasadjoshi124@gmail.com>
Cc: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools, qcow: Rename struct qcow_l2_cache to struct qcow_l2_table
Pekka Enberg [Sat, 9 Jul 2011 11:13:51 +0000 (14:13 +0300)]
kvm tools, qcow: Rename struct qcow_l2_cache to struct qcow_l2_table

This patch renames 'struct qcow_l2_cache' to 'struct qcow_l2_table' in
preparation for replacing the untyped L2 table arrays with the struct.

Cc: Asias He <asias.hejun@gmail.com>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Prasad Joshi <prasadjoshi124@gmail.com>
Cc: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: fix instances enumeration
Konstantin Khlebnikov [Sun, 10 Jul 2011 12:13:27 +0000 (16:13 +0400)]
kvm tools: fix instances enumeration

Calling readdir() with NULL dirp leads to segfault.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
[ penberg@kernel.org: use 'while' instead of 'for' ]
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Move uip to net directory
Asias He [Sat, 9 Jul 2011 23:58:19 +0000 (07:58 +0800)]
kvm tools: Move uip to net directory

This mirrors what the kernel already has.

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 tools: Make virtio net work on older kernels
Asias He [Sat, 9 Jul 2011 23:58:18 +0000 (07:58 +0800)]
kvm tools: Make virtio net work on older kernels

Some old kernels do not support TUNSETVNETHDRSZ ioctl which modifies the virtio
net header size. The default header size should work, so let's go on if the
TUNSETVNETHDRSZ ioctl is not supported and just give a warnning.

Reported-by: John Floren <john@jfloren.net>
Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Add KVMTOOLS-VERSION-FILE to .gitignore
Pekka Enberg [Sat, 9 Jul 2011 07:12:30 +0000 (10:12 +0300)]
kvm tools: Add KVMTOOLS-VERSION-FILE to .gitignore

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Rename debug options under 'kvm run'
Sasha Levin [Sat, 9 Jul 2011 06:57:30 +0000 (09:57 +0300)]
kvm tools: Rename debug options under 'kvm run'

Rename debug options to make them consistent with each other.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Rename command source files
Sasha Levin [Sat, 9 Jul 2011 06:57:29 +0000 (09:57 +0300)]
kvm tools: Rename command source files

Rename kvm-[command] into builtin-[command] to prevent
clashes with non-command files such as kvm-cpu.h

Suggested-by: Pekka Enberg <penberg@kernel.org>
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Don't sort command-list.txt for help text
Pekka Enberg [Fri, 8 Jul 2011 22:25:28 +0000 (01:25 +0300)]
kvm tools: Don't sort command-list.txt for help text

This patch removes the alphabetical sorting from util/generate-cmdlist.h so
that 'kvm run' command, for example, is displayed first:

  $ ./kvm

   usage: kvm [--version] [--help] COMMAND [ARGS]

   The most commonly used kvm commands are:
     run       Start the virtual machine
     pause     Pause/resume the virtual machine
     version   Print the version of the kernel tree kvm tools
     list      Print a list of running instances on the host.
     debug     Print debug information from a running instance
     balloon   Inflate or deflate the virtio balloon

   See 'kvm help COMMAND' for more information on a specific command.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Properly add 'kvm balloon' to command list
Sasha Levin [Fri, 8 Jul 2011 21:56:12 +0000 (00:56 +0300)]
kvm tools: Properly add 'kvm balloon' to command list

Also adds some documentation.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Update 'kvm pause' documentation
Sasha Levin [Fri, 8 Jul 2011 21:56:11 +0000 (00:56 +0300)]
kvm tools: Update 'kvm pause' documentation

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Properly add 'kvm debug' to command list
Sasha Levin [Fri, 8 Jul 2011 21:56:10 +0000 (00:56 +0300)]
kvm tools: Properly add 'kvm debug' to command list

Also adds some basic documentation.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Properly add 'kvm list' to command list
Sasha Levin [Fri, 8 Jul 2011 21:56:09 +0000 (00:56 +0300)]
kvm tools: Properly add 'kvm list' to command list

Also adds some basic documentation.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Add 'kvm version' command
Sasha Levin [Fri, 8 Jul 2011 21:56:08 +0000 (00:56 +0300)]
kvm tools: Add 'kvm version' command

Add a 'kvm version' command which prints the version of the kernel
used to build kvm tools.

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

Suggested-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Fix guest single-stepping setup
Pekka Enberg [Thu, 7 Jul 2011 18:12:45 +0000 (21:12 +0300)]
kvm tools: Fix guest single-stepping setup

"K. Watts" writes:

  When the singlestep is enabled the ioctl to sent out when the kvm_cpu
  is initialized (kvm-cpu.c in the for loop that gets each vcpu built).
  When the ioct goes out the CPU is sitting at the initialization vector
  of 0xf000:0xfff0 on CPU #0 and 0x000000 on the other SMP CPUs.  The
  new host kernel code that handles setting the TF was changed in 2.6.32
  and again at 2.6.38.  2.6.32 seems just flat broken, but 2.6.38 checks
  that the linear address of the RIP matches what it was when the
  KVM_GUESTDBG_SINGLESTEP flag was set.  Because the kvm-tool doesn't
  start the CPU at the initialization vector (0xfff0) (0x7c00 for the
  MBR and where ever you guys map the linux kernel to) they don't match
  and the host kernel won't set the trap flag.

  Basically the debug and singlestep ioclts need to happen after the CPU
  has been initialized.  I moved kvm_cpu__enable_singlestep to happen in
  kvm_cpu__reset_vcpu after the registers are set (EIP points to boot
  address) and the TRAP flags get set and all is good with the world.

  Singlestepping is disabled when the guest issues a CLI because the
  Linux host doesn't support features in new Intel and AMD CPUs.  We can
  sort of "shadow" the interrupt mask and still get the CPU to trap out
  at ever instruction even when the guest has disabled interrupts on the
  CPU.  I have to get the bios disk handler working completely first,
  but that may be my next task so that we can trace all the CPU
  instructions.  My current hack is to just re-enable the trap flag
  every time a VMEXIT occurs.  I get enough instructions to get me by.

This patch fixes the problem by moving the kvm_cpu__enable_singlestep() into
kvm_cpu__start().

Suggested-by: K. Watts <traetox@gmail.com>
Cc: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Clean ghost pid files in 'kvm list'
Sasha Levin [Tue, 5 Jul 2011 09:35:45 +0000 (12:35 +0300)]
kvm tools: Clean ghost pid files in 'kvm list'

When running 'kvm list', first make sure that the guest process
is up and running before printing the entry.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Export kvm__remove_pidfile
Sasha Levin [Tue, 5 Jul 2011 09:35:44 +0000 (12:35 +0300)]
kvm tools: Export kvm__remove_pidfile

This will allow cleaning up ghost pid files outside of the module.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Allow pausing and debugging all running instances
Sasha Levin [Sun, 3 Jul 2011 15:38:10 +0000 (18:38 +0300)]
kvm tools: Allow pausing and debugging all running instances

Add a 'kvm [debug,pause] all' command to allow pausing or debugging
all running guests on a host.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Add 'kvm list' command
Sasha Levin [Sun, 3 Jul 2011 15:38:09 +0000 (18:38 +0300)]
kvm tools: Add 'kvm list' command

Use 'kvm list' to list running virtual guest.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Add instance enumerator
Sasha Levin [Sun, 3 Jul 2011 15:38:08 +0000 (18:38 +0300)]
kvm tools: Add instance enumerator

Add API kvm__enumerate_instances() to enumerate running guest
instances.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Give guest instances default name
Sasha Levin [Sun, 3 Jul 2011 15:38:07 +0000 (18:38 +0300)]
kvm tools: Give guest instances default name

Name instances which aren't specifically named by the user (using
the --name flag) with the following pattern: 'guest-<pid>'

Suggested-by: Pekka Enberg <penberg@kernel.org>
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Fix home dir resolution
Sasha Levin [Sun, 3 Jul 2011 15:38:06 +0000 (18:38 +0300)]
kvm tools: Fix home dir resolution

Previous code didn't properly resolve home directory.
Resolve user's home dir using the $HOME enviroment variable.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agoMerge commit 'v3.0-rc5' into kvm/core
Pekka Enberg [Sat, 2 Jul 2011 10:53:10 +0000 (13:53 +0300)]
Merge commit 'v3.0-rc5' into kvm/core

13 years agokvm tools: Stop VCPUs before freeing struct kvm
Sasha Levin [Sat, 2 Jul 2011 23:52:11 +0000 (02:52 +0300)]
kvm tools: Stop VCPUs before freeing struct kvm

Not stopping VCPUs before leads to seg faults and other errors due to
synchronization between threads.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Add 'kvm balloon' command
Sasha Levin [Sat, 2 Jul 2011 23:52:10 +0000 (02:52 +0300)]
kvm tools: Add 'kvm balloon' command

Add a command to allow easily inflate/deflate the balloon driver in running
instances.

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

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

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>