]> git.proxmox.com Git - qemu.git/log
qemu.git
12 years agoqemu-tls.h: Add abstraction layer for TLS variables
Peter Maydell [Fri, 28 Oct 2011 09:52:40 +0000 (10:52 +0100)]
qemu-tls.h: Add abstraction layer for TLS variables

Add an abstraction layer for defining and using thread-local
variables. For the moment this is implemented only for Linux,
which means they can only be used in restricted circumstances.
The abstraction layer allows us to add POSIX and Win32 support
later.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoError check find_ram_offset
Alex Williamson [Mon, 31 Oct 2011 14:54:09 +0000 (08:54 -0600)]
Error check find_ram_offset

Spotted via code review, we initialize offset to 0 to avoid a
compiler warning, but in the unlikely case that offset is
never set to something else, we should abort instead of return
a value that will almost certainly cause problems.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agousb-host: fix host close
Gerd Hoffmann [Fri, 28 Oct 2011 14:13:50 +0000 (16:13 +0200)]
usb-host: fix host close

The whole usb_host_close() function is skipped in case the device is not
in attached state.  This is wrong though, only then usb_device_detach()
must be skipped, all other cleanup (especially device reset and closing
the file handle) still needs to be done.  There are code paths where
usb_host_close() is called with the device in detached state already.

This fixes usb-host devices not being released and returned to the host
after removing them with device_del.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agousb: change VID/PID for usb-hub and usb-msd to prevent conflict
Roy Tam [Thu, 15 Sep 2011 03:25:47 +0000 (11:25 +0800)]
usb: change VID/PID for usb-hub and usb-msd to prevent conflict

Some USB drivers, for example USBASPI.SYS, will skip different type of
device which has same VID/PID. The following patch helps preventing
usb-msd being skipped by the driver.

Signed-off-by: Roy Tam <roytam@gmail.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agoSupport running QEMU on Valgrind
Stefan Weil [Mon, 31 Oct 2011 20:29:46 +0000 (21:29 +0100)]
Support running QEMU on Valgrind

Valgrind is a tool which can automatically detect many kinds of bugs.

Running QEMU on Valgrind with x86_64 hosts was not possible because
Valgrind aborts when memalign is called with an alignment larger than
1 MiB. QEMU normally uses 2 MiB on Linux x86_64.

Now the alignment is reduced to the page size when QEMU is running on
Valgrind.

v2:
Instead of using the macro RUNNING_ON_VALGRIND from valgrind.h,
the patch now uses a hack from libvirt which tests for the pre-loaded
vgpreload_*.so shared libraries. This avoids the need for valgrind.h.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoMAINTAINERS: Add PReP maintainer
Andreas Färber [Mon, 31 Oct 2011 23:03:07 +0000 (00:03 +0100)]
MAINTAINERS: Add PReP maintainer

Officially take on maintainership for PReP and upgrade to Odd Fixes.

Acked-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
Cc: Alexander Graf <agraf@suse.de>
Cc: Hervé Poussineau <hpoussin@reactos.org>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agotrace: Add wildcard trace event support
Mark Wu [Mon, 31 Oct 2011 03:29:04 +0000 (11:29 +0800)]
trace: Add wildcard trace event support

A basic wildcard matching is supported in both the monitor command
"trace-event" and the events list file. That means you can enable/disable
the events having a common prefix in a batch. For example, virtio-blk trace
events could be enabled using:
    trace-event virtio_blk_* on

Signed-off-by: Mark Wu <wudxw@linux.vnet.ibm.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agousb-hub: wakeup on attach
Gerd Hoffmann [Fri, 14 Oct 2011 09:36:43 +0000 (11:36 +0200)]
usb-hub: wakeup on attach

When attaching a new device we must send a wakeup request to the root
hub, otherwise the guest will not notice the new device in case the
usb hub is suspended.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agoqxl: create slots on post_load in vga state
Alon Levy [Tue, 25 Oct 2011 13:39:50 +0000 (15:39 +0200)]
qxl: create slots on post_load in vga state

RHBZ 740547

If we migrate when the device is in vga state the guest
still believes the slots are created, and will cause operations
that reference the slots, causing a "panic: virtual address out of range"
on the first of them. Easy to see by migrating in vga mode with
a driver loaded, for instance windows cmd window in full screen mode,
and then exiting vga mode back to native mode will cause said panic.

Fixed by doing the slot recreation in post_load for vga mode as well.
Note that compat does not require any changes because it creates it's
only slot by a side effect of QXL_IO_SET_MODE.

Signed-off-by: Alon Levy <alevy@redhat.com>
12 years agoqxl: make sure we continue to run with a shared buffer
Gerd Hoffmann [Fri, 21 Oct 2011 19:53:54 +0000 (21:53 +0200)]
qxl: make sure we continue to run with a shared buffer

The qxl renderer works only with a shared displaysurface.  So better
make sure we actually have one and restore it when needed.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agoqxl: stride fixup
Gerd Hoffmann [Fri, 21 Oct 2011 13:59:07 +0000 (15:59 +0200)]
qxl: stride fixup

spice uses negative stride value to signal the bitmap is upside down.
The qxl renderer (used for scl, vnc and screenshots) wants a positive
value because it is easier to work with.  The positive value is then
stored in the very same variable, which has the drawback that the
upside-down test works only once.  Fix by using two variables.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agoacl: Fix use after free in qemu_acl_reset()
Markus Armbruster [Fri, 28 Oct 2011 15:07:02 +0000 (17:07 +0200)]
acl: Fix use after free in qemu_acl_reset()

Reproducer:

    $ MALLOC_PERTURB_=234 qemu-system-x86_64 -vnc :0,acl,sasl [...]
    QEMU 0.15.50 monitor - type 'help' for more information
    (qemu) acl_add vnc.username fred allow
    acl: added rule at position 1
    (qemu) acl_reset vnc.username
    Segmentation fault (core dumped)

Spotted by Coverity.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agoqapi: fix typos in documentation JSON examples
Stefan Hajnoczi [Fri, 28 Oct 2011 14:58:26 +0000 (15:58 +0100)]
qapi: fix typos in documentation JSON examples

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agosysbus: Supply missing va_end()
Markus Armbruster [Fri, 28 Oct 2011 08:52:25 +0000 (10:52 +0200)]
sysbus: Supply missing va_end()

C99 7.15.1: Each invocation of the va_start and va_copy macros shall
be matched by a corresponding invocation of the va_end macro in the
same function.

Spotted by Coverity.  Harmless on the (common) systems where va_end()
does nothing.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agonet: tap-linux: Fix unhelpful error message
Luiz Capitulino [Fri, 14 Oct 2011 18:05:10 +0000 (15:05 -0300)]
net: tap-linux: Fix unhelpful error message

I'm getting:

    could not configure /dev/net/tun (tap%d): Operation not permitted

When the ioctl() fails, ifr.ifr_name will most likely not be overwritten.
So we better only use it when ifname contains a string.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agotcg: Add tcg interpreter to configure / make
Stefan Weil [Wed, 19 Oct 2011 05:07:18 +0000 (07:07 +0200)]
tcg: Add tcg interpreter to configure / make

Signed-off-by: Stefan Weil <sw@weilnetz.de>
12 years agotcg: Add tci disassembler
Stefan Weil [Wed, 5 Oct 2011 18:03:53 +0000 (20:03 +0200)]
tcg: Add tci disassembler

Signed-off-by: Stefan Weil <sw@weilnetz.de>
12 years agotcg: Add interpreter for bytecode
Stefan Weil [Tue, 27 Sep 2011 04:30:58 +0000 (06:30 +0200)]
tcg: Add interpreter for bytecode

Signed-off-by: Stefan Weil <sw@weilnetz.de>
12 years agotcg: Add bytecode generator for tcg interpreter
Stefan Weil [Wed, 5 Oct 2011 18:03:02 +0000 (20:03 +0200)]
tcg: Add bytecode generator for tcg interpreter

Unlike other tcg target code generators, this one does not generate
machine code for some cpu. It generates machine independent bytecode
which is interpreted later.

This allows running QEMU on any host.

Interpreted bytecode is slower than direct execution of generated
machine code.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
12 years agotcg: Make ARRAY_SIZE(tcg_op_defs) globally available
Stefan Weil [Thu, 29 Sep 2011 16:33:21 +0000 (18:33 +0200)]
tcg: Make ARRAY_SIZE(tcg_op_defs) globally available

tcg_op_defs was already a global array.

The tci disassembler also needs ARRAY_SIZE(tcg_op_defs),
so add a new global constant with this value.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
12 years agotcg: TCG targets may define tcg_qemu_tb_exec
Stefan Weil [Fri, 30 Sep 2011 19:23:06 +0000 (21:23 +0200)]
tcg: TCG targets may define tcg_qemu_tb_exec

Targets may use a non standard definition of tcg_tb_exec
by defining this macro in their tcg_target.h.

This is used here by ppc. It will be used by the TCG interpreter, too.

Cc: malc <av1474@comtv.ru>
Signed-off-by: Stefan Weil <sw@weilnetz.de>
12 years agoMerge remote-tracking branch 'riku/linux-user-for-upstream' into staging
Anthony Liguori [Mon, 31 Oct 2011 20:05:40 +0000 (15:05 -0500)]
Merge remote-tracking branch 'riku/linux-user-for-upstream' into staging

12 years agoMerge remote-tracking branch 'kwolf/for-anthony' into staging
Anthony Liguori [Mon, 31 Oct 2011 16:09:00 +0000 (11:09 -0500)]
Merge remote-tracking branch 'kwolf/for-anthony' into staging

Conflicts:
block/vmdk.c

12 years agoMerge remote-tracking branch 'aneesh/for-upstream-7' into staging
Anthony Liguori [Mon, 31 Oct 2011 16:06:02 +0000 (11:06 -0500)]
Merge remote-tracking branch 'aneesh/for-upstream-7' into staging

12 years agoMerge remote-tracking branch 'qmp/queue/qmp' into staging
Anthony Liguori [Mon, 31 Oct 2011 16:02:29 +0000 (11:02 -0500)]
Merge remote-tracking branch 'qmp/queue/qmp' into staging

Conflicts:
ui/spice-core.c

12 years agoMerge remote-tracking branch 'qemu-kvm-tmp/uq/master' into staging
Anthony Liguori [Mon, 31 Oct 2011 16:00:27 +0000 (11:00 -0500)]
Merge remote-tracking branch 'qemu-kvm-tmp/uq/master' into staging

12 years agoMerge remote-tracking branch 'stefanha/trivial-patches' into staging
Anthony Liguori [Mon, 31 Oct 2011 15:23:15 +0000 (10:23 -0500)]
Merge remote-tracking branch 'stefanha/trivial-patches' into staging

12 years agoMerge remote-tracking branch 'alon/pull-libcacard-assert' into staging
Anthony Liguori [Mon, 31 Oct 2011 15:14:06 +0000 (10:14 -0500)]
Merge remote-tracking branch 'alon/pull-libcacard-assert' into staging

12 years agoMerge remote-tracking branch 'spice/spice.v45' into staging
Anthony Liguori [Mon, 31 Oct 2011 15:12:14 +0000 (10:12 -0500)]
Merge remote-tracking branch 'spice/spice.v45' into staging

12 years agohw/9pfs: Replace rwlocks with RCU variants of interfaces.
Harsh Prateek Bora [Thu, 13 Oct 2011 20:35:02 +0000 (02:05 +0530)]
hw/9pfs: Replace rwlocks with RCU variants of interfaces.

Use QLIST_INSERT_HEAD_RCU and rcu_read_lock/unlock instead of rwlocks.
Use v9fs_synth_mutex as a write-only mutex to handle concurrent writers.

Signed-off-by: Harsh Prateek Bora <harsh@linux.vnet.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
12 years agoqemu-queue: Introduce QLIST_INSERT_HEAD_RCU and dummy RCU wrappers.
Harsh Prateek Bora [Tue, 25 Oct 2011 06:40:40 +0000 (12:10 +0530)]
qemu-queue: Introduce QLIST_INSERT_HEAD_RCU and dummy RCU wrappers.

SynthFS needs a QLIST_INSERT_HEAD_RCU to make sure list instructions are not
re-ordered and therefore avoiding a crash. There may be parallel readers which
should be allowed for lock-free access and this variant allows us to get rid
of rwlocks used by readers.

SynthFS is a special case where we dont really need full RCU capabilities as
it doesnt allow list entry deletion but concurrent readers/writers and
instruction re-ordering should not result in a crash.

Also, once the real rcu is available, dummy rcu macro definitions will go away
and the code will still work as expected.

This patchwork is based on inputs from Paolo Bonzini.

Signed-off-by: Harsh Prateek Bora <harsh@linux.vnet.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
12 years agohw/9pfs: Add synthetic file system support using 9p
Aneesh Kumar K.V [Tue, 25 Oct 2011 06:40:40 +0000 (12:10 +0530)]
hw/9pfs: Add synthetic file system support using 9p

This patch create a synthetic file system with mount tag
v_synth when -virtfs_synth command line option is specified
in qemu. The synthetic file system can be mounted in guest
using 9p using the below command line

mount -t 9p -oversion=9p2000.L,trans=virtio v_synth  <mountpint>

Synthetic file system enabled different qemu subsystem to register
callbacks for read and write events from guest. The subsystem
can create directories and files in the synthetic file system as show
in ex below

    qemu_v9fs_synth_mkdir(NULL, 0777, "test2", &node);
    qemu_v9fs_synth_add_file(node, 0777, "testfile",
                             my_test_read, NULL, NULL);

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
12 years agohw/9pfs: Abstract open state of fid to V9fsFidOpenState
Aneesh Kumar K.V [Tue, 25 Oct 2011 06:40:40 +0000 (12:10 +0530)]
hw/9pfs: Abstract open state of fid to V9fsFidOpenState

To implement synthetic file system in Qemu we may not really
require file descriptor and Dir *. Make generic code use
V9fsFidOpenState instead.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
12 years agohw/9pfs: Read-only support for 9p export
M. Mohan Kumar [Tue, 25 Oct 2011 06:40:39 +0000 (12:10 +0530)]
hw/9pfs: Read-only support for 9p export

A new fsdev parameter "readonly" is introduced to control accessing 9p export.
"readonly" can be used to specify the access type. By default "rw" access
is given to 9p export.

Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
12 years agoqemu: Add opt_set_bool functionality
M. Mohan Kumar [Tue, 25 Oct 2011 06:40:39 +0000 (12:10 +0530)]
qemu: Add opt_set_bool functionality

Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
12 years agoconfigure: Update configure so that open_by_handle_at check returns correct value
Aneesh Kumar K.V [Tue, 25 Oct 2011 06:40:39 +0000 (12:10 +0530)]
configure: Update configure so that open_by_handle_at check returns correct value

According to David Gibson for some compiler/libc combinations, open_by_handle_at
test in configure isn't quite right: because the file_handle pointer is never
dereferenced, gcc doesn't complain even if it is undefined. Change the test
as suggested by him.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
12 years agohw/9pfs: Fix error handling in local_mknod
Aneesh Kumar K.V [Tue, 25 Oct 2011 06:40:39 +0000 (12:10 +0530)]
hw/9pfs: Fix error handling in local_mknod

Update local_chown to remove unnecessary if loop

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
12 years agohw/vexpress.c, hw/realview.c: Add PL041 to VExpress, Realview boards
Peter Maydell [Fri, 28 Oct 2011 09:55:38 +0000 (10:55 +0100)]
hw/vexpress.c, hw/realview.c: Add PL041 to VExpress, Realview boards

Instantiate the PL041 audio on the Versatile Express and
Realview board models.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
12 years agoAdd AACI audio playback support to the ARM Versatile/PB platform
Mathieu Sonet [Fri, 28 Oct 2011 09:55:37 +0000 (10:55 +0100)]
Add AACI audio playback support to the ARM Versatile/PB platform

This driver emulates the ARM AACI interface (PL041) connected to a LM4549 codec.
It enables audio playback for the Versatile/PB platform.

Limitations:
- Supports only a playback on one channel (Versatile/Vexpress)
- Supports only one TX FIFO in compact-mode or non-compact mode.
- Supports playback of 12, 16, 18 and 20 bits samples.
- Record is not supported.
- The PL041 is hardwired to a LM4549 codec.

Versatile/PB test build:
linux-2.6.38.5
buildroot-2010.11
alsa-lib-1.0.22
alsa-utils-1.0.22
mpg123-0.66

Qemu host: Ubuntu 10.04 in Vmware/OS X

Playback tested successfully with speaker-test/aplay/mpg123.

Signed-off-by: Mathieu Sonet <contact@elasticsheep.com>
[Peter Maydell: fixed typo in code clearing SL1RXBUSY/SL2RXBUSY
 bits, as spotted by Andrzej Zaborowski]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
12 years agopseries: Add partial support for PCI
David Gibson [Sun, 30 Oct 2011 17:16:46 +0000 (17:16 +0000)]
pseries: Add partial support for PCI

This patch adds a PCI bus to the pseries machine.  This instantiates
the qemu generic PCI bus code, advertises a PCI host bridge in the
guest's device tree and implements the RTAS methods specified by PAPR
to access PCI config space.  It also sets up the memory regions we
need to provide windows into the PCI memory and IO space, and
advertises those to the guest.

However, because qemu can't yet emulate an IOMMU, which is mandatory on
pseries, PCI devices which use DMA (i.e. most of them) will not work with
this code alone.  Still, this is enough to support the virtio_pci device
(which probably _should_ use emulated PCI DMA, but is specced to use
direct hypervisor access to guest physical memory instead).

[agraf] remove typedef which could cause compile errors

Signed-off-by: Alexey Kardashevskiy <aik@au1.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agoppc: Alter CPU state to mask out TCG unimplemented instructions as appropriate
David Gibson [Sun, 30 Oct 2011 15:51:24 +0000 (15:51 +0000)]
ppc: Alter CPU state to mask out TCG unimplemented instructions as appropriate

The CPU state contains two bitmaps, initialized from the CPU spec
which describes which instructions are implemented on the CPU.  A
couple of bits are defined which cover instructions (VSX and DFP)
which are not currently implemented in TCG.  So far, these are only
used to handle the case of -cpu host because a KVM guest can use
the instructions when the host CPU supports them.

However, it's a mild layering violation to simply not include those
bits in the CPU descriptions for those CPUs that do support them,
just because we can't handle them in TCG.  This patch corrects the
situation, so that the instruction bits _are_ shown correctly in the
cpu spec table, but are masked out from the cpu state in the non-KVM
case.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agopseries: Allow writes to KVM accelerated TCE table
David Gibson [Thu, 27 Oct 2011 15:56:31 +0000 (15:56 +0000)]
pseries: Allow writes to KVM accelerated TCE table

Sufficiently recent kernels include a KVM call to accelerate use of
PAPR TCE tables (IOMMU), which are used by PAPR virtual IO devices.
This involves qemu mapping the TCE table in from a kernel obtained fd,
which currently we do with PROT_READ only.  This is a hangover from
early (never released) versions of this kernel interface which only
permitted read-only mappings and required us to destroy and recreate
the table when we needed to clear it from qemu.

Now, the kernel permits read-write mappings, and we rely on this to
clear the table in spapr_vio_quiesce_one().  However, due to
insufficient testing, I forgot to update the actual mapping of the
table in kvmppc_create_spapr_tce() to add PROT_WRITE to the mmap().

This patch corrects the oversight.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agoKVM: PPC: Override host vmx/vsx/dfp only when information known
Alexander Graf [Mon, 24 Oct 2011 18:43:22 +0000 (20:43 +0200)]
KVM: PPC: Override host vmx/vsx/dfp only when information known

The -cpu host feature tries to find out the host capabilities based
on device tree information. However, we don't always have that available
because it's an optional property in dt.

So instead of force unsetting values depending on an unreliable source
of information, let's just try to be clever about it and not override
capabilities when we don't know the device tree pieces.

This fixes altivec with -cpu host on YDL PowerStations.

Reported-by: Nishanth Aravamudan <nacc@us.ibm.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agoppc: Fix up usermode only builds
David Gibson [Sun, 23 Oct 2011 17:25:04 +0000 (17:25 +0000)]
ppc: Fix up usermode only builds

The recent usage of MemoryRegion in kvm_ppc.h breaks builds with
CONFIG_USER_ONLY=y.  This patch fixes it.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agopseries: Correct vmx/dfp handling in both KVM and TCG cases
David Gibson [Mon, 17 Oct 2011 18:15:41 +0000 (18:15 +0000)]
pseries: Correct vmx/dfp handling in both KVM and TCG cases

Currently, when KVM is enabled, the pseries machine checks if the host
CPU supports VMX, VSX and/or DFP instructions and advertises
accordingly in the guest device tree.  It does this regardless of what
CPU is selected on the command line.  On the other hand, when in TCG
mode, it never advertises any of these facilities, even basic VMX
(Altivec) which is supported in TCG.

Now that we have a -cpu host option for ppc, it is fairly
straightforward to fix both problems.  This patch changes the -cpu
host code to override the basic cpu spec derived from the PVR with
information queried from the host avout VMX, VSX and DFP capability.
The pseries code then uses the instruction availability advertised in
the cpu state to set the guest device tree correctly for both the KVM
and TCG cases.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agoPPC: Fail configure when libfdt is not available
Alexander Graf [Tue, 18 Oct 2011 00:10:36 +0000 (02:10 +0200)]
PPC: Fail configure when libfdt is not available

We have several targets in the PPC tree now that basically require libfdt
to function properly, namely the pseries and the e500 targets. This dependency
will rather increase than decrease in the future, so I want to make sure
that people building shiny new 1.0 actually have libfdt installed to get
rid of a few ifdefs in the code.

Warning: This patch will likely make configure fail for people who don't
select their own --target-list, but don't have libfdt development packages
installed. However, we really need this new dependency to move on.

Signed-off-by: Alexander Graf <agraf@suse.de>
---

v1 -> v2:

  - no paranthesis
  - no fdt check for config_pseries
  - add . in error message

12 years agoppc: Avoid decrementer related kvm exits
David Gibson [Sun, 16 Oct 2011 19:26:17 +0000 (19:26 +0000)]
ppc: Avoid decrementer related kvm exits

In __cpu_ppc_store_decr(), we set up a regular timer used to trigger
decrementer interrupts.  This is necessary to implement the decrementer
properly under TCG, but is unnecessary under KVM (true for both Book3S-PR
and Book3S-HV KVM variants), because the kernel handles generating and
delivering decrementer exceptions.

Under kvm, in fact, the timer causes expensive and unnecessary exits from
kvm to qemu.  This patch, therefore, disables setting the timer when kvm
is in use.

Signed-off-by: Anton Blanchard <anton@au1.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agoPPC: Disable non-440 CPUs for ppcemb target
Alexander Graf [Tue, 18 Oct 2011 00:00:51 +0000 (02:00 +0200)]
PPC: Disable non-440 CPUs for ppcemb target

The sole reason we have the ppcemb target is to support MMUs that have
less than the usual 4k possible page size. There are very few of these
chips and I don't want to add additional QA and testing burden to everyone
to ensure that code still works when TARGET_PAGE_SIZE is not 4k.

So this patch disables all CPUs except for MMU_BOOKE capable ones from
the ppcemb target.

Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agoPPC: Bump qemu-system-ppc to 64-bit physical address space
Alexander Graf [Mon, 17 Oct 2011 23:46:08 +0000 (01:46 +0200)]
PPC: Bump qemu-system-ppc to 64-bit physical address space

Some 32-bit PPC CPUs can use up to 36 bit of physical address space.
Treat them accordingly in the qemu-system-ppc binary type.

Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agopseries: Under kvm use guest cpu = host cpu by default
David Gibson [Wed, 12 Oct 2011 22:40:34 +0000 (22:40 +0000)]
pseries: Under kvm use guest cpu = host cpu by default

Now that we've implemented -cpu host for ppc, this patch updates the
pseries machine to use the host cpu as the guest cpu by default when
running under KVM.  This is important because under KVM Book3S-HV the guest
cpu _cannot_ be of a different type to the host cpu (at the moment
KVM Book3S-HV will silently virtualize the host cpu instead of whatever was
requested, but in future it is likely to simply refuse to run the VM if
a cpu model other than the host's is requested).

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agoppc: Add cpu defs for POWER7 revisions 2.1 and 2.3
David Gibson [Wed, 12 Oct 2011 22:40:33 +0000 (22:40 +0000)]
ppc: Add cpu defs for POWER7 revisions 2.1 and 2.3

This patch adds cpu specs to the table for POWER7 revisions 2.1 and 2.3.
This allows -cpu host to be used on these host cpus.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agoppc: First cut implementation of -cpu host
David Gibson [Wed, 12 Oct 2011 22:40:32 +0000 (22:40 +0000)]
ppc: First cut implementation of -cpu host

For convenience with kvm, x86 allows the user to specify -cpu host on the
qemu command line, which means make the guest cpu the same as the host
cpu.  This patch implements the same option for ppc targets.

For now, this just read the host PVR (Processor Version Register) and
selects one of our existing CPU specs based on it.  This means that the
option will not work if the host cpu is not supported by TCG, even if that
wouldn't matter for use under kvm.

In future, we can extend this in future to override parts of the cpu spec
based on information obtained from the host (via /proc/cpuinfo, the host
device tree, or explicit KVM calls).  That will let us handle cases where
the real kvm-virtualized CPU doesn't behave exactly like the TCG-emulated
CPU.  With appropriate annotation of the CPU specs we'll also then be able
to use host cpus under kvm even when there isn't a matching full TCG model.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agoppc: Remove broken partial PVR matching
David Gibson [Wed, 12 Oct 2011 22:40:31 +0000 (22:40 +0000)]
ppc: Remove broken partial PVR matching

The ppc target contains a ppc_find_by_pvr() function, which looks up a
CPU spec based on a PVR (that is, based on the value in the target cpu's
Processor Version Register).  PVR values contain information on both the
cpu model (upper 16 bits, usually) and on the precise revision (low 16
bits, usually).

ppc_find_by_pvr, as well as making exact PVR matches, attempts to find
"close" PVR matches, when we don't have a CPU spec for the exact revision
specified.  This sounds like a good idea, execpt that the current logic
is completely nonsensical.

It seems to assume CPU families are subdivided bit by bit in the PVR in a
way they just aren't.  Specifically, it requires a match on all bits of the
specified pvr up to the last non-zero bit.  This has the bizarre effect
that when the low bits are simply a sequential revision number (a common
though not universal pattern), then odd specified revisions must be matched
exactly, whereas even specified revisions will also match the next odd
revision, likewise for powers of 4, 8 and so forth.

To correctly do inexact matching we'd need to re-organize the table of CPU
specs to include a mask showing what PVR range the spec is compatible with
(similar to the cputable code in the Linux kernel).

For now, just remove the bogosity by only permitting exact PVR matches.
That at least makes the matching simple and consistent.  If we need inexact
matching we can add the necessary per-subfamily masks later.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agopseries: Update SLOF firmware image
David Gibson [Wed, 12 Oct 2011 19:10:30 +0000 (19:10 +0000)]
pseries: Update SLOF firmware image

This patch is a general update to the SLOF firmware image used on the
pseries machine.  This doesn't contain updates for specific features but
contains a number of bugfixes and enhancements in the main SLOF tree from
Thomas Huth.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agopseries: Add device tree properties for VMX/VSX and DFP under kvm
David Gibson [Mon, 10 Oct 2011 18:31:01 +0000 (18:31 +0000)]
pseries: Add device tree properties for VMX/VSX and DFP under kvm

Sufficiently recent PAPR specifications define properties "ibm,vmx"
and "ibm,dfp" on the CPU node which advertise whether the VMX vector
extensions (or the later VSX version) and/or the Decimal Floating
Point operations from IBM's recent POWER CPUs are available.

Currently we do not put these in the guest device tree and the guest
kernel will consequently assume they are not available.  This is good,
because they are not supported under TCG.  VMX is similar enough to
Altivec that it might be trivial to support, but VSX and DFP would
both require significant work to support in TCG.

However, when running under kvm on a host which supports these
instructions, there's no reason not to let the guest use them.  This
patch, therefore, checks for the relevant support on the host CPU
and, if present, advertises them to the guest as well.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agoppc: Generalize the kvmppc_get_clockfreq() function
David Gibson [Mon, 10 Oct 2011 18:31:00 +0000 (18:31 +0000)]
ppc: Generalize the kvmppc_get_clockfreq() function

Currently the kvmppc_get_clockfreq() function reads the host's clock
frequency from /proc/device-tree, which is useful to past to the guest
in KVM setups.  However, there are some other host properties
advertised in the device tree which can also be relevant to the
guests.

This patch, therefore, replaces kvmppc_get_clockfreq() which can
retrieve any named, single integer property from the host device
tree's CPU node.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agoSet an invalid-bits mask for each SPE instructions
Fabien Chouteau [Wed, 28 Sep 2011 05:54:05 +0000 (05:54 +0000)]
Set an invalid-bits mask for each SPE instructions

SPE instructions are defined by pairs. Currently, the invalid-bits mask is set
for the first instruction, but the second one can have a different mask.

example:
GEN_SPE(efdcmpeq,    efdcfs,      0x17, 0x0B, 0x00600000, 0x00180000, PPC_SPE_DOUBLE),

Signed-off-by: Fabien Chouteau <chouteau@adacore.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agopseries: Update SLOF firmware image
David Gibson [Thu, 29 Sep 2011 21:39:13 +0000 (21:39 +0000)]
pseries: Update SLOF firmware image

This patch updates the SLOF submodule and precompiled image.  The new
SLOF versions contains two changes of note:

 * The previous SLOF has a bug in SCSI condition handling that was
   exposed by recent updates to qemu's SCSI emulation.  This update
   fixes the bug.

 * The previous SLOF has a bug in its addressing of SCSI devices,
   which can be exposed under certain conditions.  The new SLOF also
   fixes this.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agopseries: Use Book3S-HV TCE acceleration capabilities
David Gibson [Thu, 29 Sep 2011 21:39:12 +0000 (21:39 +0000)]
pseries: Use Book3S-HV TCE acceleration capabilities

The pseries machine of qemu implements the TCE mechanism used as a
virtual IOMMU for the PAPR defined virtual IO devices.  Because the
PAPR spec only defines a small DMA address space, the guest VIO
drivers need to update TCE mappings very frequently - the virtual
network device is particularly bad.  This means many slow exits to
qemu to emulate the H_PUT_TCE hypercall.

Sufficiently recent kernels allow this to be mitigated by implementing
H_PUT_TCE in the host kernel.  To make use of this, however, qemu
needs to initialize the necessary TCE tables, and map them into itself
so that the VIO device implementations can retrieve the mappings when
they access guest memory (which is treated as a virtual DMA
operation).

This patch adds the necessary calls to use the KVM TCE acceleration.
If the kernel does not support acceleration, or there is some other
error creating the accelerated TCE table, then it will still fall back
to full userspace TCE implementation.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agopseries: Allow KVM Book3S-HV on PPC970 CPUS
David Gibson [Thu, 29 Sep 2011 21:39:11 +0000 (21:39 +0000)]
pseries: Allow KVM Book3S-HV on PPC970 CPUS

At present, using the hypervisor aware Book3S-HV KVM will only work
with qemu on POWER7 CPUs.  PPC970 CPUs also have hypervisor
capability, but they lack the VRMA feature which makes assigning guest
memory easier.

In order to allow KVM Book3S-HV on PPC970, we need to specially
allocate the first chunk of guest memory (the "Real Mode Area" or
RMA), so that it is physically contiguous.

Sufficiently recent host kernels allow such contiguous RMAs to be
allocated, with a kvm capability advertising whether the feature is
available and/or necessary on this hardware.  This patch enables qemu
to use this support, thus allowing kvm acceleration of pseries qemu
machines on PPC970 hardware.

Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
---

agraf: fix to use memory api

12 years agopseries: Support SMT systems for KVM Book3S-HV
David Gibson [Thu, 29 Sep 2011 21:39:10 +0000 (21:39 +0000)]
pseries: Support SMT systems for KVM Book3S-HV

Alex Graf has already made qemu support KVM for the pseries machine
when using the Book3S-PR KVM variant (which runs the guest in
usermode, emulating supervisor operations).  This code allows gets us
very close to also working with KVM Book3S-HV (using the hypervisor
capabilities of recent POWER CPUs).

This patch moves us another step towards Book3S-HV support by
correctly handling SMT (multithreaded) POWER CPUs.  There are two
parts to this:

 * Querying KVM to check SMT capability, and if present, adjusting the
   cpu numbers that qemu assigns to cause KVM to assign guest threads
   to cores in the right way (this isn't automatic, because the POWER
   HV support has a limitation that different threads on a single core
   cannot be in different guests at the same time).

 * Correctly informing the guest OS of the SMT thread to core mappings
   via the device tree.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agoppc/e500_pci: Fix an array overflow issue
Liu Yu-B13201 [Thu, 29 Sep 2011 17:52:50 +0000 (17:52 +0000)]
ppc/e500_pci: Fix an array overflow issue

When access PPCE500_PCI_IW1 the previous index get overflow.
The patch fix the issue and update all to keep consistent style.

Signed-off-by: Liu Yu <yu.liu@freescale.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agoppc/e500_pci: Fix code style
Liu Yu-B13201 [Thu, 29 Sep 2011 17:52:49 +0000 (17:52 +0000)]
ppc/e500_pci: Fix code style

Put trailing statements on next line.

Signed-off-by: Liu Yu <yu.liu@freescale.com>
Reviewed-by: Andreas Färber <andreas.faerber@web.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agoMAINTAINERS: update wiki URL and machine names for target-xtensa
Max Filippov [Thu, 27 Oct 2011 22:11:05 +0000 (02:11 +0400)]
MAINTAINERS: update wiki URL and machine names for target-xtensa

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotcg: Optimize some forms of deposit.
Richard Henderson [Thu, 27 Oct 2011 21:15:00 +0000 (14:15 -0700)]
tcg: Optimize some forms of deposit.

If the deposit replaces the entire word, optimize to a move.

If we're inserting to the top of the word, avoid the mask of arg2
as we'll be shifting out all of the garbage and shifting in zeros.

If the host is 32-bit, reduce a 64-bit deposit to a 32-bit deposit
when possible.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agohw/9pfs: Make VirtFS tracing work correctly
Aneesh Kumar K.V [Mon, 24 Oct 2011 09:39:49 +0000 (15:09 +0530)]
hw/9pfs: Make VirtFS tracing work correctly

this patch fix multiple issues with VirtFS tracing.
a) Add tracepoint to the correct code path. We handle error in complete_pdu
b) Fix indentation in python script
c) Fix variable naming issue in python script

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoexec-all: Fix void pointer arithmetic
Stefan Weil [Sun, 23 Oct 2011 06:19:10 +0000 (08:19 +0200)]
exec-all: Fix void pointer arithmetic

Adding an offset to a void pointer works with gcc but is not allowed
by the current C standards. With -pedantic, gcc complains:

exec-all.h:344: error: pointer of type ‘void *’ used in arithmetic

Fix this, and also replace (unsigned long) by (uintptr_t) in the same
statement.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoAdd linux-headers/asm to .gitignore
David Gibson [Thu, 20 Oct 2011 00:41:01 +0000 (11:41 +1100)]
Add linux-headers/asm to .gitignore

linux-headers/asm is a symlink generated during configure.  It should not,
therefore be committed to git, nor show up in git diffs and the like.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoscsi-disk: add scsi-block for device passthrough
Paolo Bonzini [Tue, 25 Oct 2011 10:53:37 +0000 (12:53 +0200)]
scsi-disk: add scsi-block for device passthrough

scsi-block is a new device that supports device passthrough of Linux
block devices (i.e. /dev/sda, not /dev/sg0).  It uses SG_IO for commands
other than I/O commands, and regular AIO read/writes for I/O commands.
Besides being simpler to configure (no mapping required to scsi-generic
device names), this removes the need for a large bounce buffer and,
in the future, will get scatter/gather support for free from scsi-disk.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi: push request restart to SCSIDevice
Paolo Bonzini [Tue, 25 Oct 2011 10:53:36 +0000 (12:53 +0200)]
scsi: push request restart to SCSIDevice

The request restart mechanism is generic and could be reused for
scsi-generic.  In the meanwhile, pushing it to SCSIDevice avoids
that scsi_dma_restart_bh looks at SCSIGenericReqs when working on
a scsi-block device.

The code is the same that is already in hw/scsi-disk.c, with
the type flags replaced by req->cmd.mode and a more generic way to
requeue SCSI_XFER_NONE commands.

I also added a missing call to qemu_del_vm_change_state_handler.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi-generic: bump SCSIRequest reference count until aio completion runs
Paolo Bonzini [Tue, 25 Oct 2011 10:53:35 +0000 (12:53 +0200)]
scsi-generic: bump SCSIRequest reference count until aio completion runs

Same as before, but for scsi-generic.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi-disk: bump SCSIRequest reference count until aio completion runs
Paolo Bonzini [Tue, 25 Oct 2011 10:53:34 +0000 (12:53 +0200)]
scsi-disk: bump SCSIRequest reference count until aio completion runs

In some cases a request may be canceled before the completion callback
runs.  Keep a reference to the request between starting an AIO operation
and the corresponding scsi_req_cancel or scsi_*_complete.

When a request has to be retried, the request can be dropped because
scsi_dma_restart_bh only looks at requests that are enqueued.  As such,
they always have at least a reference.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi: do not call transfer_data after canceling a request
Paolo Bonzini [Tue, 25 Oct 2011 10:53:33 +0000 (12:53 +0200)]
scsi: do not call transfer_data after canceling a request

Otherwise, if cancellation is "faked" by the AIO layer and goes
through qemu_aio_flush, the whole request is completed synchronously
during scsi_req_cancel.

Using the enqueued flag would work here, but not in the next patches,
so I'm introducing a new io_canceled flag.  That's because scsi_req_data
is a synchronous callback and the enqueued flag might be reset by the
time it returns.  scsi-disk cannot unref the request until after calling
scsi_req_data.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi: pass cdb to alloc_req
Paolo Bonzini [Wed, 12 Oct 2011 10:58:31 +0000 (12:58 +0200)]
scsi: pass cdb to alloc_req

This will let scsi-block choose between passthrough and emulation.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi: export scsi_generic_reqops
Paolo Bonzini [Wed, 12 Oct 2011 10:54:31 +0000 (12:54 +0200)]
scsi: export scsi_generic_reqops

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi: make reqops const
Paolo Bonzini [Wed, 12 Oct 2011 10:57:59 +0000 (12:57 +0200)]
scsi: make reqops const

Also delete a stale occurrence of SCSIReqOps inside SCSIDeviceInfo.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi: move max_lba to SCSIDevice
Paolo Bonzini [Thu, 13 Oct 2011 08:39:50 +0000 (10:39 +0200)]
scsi: move max_lba to SCSIDevice

The field is only in scsi-disk for now.  Moving it up to SCSIDevice makes
it easier to reuse the scsi-generic reqops elsewhere.

At the same time, make scsi-generic get max_lba from snooped READ CAPACITY
commands as well.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi-disk: small clean up to INQUIRY
Paolo Bonzini [Wed, 12 Oct 2011 12:27:40 +0000 (14:27 +0200)]
scsi-disk: small clean up to INQUIRY

Set s->removable, s->qdev.blocksize and s->qdev.type in the callers
of scsi_initfn.

With this in place, s->qdev.type is allowed, and we can just reuse it
as the first byte in VPD data (just like we do in standard INQUIRY data).
Also set s->removable is set consistently and we can use it.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi-disk: remove cluster_size
Paolo Bonzini [Thu, 13 Oct 2011 08:35:46 +0000 (10:35 +0200)]
scsi-disk: remove cluster_size

This field is redundant, and having it makes it more complicated
to share reqops between the upcoming scsi-block and scsi-generic.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi-disk: do not duplicate BlockDriverState member
Paolo Bonzini [Wed, 12 Oct 2011 10:54:16 +0000 (12:54 +0200)]
scsi-disk: do not duplicate BlockDriverState member

Same as for scsi-generic, avoid duplication even if it causes longer
lines.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi-generic: snoop READ CAPACITY commands to get block size
Paolo Bonzini [Thu, 13 Oct 2011 08:36:27 +0000 (10:36 +0200)]
scsi-generic: snoop READ CAPACITY commands to get block size

Instead of "guessing" the block size when there is no medium in the
drive, wait for the guest to send a READ CAPACITY command and snoop
it from there.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi-generic: look at host status
Paolo Bonzini [Wed, 12 Oct 2011 12:53:43 +0000 (14:53 +0200)]
scsi-generic: look at host status

Pass down the host status so that failing transport can be detected
by the guest.  Similar treatment of host status could be done in
virtio-blk, too.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi-generic: check ioctl statuses when SG_IO succeeds
Paolo Bonzini [Wed, 12 Oct 2011 12:49:48 +0000 (14:49 +0200)]
scsi-generic: check ioctl statuses when SG_IO succeeds

A succeeding ioctl does not imply that the SCSI command succeeded.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi-generic: remove scsi_req_fixup
Paolo Bonzini [Wed, 12 Oct 2011 09:54:59 +0000 (11:54 +0200)]
scsi-generic: remove scsi_req_fixup

This is not needed anymore, since asynchronous ioctls were introduced
by commit 221f715 (new scsi-generic abstraction, use SG_IO, 2009-03-28).

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi-generic: drop SCSIGenericState
Paolo Bonzini [Wed, 12 Oct 2011 10:49:35 +0000 (12:49 +0200)]
scsi-generic: drop SCSIGenericState

It is not needed, because s->bs is already stored in SCSIDevice, and
can be reached from the conf.bs member.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi-disk: fix retrying a flush
Paolo Bonzini [Tue, 4 Oct 2011 13:36:05 +0000 (15:36 +0200)]
scsi-disk: fix retrying a flush

Flush does not go anymore through scsi_disk_emulate_command.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi-disk: fail READ CAPACITY if LBA != 0 but PMI == 0
Paolo Bonzini [Mon, 3 Oct 2011 11:57:06 +0000 (13:57 +0200)]
scsi-disk: fail READ CAPACITY if LBA != 0 but PMI == 0

Tested by the Windows Logo Kit SCSI Compliance test. From SBC-3, paragraph
5.25: "The LOGICAL BLOCK ADDRESS field shall be set to zero if the PMI
bit is set to zero. If the PMI bit is set to zero and the LOGICAL BLOCK
ADDRESS field is not set to zero, then the device server shall terminate
the command with CHECK CONDITION status with the sense key set to ILLEGAL
REQUEST and the additional sense code set to INVALID FIELD IN CDB".

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi: add channel to addressing
Paolo Bonzini [Wed, 27 Jul 2011 21:24:50 +0000 (23:24 +0200)]
scsi: add channel to addressing

This also requires little more than adding the new argument to
scsi_device_find, and the qdev property.  All devices by default
end up on channel 0.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi: allow arbitrary LUNs
Paolo Bonzini [Sat, 13 Aug 2011 16:55:17 +0000 (18:55 +0200)]
scsi: allow arbitrary LUNs

This only requires changes in two places: in SCSIBus, we need to look
for a free LUN if somebody creates a device with a pre-existing scsi-id
but the default LUN (-1, meaning "search for a free spot"); in vSCSI,
we need to actually parse the LUN according to the SCSI spec.

For vSCSI, max_target/max_lun are set according to the logical unit
addressing format in SAM.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi: implement REPORT LUNS for arbitrary LUNs
Paolo Bonzini [Wed, 14 Sep 2011 18:39:36 +0000 (20:39 +0200)]
scsi: implement REPORT LUNS for arbitrary LUNs

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi: remove devs array from SCSIBus
Paolo Bonzini [Thu, 28 Jul 2011 16:02:13 +0000 (18:02 +0200)]
scsi: remove devs array from SCSIBus

Change the devs array into a linked list, and add a scsi_device_find
function to navigate the children list instead.  This lets the SCSI
bus use more complex addressing, and HBAs can talk to the correct device
when there are multiple LUNs per target.

scsi_device_find may return another LUN on the same target if none is
found that matches exactly.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoqdev: switch children device list to QTAILQ
Paolo Bonzini [Wed, 14 Sep 2011 07:28:06 +0000 (09:28 +0200)]
qdev: switch children device list to QTAILQ

SCSI buses will need to read the children list first-to-last.  This
requires using a QTAILQ, because hell breaks loose if you just try
inserting at the tail (thus reversing the order of all existing
visits from last-to-first to first-to-tail).

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi: move tcq/ndev to SCSIBusOps (now SCSIBusInfo)
Paolo Bonzini [Sat, 13 Aug 2011 13:44:45 +0000 (15:44 +0200)]
scsi: move tcq/ndev to SCSIBusOps (now SCSIBusInfo)

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi-disk: report media changed via GET EVENT STATUS NOTIFICATION
Paolo Bonzini [Tue, 13 Sep 2011 14:26:51 +0000 (16:26 +0200)]
scsi-disk: report media changed via GET EVENT STATUS NOTIFICATION

This adds support for media change notification via the GET EVENT STATUS
NOTIFICATION command, used by Linux versions 2.6.38 and newer.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi-disk: support READ DVD STRUCTURE
Paolo Bonzini [Tue, 13 Sep 2011 13:57:15 +0000 (15:57 +0200)]
scsi-disk: support READ DVD STRUCTURE

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi-disk: support DVD profile in GET CONFIGURATION
Paolo Bonzini [Tue, 13 Sep 2011 13:22:31 +0000 (15:22 +0200)]
scsi-disk: support DVD profile in GET CONFIGURATION

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoatapi/scsi-disk: make mode page values coherent between the two
Paolo Bonzini [Tue, 13 Sep 2011 13:08:22 +0000 (15:08 +0200)]
atapi/scsi-disk: make mode page values coherent between the two

This patch adds to scsi-disk the missing mode page 0x01 for both disk
and CD-ROM drives, and mode page 0x0e for CD drives only.

A few offsets were wrong in atapi.c.  Also change the 2Ah mode page to
expose DVD media read capabilities in the IDE cdrom.  This lets you run
dvd+rw-mediainfo on the virtual DVD drives.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi-disk: store valid mode pages in a table
Paolo Bonzini [Tue, 13 Sep 2011 12:50:15 +0000 (14:50 +0200)]
scsi-disk: store valid mode pages in a table

A small refactoring of the MODE SENSE implementation in scsi-disk.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi-disk: add stubs for more MMC commands
Paolo Bonzini [Tue, 13 Sep 2011 12:33:47 +0000 (14:33 +0200)]
scsi-disk: add stubs for more MMC commands

This patch adds a few stub implementations for MMC commands to
scsi-disk, to be filled in later in the series.  It also adds to
scsi-defs.h constants for commands implemented by ide/atapi.c,
when missing.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi-disk: fix coding style issues (braces)
Paolo Bonzini [Mon, 17 Oct 2011 14:39:27 +0000 (16:39 +0200)]
scsi-disk: fix coding style issues (braces)

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>