]> git.proxmox.com Git - qemu.git/log
qemu.git
11 years agoupdate VERSION for 1.1.2 stable-1.1 origin/stable-1.1 v1.1.2
Michael Roth [Tue, 21 Aug 2012 16:49:43 +0000 (11:49 -0500)]
update VERSION for 1.1.2

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoconsole: bounds check whenever changing the cursor due to an escape code
Ian Campbell [Tue, 4 Sep 2012 18:26:11 +0000 (13:26 -0500)]
console: bounds check whenever changing the cursor due to an escape code

This is XSA-17 / CVE-2012-3515

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoqemu-timer: properly arm alarm timer for timers set by device initialization
Paolo Bonzini [Mon, 3 Sep 2012 15:34:32 +0000 (17:34 +0200)]
qemu-timer: properly arm alarm timer for timers set by device initialization

QEMU will hang when fed the following command-line

  qemu-system-mips -kernel vmlinux-2.6.32-5-4kc-malta -append "console=ttyS0" -nographic -net none

The -net none is important otherwise it seems some events are generated
causing the things to work. When it doesn't work, the guest hangs when
measuring the CPU frequency, after the following line:

  [    0.000000] NR_IRQS:256

Pressing a key on the serial port unblocks it, hinting that the problem
is due to the recent elimination of the 1 second timeout in the main
loop.

The problem is that because init_timer_alarm sets the timer's pending
flag to true, the alarm timer is never armed until after the first time
through the main loop.  Thus the bug started when QEMU started testing
the pending flag in qemu_mod_timer (commit 1828be3, more alarm timer
cleanup, 2010-03-10).

But actually, it isn't true at all that a timer is pending when the
alarm timer is created, and the real bug has been latent forever: the
fix is to remove the bogus setting of pending flag.

Reported-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com>
Tested-by: Aurelien Jarno <aurelien@aurel32.net>
Tested-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
(cherry picked from commit de188751da8db3c77a681bf903035a0e5218c463)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agotarget-xtensa: return ENOSYS for unimplemented simcalls
Max Filippov [Wed, 22 Aug 2012 18:03:35 +0000 (22:03 +0400)]
target-xtensa: return ENOSYS for unimplemented simcalls

This prevents guest from proceeding with uninitialised garbage returned
from unimplemented simcalls.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
(cherry picked from commit e7eee62a90c671d22d50964b7de05e3f4fd96f5f)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agotarget-xtensa: fix big-endian BBS/BBC implementation
Max Filippov [Tue, 17 Jul 2012 19:45:23 +0000 (23:45 +0400)]
target-xtensa: fix big-endian BBS/BBC implementation

Quote from ISA, 2.1:

For most Xtensa instructions, bit numbering is irrelevant; only the BBC
and BBS instructions assign bit numbers to values on which the processor
operates. The BBC/BBS instructions use big-endian bit ordering (0 is the
most-significant bit) on a big-endian processor configuration.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
(cherry picked from commit 7ff7563fc1c3c57914aafec1753219604346fe18)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoehci: Fix NULL ptr deref when unplugging an USB dev with an iso stream active
Hans de Goede [Tue, 28 Aug 2012 09:50:26 +0000 (11:50 +0200)]
ehci: Fix NULL ptr deref when unplugging an USB dev with an iso stream active

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
(cherry picked from commit 7ce86aa1aafaa65e7d3e572873bdf37bdb896f49)

Conflicts:

hw/usb/hcd-ehci.c

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agomsix: make [un]use vectors on reset/load optional
Michael S. Tsirkin [Wed, 29 Aug 2012 16:40:56 +0000 (19:40 +0300)]
msix: make [un]use vectors on reset/load optional

The facility to use/unuse vectors dynamically is helpful
for virtio but little else: everyone just seems to use
vectors in their init function.

Avoid clearing msix vector use info on reset and load.
For virtio, clear it explicitly.
This should fix regressions reported with ivshmem - though
I didn't test this, I verified that virtio keeps
working like it did.

Tested-by: Cam Macdonell <cam@cs.ualberta.ca>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
(cherry picked from commit 3cac001e5ae3c0ceb33e0a1978a48cb5e2482ab2)

Conflicts:

hw/msix.c
hw/virtio-pci.c

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoreset PMBA and PMREGMISC PIIX4 registers.
Gleb Natapov [Tue, 7 Aug 2012 12:52:03 +0000 (15:52 +0300)]
reset PMBA and PMREGMISC PIIX4 registers.

The bug causes Windows + OVMF hang after reboot since OVMF
checks PMREGMISC to see if IO space is enabled and skip
configuration if it is.

Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
(cherry picked from commit 4d09d37c6aa9a02b44b1fdb6268820fab92499bd)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoqemu_rearm_alarm_timer: do not call rearm if the next deadline is INT64_MAX
Stefano Stabellini [Tue, 29 May 2012 03:35:24 +0000 (03:35 +0000)]
qemu_rearm_alarm_timer: do not call rearm if the next deadline is INT64_MAX

qemu_rearm_alarm_timer partially duplicates the code in
qemu_next_alarm_deadline to figure out if it needs to rearm the timer.
If it calls qemu_next_alarm_deadline, it always rearms the timer even if
the next deadline is INT64_MAX.

This patch simplifies the behavior of qemu_rearm_alarm_timer and removes
the duplicated code, always calling qemu_next_alarm_deadline and only
rearming the timer if the deadline is less than INT64_MAX.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Reviewed-by: Stefan Weil <sw@weilnetz.de>
Tested-by: Andreas Färber <andreas.faerber@web.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
(cherry picked from commit 8227421e0476d9caf2a9a089465bb40c23834e33)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoqemu-ga: Fix null pointer passed to unlink in failure branch
Stefan Weil [Fri, 24 Aug 2012 05:03:03 +0000 (07:03 +0200)]
qemu-ga: Fix null pointer passed to unlink in failure branch

Clang reports this warning:

Null pointer passed as an argument to a 'nonnull' parameter

Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
(cherry picked from commit 4bdb1a3059d7d3a931de0748a2eec39a0ab41b4e)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agomemory: Fix copy&paste mistake in memory_region_iorange_write
Jan Kiszka [Sun, 26 Aug 2012 08:12:47 +0000 (10:12 +0200)]
memory: Fix copy&paste mistake in memory_region_iorange_write

The last argument of find_portio is "write", so this must be true here.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
(cherry picked from commit 7e2a62d82a3f1397acd67685c3008046eba8344b)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoivshmem: remove redundant ioeventfd configuration
Cam Macdonell [Mon, 27 Aug 2012 18:12:19 +0000 (12:12 -0600)]
ivshmem: remove redundant ioeventfd configuration

setup_ioeventfds() is unnecessary and actually causes a segfault when used
ioeventfd=on is used on the command-line.  Since ioeventfds are handled within
the memory API, it can be removed.

Signed-off-by: Cam Macdonell <cam@cs.ualberta.ca>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
(cherry picked from commit 7e7de876ae9bdb1b994dee148c6dc009ce94c48e)

Conflicts:

hw/ivshmem.c

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agohw/arm_gic.c: Define .class_size in arm_gic_info TypeInfo
Peter Maydell [Wed, 29 Aug 2012 07:52:37 +0000 (08:52 +0100)]
hw/arm_gic.c: Define .class_size in arm_gic_info TypeInfo

Add the missing .class_size definition to the arm_gic_info TypeInfo.
This fixes the memory corruption and possible segfault that otherwise
results when the class struct is allocated at too small a size and
the class init function writes off the end of it.

Reported-by: Adam Lackorzynski <adam@os.inf.tu-dresden.de>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
(cherry picked from commit 998a74bcda7f3297813732ddc2f28ffe5a12e37a)

 - ARMGICClass isn't in 1.1, set class size to SysBusDeviceClass instead

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agotcg/mips: fix broken CONFIG_TCG_PASS_AREG0 code
Aurelien Jarno [Mon, 27 Aug 2012 20:13:27 +0000 (22:13 +0200)]
tcg/mips: fix broken CONFIG_TCG_PASS_AREG0 code

The CONFIG_TCG_PASS_AREG0 code for calling ld/st helpers was
broken in that it did not respect the ABI requirement that 64
bit values were passed in even-odd register pairs. The simplest
way to fix this is to implement some new utility functions
for marshalling function arguments into the correct registers
and stack, so that the code which sets up the address and
data arguments does not need to care whether there has been
a preceding env argument.

Based on commit 9716ef3b for ARM by Peter Maydell.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
(cherry picked from commit 18fec301cd2a38f72a5eeba2656a0c5b4fa69fb7)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoaudio/winwave: previous audio buffer should be flushed
munkyu.im [Tue, 28 Aug 2012 07:42:06 +0000 (16:42 +0900)]
audio/winwave: previous audio buffer should be flushed

Winwave audio backend has problem with pausing and restart audio out.
Unlike other backends, Winwave pausing API does not flush audio buffer.
As a result, the previous audio data are played in front of
user expected sound when user restart audio.
So changes it to waveOutReset()

Signed-off-by: Munkyu Im <munkyu.im@samsung.com>
Signed-off-by: malc <av1474@comtv.ru>
(cherry picked from commit 13ef70f64e9e4d7583fbd9918d8ea76194023d37)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agotarget-mips: allow microMIPS SWP and SDP to have RD equal to BASE
Eric Johnson [Sun, 18 Sep 2011 00:28:16 +0000 (17:28 -0700)]
target-mips: allow microMIPS SWP and SDP to have RD equal to BASE

The microMIPS SWP and SDP instructions do not modify GPRs.  So their
behavior is well defined when RD equals BASE.  The MIPS Architecture
Verification Programs (AVPs) check that they work as expected.  This
is required for AVPs to pass.

Signed-off-by: Eric Johnson <ericj@mips.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
(cherry picked from commit 36c6711bbe79642b0102416a9dd4243505e874a6)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agotarget-mips: add privilege level check to several Cop0 instructions
Eric Johnson [Sun, 18 Sep 2011 00:05:32 +0000 (17:05 -0700)]
target-mips: add privilege level check to several Cop0 instructions

The MIPS Architecture Verification Programs (AVPs) check privileged
instructions for the required privilege level.  These changes are needed
to pass the AVP suite.

Signed-off-by: Eric Johnson <ericj@mips.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
(cherry picked from commit 2e15497c5b8d0d172dece0cf56e2d2e977a6b679)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agomips-linux-user: Always support rdhwr.
Richard Henderson [Fri, 30 Mar 2012 17:16:37 +0000 (13:16 -0400)]
mips-linux-user: Always support rdhwr.

The kernel will emulate this instruction if it's not supported
natively.  This insn is used for TLS, among other things, and
so is required by modern glibc.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Cc: Riku Voipio <riku.voipio@iki.fi>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
(cherry picked from commit b3167288367f79754b74ad933146e37938ebff13)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agotarget-mips: Streamline indexed cp1 memory addressing.
Richard Henderson [Fri, 30 Mar 2012 17:16:36 +0000 (13:16 -0400)]
target-mips: Streamline indexed cp1 memory addressing.

We've already eliminated both base and index being zero.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
(cherry picked from commit 05168674505153a641c7bfddb691d2eda11d13d1)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoFix order of CVT.PS.S operands
Richard Sandiford [Mon, 27 Aug 2012 08:53:29 +0000 (09:53 +0100)]
Fix order of CVT.PS.S operands

The FS input to CVT.PS.S is the high half and FT is the low half.
tcg_gen_concat_i32_i64 takes the low half first, so the operands
were in the wrong order.

Signed-off-by: Richard Sandiford <rdsandiford@googlemail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
(cherry picked from commit 13d24f49720a3e7b35a21222ef182c8513f139db)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoFix operands of RECIP2.S and RECIP2.PS
Richard Sandiford [Mon, 27 Aug 2012 08:50:38 +0000 (09:50 +0100)]
Fix operands of RECIP2.S and RECIP2.PS

Read the second input operand of RECIP2.S and RECIP2.PS from FT rather
than FD.  RECIP2.D is already correct.

Signed-off-by: Richard Sandiford <rdsandiford@googlemail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
(cherry picked from commit d22d7289877ecd3ef86570f6f6d0574da40711dc)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agotcg/ia64: fix and optimize ld/st slow path
Aurelien Jarno [Sat, 25 Aug 2012 22:45:27 +0000 (00:45 +0200)]
tcg/ia64: fix and optimize ld/st slow path

Store slow path has been broken in e141ab52d:
- the arguments are shifted before the last one (mem_index) is written.
- the shift is done for both slow and fast paths.

Fix that. Also optimize a bit by bundling the move together. This still
can be optimized, but it's better to wait for a decision to be taken on
the arguments order.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
(cherry picked from commit d03c98d80ffb7c561d9e6874580f52fe7ecc8c6c)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agotcg/ia64: fix prologue/epilogue
Aurelien Jarno [Sat, 25 Aug 2012 21:59:58 +0000 (23:59 +0200)]
tcg/ia64: fix prologue/epilogue

Prologue and epilogue code has been broken in cea5f9a28.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
(cherry picked from commit 18d445b443a5fa06a7c2819a170623b970afb3fb)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agotcg/arm: Fix broken CONFIG_TCG_PASS_AREG0 code
Peter Maydell [Sun, 26 Aug 2012 13:40:02 +0000 (14:40 +0100)]
tcg/arm: Fix broken CONFIG_TCG_PASS_AREG0 code

The CONFIG_TCG_PASS_AREG0 code for calling ld/st helpers was
broken in that it did not respect the ABI requirement that 64
bit values were passed in even-odd register pairs. The simplest
way to fix this is to implement some new utility functions
for marshalling function arguments into the correct registers
and stack, so that the code which sets up the address and
data arguments does not need to care whether there has been
a preceding env argument.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
(cherry picked from commit 9716ef3b1b48ebbb4b6515fb4685a5db96ce41d9)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agotarget-i386/translate.c: mov to/from crN/drN: ignore mod bits
Matthew Ogilvie [Thu, 23 Aug 2012 06:24:39 +0000 (00:24 -0600)]
target-i386/translate.c: mov to/from crN/drN: ignore mod bits

> This instruction is always treated as a register-to-register (MOD = 11)
> instruction, regardless of the encoding of the MOD field in the MODR/M
> byte.

Also, Microport UNIX System V/386 v 2.1 (ca 1987) runs fine on
real Intel 386 and 486 CPU's (at least), but does not run in qemu without
this patch.

Signed-off-by: Matthew Ogilvie <mmogilvi_qemu@miniinfo.net>
Signed-off-by: malc <av1474@comtv.ru>
(cherry picked from commit 5c73b757e3aa80dc84352b2ede0d8bdea5419f6d)

Conflicts:

target-i386/translate.c

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoivshmem: fix memory_region_del_eventfd assertion failure
Paolo Bonzini [Wed, 22 Aug 2012 21:09:47 +0000 (23:09 +0200)]
ivshmem: fix memory_region_del_eventfd assertion failure

We do not register ioeventfds unless the IVSHMEM_IOEVENTFD feature
is set.  The same feature must be checked before releasing the eventfds.
Regression introduced by commit 563027c (ivshmem: use EventNotifier and
memory API, 2012-07-05).

Reported-by: Cam Macdonnell <cam@cs.ualberta.ca>
Tested-by: Cam Macdonnell <cam@cs.ualberta.ca>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
(cherry picked from commit 98609cd8fcf755c0ba7049d751353b8b2e243b65)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoqom: object_delete should unparent the object first
Paolo Bonzini [Wed, 22 Aug 2012 21:09:46 +0000 (23:09 +0200)]
qom: object_delete should unparent the object first

object_deinit is only called when the reference count goes to zero,
and yet tries to do an object_unparent.  Now, object_unparent
either does nothing or it will decrease the reference count.
Because we know the reference count is zero, the object_unparent
call in object_deinit is useless.

Instead, we need to disconnect the object from its parent just
before we remove the last reference apart from the parent's.  This
happens in object_delete.  Once we do this, all calls to
object_unparent peppered through QEMU can go away.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
(cherry picked from commit da5a44e8b0b727681fc33e8d94832d1cae48a788)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agomonitor: don't try to initialize json parser when monitor is HMP
Anthony Liguori [Thu, 23 Aug 2012 18:49:02 +0000 (13:49 -0500)]
monitor: don't try to initialize json parser when monitor is HMP

Reported-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
(cherry picked from commit 26efaca377e004b79ff50a6e936d029a0c095b8b)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agotarget-mips: Fix some helper functions (VR54xx multiplication)
Stefan Weil [Sun, 4 Mar 2012 07:21:39 +0000 (08:21 +0100)]
target-mips: Fix some helper functions (VR54xx multiplication)

Commits b5dc7732e1cc2fb549e48b7b5d664f2c79628e2e and
be24bb4f3007c3e07cbf1934f7e781493d876ab7 optimized the code
and removed the correct setting of t0. Fix this.

gcc-4.7 detected this bug because parameter arg1 was unused
but set in set_HIT0_LO and set_HI_LOT0.

Cc: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
(cherry picked from commit 6fc97fafce05eee76479ca6d289241772d21b370)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agotarget-mips: Enable access to required RDHWR hardware registers
Meador Inge [Tue, 21 Aug 2012 17:31:37 +0000 (12:31 -0500)]
target-mips: Enable access to required RDHWR hardware registers

While running in the usermode emulator all of the required*
MIPS32r2 RDHWR hardware registers should be accessible (the
Linux kernel enables access to these same registers).  Note
that these registers are still enabled when the MIPS ISA is
not release 2.  This is OK since the Linux kernel emulates
access to them when they are not available in hardware.

* There is also the ULR register which is only recommended
  for full release 2 compliance.  Incidentally, accessing
  this register in the current implementation works fine
  without flipping its access bit.

Signed-off-by: Meador Inge <meadori@codesourcery.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
(cherry picked from commit 94159135cb59684853dcd45ff70d6dbc54a29209)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agomonitor: move json init from OPEN event to init
Anthony Liguori [Thu, 23 Aug 2012 13:03:21 +0000 (08:03 -0500)]
monitor: move json init from OPEN event to init

At some point in the past, the OPEN event was changed to be issued from a
bottom half.  This creates a small window whereas a data callback registered in
init may be invoked before the OPEN event has been issued.

This is reproducible with:

 echo "{'execute': 'qmp_capabilities'}" | qemu-system-x86_64 -M none -qmp stdio

We can fix this for the monitor by moving the parser initialization to init.

The remaining state that is set in OPEN appears harmless.

Reported-by: Daniel Berrange <berrange@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
(cherry picked from commit 58617a795c8067b2f9800cffce60f38707d3aa31)

Conflicts:

monitor.c

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agosoftmmu-semi: fix lock_user* functions not to deref NULL upon OOM
Jim Meyering [Wed, 22 Aug 2012 11:55:56 +0000 (13:55 +0200)]
softmmu-semi: fix lock_user* functions not to deref NULL upon OOM

Return NULL upon malloc failure.

Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
(cherry picked from commit 15d9e3bc6af8a56af8c61911aab8453a54795db1)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoarm-semi: don't leak 1KB user string lock buffer upon TARGET_SYS_OPEN
Jim Meyering [Wed, 22 Aug 2012 11:55:55 +0000 (13:55 +0200)]
arm-semi: don't leak 1KB user string lock buffer upon TARGET_SYS_OPEN

Always call unlock_user before returning.

Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
(cherry picked from commit 396bef4b3846bf4e80a2bee38e9a2d8554d0f251)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agosheepdog: don't leak socket file descriptor upon connection failure
Jim Meyering [Wed, 22 Aug 2012 11:55:54 +0000 (13:55 +0200)]
sheepdog: don't leak socket file descriptor upon connection failure

Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
(cherry picked from commit a7e47d4bfcbf256fae06891a8599950ff8e1b61b)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agolinux-user: do_msgrcv: don't leak host_mb upon TARGET_EFAULT failure
Jim Meyering [Wed, 22 Aug 2012 11:55:53 +0000 (13:55 +0200)]
linux-user: do_msgrcv: don't leak host_mb upon TARGET_EFAULT failure

Also, use g_malloc to avoid NULL-deref upon OOM.

Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
(cherry picked from commit 0d07fe47d4986271a21ed4ff5237275ff55dd93f)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoqemu-ga: don't leak a file descriptor upon failed lockf
Jim Meyering [Wed, 22 Aug 2012 11:55:52 +0000 (13:55 +0200)]
qemu-ga: don't leak a file descriptor upon failed lockf

Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
(cherry picked from commit 4144f122b477164cf466ca69be24cf4ef5c218d3)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoxen-all.c: fix multiply issue for int and uint types
Dongxiao Xu [Wed, 22 Aug 2012 10:17:43 +0000 (10:17 +0000)]
xen-all.c: fix multiply issue for int and uint types

If the two multiply operands are int and uint types separately,
the int type will be transformed to uint firstly, which is not the
intent in our code piece. The fix is to add (int64_t) transform
for the uint type before the multiply.

Signed-off-by: Dongxiao Xu <dongxiao.xu@intel.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
(cherry picked from commit 14d40183725361e6350166099556c7661063921b)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoFix invalidate if memory requested was not bucket aligned
Frediano Ziglio [Wed, 22 Aug 2012 10:17:04 +0000 (10:17 +0000)]
Fix invalidate if memory requested was not bucket aligned

When memory is mapped in qemu_map_cache with lock != 0 a reverse mapping
is created pointing to the virtual address of location requested.
The cached mapped entry is saved in last_address_vaddr with the memory
location of the base virtual address (without bucket offset).
However when this entry is invalidated the virtual address saved in the
reverse mapping is used. This cause that the mapping is freed but the
last_address_vaddr is not reset.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
(cherry picked from commit 27b7652ef515bb4c694f79d657d2052c72b19536)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoi82378: Remove bogus MMIO coalescing
Jan Kiszka [Fri, 17 Aug 2012 10:56:44 +0000 (12:56 +0200)]
i82378: Remove bogus MMIO coalescing

This MMIO area is an entry gate to legacy PC ISA devices, addressed via
PIO over there. Quite a few of the PIO ports have side effects on access
like starting/stopping timers that must be executed properly ordered
/wrt the CPU. So we have to remove the coalescing mark.

Acked-by: Hervé Poussineau <hpoussin@reactos.org>
Acked-by: Andreas Färber <andreas.faerber@web.de>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
(cherry picked from commit 0ec64507a5e6366e6d8070a82c866b935f687ed9)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoeventfd: making it thread safe
Alexey Kardashevskiy [Wed, 18 Jul 2012 12:52:04 +0000 (22:52 +1000)]
eventfd: making it thread safe

QEMU uses IO handlers to run select() in the main loop.
The handlers list is managed by qemu_set_fd_handler() helper
which works fine when called from the main thread as it is
called when select() is not waiting.

However IO handlers list can be changed in the thread other than
the main one doing os_host_main_loop_wait(), for example, as a result
of a hypercall which changes PCI config space (VFIO on POWER is the case)
and enables/disabled MSI/MSIX which closes/creates eventfd handles.
As the main loop should be waiting on the newly created eventfds,
it has to be restarted.

The patch adds the qemu_notify_event() call to interrupt select()
to make main_loop() restart select() with the updated IO handlers
list.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
(cherry picked from commit 55ce75faf253d4369670f60409c608e665e8dde9)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoiscsi: fix races between task completion and abort
Paolo Bonzini [Sat, 18 Aug 2012 21:35:49 +0000 (23:35 +0200)]
iscsi: fix races between task completion and abort

This patch fixes two main issues with block/iscsi.c:

1) iscsi_task_mgmt_abort_task_async calls iscsi_scsi_task_cancel which
was also directly called in iscsi_aio_cancel

2) a race between task completion and task abortion could happen cause
the scsi_free_scsi_task were done before iscsi_schedule_bh has finished.
To fix this, all the freeing of IscsiTasks and releasing of the AIOCBs
is centralized in iscsi_bh_cb, independent of whether the SCSI command
has completed or was cancelled.

3) iscsi_aio_cancel was not synchronously waiting for the end of the
command.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 1bd075f29ea6d11853475c7c42734595720c3ac6)

Conflicts:

block/iscsi.c

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoiscsi: simplify iscsi_schedule_bh
Paolo Bonzini [Sat, 18 Aug 2012 21:38:03 +0000 (23:38 +0200)]
iscsi: simplify iscsi_schedule_bh

It is always used with the same callback, remove the argument.  And
its return value is never used, assume allocation succeeds.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit cfb3f5064af2d2e29c976e292c9472dfe9d61e31)

Conflicts:

block/iscsi.c

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoiscsi: move iscsi_schedule_bh and iscsi_readv_writev_bh_cb
Paolo Bonzini [Sat, 18 Aug 2012 21:37:31 +0000 (23:37 +0200)]
iscsi: move iscsi_schedule_bh and iscsi_readv_writev_bh_cb

Put these functions at the beginning, to avoid forward references
in the next patches.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 27cbd828c617944c0f9603763fdf4fa87e7ad923)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoDocumentation: Warn against qemu-img on active image
Kevin Wolf [Thu, 16 Aug 2012 08:56:35 +0000 (10:56 +0200)]
Documentation: Warn against qemu-img on active image

People have repeatedly expected that you can do things like snapshotting
an image with qemu-img while a qemu instance is running. Maybe we need
to consider locking the files while they are in use, but having a
warning in the qemu-img manpage is doable for 1.2 and can't hurt anyway.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit 48467328c6dccc9c7be6628ed0ef0810f83be2a9)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agovmdk: Read footer for streamOptimized images
Kevin Wolf [Thu, 16 Aug 2012 08:39:33 +0000 (10:39 +0200)]
vmdk: Read footer for streamOptimized images

The footer takes precedence over the header when it exists. It contains
the real grain directory offset that is missing in the header. Without
this patch, streamOptimized images with a footer cannot be read.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Reviewed-by: Jeff Cody <jcody@redhat.com>
(cherry picked from commit 65bd155c7356d448ffee7f89149c4d473076b0ba)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agovmdk: Fix header structure
Kevin Wolf [Thu, 16 Aug 2012 08:34:10 +0000 (10:34 +0200)]
vmdk: Fix header structure

Commit bb45ded9 swapped gd_offset and rgd_offset. This is wrong.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit 7a736bfa4e0a58087054cad68a1d4b3804bbb708)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agovl: Round argument of -m up to multiple of 8KiB
Markus Armbruster [Wed, 15 Aug 2012 11:12:19 +0000 (13:12 +0200)]
vl: Round argument of -m up to multiple of 8KiB

Partial pages make little sense and don't work.  Ensure the RAM size
is a multiple of any possible target's page size.

Fixes

    $ qemu-system-x86_64 -nodefaults -S -vnc :0 -m 0.8
    qemu-system-x86_64: /work/armbru/qemu/exec.c:2255: register_subpage: Assertion `existing->mr->subpage || existing->mr == &io_mem_unassigned' failed.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
(cherry picked from commit ff961015529437f4b83fca0a92069aebcf533c9c)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agopc: Fix RTC CMOS info on RAM for ram_size < 1MiB
Markus Armbruster [Wed, 15 Aug 2012 11:12:20 +0000 (13:12 +0200)]
pc: Fix RTC CMOS info on RAM for ram_size < 1MiB

pc_cmos_init() always claims 640KiB base memory, and ram_size - 1MiB
extended memory.  The latter can underflow to "lots of extended
memory".  Fix both, and clean up some.

Note: SeaBIOS currently requires 1MiB of RAM, and doesn't check
whether it got enough.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
(cherry picked from commit e89001f72edde37fb36fa7c964daa1bbeb2eca26)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agokvm: i8254: Finish time conversion fix
Jan Kiszka [Tue, 14 Aug 2012 08:24:47 +0000 (10:24 +0200)]
kvm: i8254: Finish time conversion fix

0cdd3d1444 fixed reading back the counter load time from the kernel
while assuming the kernel would always update its load time on writing
the state. That is only true for channel 1, and so pit_get_channel_info
returned wrong output pin states for high counter values.

Fix this by applying the offset also on kvm_pit_put. Now we also need to
update the offset when we write the state while the VM is stopped as it
keeps on changing in that state.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
(cherry picked from commit 050a46065de8e3d4ee5a04f5598d666f63d34800)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agokvm: i8254: Cache kernel clock offset in KVMPITState
Jan Kiszka [Tue, 14 Aug 2012 08:24:03 +0000 (10:24 +0200)]
kvm: i8254: Cache kernel clock offset in KVMPITState

To prepare the final fix for clock calibration issues with the in-kernel
PIT, we want to cache the offset between vmclock and the clock used by
the in-kernel PIT. So far, we only need to update it when the VM state
changes between running and stopped because we only read the in-kernel
PIT state while the VM is running.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
(cherry picked from commit 205df4d1a87cbb14a50655fb2c0a987467fb29d6)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoahci: Fix ahci cdrom read corruptions for reads > 128k
Jason Baron [Fri, 3 Aug 2012 19:57:06 +0000 (15:57 -0400)]
ahci: Fix ahci cdrom read corruptions for reads > 128k

While testing q35, which has its cdrom attached to the ahci controller, I found
that the Fedora 17 install would panic on boot. The panic occurs while
squashfs is trying to read from the cdrom. The errors are:

[    8.622711] SQUASHFS error: xz_dec_run error, data probably corrupt
[    8.625180] SQUASHFS error: squashfs_read_data failed to read block
0x20be48a

I was also able to produce corrupt data reads using an installed piix based
qemu machine, using 'dd'. I found that the corruptions were only occuring when
then read size was greater than 128k. For example, the following command
results in corrupted reads:

dd if=/dev/sr0 of=/tmp/blah bs=256k iflag=direct

The > 128k size reads exercise a different code path than 128k and below. In
ide_atapi_cmd_read_dma_cb() s->io_buffer_size is capped at 128k. Thus,
ide_atapi_cmd_read_dma_cb() is called a second time when the read is > 128k.
However, ahci_dma_rw_buf() restart the read from offset 0, instead of at 128k.
Thus, resulting in a corrupted read.

To fix this, I've introduced 'io_buffer_offset' field in IDEState to keep
track of the offset. I've also modified ahci_populate_sglist() to take a new
3rd offset argument, so that the sglist is property initialized.

I've tested this patch using 'dd' testing, and Fedora 17 now correctly boots
and installs on q35 with the cdrom ahci controller.

Signed-off-by: Jason Baron <jbaron@redhat.com>
Tested-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit 61f52e06f0a21bab782f98ef3ea789aa6d0aa046)

Conflicts:

hw/ide/ahci.c

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoahci: Fix sglist memleak in ahci_dma_rw_buf()
Jason Baron [Fri, 3 Aug 2012 19:57:10 +0000 (15:57 -0400)]
ahci: Fix sglist memleak in ahci_dma_rw_buf()

I noticed that in hw/ide/ahci:ahci_dma_rw_buf() we do not free the sglist. Thus,
I've added a call to qemu_sglist_destroy() to fix this memory leak.

In addition, I've adeed a call in qemu_sglist_destroy() to 0 all of the sglist
fields, in case there is some other codepath that tries to free the sglist.

Signed-off-by: Jason Baron <jbaron@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit ea8d82a1ed72634f089ed1bccccd9c84cc1ab855)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoapic: Defer interrupt updates to VCPU thread
Jan Kiszka [Mon, 9 Jul 2012 14:42:32 +0000 (16:42 +0200)]
apic: Defer interrupt updates to VCPU thread

KVM performs TPR raising asynchronously to QEMU, specifically outside
QEMU's global lock. When an interrupt is injected into the APIC and TPR
is checked to decide if this can be delivered, a stale TPR value may be
used, causing spurious interrupts in the end.

Fix this by deferring apic_update_irq to the context of the target VCPU.
We introduce a new interrupt flag for this, CPU_INTERRUPT_POLL. When it
is set, the VCPU calls apic_poll_irq before checking for further pending
interrupts. To avoid special-casing KVM, we also implement this logic
for TCG mode.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
(cherry picked from commit 5d62c43a17edaa7f6a88821c9086e6c8e0e5327d)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoapic: Reevaluate pending interrupts on LVT_LINT0 changes
Jan Kiszka [Mon, 9 Jul 2012 14:42:31 +0000 (16:42 +0200)]
apic: Reevaluate pending interrupts on LVT_LINT0 changes

When the guest modifies the LVT_LINT0 register, we need to check if some
pending PIC interrupt can now be delivered.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
(cherry picked from commit a94820ddc36f8c452b37f9dcb323f55ffdbc75f9)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoapic: Resolve potential endless loop around apic_update_irq
Jan Kiszka [Mon, 9 Jul 2012 14:42:30 +0000 (16:42 +0200)]
apic: Resolve potential endless loop around apic_update_irq

Commit d96e173769 refactored the reinjection of pending PIC interrupts.
However, it missed the potential loop of apic_update_irq ->
apic_deliver_pic_intr -> apic_local_deliver -> apic_set_irq ->
apic_update_irq that /could/ occur if LINT0 is injected as APIC_DM_FIXED
and that vector is currently blocked via TPR.

Resolve this by reinjecting only where it matters: inside
apic_get_interrupt. This function may clear a vector while a
PIC-originated reason still exists.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
(cherry picked from commit 3db3659bf60094657e1465cc809acb09551816ee)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoslirp: Improve error reporting of inaccessible smb directories
Jan Kiszka [Fri, 6 Jul 2012 06:40:48 +0000 (08:40 +0200)]
slirp: Improve error reporting of inaccessible smb directories

Instead of guessing, print the error code returned by access.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
(cherry picked from commit 22a61f365df83d5d7884cceb1c462295977cb2db)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoslirp: Ensure smbd and shared directory exist when enable smb
Dunrong Huang [Fri, 6 Jul 2012 06:04:43 +0000 (14:04 +0800)]
slirp: Ensure smbd and shared directory exist when enable smb

Users may pass the following parameters to qemu:
    $ qemu-kvm -net nic -net user,smb= ...
    $ qemu-kvm -net nic -net user,smb ...
    $ qemu-kvm -net nic -net user,smb=bad_directory ...

In these cases, qemu started successfully while samba server
failed to start. Users will confuse since samba server
failed silently without any indication of what it did wrong.

To avoid it, we check whether the shared directory exist and
if users have permission to access this directory when QEMU's
"built-in" SMB server is enabled.

Signed-off-by: Dunrong Huang <riegamaths@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
(cherry picked from commit 927d811b282ffdf5386bd63f435c1507634ba49a)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoslirp: Enforce host-side user of smb share
Jan Kiszka [Thu, 5 Jul 2012 17:35:57 +0000 (19:35 +0200)]
slirp: Enforce host-side user of smb share

Windows 7 (and possibly other versions) cannot connect to the samba
share if the exported host directory is not world-readable. This can be
resolved by forcing the username used for access checks to the one
under which QEMU and smbd are running.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
(cherry picked from commit 1cb1c5d10bb9e180bd3f7be2c10b212ed86a97b4)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agocheck-qjson: add test for large JSON objects
Michael Roth [Wed, 15 Aug 2012 18:45:44 +0000 (13:45 -0500)]
check-qjson: add test for large JSON objects

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
(cherry picked from commit 7109edfeb69c1d3c2164175837784dfcd210fed0)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agojson-parser: don't replicate tokens at each level of recursion
Michael Roth [Wed, 15 Aug 2012 18:45:43 +0000 (13:45 -0500)]
json-parser: don't replicate tokens at each level of recursion

Currently, when parsing a stream of tokens we make a copy of the token
list at the beginning of each level of recursion so that we do not
modify the original list in cases where we need to fall back to an
earlier state.

In the worst case, we will only read 1 or 2 tokens off the list before
recursing again, which means an upper bound of roughly N^2 token allocations.

For a "reasonably" sized QMP request (in this a QMP representation of
cirrus_vga's device state, generated via QIDL, being passed in via
qom-set), this caused my 16GB's of memory to be exhausted before any
noticeable progress was made by the parser.

This patch works around the issue by using single copy of the token list
in the form of an indexable array so that we can save/restore state by
manipulating indices.

A subsequent commit adds a "large_dict" test case which exhibits the
same behavior as above. With this patch applied the test case successfully
completes in under a second.

Tested with valgrind, make check, and QMP.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
(cherry picked from commit 65c0f1e9558c7c762cdb333406243fff1d687117)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoqlist: add qlist_size()
Michael Roth [Wed, 15 Aug 2012 18:45:42 +0000 (13:45 -0500)]
qlist: add qlist_size()

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
(cherry picked from commit a86a4c2f7b7f0b72816ea1c219d8140699b6665b)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agousb-ehci: Fix an assert whenever isoc transfers are used
Hans de Goede [Fri, 6 Jul 2012 10:09:33 +0000 (12:09 +0200)]
usb-ehci: Fix an assert whenever isoc transfers are used

hcd-ehci.c is missing an usb_packet_init() call for the ipacket UsbPacket
it uses for isoc transfers, triggering an assert (taking the entire vm down)
in usb_packet_setup as soon as any isoc transfers are done by a high speed
USB device.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 7341ea075c09258b98a1d0efc60efd402cbfc9b4)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agousb-redir: Correctly handle the usb_redir_babble usbredir status
Hans de Goede [Fri, 6 Jul 2012 10:09:32 +0000 (12:09 +0200)]
usb-redir: Correctly handle the usb_redir_babble usbredir status

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit adae502c0ae4572ef08f71cb5b5ed5a8e90299fe)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agousb: restore USBDevice->attached on vmload
Gerd Hoffmann [Fri, 8 Jun 2012 10:58:46 +0000 (12:58 +0200)]
usb: restore USBDevice->attached on vmload

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 495d544798151206bafca65ec588c0388637eb40)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agouhci: fix uhci_async_cancel_all
Gerd Hoffmann [Fri, 15 Jun 2012 07:39:50 +0000 (09:39 +0200)]
uhci: fix uhci_async_cancel_all

We update the QTAILQ in the loop, thus we must use the SAFE version
to make sure we don't touch the queue struct after freeing it.

https://bugzilla.novell.com/show_bug.cgi?id=766310

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 77fa9aee38758a078870e25f0dcf642066b4d5cc)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoehci: don't flush cache on doorbell rings.
Gerd Hoffmann [Wed, 20 Jun 2012 11:14:08 +0000 (13:14 +0200)]
ehci: don't flush cache on doorbell rings.

Commit 4be23939ab0d7019c7e59a37485b416fbbf0f073 makes ehci instantly
zap any unlinked queue heads when the guest rings the doorbell.

While hacking up uas support this turned out to be a problem.  The linux
kernel can unlink and instantly relink the very same queue head, thereby
killing any async packets in flight.  That alone isn't an issue yet, the
packet will canceled and resubmitted and everything is fine.  We'll run
into trouble though in case the async packet is completed already, so we
can't cancel it any more.  The transaction is simply lost then.

usb_ehci_qh_ptrs q (nil) - QH @ 39c4f000: next 39c4f122 qtds 00000000,00000001,39c50000
usb_ehci_qh_fields QH @ 39c4f000 - rl 0, mplen 0, eps 0, ep 0, dev 0
usb_ehci_qh_ptrs q 0x7f95feba90a0 - QH @ 39c4f000: next 39c4f122 qtds 00000000,00000001,39c50000
usb_ehci_qh_fields QH @ 39c4f000 - rl 0, mplen 0, eps 0, ep 0, dev 0
usb_ehci_qh_ptrs q 0x7f95fe515210 - QH @ 39c4f120: next 39c4f0c2 qtds 29dbce40,29dbc4e0,00000009
usb_ehci_qh_fields QH @ 39c4f120 - rl 4, mplen 512, eps 2, ep 1, dev 2
usb_ehci_packet_action q 0x7f95fe515210 p 0x7f95fdec32a0: alloc
usb_packet_state_change bus 0, port 2, ep 1, packet 0x7f95fdec32e0, state undef -> setup
usb_ehci_packet_action q 0x7f95fe515210 p 0x7f95fdec32a0: process
usb_uas_command dev 2, tag 0x2, lun 0, lun64 00000000-00000000
scsi_req_parsed target 0 lun 0 tag 2 command 42 dir 2 length 16384
scsi_req_parsed_lba target 0 lun 0 tag 2 command 42 lba 5933312
scsi_req_alloc target 0 lun 0 tag 2
scsi_req_continue target 0 lun 0 tag 2
scsi_req_data target 0 lun 0 tag 2 len 16384
usb_uas_scsi_data dev 2, tag 0x2, bytes 16384
usb_uas_write_ready dev 2, tag 0x2
usb_packet_state_change bus 0, port 2, ep 1, packet 0x7f95fdec32e0, state setup -> complete
usb_ehci_packet_action q 0x7f95fe515210 p 0x7f95fdec32a0: free
usb_ehci_qh_ptrs q 0x7f95fdec3210 - QH @ 39c4f0c0: next 39c4f002 qtds 29dbce40,00000001,00000009
usb_ehci_qh_fields QH @ 39c4f0c0 - rl 4, mplen 512, eps 2, ep 2, dev 2
usb_ehci_queue_action q 0x7f95fe5152a0: free
usb_packet_state_change bus 0, port 2, ep 2, packet 0x7f95feba9170, state async -> complete
^^^ async packets completes.
usb_ehci_packet_action q 0x7f95fdec3210 p 0x7f95feba9130: wakeup

usb_ehci_qh_ptrs q (nil) - QH @ 39c4f000: next 39c4f122 qtds 00000000,00000001,39c50000
usb_ehci_qh_fields QH @ 39c4f000 - rl 0, mplen 0, eps 0, ep 0, dev 0
usb_ehci_qh_ptrs q 0x7f95feba90a0 - QH @ 39c4f000: next 39c4f122 qtds 00000000,00000001,39c50000
usb_ehci_qh_fields QH @ 39c4f000 - rl 0, mplen 0, eps 0, ep 0, dev 0
usb_ehci_qh_ptrs q 0x7f95fe515210 - QH @ 39c4f120: next 39c4f002 qtds 29dbc4e0,29dbc8a0,00000009
usb_ehci_qh_fields QH @ 39c4f120 - rl 4, mplen 512, eps 2, ep 1, dev 2
usb_ehci_queue_action q 0x7f95fdec3210: free
usb_ehci_packet_action q 0x7f95fdec3210 p 0x7f95feba9130: free
^^^ endpoint #2 queue head removed from schedule, doorbell makes ehci zap the queue,
    the (completed) usb packet is freed too and gets lost.

usb_ehci_qh_ptrs q (nil) - QH @ 39c4f000: next 39c4f0c2 qtds 00000000,00000001,39c50000
usb_ehci_qh_fields QH @ 39c4f000 - rl 0, mplen 0, eps 0, ep 0, dev 0
usb_ehci_qh_ptrs q 0x7f95feba90a0 - QH @ 39c4f000: next 39c4f0c2 qtds 00000000,00000001,39c50000
usb_ehci_qh_fields QH @ 39c4f000 - rl 0, mplen 0, eps 0, ep 0, dev 0
usb_ehci_queue_action q 0x7f9600dff570: alloc
usb_ehci_qh_ptrs q 0x7f9600dff570 - QH @ 39c4f0c0: next 39c4f122 qtds 29dbce40,00000001,00000009
usb_ehci_qh_fields QH @ 39c4f0c0 - rl 4, mplen 512, eps 2, ep 2, dev 2
usb_ehci_packet_action q 0x7f9600dff570 p 0x7f95feba9130: alloc
usb_packet_state_change bus 0, port 2, ep 2, packet 0x7f95feba9170, state undef -> setup
usb_ehci_packet_action q 0x7f9600dff570 p 0x7f95feba9130: process
usb_packet_state_change bus 0, port 2, ep 2, packet 0x7f95feba9170, state setup -> async
usb_ehci_packet_action q 0x7f9600dff570 p 0x7f95feba9130: async
^^^ linux kernel relinked the queue head, ehci creates a new usb packet,
    but we should have delivered the completed one instead.
usb_ehci_qh_ptrs q 0x7f95fe515210 - QH @ 39c4f120: next 39c4f002 qtds 29dbc4e0,29dbc8a0,00000009
usb_ehci_qh_fields QH @ 39c4f120 - rl 4, mplen 512, eps 2, ep 1, dev 2

So instead of instantly zapping the queue we'll set a flag that the
queue needs revalidation in case we'll see it again in the schedule.
ehci then checks that the queue head fields addressing / describing the
endpoint and the qtd pointer match the cached content before reusing it.

Cc: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 9bc3a3a216e2689bfcdd36c3e079333bbdbf3ba0)

Conflicts:

hw/usb/hcd-ehci.c

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoehci: fix reset
Gerd Hoffmann [Thu, 24 May 2012 10:04:50 +0000 (12:04 +0200)]
ehci: fix reset

Check for the reset bit first when processing USBCMD register writes.
Also break out of the switch, there is no need to check the other bits.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 7046530c36fa3a3f87692bdb54556f5d891a9c03)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agovirtio-blk: fix use-after-free while handling scsi commands
Avi Kivity [Mon, 6 Aug 2012 12:49:03 +0000 (15:49 +0300)]
virtio-blk: fix use-after-free while handling scsi commands

The scsi passthrough handler falls through after completing a
request into the failure path, resulting in a use after free.

Reproducible by running a guest with aio=native on a block device.

Reported-by: Stefan Priebe <s.priebe@profihost.ag>
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit 730a9c53b4e52681fcfe31cf38854cbf91e132c7)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoqdev: fix use-after-free in the error path of qdev_init_nofail
Anthony Liguori [Wed, 27 Jun 2012 12:37:54 +0000 (07:37 -0500)]
qdev: fix use-after-free in the error path of qdev_init_nofail

From Markus:

Before:

    $ qemu-system-x86_64 -display none -drive if=ide
    qemu-system-x86_64: Device needs media, but drive is empty
    qemu-system-x86_64: Initialization of device ide-hd failed
    [Exit 1 ]

After:

    $ qemu-system-x86_64 -display none -drive if=ide
    qemu-system-x86_64: Device needs media, but drive is empty
    Segmentation fault (core dumped)
    [Exit 139 (SIGSEGV)]

This error always existed as qdev_init() frees the object.  But QOM
goes a bit further and purposefully sets the class pointer to NULL to
help find use-after-free.  It worked :-)

Cc: Andreas Faerber <afaerber@suse.de>
Reported-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
(cherry picked from commit 7de3abe505e34398cef5bddf6c4d0bd9ee47007f)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agokvmvapic: Disable if there is insufficient memory
Jan Kiszka [Tue, 14 Aug 2012 11:43:12 +0000 (13:43 +0200)]
kvmvapic: Disable if there is insufficient memory

We need at least 1M of RAM to map the option ROM. Otherwise, we will
corrupt host memory or even crash:

    $ qemu-system-x86_64 -nodefaults --enable-kvm -vnc :0 -m 640k
    Segmentation fault (core dumped)

Reported-and-tested-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
(cherry picked from commit a9605e0317c7a6d5e68f3a3b6708c8ef1096f4bc)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agos390: Fix error handling and condition code of service call
Christian Borntraeger [Mon, 23 Jul 2012 21:37:04 +0000 (21:37 +0000)]
s390: Fix error handling and condition code of service call

Invalid sccb addresses will cause specification or addressing exception.
Lets add those checks. Furthermore, the good case (cc=0) was incorrect
for KVM, we did not set the CC at all. We now use return codes < 0
as program checks and return codes > 0 as condition code values.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
(cherry picked from commit 9abf567d95a4e840df868ca993219175fbef8c22)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoppc: Fix bug in handling of PAPR hypercall exits
David Gibson [Mon, 6 Aug 2012 18:44:45 +0000 (18:44 +0000)]
ppc: Fix bug in handling of PAPR hypercall exits

Currently for powerpc, kvm_arch_handle_exit() always returns 1, meaning
that its caller - kvm_cpu_exec() - will always exit immediately afterwards
to the loop in qemu_kvm_cpu_thread_fn().

There's no need to do this.  Once we've handled the hypercall there's no
reason we can't go straight around and KVM_RUN again, which is what ret = 0
will signal.  The only exception might be for hypercalls which affect the
state of cpu_can_run(), however the only one that might do this is H_CEDE
and for kvm that is always handled in the kernel, not qemu.

Furtherm setting ret = 0 means that when exit_requested is set from a
hypercall, we will enter KVM_RUN once more with a signal which lets the
the kernel do its internal logic to complete the hypercall with out
actually executing any more guest code.  This is important if our hypercall
also triggered a reset, which previously would re-initialize everything
without completing the hypercall.  This caused the kernel to get confused
because it thought the guest was still in the middle of a hypercall when
it has actually been reset.

This patch therefore changes to ret = 0, which is both a bugfix and a small
optimization.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
(cherry picked from commit 78e8fde26c032931ca2ae13bfc7c59e38afd17ee)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoconfigure: Don't override user's --cpu on MacOS and Solaris
Peter Maydell [Tue, 14 Aug 2012 14:35:34 +0000 (15:35 +0100)]
configure: Don't override user's --cpu on MacOS and Solaris

Both MacOS and Solaris have special case handling for the CPU
type, because the check_define probes will return i386 even if
the hardware is 64 bit and x86_64 would be preferable. Move
these checks earlier in the configure probing so that we can
do them only if the user didn't specify a CPU with --cpu. This
fixes a bug where the user's command line argument was being
ignored.

Reviewed-by: Andreas F=E4rber <afaerber@suse.de>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
(cherry picked from commit bbea4050802a2e7e0296a21823c0925782c02b93)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoqtest: fix infinite loop when QEMU aborts abruptly
Anthony Liguori [Wed, 27 Jun 2012 13:20:43 +0000 (08:20 -0500)]
qtest: fix infinite loop when QEMU aborts abruptly

From Markus:

Makes "make check" hang:

    QTEST_QEMU_BINARY=x86_64-softmmu/qemu-system-x86_64 gtester -k --verbose -m=quick tests/crash-test tests/rtc-test
    TEST: tests/crash-test... (pid=972)
    qemu-system-x86_64: Device needs media, but drive is empty
[Nothing happens, wait a while, then hit ^C]
    make: *** [check-qtest-x86_64] Interrupt

This was due to the fact that we weren't checked for errors when
reading from the QMP socket.  This patch adds appropriate error
checking.

Reported-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
(cherry picked from commit 039380a8e18f618cdacf72486449c04dc1b70eef)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoupdate VERSION for v1.1.1 v1.1.1
Michael Roth [Thu, 12 Jul 2012 18:36:14 +0000 (13:36 -0500)]
update VERSION for v1.1.1

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoMerge remote-tracking branch 'agraf/s390-for-upstream-1.1' into HEAD
Michael Roth [Tue, 10 Jul 2012 19:08:37 +0000 (14:08 -0500)]
Merge remote-tracking branch 'agraf/s390-for-upstream-1.1' into HEAD

11 years agos390x: fix s390 virtio aliases
Alexander Graf [Fri, 18 May 2012 00:36:26 +0000 (02:36 +0200)]
s390x: fix s390 virtio aliases

Some of the virtio devices have the same frontend name, but actually
implement different devices behind the scenes through aliases.

The indicator which device type to use is the architecture. On s390, we
want s390 virtio devices. On everything else, we want PCI devices.

Reflect this in the alias selection code. This way we fix commands like
-device virtio-blk on s390x which with this patch applied select the
correct virtio-blk-s390 device rather than virtio-blk-pci.

Reported-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agortl8139: validate rx ring before receiving packets
Jason Wang [Thu, 17 May 2012 05:25:43 +0000 (13:25 +0800)]
rtl8139: validate rx ring before receiving packets

Commit ff71f2e8cacefae99179993204172bc65e4303df prevent the possible
crash during initialization of linux driver by checking the operating
mode.This seems too strict as:

- the real card could still work in mode other than normal
- some buggy driver who does not set correct opmode after eeprom
 access

So, considering rx ring address were reset to zero (which could be
safely trated as an address not intened to DMA to), in order to
both letting old guest work and preventing the unexpected DMA to
guest, we can forbid packet receiving when rx ring address is zero.

Tested-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
(cherry picked from commit fcce6fd25f3e233f9da9ef01230a668ab35bd343)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoahci: SATA FIS is 20 bytes, not 0x20
Daniel Verkamp [Tue, 22 May 2012 23:26:42 +0000 (16:26 -0700)]
ahci: SATA FIS is 20 bytes, not 0x20

As in the SATA and AHCI specifications, a FIS is 5 Dwords of 4 bytes
each, which comes to 20 bytes (decimal), not 0x20.

Signed-off-by: Daniel Verkamp <daniel@drv.nu>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit 4bb9c939a57103898f5a51aa6a7336eb3320d923)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoqemu-img: document qed format on qemu-img man page
Stefan Hajnoczi [Wed, 13 Jun 2012 13:29:15 +0000 (14:29 +0100)]
qemu-img: document qed format on qemu-img man page

The qemu-img.1 man page is missing the qed format from its list of
supported formats.  Document the image creation options for qed.

Suggested-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit f085800e245836fed27fddb3b624a29326637657)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agovirtio: Fix compiler warning for non Linux hosts
Stefan Weil [Tue, 22 May 2012 21:23:32 +0000 (23:23 +0200)]
virtio: Fix compiler warning for non Linux hosts

The local variables ret, i are only used if __linux__ is defined.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit 47ce9ef7f89032c4079bf5132a12d1bfd4d5bca5)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agosheepdog: fix return value of do_load_save_vm_state
MORITA Kazutaka [Tue, 29 May 2012 16:05:15 +0000 (01:05 +0900)]
sheepdog: fix return value of do_load_save_vm_state

bdrv_save_vmstate and bdrv_load_vmstate should return the vmstate size
on success, and -errno on error.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit 6f3c714eb7730630241fd0b33b799352d7feb876)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoqemu/xendisk: set maximum number of grants to be used
Jan Beulich [Mon, 11 Jun 2012 09:52:27 +0000 (09:52 +0000)]
qemu/xendisk: set maximum number of grants to be used

Legacy (non-pvops) gntdev drivers may require this to be done when the
number of grants intended to be used simultaneously exceeds a certain
driver specific default limit.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
(cherry picked from commit 64c27e5b1fdb6d94bdc0bda3b1869d7383a35c65)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agobuild: install qmp-commands.txt
Bruce Rogers [Wed, 13 Jun 2012 22:29:17 +0000 (16:29 -0600)]
build: install qmp-commands.txt

File is targeted for install, but is never installed.

Signed-off-by: Bruce Rogers <brogers@suse.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
(cherry picked from commit 0cd23fcc0afe0a847e2e68797b64b297b20121f9)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agofdc: fix implied seek while there is no media in drive
Pavel Hrdina [Wed, 13 Jun 2012 13:43:11 +0000 (15:43 +0200)]
fdc: fix implied seek while there is no media in drive

The Windows uses 'READ' command at the start of an instalation
without checking the 'dir' register. We have to abort the transfer
with an abnormal termination if there is no media in the drive.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit c52acf60b6c12ff5eb58eb6ac568c159ae0c8737)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoqcow2: fix autoclear image header update
Stefan Hajnoczi [Thu, 14 Jun 2012 10:42:23 +0000 (11:42 +0100)]
qcow2: fix autoclear image header update

The autoclear feature bits can be used for qcow2 file format features
that are safe to "drop" by old programs that do not understand the
feature.  Upon opening the image file unknown autoclear feature bits are
cleared and the image file header is rewritten, but this was happening
too early in the code when critical header fields were not yet loaded.

Process autoclear feature bits after all necessary header information
has been loaded.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit af7b708db2d03eb47f7ba44a050439ad9ee65e7a)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoPrevent disk data loss when closing qemu
Pavel Dovgaluk [Wed, 30 May 2012 06:08:04 +0000 (10:08 +0400)]
Prevent disk data loss when closing qemu

Prevent disk data loss when closing qemu console window
under Windows 7.

v3. Comment for Sleep() parameter was updated.

Signed-off-by: Pavel Dovgalyuk<pavel.dovgaluk@gmail.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit b75a02829dde98723dfe16fa098338cb267b28b9)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoqcow2: fix endianness conversion
Zhi Yong Wu [Sat, 28 Apr 2012 07:38:08 +0000 (15:38 +0800)]
qcow2: fix endianness conversion

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit 87267753a36798e25262ee48264bea2ab70921aa)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agopci_bridge_dev: fix error path in pci_bridge_dev_initfn()
Jason Baron [Thu, 3 May 2012 02:42:15 +0000 (22:42 -0400)]
pci_bridge_dev: fix error path in pci_bridge_dev_initfn()

Currently, we do not properly cleanup, if pci_bridge_dev_initfn
fails to initialize properly. Make sure to call pci_bridge_exitfn()
in the error path.

Signed-off-by: Jason Baron <jbaron@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 80aa796bf38b7ef21daa42673b4711510c450d8a)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoqdev: release parent properties on dc->init failure
Jason Baron [Thu, 3 May 2012 02:42:10 +0000 (22:42 -0400)]
qdev: release parent properties on dc->init failure

While looking into hot-plugging bridges, I can create a qemu segfault via:

$ device_add pci-bridge

Bridge chassis not specified. Each bridge is required to be assigned a unique chassis id > 0.
**
ERROR:qom/object.c:389:object_delete: assertion failed: (obj->ref == 0)

I'm proposing to fix this by adding a call to 'object_unparent()', before the
call to qdev_free(). I see there is already a precedent for this usage pattern as
seen in qdev_simple_unplug_cb():

/* can be used as ->unplug() callback for the simple cases */
int qdev_simple_unplug_cb(DeviceState *dev)
{
    /* just zap it */
    object_unparent(OBJECT(dev));
    qdev_free(dev);
    return 0;
}

Signed-off-by: Jason Baron <jbaron@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 266ca11a0433643a3cc3146a9837d9f2b0bfbe3b)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agointel-hda: Fix reset of MSI function
Jan Kiszka [Fri, 11 May 2012 14:42:35 +0000 (11:42 -0300)]
intel-hda: Fix reset of MSI function

Call msi_reset on device reset as still required by the core.

CC: Gerd Hoffmann <kraxel@redhat.com>
CC: qemu-stable@nongnu.org
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 8e729e3b521d9fcd87fc2e40b6322e684f58bb2e)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoahci: Fix reset of MSI function
Jan Kiszka [Fri, 11 May 2012 14:42:34 +0000 (11:42 -0300)]
ahci: Fix reset of MSI function

Call msi_reset on device reset as still required by the core.

CC: Alexander Graf <agraf@suse.de>
CC: qemu-stable@nongnu.org
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 868a1a52267daddf933ee18480ae036da029b561)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agortl8139: honor RxOverflow flag in can_receive method
Fernando Luis Vazquez Cao [Mon, 4 Jun 2012 14:35:11 +0000 (17:35 +0300)]
rtl8139: honor RxOverflow flag in can_receive method

Some drivers (Linux' 8139too among them) rely on the NIC
injecting an interrupt in the event of a receive buffer overflow
and, accordingly, set the RxOverflow bit in the interrupt
mask. Unfortunately rtl8139's can_receive method ignores the
RxOverflow flag, which may lead to a situation where rtl8139
stops receiving packets (can_receive returns 0) when the receive
buffer becomes full.

If the driver eventually read from the receive buffer or reset
the card the emulator could recover from this situation. However
some implementations only do this upon receiving an interrupt
with either RxOK or RxOverflow set in the ISR; interrupt that
will never come because QEMU's flow control mechanisms would
prevent rtl8139 from receiving any packet.

Letting packets go through when the overflow interrupt is enabled
makes the QEMU emulator compliant to the spec and solves the
problem.

This patch should fix a relatively common (in our experience)
network stall observed when running enterprise distros with
rtl8139 as the NIC; in some cases the 8139too device driver gets
loaded and when under heavy load the network eventually stops
working.

Reported-by: Hayato Kakuta <kakuta.hayato@oss.ntt.co.jp>
Tested-by: Hayato Kakuta <kakuta.hayato@oss.ntt.co.jp>
Acked-by: Igor Kovalenko <igor.v.kovalenko@gmail.com>
Signed-off-by: Fernando Luis Vazquez Cao <fernando@oss.ntt.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit fee9d348ffc5c9f80068086799a948996f633f7e)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoconfigure: Fix build for some versions of glibc (9pfs)
Stefan Weil [Wed, 6 Jun 2012 19:35:57 +0000 (19:35 +0000)]
configure: Fix build for some versions of glibc (9pfs)

Some versions declare open_by_handle_at, but don't define AT_EMPTY_PATH.
Extend the check in configure to test both preconditions.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
(cherry picked from commit acc55ba8b1519bda27be19fad50b65d2b0c7d26d)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agomonitor: Fix memory leak with readline completion
Stefan Weil [Mon, 14 May 2012 09:47:20 +0000 (09:47 +0000)]
monitor: Fix memory leak with readline completion

Each string which is shown during readline completion in the QEMU monitor
is allocated dynamically but currently never deallocated.

Add the missing loop which calls g_free for the allocated strings.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
(cherry picked from commit fc9fa4bd0a295ac18808c4cd2cfac484bc4649d3)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoqcow2: Silence false warning
Kevin Wolf [Fri, 15 Jun 2012 11:43:18 +0000 (13:43 +0200)]
qcow2: Silence false warning

Some gcc versions seem not to be able to figure out that the switch
statement covers all possible values and that c is therefore always
initialised. Add a default branch for them.

Reported-by: malc <av1474@comtv.ru>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: malc <av1474@comtv.ru>
(cherry picked from commit 1417d7e40eaf1418333fb2ec43d0c7f4245b10e7)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agokvm: i8254: Fix conversion of in-kernel to userspace state
Jan Kiszka [Wed, 6 Jun 2012 14:28:42 +0000 (16:28 +0200)]
kvm: i8254: Fix conversion of in-kernel to userspace state

Due to a offset between the clock used to generate the in-kernel
count_load_time (CLOCK_MONOTONIC) and the clock used for processing this
in userspace (vm_clock), reading back the output of PIT channel 2 via
port 0x61 was broken. One use cases that suffered from it was the CPU
frequency calibration of SeaBIOS, which also affected IDE/AHCI timeouts.

This fixes it by calibrating the offset between both clocks on
kvm_pit_get and adjusting the kernel value before saving it in the
userspace state. As the calibration only works while the vm_clock is
running, we cache the in-kernel state across stopped phases.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
(cherry picked from commit 0cdd3d14447da1a04e778c219c77db8b96f9cf33)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agokvm/apic: correct short memset
Jim Meyering [Thu, 10 May 2012 16:19:47 +0000 (18:19 +0200)]
kvm/apic: correct short memset

kvm_put_apic_state's attempt to clear *kapic before setting its
bits cleared sizeof(void*) bytes (no more than 8) rather than the
intended 1024 (KVM_APIC_REG_SIZE) bytes. Spotted by coverity.

Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
(cherry picked from commit 0614cb82ca27bdffb83864e693fc29e29182667b)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoconfigure: report missing libraries for virtfs
Harsh Prateek Bora [Thu, 7 Jun 2012 21:50:43 +0000 (03:20 +0530)]
configure: report missing libraries for virtfs

Signed-off-by: Harsh Prateek Bora <harsh@linux.vnet.ibm.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
(cherry picked from commit 263ddcc81bf45d475ef86100a8567b3fb2129b8d)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agotrace/simple.c: fix deprecated glib2 interface
Harsh Prateek Bora [Thu, 7 Jun 2012 21:50:42 +0000 (03:20 +0530)]
trace/simple.c: fix deprecated glib2 interface

Signed-off-by: Harsh Prateek Bora <harsh@linux.vnet.ibm.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
(cherry picked from commit 0d665005c7fd3800f1ae590701f60fe7e4c9a57a)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>