]> git.karo-electronics.de Git - karo-tx-linux.git/log
karo-tx-linux.git
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>
13 years agokvm tools: Advise memory allocated for guest RAM as KSM mergable
Sasha Levin [Sat, 2 Jul 2011 23:52:09 +0000 (02:52 +0300)]
kvm tools: Advise memory allocated for guest RAM as KSM mergable

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

From the virtio spec:

The virtio memory balloon device is a primitive device for managing guest
memory: the device asks for a certain amount of memory, and the guest supplies
it (or withdraws it, if the device has more than it asks for). This allows the
guest to adapt to changes in allowance of underlying physical memory.

To activate the virtio-balloon device run kvm tools with the '--balloon'
command line parameter.

Current implementation listens for two signals:

 - SIGKVMADDMEM: Adds 1M to the balloon driver (inflate). This will decrease
available memory within the guest.
 - SIGKVMDELMEM: Remove 1M from the balloon driver (deflate). This will
increase available memory within the guest.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Provide instance name when running 'kvm pause'
Sasha Levin [Sat, 2 Jul 2011 23:52:07 +0000 (19:52 -0400)]
kvm tools: Provide instance name when running 'kvm pause'

Instead of sending a signal to the first instance found, send it
to a specific instance.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Provide instance name when running 'kvm debug'
Sasha Levin [Sat, 2 Jul 2011 23:52:06 +0000 (19:52 -0400)]
kvm tools: Provide instance name when running 'kvm debug'

Instead of sending a signal to the first instance found, send it
to a specific instance.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Allow giving instance names
Sasha Levin [Sat, 2 Jul 2011 23:52:05 +0000 (19:52 -0400)]
kvm tools: Allow giving instance names

This will allow tracking instance names and sending commands
to specific instances if multiple instances are running.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Process virtio-blk requests in parallel
Sasha Levin [Sat, 2 Jul 2011 23:52:04 +0000 (19:52 -0400)]
kvm tools: Process virtio-blk requests in parallel

Process multiple requests within a virtio-blk device's vring
in parallel.

Doing so may improve performance in cases when a request which can
be completed using data which is present in a cache is queued after
a request with un-cached data.

bonnie++ benchmarks have shown a 6% improvement with reads, and 2%
improvement in writes.

Suggested-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Don't dynamically allocate threadpool jobs
Sasha Levin [Sat, 2 Jul 2011 23:52:03 +0000 (19:52 -0400)]
kvm tools: Don't dynamically allocate threadpool jobs

To allow efficient use of shorter-term threadpool jobs, don't
allocate them dynamically upon creation. Instead, store them
within 'job' structures.

This will prevent some overhead creating/destroying jobs which live
for a short time.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agotools/kvm/9p: return EOPNOTSUPP if the handler is not implemented
Aneesh Kumar K.V [Tue, 28 Jun 2011 06:56:50 +0000 (12:26 +0530)]
tools/kvm/9p: return EOPNOTSUPP if the handler is not implemented

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agotools/kvm/9p: Add encode/decode routines for protocol data
Aneesh Kumar K.V [Tue, 28 Jun 2011 06:56:49 +0000 (12:26 +0530)]
tools/kvm/9p: Add encode/decode routines for protocol data

The protocol data is in little-endian format.

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: Introduce struct net_dev_operations
Asias He [Wed, 29 Jun 2011 08:47:36 +0000 (16:47 +0800)]
kvm tools: Introduce struct net_dev_operations

virtio_net_{tx, rx}_thread can use ops->{tx, rx} to send and recevie
network package in both tap mode and user mode.

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 default host ip address to 192.168.33.1
Asias He [Wed, 29 Jun 2011 08:47:35 +0000 (16:47 +0800)]
kvm tools: Make default host ip address to 192.168.33.1

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Make default network mode to user mode
Asias He [Wed, 29 Jun 2011 08:47:34 +0000 (16:47 +0800)]
kvm tools: Make default network mode to user mode

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 with user mode network
Asias He [Wed, 29 Jun 2011 08:47:33 +0000 (16:47 +0800)]
kvm tools: Make virtio net work with user mode network

- Call uip_rx() and uip_tx() in virtio_net_rx_thread() and
  virtio_net_tx_thread() if user mode network is enabled.

- Initialize uip in virtio_net__init() if user mode network is enabled.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Change default guest MAC address to 00:15:15:15:15:15
Asias He [Wed, 29 Jun 2011 08:47:32 +0000 (16:47 +0800)]
kvm tools: Change default guest MAC address to 00:15:15:15:15:15

This patch makes guest MAC address the last portion of
default guest IP address which is 192.168.33.15.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Introduce -net {user, tap, none} options for virtio net
Asias He [Wed, 29 Jun 2011 08:47:31 +0000 (16:47 +0800)]
kvm tools: Introduce -net {user, tap, none} options for virtio net

Use '-net user' to enable user model network, which enables plain user
without speical privileges to use network in guest.

Use '-net tap' to enable tap based network, which requres special
privileges.

Use '-net none' to disable virtio net.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Reanme net_device to net_dev
Asias He [Wed, 29 Jun 2011 08:47:30 +0000 (16:47 +0800)]
kvm tools: Reanme net_device to net_dev

This patch makes virtio net device's name convention consistent with others in
virtio/*.c.  struct {net_dev, blk_dev, con_dev, rng_dev, p9_dev}.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Add MACRO for user and tap mode for virtio net
Asias He [Wed, 29 Jun 2011 08:47:29 +0000 (16:47 +0800)]
kvm tools: Add MACRO for user and tap mode for virtio net

This patch prepares the user and tap mode for virtio net.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Introduce uip_rx() for uip
Asias He [Wed, 29 Jun 2011 08:47:28 +0000 (16:47 +0800)]
kvm tools: Introduce uip_rx() for uip

This patch implement rx interface for uip. uip_rx() can be called in
virtio_net_rx_thread().

It is a consumer of the ethernet used buffer. It sleeps until there is
used buffer avaiable and copy ethernet data into virtio iov buffers
which provided by virtio_net_rx_thread().

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Introduce uip_tx() for uip
Asias He [Wed, 29 Jun 2011 08:47:27 +0000 (16:47 +0800)]
kvm tools: Introduce uip_tx() for uip

This patch implement tx interface for uip. uip_tx() can be called in
virtio_net_tx_thread().

It dispatches ethernet frame to ARP or IP handling code.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Introduce uip_init() for uip
Asias He [Wed, 29 Jun 2011 08:47:26 +0000 (16:47 +0800)]
kvm tools: Introduce uip_init() for uip

- Initialize TCP/UDP socket list, ethernet buffer list.

- Allocate memory for ethernet buffer.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Add TCP support for uip
Asias He [Wed, 29 Jun 2011 08:47:25 +0000 (16:47 +0800)]
kvm tools: Add TCP support for uip

- Implement uip_tx_do_ipv4_tcp() to send TCP package to remote host.

- Implement uip_tcp_socket_thread() to receive TCP package from
  remote host.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Implement uip_csum_tcp() to calculate TCP checksum
Asias He [Wed, 29 Jun 2011 08:47:24 +0000 (16:47 +0800)]
kvm tools: Implement uip_csum_tcp() to calculate TCP checksum

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Add helper to allocate and get TCP initial sequence number
Asias He [Wed, 29 Jun 2011 08:47:23 +0000 (16:47 +0800)]
kvm tools: Add helper to allocate and get TCP initial sequence number

Guest's initial sequence number can be found in the SYN package that
guest send to us to intialize a TCP session.

Remote server's initial sequence number is faked. RFC 793 specifies
that the ISN should be viewed as a 32-bit counter that increments
by one every 4 microseconds. For simplicity's sake, current
implementation in uip just returns a constant.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Add helpers to test whether SYN or FIN bit is set.
Asias He [Wed, 29 Jun 2011 08:47:22 +0000 (16:47 +0800)]
kvm tools: Add helpers to test whether SYN or FIN bit is set.

This patch adds too helpers uip_tcp_is_syn(), uip_tcp_is_fin() to check if SYN and
FIN bit is set.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Add helper to return start address of TCP payload
Asias He [Wed, 29 Jun 2011 08:47:21 +0000 (16:47 +0800)]
kvm tools: Add helper to return start address of TCP payload

uip_tcp_payload() returns start address of TCP payload in a TCP package.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Add helpers to return TCP {header, total, payload} length
Asias He [Wed, 29 Jun 2011 08:47:20 +0000 (16:47 +0800)]
kvm tools: Add helpers to return TCP {header, total, payload} length

This patch adds three helpers uip_tcp_hdrlen(), uip_tcp_len(),
uip_tcp_payloadlen() to return TCP header length, TCP totoal
length, and tcp payload length.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Introduce struct uip_tcp_socket
Asias He [Wed, 29 Jun 2011 08:47:19 +0000 (16:47 +0800)]
kvm tools: Introduce struct uip_tcp_socket

struct uip_tcp_socket is used to present every session
between guest and remote host.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Introduce struct uip_tcp to present TCP package.
Asias He [Wed, 29 Jun 2011 08:47:18 +0000 (16:47 +0800)]
kvm tools: Introduce struct uip_tcp to present TCP package.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Add UDP support for uip
Asias He [Wed, 29 Jun 2011 08:47:17 +0000 (16:47 +0800)]
kvm tools: Add UDP support for uip

- Implement uip_tx_do_ipv4_udp() to send UDP package to remote host.

- Implement uip_udp_socket_thread() to receive UDP package from
  remote host.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Implement uip_csum_udp() to calculate UDP checksum
Asias He [Wed, 29 Jun 2011 08:47:16 +0000 (16:47 +0800)]
kvm tools: Implement uip_csum_udp() to calculate UDP checksum

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Add helper to return ethernet header length
Asias He [Wed, 29 Jun 2011 08:47:15 +0000 (16:47 +0800)]
kvm tools: Add helper to return ethernet header length

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Add two helpers to return UDP {header, total} length
Asias He [Wed, 29 Jun 2011 08:47:14 +0000 (16:47 +0800)]
kvm tools: Add two helpers to return UDP {header, total} length

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Introduce struct uip_udp_socket
Asias He [Wed, 29 Jun 2011 08:47:13 +0000 (16:47 +0800)]
kvm tools: Introduce struct uip_udp_socket

struct uip_udp_socket is used to present every "connection" between
guest and remote host.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Introduce struct uip_pseudo_hdr to present UDP pseudo header
Asias He [Wed, 29 Jun 2011 08:47:12 +0000 (16:47 +0800)]
kvm tools: Introduce struct uip_pseudo_hdr to present UDP pseudo header

This pseudo header is used for UDP checksum.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Introduce struct uip_udp to present UDP package
Asias He [Wed, 29 Jun 2011 08:47:11 +0000 (16:47 +0800)]
kvm tools: Introduce struct uip_udp to present UDP package

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Add ICMP support for uip
Asias He [Wed, 29 Jun 2011 08:47:10 +0000 (16:47 +0800)]
kvm tools: Add ICMP support for uip

- Introduce struct uip_icmp to present ICMP package

- Implement uip_csum_icmp() to calculate ICMP checksum

- Current ICMP implementation in uip does not really send ICMP package
  to remote host in question, instead it just fake a ICMP reply to fool guest.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Implement IP checksum for uip
Asias He [Wed, 29 Jun 2011 08:47:09 +0000 (16:47 +0800)]
kvm tools: Implement IP checksum for uip

Other protocal, e.g. TCP, UDP, ICMP, can use uip_csum() to make
checsksum as well.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Add IPV4 support for uip
Asias He [Wed, 29 Jun 2011 08:47:08 +0000 (16:47 +0800)]
kvm tools: Add IPV4 support for uip

- Introduce struct uip_ip to present IP package

- Add a helper uip_ip_len() to return totoal length of a IP package

- Add a helper uip_ip_hdrlen() to return the IP header length

- Currently, uip does not support IP options
  Drop IP package if IP header length is not 20 bytes which means it
  contains IP options.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Add ARP support for uip
Asias He [Wed, 29 Jun 2011 08:47:07 +0000 (16:47 +0800)]
kvm tools: Add ARP support for uip

- Introduce struct uip_arp to present ARP package
- uip_tx_do_arp()
  Clone incoming ARP ethernet frame, if ARP is requesting
  host IP address, tell guest host MAC address.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm tools: Introduce ethernet frame buffer system for uip
Asias He [Wed, 29 Jun 2011 08:47:06 +0000 (16:47 +0800)]
kvm tools: Introduce ethernet frame buffer system for uip

- uip_buf_get_free()
  Get a free buffer from buffer pool, sleep if there is no free buffer.

- uip_buf_get_used()
  Get a used buffer from buffer pool, sleep if there is no used buffer.

- uip_buf_set_free()
  Set a buffer as free, so it can be reused by the buffer producer.

- uip_buf_set_used()
  Set a buffer as used, uip rx code will inject the ethernet frame in
  this buffer into guest.

- uip_buf_clone()
  Get a free buffer, and clone data into it.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agoLinux 3.0-rc5 v3.0-rc5
Linus Torvalds [Tue, 28 Jun 2011 02:12:22 +0000 (19:12 -0700)]
Linux 3.0-rc5

13 years agodrm/i915: more struct_mutex locking
Hugh Dickins [Mon, 27 Jun 2011 23:18:20 +0000 (16:18 -0700)]
drm/i915: more struct_mutex locking

When auditing the locking in i915_gem.c (for a prospective change which
I then abandoned), I noticed two places where struct_mutex is not held
across GEM object manipulations that would usually require it.

Since one is in initial setup and the other in driver unload, I'm
guessing the mutex is not required for either; but post a patch in case
it is.

Signed-off-by: Hugh Dickins <hughd@google.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Keith Packard <keithp@keithp.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
13 years agodrm/i915: use shmem_truncate_range
Hugh Dickins [Mon, 27 Jun 2011 23:18:19 +0000 (16:18 -0700)]
drm/i915: use shmem_truncate_range

The interface to ->truncate_range is changing very slightly: once "tmpfs:
take control of its truncate_range" has been applied, this can be applied.
 For now there is only a slight inefficiency while this remains unapplied,
but it will soon become essential for managing shmem's use of swap.

Change i915_gem_object_truncate() to use shmem_truncate_range() directly:
which should also spare i915 later change if we switch from
inode_operations->truncate_range to file_operations->fallocate.

Signed-off-by: Hugh Dickins <hughd@google.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Keith Packard <keithp@keithp.com>
Cc: Dave Airlie <airlied@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
13 years agodrm/i915: use shmem_read_mapping_page
Hugh Dickins [Mon, 27 Jun 2011 23:18:18 +0000 (16:18 -0700)]
drm/i915: use shmem_read_mapping_page

Soon tmpfs will stop supporting ->readpage and read_cache_page_gfp(): once
"tmpfs: add shmem_read_mapping_page_gfp" has been applied, this patch can
be applied to ease the transition.

Make i915_gem_object_get_pages_gtt() use shmem_read_mapping_page_gfp() in
the one place it's needed; elsewhere use shmem_read_mapping_page(), with
the mapping's gfp_mask properly initialized.

Forget about __GFP_COLD: since tmpfs initializes its pages with memset,
asking for a cold page is counter-productive.

Include linux/shmem_fs.h also in drm_gem.c: with shmem_file_setup() now
declared there too, we shall remove the prototype from linux/mm.h later.

Signed-off-by: Hugh Dickins <hughd@google.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Keith Packard <keithp@keithp.com>
Cc: Dave Airlie <airlied@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>