sdk/emulator/qemu.git
13 years agoqdev: Add HEX8 property
Jan Kiszka [Fri, 7 Oct 2011 07:19:52 +0000 (09:19 +0200)]
qdev: Add HEX8 property

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agoi8259: Eliminate PicState2
Jan Kiszka [Fri, 7 Oct 2011 07:19:51 +0000 (09:19 +0200)]
i8259: Eliminate PicState2

Introduce a reference to the slave PIC for the few cases we need to
access it without a proper pointer at hand and drop PicState2. We could
even live without slave_pic if we had a better way of modeling the
cascade bus the PICs are attached to (in addition to the ISA bus).

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agoi8259: Replace PicState::pics_state with master flag
Jan Kiszka [Fri, 7 Oct 2011 07:19:50 +0000 (09:19 +0200)]
i8259: Replace PicState::pics_state with master flag

This reflects how real PICs indentify their role (in non-buffered mode):
Pass the state of the /SP input on pic_init and use it instead of
pics_state to differentiate between master and slave mode.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agoi8259: PREP: Replace pic_intack_read with pic_read_irq
Jan Kiszka [Fri, 7 Oct 2011 07:19:49 +0000 (09:19 +0200)]
i8259: PREP: Replace pic_intack_read with pic_read_irq

There is nothing in the i8259 spec that justifies the special
pic_intack_read. At least the Linux PREP kernels configure the PICs
properly so that pic_read_irq returns identical values, and setting
read_reg_select in PIC0 cannot be derived from any special i8259 mode.

So switch ppc_prep to pic_read_irq and drop the now unused PIC code.

CC: Andreas Färber <andreas.faerber@web.de>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agoi8259: Clean up pic_ioport_read
Jan Kiszka [Fri, 7 Oct 2011 07:19:48 +0000 (09:19 +0200)]
i8259: Clean up pic_ioport_read

Drop redundant local address variable.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agoi8259: Fix poll command
Jan Kiszka [Fri, 7 Oct 2011 07:19:47 +0000 (09:19 +0200)]
i8259: Fix poll command

This was probably never used so far: According to the spec, polling
means ack'ing the pending IRQ and setting its corresponding bit in isr.
Moreover, we have to signal a pending IRQ via bit 7 of the returned
value, and we must not return a spurious IRQ if none is pending.

This implements the poll command without the help of pic_poll_read which
is left untouched as pic_intack_read is still using it.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agoi8259: Switch to per-PIC IRQ update
Jan Kiszka [Fri, 7 Oct 2011 07:19:46 +0000 (09:19 +0200)]
i8259: Switch to per-PIC IRQ update

This converts pic_update_irq to work against a single PIC instead of the
complete cascade. Along this change, the required update after
pic_set_irq1 is now moved into that function.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agoi8259: Clear ELCR on reset
Jan Kiszka [Fri, 7 Oct 2011 07:19:45 +0000 (09:19 +0200)]
i8259: Clear ELCR on reset

The ELCR is actually part of the chipset but we model it here for
simplicity reasons. The PIIX3 clears the ELCR on reset, which was once
broken by 4dbe19e181. Fix this by splitting up pic_init_reset from
pic_reset and clearing the register in the latter.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agoi8259: Update IRQ state after reset
Jan Kiszka [Fri, 7 Oct 2011 07:19:44 +0000 (09:19 +0200)]
i8259: Update IRQ state after reset

MIPS and PPC users of the i8259 output signal expect us to report state
updates also after reset. As no consumer (including the master PIC) can
misinterpret the deassert as an activation event, it is safe to simply
update the IRQ state after reset.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agoi8259: Reorder intack in pic_read_irq
Jan Kiszka [Fri, 7 Oct 2011 07:19:43 +0000 (09:19 +0200)]
i8259: Reorder intack in pic_read_irq

As we want to move the IRQ update to pic_intack, ordering matters: the
slave ack must be executed before the master ack to avoid missing
further pending slave IRQs.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agoi8259: Do not update IRQ output after spurious pic_poll_read
Jan Kiszka [Fri, 7 Oct 2011 07:19:42 +0000 (09:19 +0200)]
i8259: Do not update IRQ output after spurious pic_poll_read

If pic_poll_read finds no pending IRQ and return a spurious one instead,
no PIC state is changed, thus we do not need to call pic_update_irq.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agoi8239: Introduce per-PIC output interrupt
Jan Kiszka [Fri, 7 Oct 2011 07:19:41 +0000 (09:19 +0200)]
i8239: Introduce per-PIC output interrupt

As a first step towards more generic master-slave support, remove
parent_irq in favor of a per-PIC output interrupt line. The slave's
line is attached to IRQ2 of the master, but it remains unused for now.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agoi8259: Move pic_set_irq1 after pic_update_irq
Jan Kiszka [Fri, 7 Oct 2011 07:19:40 +0000 (09:19 +0200)]
i8259: Move pic_set_irq1 after pic_update_irq

We are about to call the latter from the former. No functional changes.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agoi8259: Drop obsolete prototypes
Jan Kiszka [Fri, 7 Oct 2011 07:19:39 +0000 (09:19 +0200)]
i8259: Drop obsolete prototypes

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agoi8259: Remove premature inline function attributes
Jan Kiszka [Fri, 7 Oct 2011 07:19:38 +0000 (09:19 +0200)]
i8259: Remove premature inline function attributes

The compiler is smarter in choosing the right optimization.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agopc: Fix and clean up PIC-to-APIC IRQ path
Jan Kiszka [Fri, 7 Oct 2011 07:19:37 +0000 (09:19 +0200)]
pc: Fix and clean up PIC-to-APIC IRQ path

The master PIC is connected to the LINTIN0 of the APICs. As the APIC
currently does not track the state of that line, we have to ask the PIC
to reinject its IRQ after the CPU picked up an event from the APIC.

This introduces pic_get_output to read the master PIC IRQ line state
without changing it. The APIC uses this function to decide if a PIC IRQ
should be reinjected on apic_update_irq. This reflects better how the
real hardware works.

The patch fixes some failures of the kvm unit tests apic and eventinj by
allowing to enable the proper CPU IRQ deassertion when the guest masks
some pending IRQs at PIC level.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agopc: Convert GSIState::i8259_irq into array
Jan Kiszka [Fri, 7 Oct 2011 07:19:36 +0000 (09:19 +0200)]
pc: Convert GSIState::i8259_irq into array

Will be required when we no longer let i8259_init allocate the PIC IRQs
but convert that chips to qdev.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agopc: Generalize ISA IRQs to GSIs
Jan Kiszka [Fri, 7 Oct 2011 07:19:35 +0000 (09:19 +0200)]
pc: Generalize ISA IRQs to GSIs

The ISA bus IRQ range is 0..15. What isa_irq_handler and IsaIrqState are
actually dealing with are the Global System Interrupts. Refactor the
code to clarify this.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agopc: Drop useless test from isa_irq_handler
Jan Kiszka [Fri, 7 Oct 2011 07:19:34 +0000 (09:19 +0200)]
pc: Drop useless test from isa_irq_handler

IsaIrqState::ioapic is always non-NULL. Probably, the concrete
qemu_irq was supposed to be tested, but that's already done by
qemu_set_irq.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agotarget-xtensa: add Avnet LX60/LX110/LX200 boards
Max Filippov [Sat, 15 Oct 2011 22:56:46 +0000 (02:56 +0400)]
target-xtensa: add Avnet LX60/LX110/LX200 boards

These boards carry similar hardware: SDRAM (48M for LX110, 64M for LX60,
96M for LX200), 16 Mbyte FLASH, FPGA, 10/100 Mbps Ethernet PHY and 16550
UART. FPGA may be loaded with almost any Tensilica processor. It is also
used to implement Ethernet MAC, e.g. OpenCores 10/100 Mbps Ethernet MAC
and LED/DIP switches access.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agohw: add OpenCores 10/100 Mbps Ethernet controller
Max Filippov [Sat, 15 Oct 2011 22:56:45 +0000 (02:56 +0400)]
hw: add OpenCores 10/100 Mbps Ethernet controller

This is OpenCores Ethernet MAC + subset of National Semiconductors
DP83838C PHY.
OpenCores Ethernet MAC project: http://opencores.org/project,ethmac

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agotarget-xtensa: rename dc232b board to sim
Max Filippov [Sat, 15 Oct 2011 22:56:07 +0000 (02:56 +0400)]
target-xtensa: rename dc232b board to sim

This is to get aligned with the linux name for this machine.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agotarget-xtensa: add fsf core
Max Filippov [Sat, 15 Oct 2011 22:56:06 +0000 (02:56 +0400)]
target-xtensa: add fsf core

This is FSF big endian core implemented through linux overlay.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agotarget-xtensa: add dc232b core
Max Filippov [Sat, 15 Oct 2011 22:56:05 +0000 (02:56 +0400)]
target-xtensa: add dc232b core

This is Diamond 232L Standard Core Rev.B (LE), implemented through
linux/gdb overlay.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agotarget-xtensa: extract core configuration from overlay
Max Filippov [Sat, 15 Oct 2011 22:56:04 +0000 (02:56 +0400)]
target-xtensa: extract core configuration from overlay

Introduce overlay_tool.h that defines core configuration blocks from
data available in the linux architecture variant overlay.

Overlay data is automatically generated in the core configuration
process by Tensilica tools and can be directly converted to qemu xtensa
core description by overlay_tool.h

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agotarget-xtensa: implement external interrupt mapping
Max Filippov [Sat, 15 Oct 2011 22:56:03 +0000 (02:56 +0400)]
target-xtensa: implement external interrupt mapping

Xtensa cores may have different mapping of external interrupt pins to
internal IRQ numers. Implement API to acquire core IRQ by its external
interrupt number.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agotarget-xtensa: remove hand-written xtensa cores implementations
Max Filippov [Sat, 15 Oct 2011 22:56:02 +0000 (02:56 +0400)]
target-xtensa: remove hand-written xtensa cores implementations

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agotarget-xtensa: increase xtensa options accuracy
Max Filippov [Sat, 15 Oct 2011 22:56:01 +0000 (02:56 +0400)]
target-xtensa: increase xtensa options accuracy

- add separate options for each operation in the MISC_OP;
- add an option for MULSH/MULUH;
- put S32C1I under conditional store option.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agotarget-xtensa: update qemu-doc.texi
Max Filippov [Mon, 10 Oct 2011 10:48:23 +0000 (14:48 +0400)]
target-xtensa: update qemu-doc.texi

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agotarget-xtensa: add MAC16 unit tests
Max Filippov [Mon, 10 Oct 2011 02:25:41 +0000 (06:25 +0400)]
target-xtensa: add MAC16 unit tests

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agotarget-xtensa: implement MAC16 option
Max Filippov [Mon, 10 Oct 2011 02:25:40 +0000 (06:25 +0400)]
target-xtensa: implement MAC16 option

See ISA, 4.3.7 for the details.

- add ACC and MR special registers;
- implement MAC16 and all inner MAC* opcode groups.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agotarget-xtensa: fix guest hang on masked CCOMPARE interrupt
Max Filippov [Mon, 10 Oct 2011 02:25:04 +0000 (06:25 +0400)]
target-xtensa: fix guest hang on masked CCOMPARE interrupt

QEMU timer is used to post CCOMPARE interrupt when the core is halted.
If that CCOMPARE interrupt is masked off then the timer must be rearmed
in the callback, otherwise it will be rearmed next time the core goes to
halt by the waiti instruction.

Add test case into timer testsuite.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agoDrop obsolete nographic timer
Jan Kiszka [Fri, 30 Sep 2011 10:31:18 +0000 (12:31 +0200)]
Drop obsolete nographic timer

We flush coalesced MMIO in the device models now, and VNC - for which
this was once introduced - is also fine without it as it has its own
refresh timer.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agoMove graphic-related coalesced MMIO flushes to affected device models
Jan Kiszka [Fri, 30 Sep 2011 10:31:14 +0000 (12:31 +0200)]
Move graphic-related coalesced MMIO flushes to affected device models

This is conceptually cleaner and will allow us to drop the nographic
timer. Moreover, it will be mandatory to fully exploit future per-device
coalesced MMIO rings.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agoMerge remote-tracking branch 'kwolf/for-anthony' into staging
Anthony Liguori [Fri, 14 Oct 2011 17:36:50 +0000 (12:36 -0500)]
Merge remote-tracking branch 'kwolf/for-anthony' into staging

13 years agoMerge remote-tracking branch 'stefanha/trivial-patches' into staging
Anthony Liguori [Fri, 14 Oct 2011 15:47:33 +0000 (10:47 -0500)]
Merge remote-tracking branch 'stefanha/trivial-patches' into staging

13 years agoMerge remote-tracking branch 'kraxel/usb.28' into staging
Anthony Liguori [Fri, 14 Oct 2011 15:46:35 +0000 (10:46 -0500)]
Merge remote-tracking branch 'kraxel/usb.28' into staging

13 years agoMerge remote-tracking branch 'qemu-kvm-tmp/memory/batch' into staging
Anthony Liguori [Fri, 14 Oct 2011 15:44:52 +0000 (10:44 -0500)]
Merge remote-tracking branch 'qemu-kvm-tmp/memory/batch' into staging

13 years agoblock: drop bdrv_has_async_rw()
Stefan Hajnoczi [Thu, 13 Oct 2011 20:09:32 +0000 (21:09 +0100)]
block: drop bdrv_has_async_rw()

Commit cd74d83345e0e3b708330ab8c4cd9111bb82cda6 ("block: switch
bdrv_read()/bdrv_write() to coroutines") removed the bdrv_has_async_rw()
callers.  This patch removes bdrv_has_async_rw() since it is no longer
used.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblock: drop .bdrv_read()/.bdrv_write() emulation
Stefan Hajnoczi [Thu, 13 Oct 2011 20:09:31 +0000 (21:09 +0100)]
block: drop .bdrv_read()/.bdrv_write() emulation

There is no need to emulate .bdrv_read()/.bdrv_write() since these
interfaces are only called if aio and coroutine interfaces are not
present.  All valid BlockDrivers must implement either sync, aio, or
coroutine interfaces.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblock: use coroutine interface for raw format
Stefan Hajnoczi [Thu, 13 Oct 2011 20:09:30 +0000 (21:09 +0100)]
block: use coroutine interface for raw format

The raw format delegates all operations to bs->file (the protocol).
Previously this block driver exposed both sync and aio interfaces.
Since the block layer now works in terms of coroutines, expose the
coroutine interfaces and drop the others.  This avoids unnecessary
emulation of sync and aio interfaces.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoraw-posix: remove bdrv_read()/bdrv_write()
Stefan Hajnoczi [Thu, 13 Oct 2011 20:09:29 +0000 (21:09 +0100)]
raw-posix: remove bdrv_read()/bdrv_write()

Block drivers only need to provide one of sync, aio, or coroutine
interfaces.  Since raw-posix.c provides aio interfaces, simply drop the
synchronous interfaces since they can be emulated using aio and
coroutines.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblock: drop emulation functions that use coroutines
Stefan Hajnoczi [Thu, 13 Oct 2011 20:09:28 +0000 (21:09 +0100)]
block: drop emulation functions that use coroutines

Block drivers that implement coroutine functions used to get sync and
aio wrappers.  This is no longer necessary since all request processing
now happens in a coroutine.  If a block driver implements the coroutine
interface then none of the other interfaces will be invoked.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblock/qcow: Fix use of free() instead of g_free()
Stefan Weil [Fri, 7 Oct 2011 05:32:47 +0000 (07:32 +0200)]
block/qcow: Fix use of free() instead of g_free()

cppcheck reported this error:

qemu/block/qcow.c:599: error: Mismatching allocation and deallocation: cluster_data

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agosheepdog: correct spelling
Dong Xu Wang [Fri, 14 Oct 2011 07:41:06 +0000 (15:41 +0800)]
sheepdog: correct spelling

Reviewed-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agotcg: Fix spelling in comment (varables -> variables)
Stefan Weil [Tue, 11 Oct 2011 17:43:15 +0000 (19:43 +0200)]
tcg: Fix spelling in comment (varables -> variables)

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agoremove hpet.h
Paolo Bonzini [Tue, 11 Oct 2011 07:49:43 +0000 (09:49 +0200)]
remove hpet.h

It is unused since the HPET and RTC timers were removed (commit
25f3151, 2011-05-31).

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agoarm_pic: Fix typo
Andreas Färber [Sun, 9 Oct 2011 23:27:01 +0000 (01:27 +0200)]
arm_pic: Fix typo

interrput -> interrupt

Cc: Paul Brook <paul@codesourcery.com>
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agoqemu-char: Fix use of free() instead of g_free()
Stefan Weil [Fri, 7 Oct 2011 05:38:46 +0000 (07:38 +0200)]
qemu-char: Fix use of free() instead of g_free()

cppcheck reported these errors:

qemu-char.c:1667: error: Mismatching allocation and deallocation: s
qemu-char.c:1668: error: Mismatching allocation and deallocation: chr
qemu-char.c:1769: error: Mismatching allocation and deallocation: s
qemu-char.c:1770: error: Mismatching allocation and deallocation: chr

Tested-by: Dongxu Wang <wdongxu@linux.vnet.ibm.com>
Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agoqemu-options: avoid #if in spicevmc texi help
Stefan Hajnoczi [Thu, 6 Oct 2011 10:24:12 +0000 (11:24 +0100)]
qemu-options: avoid #if in spicevmc texi help

Preprocessor directives cannot be used in STEXI/ETEXI sections since
they are not passed through the preprocessor.  The spicevmc chardev
option help currently uses #if, which is included verbatim in the man
page output.

Fix this by simply stating that spicevmc chardevs are available only in
builds with spice support.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agolinux-aio: Allow reads beyond the end of growable images
Kevin Wolf [Thu, 13 Oct 2011 13:42:52 +0000 (15:42 +0200)]
linux-aio: Allow reads beyond the end of growable images

This is the linux-aio version of commits 22afa7b5 (raw-posix, synchronous) and
ba1d1afd (posix-aio-compat). Reads now produce zeros after the end of file
instead of failing or resulting in short reads, making linux-aio compatible
with the behaviour of synchronous raw-posix requests and posix-aio-compat.

The problem can be reproduced like this:

dd if=/dev/zero of=/tmp/test.raw bs=1 count=1234
./qemu-io -k -n -g -c 'read -p 1024 512' /tmp/test.raw

Previously, the result of this was 'read failed: Invalid argument', now the
read completes successfully.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agoblock: switch bdrv_aio_writev() to coroutines
Stefan Hajnoczi [Thu, 13 Oct 2011 12:08:25 +0000 (13:08 +0100)]
block: switch bdrv_aio_writev() to coroutines

More sync, aio, and coroutine unification.  Make bdrv_aio_writev() go
through coroutine request processing.

Remove the dirty block callback mechanism which was needed only for aio
processing and can be done more naturally in coroutine context.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblock: mark blocks dirty on coroutine write completion
Stefan Hajnoczi [Thu, 13 Oct 2011 12:08:24 +0000 (13:08 +0100)]
block: mark blocks dirty on coroutine write completion

The aio write operation marks blocks dirty when the write operation
completes.  The coroutine write operation marks blocks dirty before
issuing the write operation.

It seems safest to mark the block dirty when the operation completes so
that anything tracking dirty blocks will not act before the change has
been made to the image file.

Make the coroutine write operation dirty blocks on write completion.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblock: switch bdrv_aio_readv() to coroutines
Stefan Hajnoczi [Thu, 13 Oct 2011 12:08:23 +0000 (13:08 +0100)]
block: switch bdrv_aio_readv() to coroutines

More sync, aio, and coroutine unification.  Make bdrv_aio_readv() go
through coroutine request processing.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblock: switch bdrv_read()/bdrv_write() to coroutines
Stefan Hajnoczi [Thu, 13 Oct 2011 12:08:22 +0000 (13:08 +0100)]
block: switch bdrv_read()/bdrv_write() to coroutines

The bdrv_read()/bdrv_write() functions call .bdrv_read()/.bdrv_write().
They should go through bdrv_co_do_readv() and bdrv_co_do_writev()
instead in order to unify request processing code across sync, aio, and
coroutine interfaces.  This is also an important step towards removing
BlockDriverState .bdrv_read()/.bdrv_write() in the future.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblock: split out bdrv_co_do_readv() and bdrv_co_do_writev()
Stefan Hajnoczi [Wed, 5 Oct 2011 16:17:03 +0000 (17:17 +0100)]
block: split out bdrv_co_do_readv() and bdrv_co_do_writev()

The public interface for I/O in coroutine context is bdrv_co_readv() and
bdrv_co_writev().  Split out the request processing code into
bdrv_co_do_readv() and bdrv_co_writev() so that it can be called
internally when we refactor all request processing to use coroutines.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblock: directly invoke .bdrv_* from emulation functions
Stefan Hajnoczi [Thu, 13 Oct 2011 12:08:21 +0000 (13:08 +0100)]
block: directly invoke .bdrv_* from emulation functions

The emulation functions which supply default BlockDriver .bdrv_*()
functions given another implemented .bdrv_*() function should not use
public bdrv_*() interfaces.  This patch ensures they invoke .bdrv_*()
directly to avoid adding an extra layer of coroutine request processing
and possibly entering an infinite loop.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblock: directly invoke .bdrv_aio_*() in bdrv_co_io_em()
Stefan Hajnoczi [Wed, 5 Oct 2011 16:17:02 +0000 (17:17 +0100)]
block: directly invoke .bdrv_aio_*() in bdrv_co_io_em()

We will unify block layer request processing across sync, aio, and
coroutines and this means a .bdrv_co_*() emulation function should not
call back into the public interface.  There's no need here, just call
.bdrv_aio_*() directly.

The gory details: bdrv_co_io_em() cannot call back into the public
bdrv_aio_*() interface since that will be handled using coroutines,
which causes us to call into bdrv_co_io_em() again in an infinite loop
:).

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agousb-hub: don't trigger assert on packet completion.
Gerd Hoffmann [Thu, 13 Oct 2011 10:52:47 +0000 (12:52 +0200)]
usb-hub: don't trigger assert on packet completion.

Calling usb_packet_complete() recursively when passing up the completion
event up the chain for devices connected via usb hub will trigger an
assert.  So don't do that, make the usb hub emulation call the upstream
completion callback directly instead.

Based on a patch from Stefan Hajnoczi <stefanha@gmail.com>

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
13 years agousb-hid: activate usb tablet / mouse after migration.
Gerd Hoffmann [Wed, 12 Oct 2011 10:54:35 +0000 (12:54 +0200)]
usb-hid: activate usb tablet / mouse after migration.

qemu uses the ps/2 mouse by default.  The usb tablet (or mouse) is
activated as soon as qemu sees some guest activity on the device,
i.e. polling for HID events.  That used to work fine for both fresh
boot and migration.

Remote wakeup support changed the picture though: There will be no
polling after migration in case the guest suspended the usb bus,
waiting for wakeup events.  Result is that the ps/2 mouse stays
active.

Fix this by activating the usb tablet / mouse in post_load() in case
the guest enabled remote wakeup.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
13 years agohw/usb-ohci: Honour endpoint maximum packet size
Peter Maydell [Wed, 14 Sep 2011 17:48:59 +0000 (18:48 +0100)]
hw/usb-ohci: Honour endpoint maximum packet size

Honour the maximum packet size for endpoints; this applies when
sending non-isochronous data and means we transfer only as
much as the endpoint allows, leaving the transfer descriptor
on the list for another go next time around. This allows
usb-net to work when connected to an OHCI controller model.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
13 years agohw/usb-ohci: Fix OHCI_TD_T1 bit position definition
Peter Maydell [Wed, 14 Sep 2011 17:49:00 +0000 (18:49 +0100)]
hw/usb-ohci: Fix OHCI_TD_T1 bit position definition

The OHCI Transfer Descriptor T (DataToggle) bits are 24 and 25;
fix an error which accidentally overlaid them both on the same bit.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
13 years agousb-host: handle USBDEVFS_SETCONFIGURATION returning EBUSY
Gerd Hoffmann [Tue, 13 Sep 2011 09:55:15 +0000 (11:55 +0200)]
usb-host: handle USBDEVFS_SETCONFIGURATION returning EBUSY

In case the host uses the usb device usbfs will refuse to set the
configuration due to the device being busy.  Handle this case by
disconnection the interfaces, then trying again.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
13 years agousb-host: factor out code
Gerd Hoffmann [Tue, 13 Sep 2011 09:37:47 +0000 (11:37 +0200)]
usb-host: factor out code

Move code to claim usb ports and to disconnect usb interfaces into
usb_host_claim_port and usb_host_disconnect_ifaces functions.  No
functional change.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
13 years agousb: fix port reset
Gerd Hoffmann [Thu, 15 Sep 2011 10:10:21 +0000 (12:10 +0200)]
usb: fix port reset

commit 891fb2cd4592b6fe76106a69e0ca40efbf82726a removed the implicit
detach before (re-)attaching in usb_attach().  Some usb host controllers
used that behavior though to do a port reset by a detach+attach
sequence.

This patch establishes old behavior by adding a new usb_reset() function
for port resets and putting it into use, thereby also unifying port
reset behavior of all host controllers.  The patch also adds asserts to
usb_attach() and usb_detach() to make sure the calls are symmetrical.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
13 years agousb-hub: need to check dev->attached
Gerd Hoffmann [Thu, 15 Sep 2011 07:20:02 +0000 (09:20 +0200)]
usb-hub: need to check dev->attached

commit 891fb2cd4592b6fe76106a69e0ca40efbf82726a did that for all host
controllers, the usb hub was left out by accident.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
13 years agousb-storage: fix NULL pointer dereference.
Gerd Hoffmann [Fri, 2 Sep 2011 11:05:13 +0000 (13:05 +0200)]
usb-storage: fix NULL pointer dereference.

When a usb packet is canceled we need to check whenever we actually have
a scsi request in flight before we try to cancel it.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
13 years agoisa: Remove isa_init_ioport_range and isa_init_ioport
Richard Henderson [Tue, 16 Aug 2011 16:02:36 +0000 (09:02 -0700)]
isa: Remove isa_init_ioport_range and isa_init_ioport

All users have been converted to either isa_register_ioport
or isa_register_old_portio_list.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
13 years agoide: Convert to isa_register_portio_list
Richard Henderson [Tue, 16 Aug 2011 15:59:00 +0000 (08:59 -0700)]
ide: Convert to isa_register_portio_list

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
13 years agovmport: Convert to isa_register_ioport
Richard Henderson [Tue, 16 Aug 2011 15:38:14 +0000 (08:38 -0700)]
vmport: Convert to isa_register_ioport

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
13 years agopc: Convert port92 to isa_register_ioport
Richard Henderson [Tue, 16 Aug 2011 15:32:44 +0000 (08:32 -0700)]
pc: Convert port92 to isa_register_ioport

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
13 years agovga: Convert to isa_register_portio_list
Richard Henderson [Tue, 16 Aug 2011 15:27:39 +0000 (08:27 -0700)]
vga: Convert to isa_register_portio_list

[jan: fix cut'n'paste errors]
[avi: adjust pci variants not to use isa functions]

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
13 years agosb16: Convert to isa_register_portio_list
Richard Henderson [Mon, 15 Aug 2011 23:10:47 +0000 (16:10 -0700)]
sb16: Convert to isa_register_portio_list

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
13 years agoparallel: Convert to isa_register_portio_list
Richard Henderson [Mon, 15 Aug 2011 22:55:09 +0000 (15:55 -0700)]
parallel: Convert to isa_register_portio_list

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
13 years agone2000: Convert to isa_register_ioport
Richard Henderson [Mon, 15 Aug 2011 22:42:46 +0000 (15:42 -0700)]
ne2000: Convert to isa_register_ioport

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
13 years agortc: Convert to isa_register_ioport
Richard Henderson [Mon, 15 Aug 2011 22:40:21 +0000 (15:40 -0700)]
rtc: Convert to isa_register_ioport

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
13 years agom48t59: Convert to isa_register_ioport
Richard Henderson [Mon, 15 Aug 2011 22:33:40 +0000 (15:33 -0700)]
m48t59: Convert to isa_register_ioport

The sysbus interface is as yet unconverted.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
13 years agogus: Convert to isa_register_portio_list
Richard Henderson [Mon, 15 Aug 2011 22:25:26 +0000 (15:25 -0700)]
gus: Convert to isa_register_portio_list

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
13 years agofdc: Convert to isa_register_portio_list
Richard Henderson [Mon, 15 Aug 2011 22:08:45 +0000 (15:08 -0700)]
fdc: Convert to isa_register_portio_list

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
13 years agoisa: Add isa_register_portio_list()
Avi Kivity [Mon, 26 Sep 2011 11:52:44 +0000 (14:52 +0300)]
isa: Add isa_register_portio_list()

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
13 years agomemory: Fix old portio word accesses
Jan Kiszka [Sun, 18 Sep 2011 12:51:58 +0000 (14:51 +0200)]
memory: Fix old portio word accesses

As we register old portio regions via ioport_register, we are also
responsible for providing the word access wrapper.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
13 years agoIntroduce PortioList
Avi Kivity [Mon, 26 Sep 2011 11:52:26 +0000 (14:52 +0300)]
Introduce PortioList

Add a type and methods for manipulating a list of disjoint I/O ports,
used in some older hardware devices.

Based on original patch by Richard Henderson.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
13 years agovvfat: Fix potential buffer overflow
Kevin Wolf [Wed, 1 Jun 2011 08:57:00 +0000 (10:57 +0200)]
vvfat: Fix potential buffer overflow

path2[PATH_MAX] can be used for the null termination, so make the array big
enough to allow this.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblock/vvfat: Remove unused code
Stefan Weil [Sat, 1 Oct 2011 07:05:45 +0000 (09:05 +0200)]
block/vvfat: Remove unused code

The unused code was detected using cppcheck.

Cc: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblock/vvfat: Fix potential memory leaks and other memory errors
Stefan Weil [Fri, 30 Sep 2011 21:29:53 +0000 (23:29 +0200)]
block/vvfat: Fix potential memory leaks and other memory errors

cppcheck reported memory leaks and mismatched g_malloc() with free()
instead of g_free().

Fix these errors.

Cc: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoHMP: Print 'io-status' information
Luiz Capitulino [Mon, 26 Sep 2011 20:43:55 +0000 (17:43 -0300)]
HMP: Print 'io-status' information

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoQMP: query-status: Add 'io-status' key
Luiz Capitulino [Mon, 26 Sep 2011 20:43:54 +0000 (17:43 -0300)]
QMP: query-status: Add 'io-status' key

Contains the I/O status for the given device. The key is only present
if the device supports it and the VM is configured to stop on errors.

Please, check the documentation being added in this commit for more
information.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoscsi: Support I/O status
Luiz Capitulino [Mon, 26 Sep 2011 20:43:53 +0000 (17:43 -0300)]
scsi: Support I/O status

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoide: Support I/O status
Luiz Capitulino [Mon, 26 Sep 2011 20:43:52 +0000 (17:43 -0300)]
ide: Support I/O status

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agovirtio: Support I/O status
Luiz Capitulino [Mon, 26 Sep 2011 20:43:51 +0000 (17:43 -0300)]
virtio: Support I/O status

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblock: Keep track of devices' I/O status
Luiz Capitulino [Mon, 26 Sep 2011 20:43:50 +0000 (17:43 -0300)]
block: Keep track of devices' I/O status

This commit adds support to the BlockDriverState type to keep track
of devices' I/O status.

There are three possible status: BDRV_IOS_OK (no error), BDRV_IOS_ENOSPC
(no space error) and BDRV_IOS_FAILED (any other error). The distinction
between no space and other errors is important because a management
application may want to watch for no space in order to extend the
space assigned to the VM and put it to run again.

Qemu devices supporting the I/O status feature have to enable it
explicitly by calling bdrv_iostatus_enable() _and_ have to be
configured to stop the VM on errors (ie. werror=stop|enospc or
rerror=stop).

In case of multiple errors being triggered in sequence only the first
one is stored. The I/O status is always reset to BDRV_IOS_OK when the
'cont' command is issued.

Next commits will add support to some devices and extend the
query-block/info block commands to return the I/O status information.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agolinux-aio: Fix laio_submit error handling
Kevin Wolf [Thu, 22 Sep 2011 12:21:30 +0000 (14:21 +0200)]
linux-aio: Fix laio_submit error handling

The error handling order was in the wrong order, so that either the ACB would
be leaked or the counter would be decremented when it shouldn't.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblock: allow resizing of images residing on host devices
Christoph Hellwig [Tue, 20 Sep 2011 23:10:37 +0000 (01:10 +0200)]
block: allow resizing of images residing on host devices

Allow to resize images that reside on host devices up to the available
space.  This allows to grow images after resizing the device manually or
vice versa.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoisa: Tidy support code for isabus_get_fw_dev_path
Richard Henderson [Mon, 15 Aug 2011 18:59:09 +0000 (11:59 -0700)]
isa: Tidy support code for isabus_get_fw_dev_path

The only user of ISADevice.ioports is isabus_get_fw_dev_path, and it
only looks at the first entry of the array.  Which suggests that this
entire array+sort operation can be replaced by a simple minimum.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
13 years agoppc_newworld: convert to memory API
Avi Kivity [Tue, 13 Sep 2011 13:30:29 +0000 (16:30 +0300)]
ppc_newworld: convert to memory API

Signed-off-by: Avi Kivity <avi@redhat.com>
13 years agohw/versatile_pci: Expose multiple sysbus mmio regions
Peter Maydell [Thu, 1 Sep 2011 17:36:53 +0000 (18:36 +0100)]
hw/versatile_pci: Expose multiple sysbus mmio regions

Clean up versatile_pci to expose the various PCI mmio regions
properly as separate mmio regions rather than as a single mmio
which uses callbacks to map and unmap everything.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Avi Kivity <avi@redhat.com>
13 years agohw/arm11mpcore: Clean up to avoid using sysbus_mmio_init_cb2
Peter Maydell [Thu, 1 Sep 2011 17:36:52 +0000 (18:36 +0100)]
hw/arm11mpcore: Clean up to avoid using sysbus_mmio_init_cb2

Clean up the initialisation of the realview_mpcore device to avoid
using sysbus_init_mmio_cb2(): we can pass through the MemoryRegion
of the private arm11mpcore_priv device directly now.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Avi Kivity <avi@redhat.com>
13 years agoppc405_boards: convert to memory API
Avi Kivity [Mon, 12 Sep 2011 13:43:53 +0000 (16:43 +0300)]
ppc405_boards: convert to memory API

Signed-off-by: Avi Kivity <avi@redhat.com>
13 years agopetalogix_s2adsp1800: convert to memory API
Avi Kivity [Mon, 12 Sep 2011 13:31:50 +0000 (16:31 +0300)]
petalogix_s2adsp1800: convert to memory API

Signed-off-by: Avi Kivity <avi@redhat.com>
13 years agopetalogix_ml605: convert to memory API
Avi Kivity [Mon, 12 Sep 2011 12:27:25 +0000 (15:27 +0300)]
petalogix_ml605: convert to memory API

Signed-off-by: Avi Kivity <avi@redhat.com>