sdk/emulator/qemu.git
13 years agosysbus: print number of irqs in dev_print
Dmitry Eremin-Solenikov [Mon, 31 Jan 2011 15:20:41 +0000 (18:20 +0300)]
sysbus: print number of irqs in dev_print

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
13 years ago.gitignore: ignore vi swap files and ctags files
Dmitry Eremin-Solenikov [Mon, 31 Jan 2011 15:20:40 +0000 (18:20 +0300)]
.gitignore: ignore vi swap files and ctags files

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
13 years agoarm: drop unused irq-related part of CPUARMState
Dmitry Eremin-Solenikov [Mon, 31 Jan 2011 15:20:42 +0000 (18:20 +0300)]
arm: drop unused irq-related part of CPUARMState

These two fields were added as a part of ARMv7 support patch (back in
2007), were never used by any code, so can be dropped.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
13 years agotarget-arm: Remove stray #include from middle of neon_helper.c
Peter Maydell [Thu, 10 Feb 2011 15:47:14 +0000 (15:47 +0000)]
target-arm: Remove stray #include from middle of neon_helper.c

Remove a stray #include <stdio.h> from the middle of neon_helper.c:
it was harmless but pointless since we include stdio.h at the top
of the file anyway.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agolinux-user/arm: fix compilation failures using softfloat's struct types
Peter Maydell [Thu, 10 Feb 2011 13:59:35 +0000 (13:59 +0000)]
linux-user/arm: fix compilation failures using softfloat's struct types

Add uses of the float32/float64 boxing and unboxing macros so that
the ARM linux-user targets will compile with USE_SOFTFLOAT_STRUCT_TYPES
enabled.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agosoftfloat: Fix compilation failures with USE_SOFTFLOAT_STRUCT_TYPES
Peter Maydell [Thu, 10 Feb 2011 13:59:34 +0000 (13:59 +0000)]
softfloat: Fix compilation failures with USE_SOFTFLOAT_STRUCT_TYPES

Make softfloat compile with USE_SOFTFLOAT_STRUCT_TYPES defined, by
adding and using new macros const_float16(), const_float32() and
const_float64() so you can use array initializers in an array of
float16/float32/float64 whether the types are bare or wrapped in the
structs.

[aurelien@aurel32.net: do the same for float16]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-arm: Use standard FPSCR for Neon half-precision operations
Peter Maydell [Thu, 10 Feb 2011 11:29:01 +0000 (11:29 +0000)]
target-arm: Use standard FPSCR for Neon half-precision operations

The Neon half-precision conversion operations (VCVT.F16.F32 and
VCVT.F32.F16) use ARM standard floating-point arithmetic, unlike
the VFP versions (VCVTB and VCVTT).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-arm: Silence NaNs resulting from half-precision conversions
Peter Maydell [Thu, 10 Feb 2011 11:29:00 +0000 (11:29 +0000)]
target-arm: Silence NaNs resulting from half-precision conversions

Silence the NaNs that may result from half-precision conversion,
as we do for the other conversions.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agosoftfloat: Correctly handle NaNs in float16_to_float32()
Peter Maydell [Thu, 10 Feb 2011 11:28:59 +0000 (11:28 +0000)]
softfloat: Correctly handle NaNs in float16_to_float32()

Correctly handle NaNs in float16_to_float32(), by defining and
using a float16ToCommonNaN() function, as we do with the other formats.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agosoftfloat: Fix single-to-half precision float conversions
Peter Maydell [Thu, 10 Feb 2011 11:28:58 +0000 (11:28 +0000)]
softfloat: Fix single-to-half precision float conversions

Fix various bugs in the single-to-half-precision conversion code:
 * input NaNs not correctly converted in IEEE mode
   (fixed by defining and using a commonNaNToFloat16())
 * wrong values returned when converting NaN/Inf into non-IEEE
   half precision value
 * wrong values returned for conversion of values which are
   on the boundary between denormal and zero for the half
   precision format
 * zeroes not correctly identified
 * excessively large results in non-IEEE mode should
   generate InvalidOp, not Overflow

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agosoftfloat: Honour default_nan_mode for float-to-float conversions
Christophe Lyon [Thu, 10 Feb 2011 11:28:57 +0000 (11:28 +0000)]
softfloat: Honour default_nan_mode for float-to-float conversions

Honour the default_nan_mode flag when doing conversions between
different floating point formats, as well as when returning a NaN from
a two-operand floating point function. This corrects the behaviour
of float<->double conversions on both ARM and SH4.

Signed-off-by: Christophe Lyon <christophe.lyon@st.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agosoftfloat: Add float16 type and float16 NaN handling functions
Peter Maydell [Thu, 10 Feb 2011 11:28:56 +0000 (11:28 +0000)]
softfloat: Add float16 type and float16 NaN handling functions

Add a float16 type to softfloat, rather than using bits16 directly.
Also add the missing functions float16_is_quiet_nan(),
float16_is_signaling_nan() and float16_maybe_silence_nan(),
which are needed for the float16 conversion routines.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agoMake tb_alloc static
Tristan Gingold [Thu, 10 Feb 2011 09:04:57 +0000 (10:04 +0100)]
Make tb_alloc static

This function is only used within exec.c, so no need to make it public.

Signed-off-by: Tristan Gingold <gingold@adacore.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agomicroblaze: Handle singlestepping over direct jmps
Edgar E. Iglesias [Wed, 9 Feb 2011 23:46:09 +0000 (00:46 +0100)]
microblaze: Handle singlestepping over direct jmps

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@petalogix.com>
13 years agoMerge branch 'linux-user-for-upstream' of git://gitorious.org/qemu-maemo/qemu
Aurelien Jarno [Wed, 9 Feb 2011 18:53:36 +0000 (19:53 +0100)]
Merge branch 'linux-user-for-upstream' of git://gitorious.org/qemu-maemo/qemu

* 'linux-user-for-upstream' of git://gitorious.org/qemu-maemo/qemu:
  linux-user: fix for loopmount ioctl
  linux-user: fix build errors for mmap2-only ports
  user: speed up init_paths a bit
  linux-user: implement sched_{g,s}etaffinity
  linux-user/FLAT: allow targets to override FLAT processing
  linux-user/FLAT: fix auto-stack sizing
  linux-user: decode MAP_{UNINITIALIZED,EXECUTABLE} in strace
  linux-user: add ppoll syscall support
  linux-user/elfload: add FDPIC support
  linux-user: fix sizeof handling for getsockopt
  linux-user: Fix possible realloc memory leak
  linux-user: Add support for -version option

13 years agotarget-arm: implement vsli.64, vsri.64
Christophe Lyon [Tue, 8 Feb 2011 17:39:02 +0000 (18:39 +0100)]
target-arm: implement vsli.64, vsri.64

Signed-off-by: Christophe Lyon <christophe.lyon@st.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-arm: fix VSHLL Neon instruction.
Christophe Lyon [Wed, 9 Feb 2011 12:19:15 +0000 (13:19 +0100)]
target-arm: fix VSHLL Neon instruction.

Fix bit mask used when widening the result of shift on narrow input.

Signed-off-by: Christophe Lyon <christophe.lyon@st.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years ago[PATCH] [MIPS] Clear softfpu exception state for round, trunc, ceil and floor
Chris Dearman [Wed, 9 Feb 2011 03:03:30 +0000 (19:03 -0800)]
[PATCH] [MIPS] Clear softfpu exception state for round, trunc, ceil and floor

MIPS FPU instructions should start with a clean softfpu status. This
is done for the arithmetic operations and cvt instructions, but not
for round, trunc, ceil and floor.

Signed-off-by: Chris Dearman <chris@mips.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-arm: Fix 32 bit signed saturating narrow
Peter Maydell [Wed, 9 Feb 2011 15:42:33 +0000 (15:42 +0000)]
target-arm: Fix 32 bit signed saturating narrow

The returned value when doing saturating signed 64->32 bit
conversion of a negative number was incorrect due to a missing cast.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-arm: Fix VQMOVUN Neon instruction.
Juha Riihimäki [Wed, 9 Feb 2011 15:42:32 +0000 (15:42 +0000)]
target-arm: Fix VQMOVUN Neon instruction.

VQMOVUN does a signed-to-unsigned saturating conversion. This is
different from both the signed-to-signed and unsigned-to-unsigned
conversions already implemented, so we need a new set of helper
functions (neon_unarrow_sat*).

Signed-off-by: Juha Riihimäki <juha.riihimaki@nokia.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agolinux-user: fix for loopmount ioctl
Martin Mohring [Tue, 8 Feb 2011 12:48:56 +0000 (14:48 +0200)]
linux-user: fix for loopmount ioctl

In case a chrooted build uses XEN or KVM, a looped mount needs to be done to setup the chroot.
The ioctl for loop mount works correctly for arm, mips, ppc32 and sh4, so its now activated.

Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
13 years agolinux-user: fix build errors for mmap2-only ports
Mike Frysinger [Mon, 7 Feb 2011 06:05:57 +0000 (01:05 -0500)]
linux-user: fix build errors for mmap2-only ports

The current print_mmap func is only enabled when the target supports the
mmap syscall, but both mmap and mmap2 syscalls use it.  This leads to a
build failure when the target supports mmap2 but not mmap.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
13 years agouser: speed up init_paths a bit
Mike Frysinger [Mon, 7 Feb 2011 06:05:56 +0000 (01:05 -0500)]
user: speed up init_paths a bit

The current init_paths code will attempt to opendir() every single file it
finds.  This can obviously generated a huge number of syscalls with even a
moderately small sysroot that will fail.  Since the readdir() call provides
the file type in the struct itself, use it.  On my system, this prevents
over 1000 syscalls from being made at every invocation of a target binary,
and I only have a C library installed.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
13 years agolinux-user: implement sched_{g,s}etaffinity
Mike Frysinger [Mon, 7 Feb 2011 06:05:55 +0000 (01:05 -0500)]
linux-user: implement sched_{g,s}etaffinity

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
13 years agolinux-user/FLAT: allow targets to override FLAT processing
Mike Frysinger [Mon, 7 Feb 2011 06:05:54 +0000 (01:05 -0500)]
linux-user/FLAT: allow targets to override FLAT processing

This brings flatload.c more in line with the current Linux FLAT loader
which allows targets to handle various FLAT aspects in their own way.
For the common behavior, the new functions get stubbed out.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
13 years agolinux-user/FLAT: fix auto-stack sizing
Mike Frysinger [Mon, 7 Feb 2011 06:05:53 +0000 (01:05 -0500)]
linux-user/FLAT: fix auto-stack sizing

The current auto-stack sizing works like it does on a NOMMU system; the
problem is that this only works if the envp/argv arrays are fairly slim.
On a desktop system, this is rarely the case, and can easily blow past
the stack and into data/text regions as the default stack for FLAT progs
is a mere 4KiB.  So rather than rely on the NOMMU calculation (which is
only there because NOMMU can't easily allocate gobs of contiguous mem),
calc the full space actually needed and let the MMU host make space.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
13 years agolinux-user: decode MAP_{UNINITIALIZED,EXECUTABLE} in strace
Mike Frysinger [Mon, 7 Feb 2011 06:05:52 +0000 (01:05 -0500)]
linux-user: decode MAP_{UNINITIALIZED,EXECUTABLE} in strace

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
13 years agolinux-user: add ppoll syscall support
Mike Frysinger [Mon, 7 Feb 2011 06:05:51 +0000 (01:05 -0500)]
linux-user: add ppoll syscall support

Some architectures (like Blackfin) only implement ppoll (and skip poll).
So add support for it using existing poll code.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
13 years agolinux-user/elfload: add FDPIC support
Mike Frysinger [Mon, 7 Feb 2011 06:05:50 +0000 (01:05 -0500)]
linux-user/elfload: add FDPIC support

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
13 years agolinux-user: fix sizeof handling for getsockopt
Mike Frysinger [Mon, 7 Feb 2011 06:05:49 +0000 (01:05 -0500)]
linux-user: fix sizeof handling for getsockopt

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
13 years agolinux-user: Fix possible realloc memory leak
Stefan Weil [Mon, 17 Jan 2011 20:36:06 +0000 (21:36 +0100)]
linux-user: Fix possible realloc memory leak

Extract from "man realloc":
"If realloc() fails the original block is left untouched;
it is not freed or moved."

Fix a possible memory leak (reported by cppcheck).

Cc: Riku Voipio <riku.voipio@iki.fi>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
13 years agolinux-user: Add support for -version option
Peter Maydell [Thu, 20 Jan 2011 03:28:02 +0000 (03:28 +0000)]
linux-user: Add support for -version option

Add support to the linux-user qemu for the -version command line
option, bringing it into line with the system emulation qemu.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
13 years agocris, microblaze: use cpu_has_work
Paolo Bonzini [Tue, 8 Feb 2011 17:18:19 +0000 (18:18 +0100)]
cris, microblaze: use cpu_has_work

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
13 years agox86: Fix MCA broadcast parameters for TCG case
Jan Kiszka [Fri, 4 Feb 2011 15:47:25 +0000 (13:47 -0200)]
x86: Fix MCA broadcast parameters for TCG case

When broadcasting MCEs, we need to set MCIP and RIPV in mcg_status like
it is done for KVM. Use the symbolic constants at this chance.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agoqemu-timer: Fix compilation of new timer code for w32, w64
Stefan Weil [Fri, 4 Feb 2011 21:01:32 +0000 (22:01 +0100)]
qemu-timer: Fix compilation of new timer code for w32, w64

qemu_next_alarm_deadline() is needed by MinGW, too.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Anthony Liguori <aliguori@us.ibm.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agoblock: enable in_use flag
Marcelo Tosatti [Wed, 26 Jan 2011 14:12:35 +0000 (12:12 -0200)]
block: enable in_use flag

Set block device in use during block migration, disallow drive_del and
bdrv_truncate for in use devices.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoAdd flag to indicate external users to block device
Marcelo Tosatti [Wed, 26 Jan 2011 14:12:34 +0000 (12:12 -0200)]
Add flag to indicate external users to block device

Certain operations such as drive_del or resize cannot be performed
while external users (eg. block migration) reference the block device.

Add a flag to indicate that.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblock-migration: add reference to target DriveInfo
Marcelo Tosatti [Wed, 26 Jan 2011 14:12:33 +0000 (12:12 -0200)]
block-migration: add reference to target DriveInfo

So that ejection of attached device by guest does not free data
in use by block migration instance.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
CC: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblockdev: add refcount to DriveInfo
Marcelo Tosatti [Wed, 26 Jan 2011 14:12:32 +0000 (12:12 -0200)]
blockdev: add refcount to DriveInfo

The host part of a block device can be deleted with in progress
block migration.

To fix this, add a reference count to DriveInfo, freeing resources
on last reference.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
CC: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblock-migration: actually disable dirty tracking on cleanup
Marcelo Tosatti [Wed, 26 Jan 2011 14:12:31 +0000 (12:12 -0200)]
block-migration: actually disable dirty tracking on cleanup

Call to set_dirty_tracking() is misplaced.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoahci: make number of ports runtime determined
Alexander Graf [Tue, 1 Feb 2011 14:51:31 +0000 (15:51 +0100)]
ahci: make number of ports runtime determined

Different AHCI controllers have a different number of ports, so the core
shouldn't care about the amount of ports available.

This patch makes the number of ports available to the AHCI core runtime
configurable, allowing us to have multiple different AHCI implementations
with different amounts of ports.

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoahci: Implement HBA reset
Alexander Graf [Tue, 1 Feb 2011 14:51:30 +0000 (15:51 +0100)]
ahci: Implement HBA reset

The ahci code was missing its soft reset functionality. This wasn't really an
issue for Linux guests, but Windows gets confused when the controller doesn't
reset when it tells it so.

Using this patch I can now successfully boot Windows 7 from AHCI using AHCI
enabled SeaBIOS.

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoahci: send init d2h fis on fis enable
Alexander Graf [Tue, 1 Feb 2011 14:51:29 +0000 (15:51 +0100)]
ahci: send init d2h fis on fis enable

The drive sends a d2h init fis on initialization. Usually, the guest doesn't
receive fises yet at that point though, so the delivery is deferred.

Let's reflect that by sending the init fis on fis receive enablement.

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoahci: split ICH and AHCI even more
Alexander Graf [Tue, 1 Feb 2011 14:51:28 +0000 (15:51 +0100)]
ahci: split ICH and AHCI even more

Sebastian's patch already did a pretty good job at splitting up ICH-9
AHCI code and the AHCI core. We need some more though. Copyright was missing,
the lspci dump belongs to ICH-9, we don't need the AHCI core to have its
own qdev device duplicate.

So let's split them a bit more in this patch, making things easier to
read an understand.

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoahci: add license header in ahci.h
Alexander Graf [Tue, 1 Feb 2011 14:51:27 +0000 (15:51 +0100)]
ahci: add license header in ahci.h

Due to popular request, this patch adds a license header to ahci.h

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoahci: split ICH9 from core
Sebastian Herbszt [Tue, 1 Feb 2011 14:51:26 +0000 (15:51 +0100)]
ahci: split ICH9 from core

There are multiple ahci devices out there. The currently implemented ich-9
is only one of the many. So let's split that one out into a separate file
to stress the difference.

Signed-off-by: Sebastian Herbszt <herbszt@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblock/vdi: Fix wrong size in conditionally used memset, memcmp
Stefan Weil [Fri, 4 Feb 2011 20:01:16 +0000 (21:01 +0100)]
block/vdi: Fix wrong size in conditionally used memset, memcmp

Error report from cppcheck:
block/vdi.c:122: error: Using sizeof for array given as function argument returns the size of pointer.
block/vdi.c:128: error: Using sizeof for array given as function argument returns the size of pointer.

Fix both by setting the correct size.

The buggy code is only used when QEMU is build without uuid support.
The bug is not critical, so there is no urgent need to apply it to
old versions of QEMU.

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 agoDocumentation: add Sheepdog disk images
MORITA Kazutaka [Mon, 7 Feb 2011 07:04:04 +0000 (16:04 +0900)]
Documentation: add Sheepdog disk images

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoqcow2: Really use cache=unsafe for image creation
Kevin Wolf [Thu, 27 Jan 2011 15:46:01 +0000 (16:46 +0100)]
qcow2: Really use cache=unsafe for image creation

For cache=unsafe we also need to set BDRV_O_CACHE_WB, otherwise we have some
strange unsafe writethrough mode.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agocheckpatch.pl: don't complain about old lines with tabs
Blue Swirl [Sat, 5 Feb 2011 13:18:20 +0000 (13:18 +0000)]
checkpatch.pl: don't complain about old lines with tabs

Don't complain when the patch includes lines with tabs
only in the hunk's untouched context.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agotarget-arm: Fix decoding of Thumb preload and hint space
Peter Maydell [Thu, 3 Feb 2011 19:43:25 +0000 (19:43 +0000)]
target-arm: Fix decoding of Thumb preload and hint space

Refine the decoding of the Thumb preload and hint space, so we
UNDEF on the patterns that are supposed to UNDEF rather than NOP.
We also move the tests for this space earlier, so we don't emit
harmless but unnecessary address generation code for preload
hints (which by their nature are likely to be in hot code paths).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-arm: Fix decoding of preload and memory hint space
Peter Maydell [Thu, 3 Feb 2011 19:43:24 +0000 (19:43 +0000)]
target-arm: Fix decoding of preload and memory hint space

Correct the decoding of the ARM preload and memory hint space,
by adding decoding of PLI, PLDW and the v7MP unallocated hint
space. This commit also corrects a slightly overexuberant
decoding of PLD(register) which was not checking that bit 4
was one.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-arm: Clean up handling of MPIDR
Peter Maydell [Thu, 3 Feb 2011 19:43:23 +0000 (19:43 +0000)]
target-arm: Clean up handling of MPIDR

The ARM cp15 register 0,c0,c0,5 is standardised in the v7 architecture
as the MPIDR. Clean up its implementation to remove A9 specific handling.

This commit includes fixing an error in the value returned for the
MPIDR on A9, where we were erroneously claiming a cluster ID of 9.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-arm: Add CPU feature flag for v7MP
Peter Maydell [Thu, 3 Feb 2011 19:43:22 +0000 (19:43 +0000)]
target-arm: Add CPU feature flag for v7MP

Add a CPU feature flag for v7MP (the multiprocessing extensions); some
instructions exist only for v7MP and not for the base v7 architecture.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agodo not pass NULL to strdup.
Gleb Natapov [Wed, 2 Feb 2011 15:34:34 +0000 (17:34 +0200)]
do not pass NULL to strdup.

Also use qemu_strdup() instead of strdup() in bootindex code.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agoSet the right overflow bit for neon 32 and 64 bit saturating add/sub.
Christophe Lyon [Fri, 4 Feb 2011 14:17:51 +0000 (15:17 +0100)]
Set the right overflow bit for neon 32 and 64 bit saturating add/sub.

Signed-off-by: Christophe Lyon <christophe.lyon@st.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-arm: Fix Neon vsra instructions.
Christophe Lyon [Tue, 25 Jan 2011 17:18:08 +0000 (18:18 +0100)]
target-arm: Fix Neon vsra instructions.

This patch fixes the errors reported by my tests in VSRA.

Signed-off-by: Christophe Lyon <christophe.lyon@st.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-sh4: fix negc
Aurelien Jarno [Fri, 4 Feb 2011 19:19:33 +0000 (20:19 +0100)]
target-sh4: fix negc

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agoioapic: Style & magics cleanup
Jan Kiszka [Thu, 3 Feb 2011 21:54:14 +0000 (22:54 +0100)]
ioapic: Style & magics cleanup

Fix a few style issues and convert magic numbers into prober symbolic
constants, also fixing the wrong but unused IOAPIC_DM_SIPI value.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoioapic: Add support for qemu-kvm's vmstate v2
Jan Kiszka [Thu, 3 Feb 2011 21:54:13 +0000 (22:54 +0100)]
ioapic: Add support for qemu-kvm's vmstate v2

qemu-kvm carries the IOAPIC base address in its v2 vmstate. We only
support the default base address so far, and saving even that in the
device state was rejected.

Add a padding field to be able to read qemu-kvm's old state, but
increase our version to 3, indicating that we are not saving a valid
address. This also gives downstream the chance to change to stop
evaluating the base_address and move to v3 as well.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoioapic: Save/restore irr
Jan Kiszka [Thu, 3 Feb 2011 21:54:12 +0000 (22:54 +0100)]
ioapic: Save/restore irr

This is a guest modifiable state that must be saved/restored properly.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoioapic: Implement EOI handling for level-triggered IRQs
Jan Kiszka [Thu, 3 Feb 2011 21:54:11 +0000 (22:54 +0100)]
ioapic: Implement EOI handling for level-triggered IRQs

Add the missing EOI broadcast from local APIC to the IOAPICs on
completion of level-triggered IRQs. This ensures that a still asserted
IRQ source properly re-triggers an APIC IRQ.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agovnc: qemu can die if the client is disconnected while updating screen
Corentin Chary [Fri, 4 Feb 2011 08:05:53 +0000 (09:05 +0100)]
vnc: qemu can die if the client is disconnected while updating screen

agraf reported that qemu_mutex_destroy(vs->output_mutex) while failing
in vnc_disconnect_finish().

It's because vnc_worker_thread_loop() tries to unlock the mutex while
not locked. The unlocking call doesn't fail (pthread bug ?), but
the destroy call does.

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agovirtio-serial: Make sure virtqueue is ready before discarding data
Amit Shah [Fri, 4 Feb 2011 08:54:18 +0000 (14:24 +0530)]
virtio-serial: Make sure virtqueue is ready before discarding data

This can happen if a port gets unplugged before guest has chance to
initialise vqs.

Reported-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoui/sdl: Fix handling of caps lock and num lock keys
Stefan Weil [Thu, 3 Feb 2011 21:35:07 +0000 (22:35 +0100)]
ui/sdl: Fix handling of caps lock and num lock keys

Starting with SDL version 1.2.14, caps lock and num lock keys
will send a SDL_KEYUP when SDL_DISABLE_LOCK_KEYS=1 is set in
the environment.

The new code sets the environment unconditionally
(it won't harm old versions which do not know it).

The workaround for SDL_KEYUP is only compiled with old SDL versions.

A similar patch without handling of old SDL versions was already
published by Benjamin Drung for Ubuntu.

Cc: Anthony Liguori <aliguori@us.ibm.com>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Benjamin Drung <benjamin.drung@gmail.com>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoUnify alarm deadline computation
Paolo Bonzini [Thu, 3 Feb 2011 13:49:01 +0000 (14:49 +0100)]
Unify alarm deadline computation

This patch shows how using the correct formula for
qemu_next_deadline_dyntick can simplify the code of
host_alarm_handler and eliminate useless duplication.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoCorrect alarm deadline computation
Paolo Bonzini [Thu, 3 Feb 2011 13:49:00 +0000 (14:49 +0100)]
Correct alarm deadline computation

When the QEMU_CLOCK_HOST clock was added, computation of its
deadline was added to qemu_next_deadline, which is correct but
incomplete.

I noticed this by reading the very convoluted rules whereby
qemu_next_deadline_dyntick is computed, which miss QEMU_CLOCK_HOST
when use_icount is true.  This patch inlines qemu_next_deadline
into qemu_next_deadline_dyntick, and then corrects the logic to skip
only QEMU_CLOCK_VIRTUAL when use_icount is true.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Cc: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agouse nanoseconds everywhere for timeout computation
Paolo Bonzini [Thu, 3 Feb 2011 13:48:59 +0000 (14:48 +0100)]
use nanoseconds everywhere for timeout computation

Suggested by Aurelien Jarno.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agosavevm: fix corruption in vmstate_subsection_load().
Yoshiaki Tamura [Thu, 3 Feb 2011 04:34:08 +0000 (13:34 +0900)]
savevm: fix corruption in vmstate_subsection_load().

Although it's rare to happen in live migration, when the head of a
byte stream contains 0x05 which is the marker of subsection, the
loader gets corrupted because vmstate_subsection_load() continues even
the device doesn't require it.  This patch adds a checker whether
subsection is needed, and skips following routines if not needed.

Signed-off-by: Yoshiaki Tamura <tamura.yoshiaki@lab.ntt.co.jp>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoOpen up the 0.15 development branch
Aurelien Jarno [Wed, 2 Feb 2011 07:39:28 +0000 (08:39 +0100)]
Open up the 0.15 development branch

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agoUpdate version for 0.14.0-rc0
Anthony Liguori [Tue, 1 Feb 2011 22:59:46 +0000 (16:59 -0600)]
Update version for 0.14.0-rc0

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoUpdate SeaBIOS to 0.6.1.2
Anthony Liguori [Tue, 1 Feb 2011 22:57:00 +0000 (16:57 -0600)]
Update SeaBIOS to 0.6.1.2

 - 06d0bdd Minor build fixes.
 - 33abfc0 Update version to 0.6.1.2.
 - 484dd56 fix virtio-blk failure after reboot
 - dd9c0d3 Update version to 0.6.1.1.
 - 50ecfa8 mark irq9 active high in DSDT

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agovhost: force vhost off for non-MSI guests
mst@redhat.com [Tue, 1 Feb 2011 20:13:42 +0000 (22:13 +0200)]
vhost: force vhost off for non-MSI guests

When MSI is off, each interrupt needs to be bounced through the io
thread when it's set/cleared, so vhost-net causes more context switches and
higher CPU utilization than userspace virtio which handles networking in
the same thread.

We'll need to fix this by adding level irq support in kvm irqfd,
for now disable vhost-net in these configurations.

Added a vhostforce flag to force vhost-net back on.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agotap: safe sndbuf default
Michael S. Tsirkin [Tue, 1 Feb 2011 12:25:40 +0000 (14:25 +0200)]
tap: safe sndbuf default

With current sndbuf default value, a blocked
target guest can prevent another guest from
transmitting any packets. While current
sndbuf value (1M) is reported to help some
UDP based workloads, the default should
be safe (0).

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoAdd boot index documentation.
Gleb Natapov [Sun, 30 Jan 2011 10:29:19 +0000 (12:29 +0200)]
Add boot index documentation.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoAdd bootindex handling into usb storage device.
Gleb Natapov [Sun, 30 Jan 2011 10:29:18 +0000 (12:29 +0200)]
Add bootindex handling into usb storage device.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agofix QemuOpts leak
Paolo Bonzini [Thu, 23 Dec 2010 12:42:54 +0000 (13:42 +0100)]
fix QemuOpts leak

Now that no backend's open function saves the passed QemuOpts, fix a leak
in the qemu_chr_open backwards-compatible parser.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoremove text_console_opts
Paolo Bonzini [Thu, 23 Dec 2010 12:42:53 +0000 (13:42 +0100)]
remove text_console_opts

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoadd set_echo implementation for text consoles
Paolo Bonzini [Thu, 23 Dec 2010 12:42:52 +0000 (13:42 +0100)]
add set_echo implementation for text consoles

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agocreate TextConsole together with the CharDeviceState
Paolo Bonzini [Thu, 23 Dec 2010 12:42:51 +0000 (13:42 +0100)]
create TextConsole together with the CharDeviceState

A nicer solution would be to get rid of the opaque pointer and
use containment, but it would also be a much bigger patch.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoadd set_echo implementation for qemu_chr_stdio
Paolo Bonzini [Thu, 23 Dec 2010 12:42:50 +0000 (13:42 +0100)]
add set_echo implementation for qemu_chr_stdio

This also requires moving QemuOpts out of term_init.

Clearing ISIG is independent of whether echo is enabled or disabled.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agomove atexit(term_exit) and O_NONBLOCK to qemu_chr_open_stdio
Paolo Bonzini [Thu, 23 Dec 2010 12:42:49 +0000 (13:42 +0100)]
move atexit(term_exit) and O_NONBLOCK to qemu_chr_open_stdio

In the next patch, term_init will be changed to enable or disable
echo at will.  Move extraneous stuff out of it.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoadd qemu_chr_set_echo
Paolo Bonzini [Thu, 23 Dec 2010 12:42:48 +0000 (13:42 +0100)]
add qemu_chr_set_echo

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoremove broken code for tty
Paolo Bonzini [Thu, 23 Dec 2010 12:42:47 +0000 (13:42 +0100)]
remove broken code for tty

This code is taking the settings for a serial port and moving it to
fd 0 when qemu exits.  This is likely just cut-and-paste, rip it.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoMerge remote branch 'qemu-kvm/uq/master' into staging
Anthony Liguori [Tue, 1 Feb 2011 21:23:24 +0000 (15:23 -0600)]
Merge remote branch 'qemu-kvm/uq/master' into staging

aliguori: fix build with !defined(KVM_CAP_ASYNC_PF)

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoMerge remote branch 'spice/spice.v29.pull' into staging
Anthony Liguori [Tue, 1 Feb 2011 21:22:48 +0000 (15:22 -0600)]
Merge remote branch 'spice/spice.v29.pull' into staging

Conflicts:
trace-events

13 years agoMerge remote branch 'spice/usb.5' into staging
Anthony Liguori [Tue, 1 Feb 2011 21:21:23 +0000 (15:21 -0600)]
Merge remote branch 'spice/usb.5' into staging

13 years agoMerge remote branch 'amit/for-anthony' into staging
Anthony Liguori [Tue, 1 Feb 2011 21:20:56 +0000 (15:20 -0600)]
Merge remote branch 'amit/for-anthony' into staging

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Watch this:

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

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

drive_init() behaves as follows:

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

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

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

Of its three callers:

* drive_init_func() is correct.

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

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

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

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

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

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

We silently ignore multiple definitions for the same drive:

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

With if=none, this can become quite confusing:

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

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

Make multiple drive definitions fail cleanly.

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

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

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

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

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

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

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

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

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

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

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

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

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>