sdk/emulator/qemu.git
13 years agovnc: Fix password expiration through 'change vnc ""' (v2)
Anthony Liguori [Mon, 31 Jan 2011 20:27:36 +0000 (14:27 -0600)]
vnc: Fix password expiration through 'change vnc ""' (v2)

commit 52c18be9e99dabe295321153fda7fce9f76647ac introduced a regression in the
change vnc password command that changed the behavior of setting the VNC
password to an empty string from disabling login to disabling authentication.

This commit refactors the code to eliminate this overloaded semantics in
vnc_display_password and instead introduces the vnc_display_disable_login.   The
monitor implementation then determines the behavior of an empty or missing
string.

Recently, a set_password command was added that allows both the Spice and VNC
password to be set.  This command has not shown up in a release yet so the
behavior is not yet defined.

This patch proposes that an empty password be treated as an empty password with
no special handling.  For specifically disabling login, I believe a new command
should be introduced instead of overloading semantics.

I'm not sure how Spice handles this but I would recommend that we have Spice
and VNC have consistent semantics here for the 0.14.0 release.

Reported-by: Neil Wilson <neil@aldur.co.uk>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
v1 -> v2
 - Add a proper return to make sure that login is really disabled instead of
   relying on the VNC server to treat empty passwords specially

13 years agolinux-user: avoid gcc array overrun warning for sparc
Peter Maydell [Tue, 1 Feb 2011 15:54:52 +0000 (15:54 +0000)]
linux-user: avoid gcc array overrun warning for sparc

Suppress a gcc array bounds overrun warning when filling in the SPARC
signal frame by adjusting our definition of the structure so that the
fp and callers_pc membes are part of the ins[] array rather than
separate fields; since qemu has no need to access the fields individually
there is no need to follow the kernel's structure field naming exactly.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agohw/slavio_intctl.c: fix gcc warning about array bounds overrun
Peter Maydell [Mon, 31 Jan 2011 10:42:26 +0000 (10:42 +0000)]
hw/slavio_intctl.c: fix gcc warning about array bounds overrun

The Ubuntu 10.10 gcc for ARM complains that we might be overrunning
the cpu_irqs[][] array: silence this by correcting the bounds on the
loop. (In fact we would not have overrun the array because bit
MAX_PILS in pil_pending and irl_out will always be 0.)

Also add a comment about why the loop's lower bound is OK.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agoSPARC: Fix Leon3 cache control
Fabien Chouteau [Mon, 31 Jan 2011 10:36:54 +0000 (11:36 +0100)]
SPARC: Fix Leon3 cache control

The "leon3_cache_control_int" (op_helper.c) function is called within leon3.c
which leads to segfault error with the global "env".

Now cache control is a CPU feature and everything is handled in op_helper.c.

Signed-off-by: Fabien Chouteau <chouteau@adacore.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agoMerge remote branch 'mst/for_anthony' into staging
Anthony Liguori [Mon, 31 Jan 2011 18:07:17 +0000 (12:07 -0600)]
Merge remote branch 'mst/for_anthony' into staging

13 years agoblockdev: Fix drive_add for drives without media
Markus Armbruster [Fri, 28 Jan 2011 10:21:46 +0000 (11:21 +0100)]
blockdev: Fix drive_add for drives without media

Watch this:

    (qemu) drive_add 0 if=none
    (qemu) info block
    none0: type=hd removable=0 [not inserted]
    (qemu) drive_del none0
    Segmentation fault (core dumped)

add_init_drive() is confused about drive_init()'s failure modes, and
cleans up when it shouldn't.  This leaves the DriveInfo with member
opts dangling.  drive_del attempts to free it, and dies.

drive_init() behaves as follows:

* If it created a drive with media, it returns its DriveInfo.

* If it created a drive without media, it clears *fatal_error and
  returns NULL.

* If it couldn't create a drive, it sets *fatal_error and returns
  NULL.

Of its three callers:

* drive_init_func() is correct.

* usb_msd_init() assumes drive_init() failed when it returns NULL.
  This is correct only because it always passes option "file", and
  "drive without media" can't happen then.

* add_init_drive() assumes drive_init() failed when it returns NULL.
  This is incorrect.

Clean up drive_init() to return NULL on failure and only on failure.
Drop its parameter fatal_error.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblockdev: Replace drive_add()'s fmt, ... by optstr parameter
Markus Armbruster [Mon, 31 Jan 2011 10:50:09 +0000 (11:50 +0100)]
blockdev: Replace drive_add()'s fmt, ... by optstr parameter

Let the callers build the optstr.  Only one wants to.  All the others
become simpler, because they don't have to worry about escaping '%'.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblockdev: Reject multiple definitions for the same drive
Markus Armbruster [Fri, 28 Jan 2011 10:21:45 +0000 (11:21 +0100)]
blockdev: Reject multiple definitions for the same drive

We silently ignore multiple definitions for the same drive:

    $ qemu-system-x86_64 -nodefaults -vnc :1 -S -monitor stdio -drive if=ide,index=1,file=tmp.qcow2 -drive if=ide,index=1,file=nonexistant
    QEMU 0.13.50 monitor - type 'help' for more information
    (qemu) info block
    ide0-hd1: type=hd removable=0 file=tmp.qcow2 backing_file=tmp.img ro=0 drv=qcow2 encrypted=0

With if=none, this can become quite confusing:

    $ qemu-system-x86_64 -nodefaults -vnc :1 -S -monitor stdio -drive if=none,index=1,file=tmp.qcow2,id=eins -drive if=none,index=1,file=nonexistant,id=zwei -device ide-drive,drive=eins -device ide-drive,drive=zwei
    qemu-system-x86_64: -device ide-drive,drive=zwei: Property 'ide-drive.drive' can't find value 'zwei'

The second -device fails, because it refers to drive zwei, which got
silently ignored.

Make multiple drive definitions fail cleanly.

Unfortunately, there's code that relies on multiple drive definitions
being silently ignored: main() merrily adds default drives even when
the user already defined these drives.  Fix that up.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblockdev: New drive_get_by_index()
Markus Armbruster [Fri, 28 Jan 2011 10:21:44 +0000 (11:21 +0100)]
blockdev: New drive_get_by_index()

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblockdev: Factor drive_index_to_{bus,unit}_id out of drive_init()
Markus Armbruster [Fri, 28 Jan 2011 10:21:43 +0000 (11:21 +0100)]
blockdev: Factor drive_index_to_{bus,unit}_id out of drive_init()

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblockdev: Make drive_add() take explicit type, index parameters
Markus Armbruster [Fri, 28 Jan 2011 10:21:41 +0000 (11:21 +0100)]
blockdev: Make drive_add() take explicit type, index parameters

Before, type & index were hidden in printf-like fmt, ... parameters,
which get expanded into an option string.  Rather inconvenient for
uses later in this series.

New IF_DEFAULT to ask for the machine's default interface.  Before,
that was done by having no option "if" in the option string.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblockdev: Fix regression in -drive if=scsi,index=N
Markus Armbruster [Fri, 28 Jan 2011 10:21:40 +0000 (11:21 +0100)]
blockdev: Fix regression in -drive if=scsi,index=N

Before commit 622b520f, index=12 meant bus=1,unit=5.

Since the commit, it means bus=0,unit=12.  The drive is created, but
not the guest device.  That's because the controllers we use with
if=scsi drives (lsi53c895a and esp) support only 7 units, and
scsi_bus_legacy_handle_cmdline() ignores drives with unit numbers
exceeding that limit.

Changing the mapping of index to bus, unit is a regression.  Breaking
-drive invocations that used to work just makes it worse.

Revert the part of commit 622b520f that causes this, and clean up
some.

Note that the fix only affects if=scsi.  You can still put more than 7
units on a SCSI bus with -device & friends.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblockdev: Put BlockInterfaceType names and max_devs in tables
Markus Armbruster [Fri, 28 Jan 2011 10:21:39 +0000 (11:21 +0100)]
blockdev: Put BlockInterfaceType names and max_devs in tables

Turns drive_init()'s lengthy conditional into a concise loop, and
makes the data available elsewhere.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblockdev: Move BlockInterfaceType from qemu-common.h to blockdev.h
Markus Armbruster [Fri, 28 Jan 2011 10:21:38 +0000 (11:21 +0100)]
blockdev: Move BlockInterfaceType from qemu-common.h to blockdev.h

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblockdev: New drive_get_next(), replacing qdev_init_bdrv()
Markus Armbruster [Fri, 28 Jan 2011 10:21:37 +0000 (11:21 +0100)]
blockdev: New drive_get_next(), replacing qdev_init_bdrv()

qdev_init_bdrv() doesn't belong into qdev.c; it's about drives, not
qdevs.  Rename to drive_get_next, move to blockdev.c, drop the bogus
DeviceState argument, and return DriveInfo instead of
BlockDriverState.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoqcow2-refcount: remove write-only variables
Blue Swirl [Sat, 29 Jan 2011 08:19:15 +0000 (08:19 +0000)]
qcow2-refcount: remove write-only variables

Variables l2_modified and l2_size are not really used, remove them.
Spotted by GCC 4.6.0:
  CC    block/qcow2-refcount.o
/src/qemu/block/qcow2-refcount.c: In function 'qcow2_update_snapshot_refcount':
/src/qemu/block/qcow2-refcount.c:708:37: error: variable 'l2_modified' set but not used [-Werror=unused-but-set-variable]
/src/qemu/block/qcow2-refcount.c:708:9: error: variable 'l2_size' set but not used [-Werror=unused-but-set-variable]

CC: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoscsi hotplug: Set DriveInfo member bus correctly
Markus Armbruster [Fri, 28 Jan 2011 10:21:36 +0000 (11:21 +0100)]
scsi hotplug: Set DriveInfo member bus correctly

drive_init() picks the first free bus and unit number, unless the user
specifies them.

This isn't a good fit for the drive_add monitor command, because there
we specify the controller by PCI address instead of using bus number
set by drive_init().

scsi_hot_add() takes care to replace the unit number set by
drive_init() by the real one, but it neglects to replace the bus
number.  Thus, bus/unit in DriveInfo may be bogus.  Affects
drive_get() and drive_get_max_bus().  I'm not aware of anything bad
happening because of that; looks like by the time we're hot-plugging,
the two functions aren't used anymore.  Fix it anyway.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoraw-win32: Fix bdrv_flush return value
Kevin Wolf [Fri, 28 Jan 2011 14:57:39 +0000 (15:57 +0100)]
raw-win32: Fix bdrv_flush return value

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoqed: Images with backing file do not require QED_F_NEED_CHECK
Stefan Hajnoczi [Fri, 28 Jan 2011 17:11:59 +0000 (17:11 +0000)]
qed: Images with backing file do not require QED_F_NEED_CHECK

The consistency check on open is necessary in order to fix inconsistent
table offsets left as a result of a crash mid-operation.  Images with a
backing file actually flush before updating table offsets and are
therefore guaranteed to be consistent.  Do not mark these images dirty.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoqcow2: Add bdrv_discard support
Kevin Wolf [Wed, 26 Jan 2011 15:56:48 +0000 (16:56 +0100)]
qcow2: Add bdrv_discard support

This adds a bdrv_discard function to qcow2 that frees the discarded clusters.
It does not yet pass the discard on to the underlying file system driver, but
the space can be reused by future writes to the image.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agoqemu-io: Fix discard command
Kevin Wolf [Wed, 26 Jan 2011 15:56:34 +0000 (16:56 +0100)]
qemu-io: Fix discard command

qemu-io passed bytes where it's supposed to pass sectors, so discard requests
were off.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agosheepdog: support creating images on remote hosts
MORITA Kazutaka [Thu, 27 Jan 2011 16:33:10 +0000 (01:33 +0900)]
sheepdog: support creating images on remote hosts

This patch parses the input filename in sd_create(), and enables us
specifying a target server to create sheepdog images.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoReorganize struct Qcow2Cache for better struct packing
Jes Sorensen [Thu, 27 Jan 2011 10:25:03 +0000 (11:25 +0100)]
Reorganize struct Qcow2Cache for better struct packing

Move size after the two pointers in struct Qcow2Cache to get better
packing of struct elements on 64 bit architectures.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoahci: Fix cpu_physical_memory_unmap() argument ordering
Stefan Hajnoczi [Wed, 26 Jan 2011 10:24:56 +0000 (10:24 +0000)]
ahci: Fix cpu_physical_memory_unmap() argument ordering

The len and is_write arguments to cpu_physical_memory_unmap() were
swapped.  This patch changes calls to use the correct argument ordering.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoAdd documentation for STRTOSZ_DEFSUFFIX_ macros
Jes Sorensen [Wed, 26 Jan 2011 10:54:58 +0000 (11:54 +0100)]
Add documentation for STRTOSZ_DEFSUFFIX_ macros

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Acked-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agovirtio-pci: Disable virtio-ioeventfd when !CONFIG_IOTHREAD
Stefan Hajnoczi [Tue, 25 Jan 2011 16:17:14 +0000 (16:17 +0000)]
virtio-pci: Disable virtio-ioeventfd when !CONFIG_IOTHREAD

It is not possible to use virtio-ioeventfd when building without an I/O
thread.  We rely on a signal to kick us out of vcpu execution.  Timers
and AIO use SIGALRM and SIGUSR2 respectively.  Unfortunately eventfd
does not support O_ASYNC (SIGIO) so eventfd cannot be used in a signal
driven manner.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agovirtio-blk: tell the guest about size changes
Christoph Hellwig [Mon, 24 Jan 2011 12:32:51 +0000 (13:32 +0100)]
virtio-blk: tell the guest about size changes

Raise a config change interrupt when the size changed.  This allows
virtio-blk guest drivers to read-read the information from the
config space once it got the config chaged interrupt.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblock: tell drivers about an image resize
Christoph Hellwig [Mon, 24 Jan 2011 12:32:41 +0000 (13:32 +0100)]
block: tell drivers about an image resize

Extend the change_cb callback with a reason argument, and use it
to tell drivers about size changes.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblock: add block_resize monitor command
Christoph Hellwig [Mon, 24 Jan 2011 12:32:33 +0000 (13:32 +0100)]
block: add block_resize monitor command

Add a monitor command that allows resizing of block devices while
qemu is running.  It uses the existing bdrv_truncate method already
used by qemu-img to do it's work.  Compared to qemu-img the size
parsing is very simplicistic, but I think having a properly numering
object is more useful for non-humand monitor users than having
the units and relative resize parsing.

For SCSI devices the new size can be updated in Linux guests by
doing the following shell command:

echo > /sys/class/scsi_device/0:0:0:0/device/rescan

For ATA devices I don't know of a way to update the block device
size in Linux system, and for virtio-blk the next two patches
will provide an automatic update of the size when this command
is issued on the host.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agostrtosz(): Use suffix macros in switch() statement
Jes Sorensen [Mon, 24 Jan 2011 15:33:31 +0000 (16:33 +0100)]
strtosz(): Use suffix macros in switch() statement

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agostrtosz(): Fix name confusion in use of modf()
Jes Sorensen [Mon, 24 Jan 2011 15:33:30 +0000 (16:33 +0100)]
strtosz(): Fix name confusion in use of modf()

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agostrtosz() use qemu_toupper() to simplify switch statement
Jes Sorensen [Mon, 24 Jan 2011 15:33:29 +0000 (16:33 +0100)]
strtosz() use qemu_toupper() to simplify switch statement

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agostrtosz(): use unsigned char and switch to qemu_isspace()
Jes Sorensen [Mon, 24 Jan 2011 15:33:28 +0000 (16:33 +0100)]
strtosz(): use unsigned char and switch to qemu_isspace()

isspace() behavior is undefined for signed char.

Bug pointed out by Eric Blake, thanks!

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoUpdate OpenBIOS images to r1018
Blue Swirl [Sun, 30 Jan 2011 13:10:10 +0000 (13:10 +0000)]
Update OpenBIOS images to r1018

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agosdl: remove unused variable
Blue Swirl [Sat, 29 Jan 2011 22:52:33 +0000 (22:52 +0000)]
sdl: remove unused variable

Variable rec is not used, remove it. Spotted by GCC 4.6.0:
  CC    ui/sdl.o
/src/qemu/ui/sdl.c: In function 'sdl_setdata':
/src/qemu/ui/sdl.c:90:14: error: variable 'rec' set but not used [-Werror=unused-but-set-variable]

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agoNew trace-event backend: stderr
Fabien Chouteau [Thu, 27 Jan 2011 09:24:41 +0000 (10:24 +0100)]
New trace-event backend: stderr

This backend sends trace events to standard error output during the emulation.

Also add a "--list-backends" option to tracetool, so configure script can
display the list of available backends.

Signed-off-by: Fabien Chouteau <chouteau@adacore.com>
Acked-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agoprep: Disable second IDE channel, as long as ISA IDE emulation doesn't support same...
Hervé Poussineau [Tue, 18 Jan 2011 21:43:56 +0000 (22:43 +0100)]
prep: Disable second IDE channel, as long as ISA IDE emulation doesn't support same irq for both channels

Cc: Andreas Färber <andreas.faerber@web.de>
Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agoprep: Remove bogus BIOS size check
Andreas Färber [Tue, 18 Jan 2011 21:43:55 +0000 (22:43 +0100)]
prep: Remove bogus BIOS size check

r3480 added this check to account for the entry vector 0xfff00100 to be
available for CPUs that need it. Today however, the NIP is not yet
initialized at this point (zero), so the check always triggers.

Moreover, BIOS size check is already done previously, so this part can
be removed too.

Cc: Alexander Graf <agraf@suse.de>
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agomc146818rtc: update registers after a format change
Aurelien Jarno [Tue, 25 Jan 2011 10:55:15 +0000 (11:55 +0100)]
mc146818rtc: update registers after a format change

For some unknown reason, the MIPS kernel briefly changes the RTC to
binary mode during boot, switch back to BCD mode and read the time. As
the registers are updated only every second, they may still be in the
old format when they are read.

This patch forces a register update immediately after a format change
(BCD/binary or 12/24H). This avoid long fsck during boot due to time
wrap.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agomc146818rtc: constantify
Aurelien Jarno [Tue, 25 Jan 2011 10:55:15 +0000 (11:55 +0100)]
mc146818rtc: constantify

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-arm: Fix Neon VQ(R)DMULH.S16 instructions
Juha Riihimäki [Thu, 27 Jan 2011 19:18:35 +0000 (19:18 +0000)]
target-arm: Fix Neon VQ(R)DMULH.S16 instructions

Correct an error in the implementation of the 16 bit
forms of VQ(R)DMULH, bringing them into line with the
32 bit implementation.

Signed-off-by: Juha Riihimäki <juha.riihimaki@nokia.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agovirtio-blk: fix cross-endianness targets
Aurelien Jarno [Tue, 25 Jan 2011 10:55:14 +0000 (11:55 +0100)]
virtio-blk: fix cross-endianness targets

virtio-blk doesn't work on cross-endian configuration, as endianness is
not handled correctly.

This patch adds missing endianness conversions to make virtio-blk
working. Tested on the following configurations:
- i386 guest on x86_64 host
- ppc guest on x86_64 host
- i386 guest on mips host
- ppc guest on mips host

Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agovirtio-net: fix cross-endianness support
Aurelien Jarno [Tue, 25 Jan 2011 10:55:14 +0000 (11:55 +0100)]
virtio-net: fix cross-endianness support

virtio-net used to work on cross-endianness configurations, but doesn't
anymore with recent guest kernels, as the new features don't handle
endianness correctly.

This patch fixes wrong conversion, and add missing ones to make
virtio-net working. Tested on the following configurations:
- i386 guest on x86_64 host
- ppc guest on x86_64 host
- i386 guest on mips host
- ppc guest on mips host

Cc: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agoescc: fix interrupt flags
Aurelien Jarno [Thu, 27 Jan 2011 07:21:35 +0000 (08:21 +0100)]
escc: fix interrupt flags

Recent PowerPC kernel end up in kernel panic during boot in -nographic
mode. In this mode the second serial port is used as the udbg console,
and thus a few characters are sent on this port. This activates the
tx interrupt flag, and later choke the Linux kernel, as it was not
expecting such a flag to be set.

The problem here comes from the fact that contrary to most devices the
interrupt flags are only set if the interrupt is enabled. Quoting the
datasheet: "If the corresponding IE bit is not set, the IP for that
source of interrupt will never be set."

This patch fixes that by enabling the interrupt flag only when the
corresponding interrupt is enabled.

Cc: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agopxa2xx_gpio: switch to using qdev
Dmitry Eremin-Solenikov [Fri, 21 Jan 2011 16:57:50 +0000 (19:57 +0300)]
pxa2xx_gpio: switch to using qdev

As noted by Markus Armbruster pxa2xx_gpio vmstate version bumped
because of a change in the or .ilevel / .olevel arrays are saved,
for convenience.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
13 years agospitz: make spitz-keyboard to use qdev infrastructure
Dmitry Eremin-Solenikov [Fri, 21 Jan 2011 16:56:10 +0000 (19:56 +0300)]
spitz: make spitz-keyboard to use qdev infrastructure

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
13 years agospitz: make sl-nand emulation use qdev infrastructure
Dmitry Eremin-Solenikov [Fri, 21 Jan 2011 10:12:11 +0000 (13:12 +0300)]
spitz: make sl-nand emulation use qdev infrastructure

Switch sl-nand emulation to use qdev and vmstate. Also drop ecc_get/_put
functions as sl-nand was the only user of that code.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
13 years agoUse vmstate to save/load spitz-lcdtg and corgi-ssp state
Dmitry Eremin-Solenikov [Thu, 20 Jan 2011 15:52:28 +0000 (18:52 +0300)]
Use vmstate to save/load spitz-lcdtg and corgi-ssp state

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
13 years agoSharpSL scoop device - convert to qdev
Dmitry Eremin-Solenikov [Thu, 20 Jan 2011 15:52:27 +0000 (18:52 +0300)]
SharpSL scoop device - convert to qdev

Convert SharpSL scoop device to qdev, remove lots of supporting code, as
lot of init and gpio related things can now be done automagically.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
13 years agopci: typo in pcibus_get_dev_path()
Isaku Yamahata [Thu, 27 Jan 2011 03:49:04 +0000 (12:49 +0900)]
pci: typo in pcibus_get_dev_path()

This patch fixes typo in pcibus_get_dev_path().
Without this patch, the result of pcibus_get_dev_path() isn't unique.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
13 years agopci: bridge control fixup
Michael S. Tsirkin [Wed, 26 Jan 2011 13:55:07 +0000 (15:55 +0200)]
pci: bridge control fixup

PCI_BRIDGE_CTL_DISCARD_STATUS (bit 10 in bridge control register)
is W1C so we should not make it writeable, otherwise the assert(!(wmask
& w1cmask)) in pci_default_write_config() is hit

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reported-by: Isaku Yamahata <yamahata@valinux.co.jp>
Tested-by: Isaku Yamahata <yamahata@valinux.co.jp>
13 years agotarget-arm: Fix loading of scalar value for Neon multiply-by-scalar
Peter Maydell [Wed, 19 Jan 2011 19:29:53 +0000 (19:29 +0000)]
target-arm: Fix loading of scalar value for Neon multiply-by-scalar

Fix the register and part of register we get the scalar from in
the various "multiply vector by scalar" ops (VMUL by scalar
and friends).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-arm: Fix garbage collection of temporaries in Neon emulation.
Christophe Lyon [Wed, 19 Jan 2011 14:37:58 +0000 (15:37 +0100)]
target-arm: Fix garbage collection of temporaries in Neon emulation.

Fix garbage collection of temporaries in Neon emulation.

Signed-off-by: Christophe Lyon <christophe.lyon@st.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agoSupport saturation with shift=0.
Christophe Lyon [Wed, 19 Jan 2011 16:10:52 +0000 (17:10 +0100)]
Support saturation with shift=0.

This patch fixes corner-case saturations, when the target range is
zero. It merely removes the guard against (sh == 0), and makes:
__ssat(0x87654321, 1) return 0xffffffff and set the saturation flag
__usat(0x87654321, 0) return 0 and set the saturation flag

Signed-off-by: Christophe Lyon <christophe.lyon@st.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-sh4: update PTEH upon MMU exception
Alexandre Courbot [Wed, 26 Jan 2011 02:57:53 +0000 (11:57 +0900)]
target-sh4: update PTEH upon MMU exception

Update the PTEH register to contain the VPN at which an MMU
exception occured as specified by the SH4 reference.

Signed-off-by: Alexandre Courbot <gnurou@gmail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agosh4: implement missing mmaped TLB read functions
Aurelien Jarno [Wed, 26 Jan 2011 01:16:39 +0000 (02:16 +0100)]
sh4: implement missing mmaped TLB read functions

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agosh4: implement missing mmaped TLB write functions
Aurelien Jarno [Wed, 26 Jan 2011 01:07:50 +0000 (02:07 +0100)]
sh4: implement missing mmaped TLB write functions

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agoetrax: Dont decrease the granularity of timers
Edgar E. Iglesias [Wed, 26 Jan 2011 09:36:37 +0000 (10:36 +0100)]
etrax: Dont decrease the granularity of timers

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
13 years agocris: Replace tcg branch sequence with setcond
Edgar E. Iglesias [Tue, 25 Jan 2011 18:47:06 +0000 (19:47 +0100)]
cris: Replace tcg branch sequence with setcond

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
13 years agopulseaudio: tweak config
Gerd Hoffmann [Mon, 24 Jan 2011 21:07:46 +0000 (22:07 +0100)]
pulseaudio: tweak config

Zap unused divisor field.
Raise the buffer size default.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: malc <av1474@comtv.ru>
13 years agopulseaudio: setup buffer attrs
Gerd Hoffmann [Mon, 24 Jan 2011 21:07:45 +0000 (22:07 +0100)]
pulseaudio: setup buffer attrs

Request reasonable buffer sizes from pulseaudio.  Without this
pa_simple_write() can block quite long and lead to dropouts,
especially with guests which use small audio ring buffers.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: malc <av1474@comtv.ru>
13 years agopulseaudio: process 1/4 buffer max at once
Gerd Hoffmann [Mon, 24 Jan 2011 21:07:44 +0000 (22:07 +0100)]
pulseaudio: process 1/4 buffer max at once

Limit the size of data pieces processed by the pulseaudio worker
threads.  Never ever process more than 1/4 of the buffer at once.

Background: The buffer area currently processed by the pulseaudio thread
is blocked, i.e. the main thread (or iothread) can't fill in more data
there.  The buffer processing time is roughly real-time due to the
pa_simple_write() call blocking when the output queue to the pulse
server is full.  Thus processing big chunks at once means blocking
a large part of the buffer for a long time.  This brings high latency
and can lead to dropouts.

When processing the buffer in smaller chunks the rpos handling becomes a
problem though.  The thread reads hw->rpos without knowing whenever
qpa_run_out has already seen the last (small) chunk processed and
updated rpos accordingly.  There is no point in reading hw->rpos though,
pa->rpos can be used instead.  We just need to take care to initialize
pa->rpos before kicking the thread.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: malc <av1474@comtv.ru>
13 years agomonitor: use after free in do_wav_capture()
Isaku Yamahata [Fri, 21 Jan 2011 10:53:55 +0000 (19:53 +0900)]
monitor: use after free in do_wav_capture()

use after free in do_wav_capture() on the error path.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agomips_fulong: remove bogus HAS_AUDIO
Isaku Yamahata [Fri, 21 Jan 2011 10:53:51 +0000 (19:53 +0900)]
mips_fulong: remove bogus HAS_AUDIO

remove bogus HAS_AUDIO according to 738012bec4c67e697e766edadab3f522c552a04d.

Cc: Blue Swirl <blauwirbel@gmail.com>
Cc: Huacai Chen <zltjiangshi@gmail.com>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agoaudio: consolidate audio_init()
Isaku Yamahata [Fri, 21 Jan 2011 10:53:45 +0000 (19:53 +0900)]
audio: consolidate audio_init()

consolidate audio_init() and remove references to shoundhw.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Acked-by: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-sh4: fix index of address read error exception
Alexandre Courbot [Tue, 25 Jan 2011 05:00:14 +0000 (14:00 +0900)]
target-sh4: fix index of address read error exception

Exception index of address read error should be 0x0e0.

Signed-off-by: Alexandre Courbot <gnurou@gmail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-sh4: fix TLB invalidation code
Alexandre Courbot [Tue, 25 Jan 2011 06:32:01 +0000 (15:32 +0900)]
target-sh4: fix TLB invalidation code

In cpu_sh4_invalidate_tlb, the UTLB was invalidated twice and the
ITLB left unchaged, probably because of some unfortunate copy/paste.

Signed-off-by: Alexandre Courbot <gnurou@gmail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agoMerge remote branch 'kwolf/for-anthony' into staging
Anthony Liguori [Mon, 24 Jan 2011 21:16:56 +0000 (15:16 -0600)]
Merge remote branch 'kwolf/for-anthony' into staging

13 years agoSPARC: Add asr17 register support
Fabien Chouteau [Mon, 24 Jan 2011 11:56:56 +0000 (12:56 +0100)]
SPARC: Add asr17 register support

This register is activated by CPU_FEATURE_ASR17 in the feature field.

Signed-off-by: Fabien Chouteau <chouteau@adacore.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agoSPARC: Emulation of Leon3
Fabien Chouteau [Mon, 24 Jan 2011 11:56:55 +0000 (12:56 +0100)]
SPARC: Emulation of Leon3

Leon3 is an open-source VHDL System-On-Chip, well known in space industry (more
information on http://www.gaisler.com).

Leon3 is made of multiple components available in the GrLib VHDL library.
Three devices are implemented: uart, timers and IRQ manager.
You can find code for these peripherals in the grlib_* files.

Signed-off-by: Fabien Chouteau <chouteau@adacore.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agoSPARC: Emulation of GRLIB APB UART
Fabien Chouteau [Mon, 24 Jan 2011 11:56:54 +0000 (12:56 +0100)]
SPARC: Emulation of GRLIB APB UART

This device exposes one parameter:
 - chardev (ptr) : Pointer to a qemu character device

Emulation of GrLib devices is base on the GRLIB IP Core User's Manual:
http://www.gaisler.com/products/grlib/grip.pdf

Signed-off-by: Fabien Chouteau <chouteau@adacore.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agoSPARC: Emulation of GRLIB IRQMP
Fabien Chouteau [Mon, 24 Jan 2011 11:56:53 +0000 (12:56 +0100)]
SPARC: Emulation of GRLIB IRQMP

This device exposes two parameters:
 - set_pil_in        (ptr) : A function to set the pil_in of the SPARC CPU
 - set_pil_in_opaque (ptr) : Opaque argument of the set_pil_in function

Emulation of GrLib devices is base on the GRLIB IP Core User's Manual:
http://www.gaisler.com/products/grlib/grip.pdf

Signed-off-by: Fabien Chouteau <chouteau@adacore.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agoSPARC: Emulation of GRLIB GPTimer
Fabien Chouteau [Mon, 24 Jan 2011 11:56:52 +0000 (12:56 +0100)]
SPARC: Emulation of GRLIB GPTimer

This device exposes three parameters:
 - frequency (uint32) : The system frequency
 - irq-line  (uint32) : IRQ line number for the first timer
                        (others use irq-line + 1, irq-line + 2...)
 - nr-timers (uint32) : Number of timers

Emulation of GrLib devices is base on the GRLIB IP Core User's Manual:
http://www.gaisler.com/products/grlib/grip.pdf

Signed-off-by: Fabien Chouteau <chouteau@adacore.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agodocs: Document scsi-disk and usb-storage removable parameter
Stefan Hajnoczi [Mon, 24 Jan 2011 15:35:01 +0000 (15:35 +0000)]
docs: Document scsi-disk and usb-storage removable parameter

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agousb-msd: Propagate removable bit to SCSI device
Stefan Hajnoczi [Mon, 24 Jan 2011 15:35:00 +0000 (15:35 +0000)]
usb-msd: Propagate removable bit to SCSI device

USB Mass Storage Devices sometimes have the RMB (removable) bit set in
the SCSI INQUIRY response.  Thumbdrives tend to have the bit set whereas
hard disks do not.

Operating systems differentiate between removable devices and fixed
devices.  Under Linux, the anaconda installer looks for removable
devices.  Under Windows, only fixed devices may have more than one
partition and AutoRun is also affected by the removable bit.

For these reasons, allow USB Mass Storage Devices to override the
removable bit:

qemu -usb
     -drive if=none,file=test.img,cache=none,id=disk0
     -device usb-storage,drive=disk0,removable=on

The default is off.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoscsi: Allow scsi_bus_legacy_add_drive() to set removable bit
Stefan Hajnoczi [Mon, 24 Jan 2011 15:34:59 +0000 (15:34 +0000)]
scsi: Allow scsi_bus_legacy_add_drive() to set removable bit

scsi-disk devices may wish to override the removable bit.  Add support
for a qdev property on SCSI devices.  This is will be used by usb-msd.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoscsi-disk: Allow overriding SCSI INQUIRY removable bit
Stefan Hajnoczi [Mon, 24 Jan 2011 15:34:58 +0000 (15:34 +0000)]
scsi-disk: Allow overriding SCSI INQUIRY removable bit

Provide the "removable" qdev property bit to override the SCSI INQUIRY
removable (RMB) bit for non-CDROM devices.  This will be used by USB
Mass Storage Devices, which sometimes have this guest-visible bit set
and sometimes do not.  They therefore requires a means for user
configuration.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agotarget-mips: fix save_cpu_state() calls
Aurelien Jarno [Mon, 17 Jan 2011 18:29:34 +0000 (19:29 +0100)]
target-mips: fix save_cpu_state() calls

The rule is:
- don't save PC if the exception is only triggered by softmmu.
- save PC if the exception can be triggered by an helper.

Fix a 64-bit kernel crash when loading modules.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agoblock: Use backing format driver during image creation
Stefan Hajnoczi [Mon, 24 Jan 2011 09:32:20 +0000 (09:32 +0000)]
block: Use backing format driver during image creation

The backing format should be honored during image creation.  For some
reason we currently use the image format to open the backing file.  This
fails when the backing file has a different format than the image being
created.  Keep the image and backing format drivers completely separate.

Also print the backing filename if there is an error opening the backing
file instead of the image filename.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Acked-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblockdev: Fix drive_del not to crash when drive is not in use
Markus Armbruster [Mon, 17 Jan 2011 18:31:29 +0000 (19:31 +0100)]
blockdev: Fix drive_del not to crash when drive is not in use

Watch this:

    (qemu) drive_add 0 if=none,file=tmp.img
    OK
    (qemu) info block
    none0: type=hd removable=0 file=tmp.img ro=0 drv=raw encrypted=0
    (qemu) drive_del none0
    Segmentation fault (core dumped)

do_drive_del()'s code to clean up the pointer from a qdev using the
drive back to the drive needs to check whether such a device exists.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblockdev: Make drive_init() use error_report()
Markus Armbruster [Mon, 17 Jan 2011 18:31:27 +0000 (19:31 +0100)]
blockdev: Make drive_init() use error_report()

This makes the errors point to the error location, and fixes drive_add
to report errors in the monitor instead of stderr.

While there, tweak a few error messages for consistency.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblockdev: Fix error message for invalid -drive CHS
Markus Armbruster [Mon, 17 Jan 2011 18:31:26 +0000 (19:31 +0100)]
blockdev: Fix error message for invalid -drive CHS

When cyls, heads or secs are out of range, the error message prints
buf, which points to the value of option "if".  Bogus, may even be
null.  Drop that.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoFix block migration when the device size is not a multiple of 1 MB
Pierre Riteau [Fri, 21 Jan 2011 11:42:30 +0000 (12:42 +0100)]
Fix block migration when the device size is not a multiple of 1 MB

b02bea3a85cc939f09aa674a3f1e4f36d418c007 added a check on the return
value of bdrv_write and aborts migration when it fails. However, if the
size of the block device to migrate is not a multiple of BLOCK_SIZE
(currently 1 MB), the last bdrv_write will fail with -EIO.

Fixed by calling bdrv_write with the correct size of the last block.

Signed-off-by: Pierre Riteau <Pierre.Riteau@irisa.fr>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoqed: Refuse to create images on block devices
Stefan Hajnoczi [Fri, 14 Jan 2011 22:44:33 +0000 (22:44 +0000)]
qed: Refuse to create images on block devices

QED relies on the underlying filesystem to extend the file and maintain
its size.  Check that images are not created on a block device.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoDocumentation: Add qemu-img check/rebase
Kevin Wolf [Mon, 17 Jan 2011 14:35:28 +0000 (15:35 +0100)]
Documentation: Add qemu-img check/rebase

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoide: Remove unneeded null pointer check
Stefan Weil [Sat, 15 Jan 2011 18:01:03 +0000 (19:01 +0100)]
ide: Remove unneeded null pointer check

With bm == NULL, other code in the same function would crash.

This bug was reported by cppcheck:
hw/ide/pci.c:280: error: Possible null pointer dereference: bm

Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoqcow2: Batch flushes for COW
Kevin Wolf [Fri, 14 Jan 2011 14:55:38 +0000 (15:55 +0100)]
qcow2: Batch flushes for COW

qcow2 calls bdrv_flush() after performing COW in order to ensure that the
L2 table change is never written before the copy is safe on disk. Now that the
L2 table is cached, we can wait with flushing until we write out the next L2
table.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoqcow2: Use QcowCache
Kevin Wolf [Mon, 10 Jan 2011 16:17:28 +0000 (17:17 +0100)]
qcow2: Use QcowCache

Use the new functions of qcow2-cache.c for everything that works on refcount
block and L2 tables.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agopci: memory leak of PCIDevice::rom_file
Isaku Yamahata [Mon, 24 Jan 2011 10:00:47 +0000 (19:00 +0900)]
pci: memory leak of PCIDevice::rom_file

PCIDevice::rom_file is leaked.
PCIDevice::rom_file is allocated in pci_qdev_init(), but not freed anywhere.
free it in qemu_unregister_device().

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
13 years agoqcow2: Add QcowCache
Kevin Wolf [Mon, 10 Jan 2011 16:15:10 +0000 (17:15 +0100)]
qcow2: Add QcowCache

This adds some new cache functions to qcow2 which can be used for caching
refcount blocks and L2 tables. When used with cache=writethrough they work
like the old caching code which is spread all over qcow2, so for this case we
have merely a cleanup.

The interesting case is with writeback caching (this includes cache=none) where
data isn't written to disk immediately but only kept in cache initially. This
leads to some form of metadata write batching which avoids the current "write
to refcount block, flush, write to L2 table" pattern for each single request
when a lot of cluster allocations happen. Instead, cache entries are only
written out if its required to maintain the right order. In the pure cluster
allocation case this means that all metadata updates for requests are done in
memory initially and on sync, first the refcount blocks are written to disk,
then fsync, then L2 tables.

This improves performance of scenarios with lots of cluster allocations
noticably (e.g. installation or after taking a snapshot).

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoide: kill ide_dma_submit_check
Christoph Hellwig [Mon, 20 Dec 2010 12:46:09 +0000 (13:46 +0100)]
ide: kill ide_dma_submit_check

Merge ide_dma_submit_check into it's only caller.  Also use tail recursion
using a goto instead of a real recursion - this avoid overflowing the
stack in the pathological situation of an recurring error that is ignored.
We'll still be busy looping in ide_dma_cb, but at least won't eat up
all stack space after this.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoide: also reset io_buffer_index for writes
Christoph Hellwig [Mon, 20 Dec 2010 12:45:58 +0000 (13:45 +0100)]
ide: also reset io_buffer_index for writes

Currenly the code only resets the io_buffer_index field for reads,
but the code seems to expect this for all types of I/O.  I guess
we simply don't hit large enough transfers that would require this
often enough.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoide: factor dma handling helpers
Christoph Hellwig [Mon, 20 Dec 2010 12:45:48 +0000 (13:45 +0100)]
ide: factor dma handling helpers

Factor the DMA I/O path that is duplicated between read and write
commands, into common helpers using the s->is_read flag added for
the macio ATA controller.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoAvoid divide by zero when there is no block device to migrate
Pierre Riteau [Wed, 12 Jan 2011 13:41:00 +0000 (14:41 +0100)]
Avoid divide by zero when there is no block device to migrate

When block migration is requested and no read-write block device is
present, a divide by zero exception is triggered because
total_sector_sum equals zero.

Signed-off-by: Pierre Riteau <Pierre.Riteau@irisa.fr>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoMake strtosz() return int64_t instead of ssize_t
Jes Sorensen [Wed, 5 Jan 2011 10:41:02 +0000 (11:41 +0100)]
Make strtosz() return int64_t instead of ssize_t

strtosz() needs to return a 64 bit type even on 32 bit
architectures. Otherwise qemu-img will fail to create disk
images >= 2GB

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agodo_snapshot_blkdev() error on missing snapshot_file argument
Jes Sorensen [Thu, 6 Jan 2011 16:02:23 +0000 (17:02 +0100)]
do_snapshot_blkdev() error on missing snapshot_file argument

Current code does not support snapshot internally to the running
image. Error in case no snapshot_file is specified.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoqemu-img snapshot: Use writeback caching
Kevin Wolf [Mon, 10 Jan 2011 11:33:02 +0000 (12:33 +0100)]
qemu-img snapshot: Use writeback caching

None of the other qemu-img subcommands uses writethrough, and there's no reason
why snapshot should be special.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agoqcow2: fix unaligned access
Aurelien Jarno [Sat, 1 Jan 2011 20:50:34 +0000 (21:50 +0100)]
qcow2: fix unaligned access

cpu_to_be64w() is called with an obviously non-aligned pointer. Use
cpu_to_be64wu() instead. It fixes unaligned accesses errors on IA64
hosts.

Cc: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agomultiboot: Fix upper memory size in multiboot info
Kevin Wolf [Tue, 4 Jan 2011 13:03:30 +0000 (14:03 +0100)]
multiboot: Fix upper memory size in multiboot info

The upper memory size field should exclude the first MB of RAM.

Signed-off-by: Kevin Wolf <mail@kevin-wolf.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agoDelete useless 'extern' qualifiers for functions
Blue Swirl [Sun, 23 Jan 2011 16:21:20 +0000 (16:21 +0000)]
Delete useless 'extern' qualifiers for functions

'extern' qualifier is useless for function declarations. Delete
them.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>