sdk/emulator/qemu.git
14 years agoiov: Move from hw/ to topdir
Amit Shah [Tue, 4 May 2010 11:09:07 +0000 (16:39 +0530)]
iov: Move from hw/ to topdir

The iov functions can be useful to other code as well.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
CC: Christoph Hellwig <hch@lst.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovnc: set the right prefered encoding
Corentin Chary [Tue, 4 May 2010 12:01:58 +0000 (14:01 +0200)]
vnc: set the right prefered encoding

message is a hint by the client as to its preference (the first
encoding specified being most preferred)"

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agosparc: Fix lazy flag calculation on interrupts, refactor
Blue Swirl [Sun, 9 May 2010 20:19:04 +0000 (20:19 +0000)]
sparc: Fix lazy flag calculation on interrupts, refactor

Recalculate Sparc64 CPU flags on interrupts, otherwise some earlier
flags could be stored to pstate.

Refactor PSR/CCR/CWP handling: concentrate the actual
functions to op_helper.c.

Thanks to Igor Kovalenko for reporting.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agosparc: lazy C flag calculation
Blue Swirl [Sun, 9 May 2010 15:40:24 +0000 (15:40 +0000)]
sparc: lazy C flag calculation

Calculate only the carry flag for ADDX/SUBX instead of full
set of flags.

Thanks to Igor Kovalenko for spotting a bug with an earlier
version.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agomips-dis: Add missing static attributes
Stefan Weil [Fri, 7 May 2010 21:20:56 +0000 (23:20 +0200)]
mips-dis: Add missing static attributes

mips_abi_choices and mips_arch_choices are only used locally.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agotcg: Add missing 'static' attribute
Stefan Weil [Fri, 7 May 2010 17:47:31 +0000 (19:47 +0200)]
tcg: Add missing 'static' attribute

tcg_out_reloc is only used locally (in */target.c which is
included in tcg.c).

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoqcow2: Remove static forward declaration
Kevin Wolf [Fri, 7 May 2010 10:43:46 +0000 (12:43 +0200)]
qcow2: Remove static forward declaration

OpenBSDs gcc is said to generate warnings for this declaration, so don't
reference bdrv_qcow2 directly, but look it up using bdrv_find_format.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoRevert "Fix OpenBSD build"
Kevin Wolf [Fri, 7 May 2010 10:43:45 +0000 (12:43 +0200)]
Revert "Fix OpenBSD build"

This reverts commit 20d97356c9df6d68fbd37d6334fdb7063f24eab6.
The BlockDriver definition should stay at the end of source files.

Conflicts:

block/qcow2.c

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoFill in unassigned mem read/write callbacks.
Richard Henderson [Fri, 7 May 2010 16:52:51 +0000 (09:52 -0700)]
Fill in unassigned mem read/write callbacks.

Implement the "functions may be omitted with NULL pointer"
interface mentioned in the function block comment by transforming
NULL entries in the read/write arrays into calls to the
unassigned_mem family of functions.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agodarwin-user: Add missing static attribute
Stefan Weil [Thu, 6 May 2010 20:19:20 +0000 (22:19 +0200)]
darwin-user: Add missing static attribute

Function usage is only used locally, so add "static".

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoAdd missing 'static' attribute
Stefan Weil [Thu, 6 May 2010 20:17:54 +0000 (22:17 +0200)]
Add missing 'static' attribute

Function usage() is only used locally.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agosparc64: fix build with older gccs
Blue Swirl [Fri, 7 May 2010 16:14:59 +0000 (16:14 +0000)]
sparc64: fix build with older gccs

Fix errors missed in 2065061ede22d401aae2ce995c3af54db9d28639:
 CC    sparc64-softmmu/helper.o
cc1: warnings being treated as errors
/src/qemu/target-sparc/helper.c: In function 'get_physical_address':
/src/qemu/target-sparc/helper.c:426: warning: 'context' may be used uninitialized in this function
/src/qemu/target-sparc/helper.c:426: note: 'context' was declared here

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agosparc64: handle asi referencing nucleus and secondary MMU contexts
Igor V. Kovalenko [Mon, 3 May 2010 07:29:44 +0000 (11:29 +0400)]
sparc64: handle asi referencing nucleus and secondary MMU contexts

- increase max supported MMU modes to 6
- handle nucleus context asi
- handle secondary context asi
- handle non-faulting loads from secondary context

Signed-off-by: Igor V. Kovalenko <igor.v.kovalenko@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agosparc64: implement global translation table entries v1
Igor V. Kovalenko [Tue, 4 May 2010 19:15:41 +0000 (23:15 +0400)]
sparc64: implement global translation table entries v1

- match global tte against any context
- show global tte in MMU dump

v0->v1: added default case to switch statement in demap_tlb
- should fix gcc warning about uninitialized context variable

Signed-off-by: Igor V. Kovalenko <igor.v.kovalenko@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agosparc64: more ultrasparc asi extensions for disassembler
Igor V. Kovalenko [Mon, 3 May 2010 07:29:34 +0000 (11:29 +0400)]
sparc64: more ultrasparc asi extensions for disassembler

Signed-off-by: Igor V. Kovalenko <igor.v.kovalenko@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoqemu: address todo comment in exec.c
Michael S. Tsirkin [Tue, 6 Apr 2010 11:18:19 +0000 (14:18 +0300)]
qemu: address todo comment in exec.c

exec.c has a comment 'XXX: optimize' for lduw_phys/stw_phys,
so let's do it, along the lines of stl_phys.

The reason to address 16 bit accesses specifically is that virtio relies
on these accesses to be done atomically, using memset as we do now
breaks this assumption, which is reported to cause qemu with kvm
to read wrong index values under stress.

https://bugzilla.redhat.com/show_bug.cgi?id=525323

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agoFix zero-length write(2).
Richard Henderson [Mon, 29 Mar 2010 17:54:42 +0000 (10:54 -0700)]
Fix zero-length write(2).

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agoBetter default guest_base
Paul Brook [Wed, 5 May 2010 15:32:59 +0000 (16:32 +0100)]
Better default guest_base

Avoid loading linux-user applications in address space already used/reserved
by the host.

Signed-off-by: Paul Brook <paul@codesourcery.com>
14 years agoRemove PAGE_RESERVED
Paul Brook [Wed, 5 May 2010 15:32:59 +0000 (16:32 +0100)]
Remove PAGE_RESERVED

The usermode PAGE_RESERVED code is not required by the current mmap
implementation, and is already broken when guest_base != 0.
Unfortunately the bsd emulation still uses the old mmap implementation,
so we can't rip it out altogether.

Signed-off-by: Paul Brook <paul@codesourcery.com>
14 years agoAvoid libaio for usermode
Paul Brook [Wed, 5 May 2010 15:32:59 +0000 (16:32 +0100)]
Avoid libaio for usermode

Linux AIO is aonly used by system emulation, so should not be linked into
the userspace emulatior.

Signed-off-by: Paul Brook <paul@codesourcery.com>
14 years agoEnable -d cpu logging by default.
Richard Henderson [Wed, 28 Apr 2010 23:07:57 +0000 (16:07 -0700)]
Enable -d cpu logging by default.

When -d cpu logging was handled by target-foo/translate.c,
it was controled by DEBUG_DISAS, which is enabled by default.
Use the same condition in cpu_exec.

At the same time, reduce the if-deffery by assuming no flags
update is required for the target.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agotarget-sh4: Remove duplicate CPU log.
Richard Henderson [Mon, 5 Apr 2010 22:58:20 +0000 (15:58 -0700)]
target-sh4: Remove duplicate CPU log.

Logging for -d cpu is done in generic code.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agotarget-ppc: Remove duplicate cpu log.
Richard Henderson [Mon, 5 Apr 2010 22:57:41 +0000 (15:57 -0700)]
target-ppc: Remove duplicate cpu log.

Logging for -d cpu is done in generic code.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agotarget-mips: Remove duplicate CPU log.
Richard Henderson [Mon, 5 Apr 2010 22:56:51 +0000 (15:56 -0700)]
target-mips: Remove duplicate CPU log.

Logging for -d cpu is done in generic code.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agotarget-i386: Remove duplicate CPU log.
Richard Henderson [Sun, 4 Apr 2010 18:40:44 +0000 (11:40 -0700)]
target-i386: Remove duplicate CPU log.

The proper logging for -d cpu is done in generic code.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agoFix cpu list("-cpu ?") breakage, spotted by TeLeMan
Blue Swirl [Tue, 4 May 2010 19:55:35 +0000 (19:55 +0000)]
Fix cpu list("-cpu ?") breakage, spotted by TeLeMan

Fix breakage by 04c9a0cbc2bf496889cef6da2d61bf00ef190a4f.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agovnc: make sure to send pointer type change event on SetEncodings
Anthony Liguori [Tue, 4 May 2010 13:28:13 +0000 (08:28 -0500)]
vnc: make sure to send pointer type change event on SetEncodings

Commit 37c34d9d5d87ea9d51760310c8863b82cb8c055a introduced a regression when
using relative mouse mode with a client that understands the PointerTypeChange
pseudo-encoding.

Reported-by: Marcelo Tosatti <mtosatti@redhat.com>
Reported-by: Gerhard Wiesinger <lists@wiesinger.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agohw: better i440 emulation
Bernhard M. Wiedemann [Tue, 20 Apr 2010 18:48:06 +0000 (20:48 +0200)]
hw: better i440 emulation

updated version of an old patch
http://xenon.stanford.edu/~eswierk/misc/qemu-linuxbios/qemu-piix-ram-size.patch
that together with
http://www.mail-archive.com/linuxbios@linuxbios.org/msg02390.html
(which is already in coreboot trunk) allows coreboot to autodetect the amount of RAM within qemu/kvm from a register in i440 northbridge.

The message on the old patch states:
Unfortunately the current version of qemu does not set these
registers, but I have patched qemu so that it emulates the i440 more
faithfully in this regard.

Signed-off-by: Bernhard M. Wiedemann <qemudevbmw@lsmod.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoblock: read-only: open cdrom as read-only when using monitor's change command
Naphtali Sprei [Sun, 25 Apr 2010 16:30:37 +0000 (19:30 +0300)]
block: read-only: open cdrom as read-only when using monitor's change command

Current code of monitor command: 'change', used to open file for read-write
uncoditionally. Change to open it as read-only for CDROM, and read-write for all others.

Signed-off-by: Naphtali Sprei <nsprei@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agofix whitespace bogon in some versions of make
Nathan Froyd [Mon, 26 Apr 2010 21:52:23 +0000 (14:52 -0700)]
fix whitespace bogon in some versions of make

With three different make binaries I have available, configuring a
pristine QEMU tree and attempting to make gives the cryptic:

Makefile:27: *** missing separator.  Stop.

This patch fixes it (presumably because it makes the output of
`set-vpath' be an empty string, rather than a bit of whitespace), but I
don't understand why this hasn't been a problem for other folks before.

Signed-off-by: Nathan Froyd <froydnj@codesourcery.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoChanges to usb-linux to conform to coding style
David Ahern [Sat, 24 Apr 2010 16:26:22 +0000 (10:26 -0600)]
Changes to usb-linux to conform to coding style

Signed-off-by: David Ahern <daahern@cisco.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoAdd KVM CFLAGS to vhost build
Jan Kiszka [Tue, 6 Apr 2010 11:31:29 +0000 (13:31 +0200)]
Add KVM CFLAGS to vhost build

The configure test of vhost uses KVM CFLAGS, so the build must use them
as well. Otherwise we specifically miss what --kerneldir provides.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoQMP: Introduce RESUME event
Luiz Capitulino [Tue, 27 Apr 2010 23:35:59 +0000 (20:35 -0300)]
QMP: Introduce RESUME event

It's emitted when the Virtual Machine resumes execution.

We currently have the STOP event but don't have the matching
RESUME one, this means that clients are notified when the VM
is stopped but don't get anything when it resumes.

Let's fix that as it's already causing some trouble to libvirt.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-9p: Create a syntactic shortcut for the file-system pass-thru
Gautham R Shenoy [Thu, 29 Apr 2010 12:15:03 +0000 (17:45 +0530)]
virtio-9p: Create a syntactic shortcut for the file-system pass-thru

Currently the commandline to create a virtual-filesystem pass-through between
the guest and the host is as follows:
#qemu -fsdev fstype,id=ID,path=path/to/share \
      -device virtio-9p-pci,fsdev=ID,mount_tag=tag \

This patch provides a syntactic short-cut to achieve the same as follows:
#qemu -virtfs fstype,path=path/to/share,mount_tag=tag

This will be internally expanded as:
#qemu -fsdev fstype,id=tag,path=path/to/share, \
      -device virtio-9p-pci,fsdev=tag,mount_tag=tag \

Signed-off-by: Gautham R Shenoy <ego@in.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-9p: Add P9_TFLUSH support
Anthony Liguori [Thu, 29 Apr 2010 12:15:02 +0000 (17:45 +0530)]
virtio-9p: Add P9_TFLUSH support

Don't do anything special for flush.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-9p: Add P9_TREMOVE support.
Anthony Liguori [Thu, 29 Apr 2010 12:15:01 +0000 (17:45 +0530)]
virtio-9p: Add P9_TREMOVE support.

Implement P9_TREMOVE support.
This gets file deletion to work.

[mohan@in.ibm.com: Fix truncate to use the relative path]

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-9p: Add P9_TWSTAT support
Anthony Liguori [Thu, 29 Apr 2010 12:15:00 +0000 (17:45 +0530)]
virtio-9p: Add P9_TWSTAT support

Implement P9_TWSTAT support.
This gets file and directory creation to work.

[jvrao@linux.vnet.ibm.com: strdup to qemu_strdup conversion]
[aneesh.kumar@linux.vnet.ibm.com: v9fs_fix_path]

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-9p: Add P9_TCREATE support
Anthony Liguori [Thu, 29 Apr 2010 12:14:59 +0000 (17:44 +0530)]
virtio-9p: Add P9_TCREATE support

Implement P9_TCREATE support.
[jvrao@linux.vnet.ibm.com: strdup to qemu_strdup conversion]

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-9p: Add P9_TWRITE support
Anthony Liguori [Thu, 29 Apr 2010 12:14:58 +0000 (17:44 +0530)]
virtio-9p: Add P9_TWRITE support

Implement P9_TWRITE support.
This gets write to file to work

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-9p: Add P9_TCLUNK support
Anthony Liguori [Thu, 29 Apr 2010 12:14:57 +0000 (17:44 +0530)]
virtio-9p: Add P9_TCLUNK support

Implement P9_TCLUNK support.
This patch gets `ls -al` to work.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-9p: Add P9_TREAD support
Anthony Liguori [Thu, 29 Apr 2010 12:14:56 +0000 (17:44 +0530)]
virtio-9p: Add P9_TREAD support

Implement P9_TREAD support.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-9p: Add P9_TOPEN support.
Anthony Liguori [Thu, 29 Apr 2010 12:14:55 +0000 (17:44 +0530)]
virtio-9p: Add P9_TOPEN support.

Implement P9_TOPEN support.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-9p: Add P9_TWALK support
Anthony Liguori [Thu, 29 Apr 2010 12:14:54 +0000 (17:44 +0530)]
virtio-9p: Add P9_TWALK support

Implement P9_TWALK support.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-9p: Add P9_TSTAT support
Anthony Liguori [Thu, 29 Apr 2010 12:14:53 +0000 (17:44 +0530)]
virtio-9p: Add P9_TSTAT support

Implement P9_TSTAT support. This get the mount to work on the guest.

[kiran@linux.vnet.ibm.com: malloc to qemu_malloc conversion]

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-9p: Add P9_TATTACH support.
Anthony Liguori [Thu, 29 Apr 2010 12:14:52 +0000 (17:44 +0530)]
virtio-9p: Add P9_TATTACH support.

Implement P9_TATTACH support.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-9p: Add P9_TVERSION support
Anthony Liguori [Thu, 29 Apr 2010 12:14:51 +0000 (17:44 +0530)]
virtio-9p: Add P9_TVERSION support

Implement P9_TVERSION support.

[sripathik@in.ibm.com: Handle unknown 9P versions as per the standards]

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-9p: Add sg helper functions
Anthony Liguori [Thu, 29 Apr 2010 12:14:50 +0000 (17:44 +0530)]
virtio-9p: Add sg helper functions

Add scatter-gather helper functions.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-9p: Add stat and mode related helper functions.
Anthony Liguori [Thu, 29 Apr 2010 12:14:49 +0000 (17:44 +0530)]
virtio-9p: Add stat and mode related helper functions.

Add helpers to obtain file stat and mode details.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-9p: Add fid and qid management support.
Anthony Liguori [Thu, 29 Apr 2010 12:14:48 +0000 (17:44 +0530)]
virtio-9p: Add fid and qid management support.

Helper APIs for FID and QID management.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-9p: Add minimal set of FileOperations
Anthony Liguori [Thu, 29 Apr 2010 12:14:47 +0000 (17:44 +0530)]
virtio-9p: Add minimal set of FileOperations

Add minimal set of FileOperations and the corresponding implementations for
local fstype. These will be required for the FID management patches later on.

[aneesh.kumar@linux.vnet.ibm.com: rpath fix ]
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-9p: Add string manipulation support.
Anthony Liguori [Thu, 29 Apr 2010 12:14:46 +0000 (17:44 +0530)]
virtio-9p: Add string manipulation support.

Add helpers to do string manipulation.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-9p: pdu processing support.
Anthony Liguori [Thu, 29 Apr 2010 12:14:45 +0000 (17:44 +0530)]
virtio-9p: pdu processing support.

Add helpers to process the PDUs.

[kiran@linux.vnet.ibm.com: malloc to qemu_malloc coversion]

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-9p: Add a virtio 9p device to qemu
Anthony Liguori [Thu, 29 Apr 2010 12:14:44 +0000 (17:44 +0530)]
virtio-9p: Add a virtio 9p device to qemu

This patch doesn't implement the 9p protocol handling
code. It adds a simple device which dump the protocol data.

[jvrao@linux.vnet.ibm.com: Little-Endian to host format conversion]
[aneesh.kumar@linux.vnet.ibm.com: Multiple-mounts support]

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-9p: Create a commandline option -fsdev
Gautham R Shenoy [Thu, 29 Apr 2010 12:14:43 +0000 (17:44 +0530)]
virtio-9p: Create a commandline option -fsdev

This patch creates a new command line option named -fsdev to hold any file
system specific information.

The option will currently hold the following attributes:
-fsdev fstype id=id,path=path_to_share
where
fstype: Type of the file system.
id:     Identifier used to refer to this fsdev
path:   The path on the host that is identified by this fsdev.

[aneesh.kumar@linux.vnet.ibm.com: Abstraction using FsContext]
Signed-off-by: Gautham R Shenoy <ego@in.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-serial: Fix check for 'assert'; prevent NULL derefs
Amit Shah [Fri, 30 Apr 2010 11:13:55 +0000 (16:43 +0530)]
virtio-serial: Fix check for 'assert'; prevent NULL derefs

In the flush_queued_data() function, we expect port to be valid. Assert
only for port and not port || discard.

Reported-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoFix the RARP protocol ID
Stefan Berger [Sat, 24 Apr 2010 12:54:07 +0000 (08:54 -0400)]
Fix the RARP protocol ID

The packet(s) sent out after migration are supposed to be RAPR type of
packets. If they are supposed to go anywhere useful, the RAPR ethernet
identifier needs to be fix.

Also see http://www.iana.org/assignments/ethernet-numbers for 0x8035 for
RARP.

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoFix tiny leak in qemu_opts_parse
Jan Kiszka [Thu, 29 Apr 2010 16:24:43 +0000 (18:24 +0200)]
Fix tiny leak in qemu_opts_parse

qemu_opts_create duplicates the id we pass in case it shall be stored in
the opts. So we do not need to dup it in qemu_opts_parse, leaking a few
bytes this way.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agolsi: Properly initialize controller state on reset
Jan Kiszka [Fri, 30 Apr 2010 12:06:13 +0000 (14:06 +0200)]
lsi: Properly initialize controller state on reset

The LSI controller was lacking a system reset handler. Simply invoke the
existing soft reset handler in this case. This also allows to drop its
explicit invocation during init.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agolsi: Purge request queue on soft reset
Jan Kiszka [Fri, 30 Apr 2010 12:06:12 +0000 (14:06 +0200)]
lsi: Purge request queue on soft reset

Avoid keeping zombie requests across controller reset by purging the
queue and also dropping the currently active request.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoFix boot once option
Alex Williamson [Fri, 30 Apr 2010 21:21:11 +0000 (15:21 -0600)]
Fix boot once option

The boot once options seems to have gotten broken since it originally
went in.  We need to wait until the second time restore_boot_devices()
gets called before restoring the standard boot order and removing itself
from the reset list.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
--
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovnc: split encoding in specific files
Corentin Chary [Mon, 3 May 2010 12:31:34 +0000 (14:31 +0200)]
vnc: split encoding in specific files

This will allow to implement new encodings (tight, zrle, ..)
in a cleaner way. This may hurt performances, because some
functions like vnc_convert_pixel are not static anymore, but
should not be a problem with gcc 4.5 and the new -flto.

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovnc: Fix compile error on x86_64 with -D_VNC_DEBUG=1
Corentin Chary [Mon, 3 May 2010 12:31:18 +0000 (14:31 +0200)]
vnc: Fix compile error on x86_64 with -D_VNC_DEBUG=1

cc1: warnings being treated as errors
vnc-auth-sasl.c: In function â€˜vnc_client_write_sasl’:
vnc-auth-sasl.c:50: error: format â€˜%d’ expects type â€˜int’, but argument 4 has type â€˜size_t’
vnc-auth-sasl.c:50: error: format â€˜%d’ expects type â€˜int’, but argument 5 has type â€˜size_t’
make: *** [vnc-auth-sasl.o] Error 1

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoMerge remote branch 'kwolf/for-anthony' into HEAD
Anthony Liguori [Mon, 3 May 2010 12:31:51 +0000 (07:31 -0500)]
Merge remote branch 'kwolf/for-anthony' into HEAD

14 years agoMerge remote branch 'qemu-kvm/uq/master' into HEAD
Anthony Liguori [Mon, 3 May 2010 12:31:37 +0000 (07:31 -0500)]
Merge remote branch 'qemu-kvm/uq/master' into HEAD

14 years agoblock: Release allocated options after bdrv_open
Jan Kiszka [Thu, 29 Apr 2010 16:24:50 +0000 (18:24 +0200)]
block: Release allocated options after bdrv_open

They aren't used afterwards nor supposed to be stored by a bdrv_create
handler.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoqemu-img rebase: Fix output image corruption
Kevin Wolf [Thu, 29 Apr 2010 12:47:48 +0000 (14:47 +0200)]
qemu-img rebase: Fix output image corruption

qemu-img rebase must always give clusters in the COW file priority over those
in the backing file. As it failed to use number of non-allocated clusters but
assumed the maximum, it was possible that allocated clusters were taken from
the backing file instead, leading to a corrupted output image.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoblock: Add wr_highest_sector blockstat
Kevin Wolf [Wed, 28 Apr 2010 12:34:01 +0000 (14:34 +0200)]
block: Add wr_highest_sector blockstat

This adds the wr_highest_sector blockstat which implements what is generally
known as the high watermark. It is the highest offset of a sector written to
the respective BlockDriverState since it has been opened.

The query-blockstat QMP command is extended to add this value to the result,
and also to add the statistics of the underlying protocol in a new "parent"
field. Note that to get the "high watermark" of a qcow2 image, you need to look
into the wr_highest_sector field of the parent (which can be a file, a
host_device, ...). The wr_highest_sector of the qcow2 BlockDriverState itself
is the highest offset on the _virtual_ disk that the guest has written to.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoqcow2: Implement bdrv_truncate() for growing images
Stefan Hajnoczi [Wed, 28 Apr 2010 10:36:11 +0000 (11:36 +0100)]
qcow2: Implement bdrv_truncate() for growing images

This patch adds the ability to grow qcow2 images in-place using
bdrv_truncate().  This enables qemu-img resize command support for
qcow2.

Snapshots are not supported and bdrv_truncate() will return -ENOTSUP.
The notion of resizing an image with snapshots could lead to confusion:
users may expect snapshots to remain unchanged, but this is not possible
with the current qcow2 on-disk format where the header.size field is
global instead of per-snapshot.  Others may expect snapshots to change
size along with the current image data.  I think it is safest to not
support snapshots and perhaps add behavior later if there is a
consensus.

Backing images continue to work.  If the image is now larger than its
backing image, zeroes are read when accessing beyond the end of the
backing image.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoqcow2: Remove abort on free_clusters failure
Kevin Wolf [Wed, 21 Apr 2010 09:37:52 +0000 (11:37 +0200)]
qcow2: Remove abort on free_clusters failure

While it's true that during regular operation free_clusters failure would be a
bug, an I/O error can always happen. There's no need to kill the VM, the worst
thing that can happen (and it will) is that we leak some clusters.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoqemu-img: Add 'resize' command to grow/shrink disk images
Stefan Hajnoczi [Sat, 24 Apr 2010 08:12:12 +0000 (09:12 +0100)]
qemu-img: Add 'resize' command to grow/shrink disk images

This patch adds a 'resize' command to grow/shrink disk images.  This
allows changing the size of disk images without copying to a new image
file.  Currently only raw files support resize.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoblock: Cache total_sectors to reduce bdrv_getlength calls
Stefan Hajnoczi [Mon, 19 Apr 2010 15:56:41 +0000 (16:56 +0100)]
block: Cache total_sectors to reduce bdrv_getlength calls

The BlockDriver bdrv_getlength function is called from the I/O code path
when checking that the request falls within the device.  Unfortunately
this involves an lseek system call in the raw protocol; every read or
write request will incur this lseek cost.

Jan Kiszka <jan.kiszka@siemens.com> identified this issue and its
latency overhead.  This patch caches device length in the existing
total_sectors variable so lseek calls can be avoided for fixed size
devices.

Growable devices fall back to the full bdrv_getlength code path because
I have not added logic to detect extending the size of the device in a
write.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoraw-posix: Use pread/pwrite instead of lseek+read/write
Stefan Hajnoczi [Mon, 19 Apr 2010 12:34:11 +0000 (13:34 +0100)]
raw-posix: Use pread/pwrite instead of lseek+read/write

This patch combines the lseek+read/write calls to use pread/pwrite
instead.  This will result in fewer system calls and is already used by
AIO.

Thanks to Jan Kiszka <jan.kiszka@siemens.com> for identifying excessive
lseek and Christoph Hellwig <hch@lst.de> for confirming that this
approach should work.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoqcow2: Avoid shadowing variable in alloc_clusters_noref()
Stefan Hajnoczi [Sat, 17 Apr 2010 09:49:07 +0000 (10:49 +0100)]
qcow2: Avoid shadowing variable in alloc_clusters_noref()

The i loop iterator is shadowed by the next free cluster index.  Both
using the variable name 'i' makes the code harder to read.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoblock: Set backing_hd to NULL after deleting it
Stefan Hajnoczi [Sat, 17 Apr 2010 09:49:06 +0000 (10:49 +0100)]
block: Set backing_hd to NULL after deleting it

It is safer to set backing_hd to NULL after deleting it so that any use
after deletion is obvious during development.  Happy segfaulting!

This patch should be applied after Kevin Wolf's "vmdk: Convert to
bdrv_open" so that vmdk does not segfault on close.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agovmdk: Convert to bdrv_open
Kevin Wolf [Fri, 16 Apr 2010 19:27:51 +0000 (21:27 +0200)]
vmdk: Convert to bdrv_open

It's a format driver, so implement bdrv_open instead of bdrv_file_open.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agovmdk: Clean up backing file handling
Kevin Wolf [Fri, 16 Apr 2010 19:07:19 +0000 (21:07 +0200)]
vmdk: Clean up backing file handling

VMDK is doing interesting things when it needs to open a backing file. This
patch changes that part to look more like in other drivers. The nice side
effect is that the file name isn't needed any more in the open function.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agovmdk: Fix COW
Kevin Wolf [Fri, 16 Apr 2010 17:28:14 +0000 (19:28 +0200)]
vmdk: Fix COW

When trying to do COW, VMDK wrote the data back to the backing file. This
problem was revealed by the patch that made backing files read-only. This patch
does not only fix the problem, but also simplifies the VMDK code a bit.

This fixes the backing file qemu-iotests cases for VMDK.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoblock: bdrv_has_zero_init
Kevin Wolf [Wed, 14 Apr 2010 15:30:35 +0000 (17:30 +0200)]
block: bdrv_has_zero_init

This fixes the problem that qemu-img's use of no_zero_init only considered the
no_zero_init flag of the format driver, but not of the underlying protocols.

Between the raw/file split and this fix, converting to host devices is broken.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoblock: Open the underlying image file in generic code
Kevin Wolf [Wed, 14 Apr 2010 12:17:38 +0000 (14:17 +0200)]
block: Open the underlying image file in generic code

Format drivers shouldn't need to bother with things like file names, but rather
just get an open BlockDriverState for the underlying protocol. This patch
introduces this behaviour for bdrv_open implementation. For protocols which
need to access the filename to open their file/device/connection/... a new
callback bdrv_file_open is introduced which doesn't get an underlying file
opened.

For now, also some of the more obscure formats use bdrv_file_open because they
open() the file themselves instead of using the block.c functions. They need to
be fixed in later patches.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoblock: Avoid forward declaration of bdrv_open_common
Kevin Wolf [Wed, 14 Apr 2010 13:24:50 +0000 (15:24 +0200)]
block: Avoid forward declaration of bdrv_open_common

Move bdrv_open_common so it's defined before its callers and remove the forward
declaration.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoblock: Split bdrv_open
Kevin Wolf [Mon, 12 Apr 2010 14:37:13 +0000 (16:37 +0200)]
block: Split bdrv_open

bdrv_open contains quite some code that is only useful for opening images (as
opposed to opening files by a protocol), for example snapshots.

This patch splits the code so that we have bdrv_open_file() for files (uses
protocols), bdrv_open() for images (uses format drivers) and bdrv_open_common()
for the code common for opening both images and files.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoblock: separate raw images from the file protocol
Christoph Hellwig [Wed, 7 Apr 2010 20:30:24 +0000 (22:30 +0200)]
block: separate raw images from the file protocol

We're running into various problems because the "raw" file access, which
is used internally by the various image formats is entangled with the
"raw" image format, which maps the VM view 1:1 to a file system.

This patch renames the raw file backends to the file protocol which
is treated like other protocols (e.g. nbd and http) and adds a new
"raw" image format which is just a wrapper around calls to the underlying
protocol.

The patch is surprisingly simple, besides changing the probing logical
in block.c to only look for image formats when using bdrv_open and
renaming of the old raw protocols to file there's almost nothing in there.

For creating images, a new bdrv_create_file is introduced which guesses the
protocol to use. This allows using qemu-img create -f raw (or just using the
default) for both files and host devices. Converting the other format drivers
to use this function to create their images is left for later patches.

The only issues still open are in the handling of the host devices.
Firstly in current qemu we can specifiy the host* format names
on various command line acceping images, but the new code can't
do that without adding some translation.  Second the layering breaks
the no_zero_init flag in the BlockDriver used by qemu-img.  I'm not
happy how this is done per-driver instead of per-state so I'll
prepare a separate patch to clean this up.

There's some more cleanup opportunity after this patch, e.g. using
separate lists and registration functions for image formats vs
protocols and maybe even host drivers, but this can be done at a
later stage.

Also there's a check for protocol in bdrv_open for the BDRV_O_SNAPSHOT
case that I don't quite understand, but which I fear won't work as
expected - possibly even before this patch.

Note that this patch requires various recent block patches from Kevin
and me, which should all be in his block queue.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoFix missing '|' in '|=', spotted by clang analyzer
Blue Swirl [Sun, 2 May 2010 18:38:10 +0000 (18:38 +0000)]
Fix missing '|' in '|=', spotted by clang analyzer

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agofix old typos in help header
Thomas Monjalon [Wed, 28 Apr 2010 12:42:01 +0000 (14:42 +0200)]
fix old typos in help header

1) Qemu is not only a PC emulator.
2) "image image" has already been changed to "disk image" in qemu-doc.texi

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoClean up definition of MAX_OPC_PARAM
Stuart Brady [Tue, 27 Apr 2010 21:23:35 +0000 (22:23 +0100)]
Clean up definition of MAX_OPC_PARAM

MAX_OPC_PARAM is intended to refer to the maximum number of entries used
in gen_opparam_buf[] for any single helper call.  It is currently defined
as 10, but for 32-bit archs, the correct value (with a maximum for four
helper arguments) is 14, and for 64-bit archs, only 9 entries are needed.

tcg_gen_callN() fills four entries with the function address, flags,
number of args, etc. and on 32-bit archs uses a further two entries per
argument (with a maximum of four helper arguments), plus two more for the
return value.  On 64-bit archs, only half as many entries are used for the
args and the return value.

In reality, TBs tend not to consist purely of helper calls exceeding the
stated 10 gen_opparam_buf[] entries, so this would never actually be a
problem on 32-bit archs, but the definition is still rather confusing.

Signed-off-by: Stuart Brady <sdb@zubnet.me.uk>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agocmd646: fix abort due to changed opaque pointer for ioport read
Igor V. Kovalenko [Thu, 22 Apr 2010 21:54:50 +0000 (01:54 +0400)]
cmd646: fix abort due to changed opaque pointer for ioport read

We cannot install different opaque pointer for read and write
of the same i/o address.

- handle zero address in bmdma_writeb_common and install
  the same opaque pointer for both read and write access.

Signed-off-by: Igor V. Kovalenko <igor.v.kovalenko@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agocmd646: pass pci_dev as it needs it
Igor V. Kovalenko [Thu, 22 Apr 2010 21:54:45 +0000 (01:54 +0400)]
cmd646: pass pci_dev as it needs it

Instead of doing tricks to get the pci_dev, just pass it in the 1st
place.  Patch is a bit longer that reverting the pci_dev field, but it
states more clearly (IMHO) what we are doing.

It also fixes the bm test, now that you told me that ->unit is not
always valid.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Igor V. Kovalenko <igor.v.kovalenko@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agokvm: port qemu-kvm's bitmap scanning
Marcelo Tosatti [Fri, 23 Apr 2010 17:04:14 +0000 (14:04 -0300)]
kvm: port qemu-kvm's bitmap scanning

Which is significantly faster.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
14 years agointroduce leul_to_cpu
Marcelo Tosatti [Fri, 23 Apr 2010 17:04:13 +0000 (14:04 -0300)]
introduce leul_to_cpu

To be used by next patch.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
14 years agovga: fix typo in length passed to kvm_log_stop
Marcelo Tosatti [Fri, 23 Apr 2010 17:04:11 +0000 (14:04 -0300)]
vga: fix typo in length passed to kvm_log_stop

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
14 years agovirtio-serial: Implement flow control for individual ports
Amit Shah [Tue, 27 Apr 2010 12:34:11 +0000 (18:04 +0530)]
virtio-serial: Implement flow control for individual ports

Individual ports can now signal to the virtio-serial core to stop
sending data if the ports cannot immediately handle new data.  When a
port later unthrottles, any data queued up in the virtqueue are sent to
the port.

Disable throttling once a port is closed (and we discard all the
unconsumed buffers in the vq).

The guest kernel can reclaim the buffers when it receives the port close
event or when a port is being removed. Ensure we free up the buffers
before we send out any events to the guest.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-serial: Discard data that guest sends us when ports aren't connected
Amit Shah [Tue, 27 Apr 2010 12:34:10 +0000 (18:04 +0530)]
virtio-serial: Discard data that guest sends us when ports aren't connected

Before the earlier patch, we relied on incorrect virtio api usage to
signal to the guest that a particular buffer wasn't consumed by the
host.

After fixing that, we now just discard the data the guest sends us while
a host port is disconnected or doesn't have a handler registered for
consuming data.

This commit really doesn't change anything from the current behaviour,
just makes the code slightly better by spinning off data handling to
ports in another function.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-serial: Apps should consume all data that guest sends out / Fix virtio api...
Amit Shah [Tue, 27 Apr 2010 12:34:09 +0000 (18:04 +0530)]
virtio-serial: Apps should consume all data that guest sends out / Fix virtio api abuse

We cannot indicate to the guest how much data was consumed by an app for
out_bufs.  So we just have to assume the apps will consume all the data
that are handed over to them.

Fix the virtio api abuse in control_out() and handle_output().

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-serial: Handle scatter/gather input from the guest
Amit Shah [Tue, 27 Apr 2010 12:34:08 +0000 (18:04 +0530)]
virtio-serial: Handle scatter/gather input from the guest

Current guests don't send more than one iov but it can change later.
Ensure we handle that case.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
CC: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-serial: Handle scatter-gather buffers for control messages
Amit Shah [Tue, 27 Apr 2010 12:34:07 +0000 (18:04 +0530)]
virtio-serial: Handle scatter-gather buffers for control messages

Current control messages are small enough to not be split into multiple
buffers but we could run into such a situation in the future or a
malicious guest could cause such a situation.

So handle the entire iov request for control messages.

Also ensure the size of the control request is >= what we expect
otherwise we risk accessing memory that we don't own.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
CC: Avi Kivity <avi@redhat.com>
Reported-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoiov: Add iov_to_buf and iov_size helpers
Amit Shah [Tue, 27 Apr 2010 12:34:06 +0000 (18:04 +0530)]
iov: Add iov_to_buf and iov_size helpers

iov_to_buf() puts the buffer contents in the iov in a linearized buffer.

iov_size() gets the length of the contents in the iov.

The iov_to_buf() function is the memcpy_to_iovec() function that was
used in virtio-ballon.c.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoiov: Introduce a new file for helpers around iovs, add iov_from_buf()
Amit Shah [Tue, 27 Apr 2010 12:34:05 +0000 (18:04 +0530)]
iov: Introduce a new file for helpers around iovs, add iov_from_buf()

The virtio-net code uses iov_fill() which fills an iov from a linear
buffer. The virtio-serial-bus code does something similar in an
open-coded function.

Create a new iov.c file that has iov_from_buf().

Convert virtio-net and virtio-serial-bus over to use this functionality.
virtio-net used ints to hold sizes, the new function is going to use
size_t types.

Later commits will add the opposite functionality -- going from an iov
to a linear buffer.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-serial: Send out guest data to ports only if port is opened
Amit Shah [Tue, 27 Apr 2010 12:34:04 +0000 (18:04 +0530)]
virtio-serial: Send out guest data to ports only if port is opened

Data should be written only when ports are open.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-serial: Propagate errors in initialising ports / devices in guest
Amit Shah [Tue, 27 Apr 2010 12:34:03 +0000 (18:04 +0530)]
virtio-serial: Propagate errors in initialising ports / devices in guest

If adding of ports or devices in the guest fails we can send out a QMP
event so that management software can deal with it.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-serial: Update copyright year to 2010
Amit Shah [Tue, 27 Apr 2010 12:34:02 +0000 (18:04 +0530)]
virtio-serial: Update copyright year to 2010

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>