sdk/emulator/qemu.git
12 years agoRevert "fix out of tree build"
Anthony Liguori [Mon, 28 Nov 2011 18:45:28 +0000 (12:45 -0600)]
Revert "fix out of tree build"

This reverts commit be85c90b74f56dca51782fa3080fcdf88593e045.

This patch is incorrect and breaks the build with a freshly cloned git tree.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoconfigure: avoid screening of --{en, dis}able-usb-redir options
Max Filippov [Thu, 24 Nov 2011 12:11:31 +0000 (16:11 +0400)]
configure: avoid screening of --{en, dis}able-usb-redir options

--*dir) option pattern precede --{en,dis}able-usb-redir) patterns in the
option analysis switch, making the latter options have no effect.

There were some --*dir that are supported by Autoconf and not by QEMU configure.
The aim was to let QEMU packagers use the rpm (or similar) macro that overrides
directories for their distribution.

Replace --*dir with exact option names.

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agocutils: Make strtosz & friends leave follow set to callers
Markus Armbruster [Tue, 22 Nov 2011 08:46:06 +0000 (09:46 +0100)]
cutils: Make strtosz & friends leave follow set to callers

strtosz() & friends require the size to be at the end of the string,
or be followed by whitespace or ','.  I find this surprising, because
the name suggests it works like strtol().

The check simplifies callers that accept exactly that follow set
slightly.  No such callers exist.

The check is redundant for callers that accept a smaller follow set,
and thus need to check themselves anyway.  Right now, this is the case
for all but one caller.  All of them neglected to check, or checked
incorrectly, but the previous few commits fixed them up.

Finally, the check is problematic for callers that accept a larger
follow set.  This is the case in monitor_parse_command().
Fortunately, the problems there are relatively harmless.

monitor_parse_command() uses strtosz() for argument type 'o'.  When
the last argument is of type 'o', a trailing ',' is diagnosed
differently than other trailing junk:

    (qemu) migrate_set_speed 1x
    invalid size
    (qemu) migrate_set_speed 1,
    migrate_set_speed: extraneous characters at the end of line

A related inconsistency exists with non-last arguments.  No such
command exists, but let's use memsave to explore the inconsistency.

The monitor permits, but does not require whitespace between
arguments.  For instance, "memsave (1-1)1024foo" is parsed as command
memsave with three arguments 0, 1024 and "foo".  Yes, this is daft,
but at least it's consistently daft.

If I change memsave's second argument from 'i' to 'o', then "memsave
(1-1)1foo" is rejected, because the size is followed by an 'f'.  But
"memsave (1-1)1," is still accepted, and duly saves to file ",".

We don't have any users of strtosz that profit from the check.  In the
users we have, it appears to encourage sloppy error checking, or gets
in the way.  Drop the bothersome check.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoqemu-img: Tighten parsing of size arguments
Markus Armbruster [Tue, 22 Nov 2011 08:46:05 +0000 (09:46 +0100)]
qemu-img: Tighten parsing of size arguments

strtosz_suffix() fails unless the size is followed by 0, whitespace or
','.  Useless here, because we need to fail for any junk following the
size, even if it starts with whitespace or ','.  Check manually.
Things like "qemu-img create xxx 1024," and "qemu-img convert -S '1024
junk'" are now caught.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agox86/cpuid: Tighten parsing of tsc_freq=FREQ
Markus Armbruster [Tue, 22 Nov 2011 08:46:04 +0000 (09:46 +0100)]
x86/cpuid: Tighten parsing of tsc_freq=FREQ

cpu_x86_find_by_name() uses strtosz_suffix_unit(), but screws up the
error checking.  It detects some failures, but not all.  Undetected
failures result in a zero tsc_khz value (error value -1 divided by
1000), which means "no tsc_freq set".

To reproduce, try "-cpu qemu64,tsc_freq=9999999T".
strtosz_suffix_unit() fails, because the value overflows int64_t,

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agovl: Tighten parsing of -m argument
Markus Armbruster [Tue, 22 Nov 2011 08:46:03 +0000 (09:46 +0100)]
vl: Tighten parsing of -m argument

strtosz_suffix() fails unless the size is followed by 0, whitespace or
','.  Useless here, because we need to fail for any junk following the
size, even if it starts with whitespace or ','.  Check manually.
Things like "-m 1024," are now caught.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agovl: Tighten parsing of -numa's parameter mem
Markus Armbruster [Tue, 22 Nov 2011 08:46:02 +0000 (09:46 +0100)]
vl: Tighten parsing of -numa's parameter mem

strtosz_suffix() fails unless the size is followed by 0, whitespace or
','.  Useless here, because we need to fail for any junk following the
size, even if it starts with whitespace or ','.  Check manually.

Things like

    -smp 4 -numa "node,mem=1024,cpus=0-1" -numa "node,mem=1024 cpus=2-3"

are now caught.  Before, the second -numa's argument was silently
interpreted as just "node,mem=1024".

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agocutils: Drop broken support for zero strtosz default_suffix
Markus Armbruster [Tue, 22 Nov 2011 08:46:01 +0000 (09:46 +0100)]
cutils: Drop broken support for zero strtosz default_suffix

Commit 9f9b17a4's strtosz() defaults a missing suffix to 'M', except
it rejects fractions then (switch case 0).

When commit d8427002 introduced strtosz_suffix(), that changed:
fractions are no longer rejected, because we go to switch case 'M' on
missing suffix now.  Not mentioned in commit message, probably
unintentional.  Not worth changing back now.

Because case 0 is still around, you can get the old behavior by
passing a zero default_suffix to strtosz_suffix() or
strtosz_suffix_unit().  Undocumented and not used.  Drop.

Commit d8427002 also neglected to update the function comment.  Fix it
up.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoconfigure: tighten pie toolchain support test for tls variables
Avi Kivity [Wed, 23 Nov 2011 09:24:25 +0000 (11:24 +0200)]
configure: tighten pie toolchain support test for tls variables

Some toolchains don't support pie properly when tls variables are
in use.  Disallow pie when such toolchains are detected.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agousb-redir: Don't try to write to the chardev after a close event
Hans de Goede [Sat, 19 Nov 2011 09:22:47 +0000 (10:22 +0100)]
usb-redir: Don't try to write to the chardev after a close event

Since we handle close async in a bh, do_write and thus write can get
called after receiving a close event. This patch adds a check to
the usb-redir write callback to not call qemu_chr_fe_write on a closed
backend.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agousb-redir: Device disconnect + re-connect robustness fixes
Hans de Goede [Sat, 19 Nov 2011 09:22:46 +0000 (10:22 +0100)]
usb-redir: Device disconnect + re-connect robustness fixes

These fixes mainly target the other side sending some (error status)
packets after a disconnect packet. In some cases these would get queued
up and then reported to the controller when a new device gets connected.

* Fully reset device state on disconnect
* Don't allow a connect message when already connected
* Ignore iso and interrupt status messages when disconnected

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agousb-redir: Call qemu_chr_fe_open/close
Hans de Goede [Sat, 19 Nov 2011 09:22:45 +0000 (10:22 +0100)]
usb-redir: Call qemu_chr_fe_open/close

To let the chardev now we're ready start receiving data. This is necessary
with the spicevmc chardev to get it registered with the spice-server.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agospice-qemu-char: Generate chardev open/close events
Hans de Goede [Sat, 19 Nov 2011 09:22:44 +0000 (10:22 +0100)]
spice-qemu-char: Generate chardev open/close events

Define a state callback and make that generate chardev open/close events when
called by the spice-server.

Notes:

1) For all but the newest spice-server versions (which have a fix for this)
the code ignores these events for a spicevmc with a subtype of vdagent, this
subtype specific knowledge is undesirable, but unavoidable for now, see:
http://lists.freedesktop.org/archives/spice-devel/2011-July/004837.html

2) This code deliberately sends the events immediately rather then from a
bh. This is done this way because:
a) There is no need to do it from a bh; and
b) Doing it from a bh actually causes issues because the spice-server may send
data immediately after the open and when the open runs from a bh, then
qemu_chr_be_can_write will return 0 for the first write which the spice-server
does not expect, when this happens the spice-server will never retry the write
causing communication to stall.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoqemu-char: rename qemu_chr_event to qemu_chr_be_event and make it public
Hans de Goede [Sat, 19 Nov 2011 09:22:43 +0000 (10:22 +0100)]
qemu-char: rename qemu_chr_event to qemu_chr_be_event and make it public

Rename qemu_chr_event to qemu_chr_be_event, since it is only to be
called by backends and make it public so that it can be used by chardev
code which lives outside of qemu-char.c

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years ago9pfs: improve portability to older systems
Aneesh Kumar K.V [Wed, 23 Nov 2011 06:16:27 +0000 (11:46 +0530)]
9pfs: improve portability to older systems

I guess we can also make sure we don't  call local_ioc_getversion at
all.

Reported-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agotci: Make flush_icache_range() inline
Stefan Weil [Thu, 24 Nov 2011 22:16:10 +0000 (23:16 +0100)]
tci: Make flush_icache_range() inline

This is standard for other tcg targets and improves tci, too.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoeepro100: Fix alignment requirement for statistical counters
Stefan Weil [Wed, 23 Nov 2011 21:20:30 +0000 (22:20 +0100)]
eepro100: Fix alignment requirement for statistical counters

According to Intel's Open Source Software Developer Manual,
the dump counters address must be Dword aligned.

The new code enforces this alignment, so s->statsaddr may now
be used with stw_le_pci_dma() and stl_le_pci_dma().

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agovirtio: add and use virtio_set_features
Paolo Bonzini [Thu, 24 Nov 2011 12:28:52 +0000 (13:28 +0100)]
virtio: add and use virtio_set_features

vdev->guest_features is not masking features that are not supported by
the guest.  Fix this by introducing a common wrapper to be used by all
virtio bus implementations.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years ago9pfs: improve portability to older systems
Paolo Bonzini [Mon, 21 Nov 2011 08:29:11 +0000 (09:29 +0100)]
9pfs: improve portability to older systems

Small requirements on "new" features have percolated to virtio-9p-local.c.
In particular, the utimensat wrapper actually only supports dirfd = AT_FDCWD
and flags = AT_SYMLINK_NOFOLLOW in the fallback code.  Remove the arguments
so that virtio-9p-local.c will not use AT_* constants.

At the same time, fail local_ioc_getversion if the ioctl is not supported
by the host.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoMerge remote-tracking branch 'kwolf/block-stable' into staging
Anthony Liguori [Mon, 28 Nov 2011 17:15:10 +0000 (11:15 -0600)]
Merge remote-tracking branch 'kwolf/block-stable' into staging

12 years agoMerge remote-tracking branch 'kraxel/usb.32' into staging
Anthony Liguori [Mon, 28 Nov 2011 17:12:39 +0000 (11:12 -0600)]
Merge remote-tracking branch 'kraxel/usb.32' into staging

12 years agoMerge remote-tracking branch 'stefanha/trivial-patches' into staging
Anthony Liguori [Mon, 28 Nov 2011 17:11:09 +0000 (11:11 -0600)]
Merge remote-tracking branch 'stefanha/trivial-patches' into staging

12 years agoRevert "i386: derive '-cpu host' from KVM_GET_SUPPORTED_CPUID"
Anthony Liguori [Sun, 27 Nov 2011 17:13:01 +0000 (11:13 -0600)]
Revert "i386: derive '-cpu host' from KVM_GET_SUPPORTED_CPUID"

This reverts commit 66e3dd9282141b5ae75637c9676002cf3ceeb988.

From Avi,

 "Anthony, I think we should revert that commit and refactor cpuid for
  1.1.  The logic is spread over too many places which makes it hard to
  reason about."

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agotci: Add entry to MAINTAINERS
Stefan Weil [Thu, 24 Nov 2011 22:20:43 +0000 (23:20 +0100)]
tci: Add entry to MAINTAINERS

This should have be part of my TCI patch series.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoMAINTAINERS: add checkpatch
Blue Swirl [Sat, 26 Nov 2011 09:51:23 +0000 (09:51 +0000)]
MAINTAINERS: add checkpatch

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agocheckpatch.pl: fix CAST detection
Florian Mickler [Fri, 25 Nov 2011 09:24:16 +0000 (10:24 +0100)]
checkpatch.pl: fix CAST detection

We should only claim that something is a cast if we did not encouter a
token before, that did set av_pending.

This fixes the operator * in the line below to be detected as binary (vs
unary).

kmalloc(sizeof(struct alphatrack_ocmd) * true_size, GFP_KERNEL);

Reported-by: Peter Chubb <nicta.com.au>
Signed-off-by: Florian Mickler <florian@mickler.org>
(cherry-picked from Linux kernel commit c023e4734c3e8801e0ecb5e81b831d42a374d861)
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Cc: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-xtensa: fix MMUv3 initialization
Max Filippov [Tue, 22 Nov 2011 07:59:16 +0000 (11:59 +0400)]
target-xtensa: fix MMUv3 initialization

- ITLB/DTLB ways 5 and 6 have 4 and 8 entries respectively;
- ITLB/DTLB way 6 attr field is set to 3 on reset.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agousb-host: add usb_host_do_reset function.
Gerd Hoffmann [Wed, 16 Nov 2011 11:37:17 +0000 (12:37 +0100)]
usb-host: add usb_host_do_reset function.

Add a special function to reset the host usb device.  It tracks the time
needed by the USBDEVFS_RESET ioctl and prints a warning in case it needs
too long.  Usually it should be finished in 200 - 300 miliseconds.
Warning threshold is one second.

Intention is to help troubleshooting by indicating that the usb device
stopped responding even to a reset request and is possibly broken.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agovpc: Add missing error handling in alloc_block
Kevin Wolf [Wed, 23 Nov 2011 10:38:01 +0000 (11:38 +0100)]
vpc: Add missing error handling in alloc_block

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agovdi: Fix memory leak
Kevin Wolf [Tue, 22 Nov 2011 15:57:34 +0000 (16:57 +0100)]
vdi: Fix memory leak

The block map is allocated in vdi_open, but was never freed.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agovvfat: Add migration blocker
Kevin Wolf [Tue, 22 Nov 2011 15:52:13 +0000 (16:52 +0100)]
vvfat: Add migration blocker

vvfat caches more or less everything when in writable mode. For migration
to work, it would have to be invalidated. Block migration for now when
in writable mode (default is readonly).

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agovpc: Add migration blocker
Kevin Wolf [Tue, 22 Nov 2011 15:51:12 +0000 (16:51 +0100)]
vpc: Add migration blocker

vpc caches the BAT. For migration to work, it would have to be
invalidated. Block migration for now.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agovmdk: Add migration blocker
Kevin Wolf [Tue, 22 Nov 2011 15:50:27 +0000 (16:50 +0100)]
vmdk: Add migration blocker

VMDK caches L2 tables. For migration to work, they would have to be
invalidated. Block migration for now.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agovdi: Add migration blocker
Kevin Wolf [Tue, 22 Nov 2011 15:46:26 +0000 (16:46 +0100)]
vdi: Add migration blocker

vdi caches the block map. For migration to work, it would have to be
invalidated. Block migration for now.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoqcow: Add migration blocker
Kevin Wolf [Tue, 22 Nov 2011 15:44:45 +0000 (16:44 +0100)]
qcow: Add migration blocker

qcow caches L2 tables. For migration to work, they would have to be
invalidated. Block migration for now.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agousb-ehci: add register names
Gerd Hoffmann [Fri, 18 Nov 2011 09:49:25 +0000 (10:49 +0100)]
usb-ehci: add register names

The mmio register name list only had the names for four port status
registers.  We emulate a EHCI adapter with six ports though, the last
two ones are listed as "unknown" in traces.  Fix it.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agousb-ehci: codestyle fixups
Gerd Hoffmann [Fri, 18 Nov 2011 09:48:47 +0000 (10:48 +0100)]
usb-ehci: codestyle fixups

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agousb-hub: implement reset
Gerd Hoffmann [Wed, 23 Nov 2011 12:31:08 +0000 (13:31 +0100)]
usb-hub: implement reset

based on a patch from hkran@linux.vnet.ibm.com

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agofix out of tree build
Stefano Stabellini [Tue, 22 Nov 2011 17:27:15 +0000 (17:27 +0000)]
fix out of tree build

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agortl8139: Fix invalid IO access alignment
Julian Pidancet [Wed, 23 Nov 2011 01:03:15 +0000 (01:03 +0000)]
rtl8139: Fix invalid IO access alignment

This patch makes iPXE work with the rtl8139 emulation. The rtl8139
driver in iPXE issues a 16bit access on the ChipCmd register
(offset 0x37) to check the status of the rx buffer. The offset of the
ioport access was getting fixed up to 0x36 in qemu, causing the value
read in iPXE to be invalid.

This fixes an issue with iPXE reporting timeouts during TFTP transfers.

Reposting this here because it is trivial enough and the original post
on qemu-devel didn't attract much attention.

Also, the inw() which was causing the issue has been replaced with an
inb() in upstream iPXE:
https://git.ipxe.org/ipxe.git/commit/91dd64ad25baa27954a7518e73df4fca8a2d0c93

Signed-off-by: Julian Pidancet <julian.pidancet@gmail.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agousb-hub: wakeup on detach too.
Gerd Hoffmann [Tue, 22 Nov 2011 12:20:14 +0000 (13:20 +0100)]
usb-hub: wakeup on detach too.

When detaching devices from the usb hub we must wakeup too,
otherwise the host misses the detach event.

Commit 4a33a9ea06f6fbb08d8311a7cfed72975344f9ab does the
same for device attach.

Found by hkran@linux.vnet.ibm.com

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agousb: fix usb_qdev_init error handling.
Gerd Hoffmann [Tue, 22 Nov 2011 11:48:14 +0000 (12:48 +0100)]
usb: fix usb_qdev_init error handling.

qdev doesn't call the ->exit callback on ->init failures, so we have to
take care ourself that we cleanup property on errors.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agousb: make usb_create_simple catch and pass up errors.
Gerd Hoffmann [Tue, 22 Nov 2011 11:39:58 +0000 (12:39 +0100)]
usb: make usb_create_simple catch and pass up errors.

Use qdev_init() instead of qdev_init_nofail(), usb device initialization
can fail, most common case being port and device speed mismatch.  Handle
failures correctly and pass up NULL pointers then.

Also fixup usb_create_simple() callers (only one was buggy) to properly
check for NULL pointers before referncing the usb_create_simple() return
value.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agoslirp: Clean up net_slirp_hostfwd_remove()'s use of get_str_sep()
Markus Armbruster [Wed, 16 Nov 2011 14:45:59 +0000 (15:45 +0100)]
slirp: Clean up net_slirp_hostfwd_remove()'s use of get_str_sep()

get_str_sep() can fail, but net_slirp_hostfwd_remove() doesn't check.
Works, because it initializes buf[] to "", which get_str_sep() doesn't
touch when it fails.  Coverity doesn't like it, and neither do I.

Change it to work exactly like slirp_hostfwd().

Acked-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agosheepdog: Avoid deadlock in error path
Dong Xu Wang [Tue, 22 Nov 2011 02:56:58 +0000 (10:56 +0800)]
sheepdog: Avoid deadlock in error path

s->lock should be unlocked before leaving add_aio_request.

Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi-generic: add as boot device
Paolo Bonzini [Fri, 18 Nov 2011 15:32:02 +0000 (16:32 +0100)]
scsi-generic: add as boot device

There is no reason why a scsi-generic device cannot boot if it has
the right type, and indeed it provides already a bootindex property.
So register those devices too.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi: fix fw path
Paolo Bonzini [Fri, 18 Nov 2011 16:03:45 +0000 (17:03 +0100)]
scsi: fix fw path

The pre-1.0 firmware path for SCSI devices already included the LUN
using the suffix argument to add_boot_device_path.  Avoid that it is
included twice, and convert the colons to commas for consistency with
other kinds of devices

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agousb-msd: do not register twice in the boot order
Paolo Bonzini [Fri, 18 Nov 2011 15:32:00 +0000 (16:32 +0100)]
usb-msd: do not register twice in the boot order

USB mass storage devices are registered twice in the boot order.
To avoid having to keep the two paths in sync, pass the bootindex
property down to the scsi-disk device and let it register itself.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agovirtio-blk: fix cross-endian config space
Paolo Bonzini [Fri, 18 Nov 2011 15:31:59 +0000 (16:31 +0100)]
virtio-blk: fix cross-endian config space

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoUpdate version for 1.0-rc3 release
Anthony Liguori [Mon, 21 Nov 2011 20:59:11 +0000 (14:59 -0600)]
Update version for 1.0-rc3 release

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoconfigure: check for EFD_NONBLOCK | EFD_CLOEXEC flags
Max Filippov [Mon, 21 Nov 2011 00:54:58 +0000 (04:54 +0400)]
configure: check for EFD_NONBLOCK | EFD_CLOEXEC flags

Add check for the EFD_NONBLOCK and EFD_CLOEXEC flags to the
CONFIG_EVENTFD test.
This fixes the following build failure on Fedora 9:

      CC    event_notifier.o
    event_notifier.c: In function `event_notifier_init':
    event_notifier.c:21: error: `EFD_NONBLOCK' undeclared (first use in this function)
    event_notifier.c:21: error: (Each undeclared identifier is reported only once
    event_notifier.c:21: error: for each function it appears in.)
    event_notifier.c:21: error: `EFD_CLOEXEC' undeclared (first use in this function)
    make: *** [event_notifier.o] Error 1

Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoconfigure: build position independent executables on x86-Linux hosts
Avi Kivity [Tue, 15 Nov 2011 18:12:17 +0000 (20:12 +0200)]
configure: build position independent executables on x86-Linux hosts

Change the default on x86 Linux hosts to building PIE (position
independent executables); instead of restricting the option to
user-only targets, apply it to all targets.

In addition, set the relocation sections to read-only (relro) when
available; this reduces the attack surface by disallowing changes to
relocation tables at runtime.

While PIE reduces performance and relro increases load time, it
greatly improves security, with the potential to reduce a code
execution vulnerability to a self denial of service.

Non-x86 are not changed, as they require TCG changes; neither are
non-Linux, due to lack of test coverage.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoivshmem: fix PCI BAR2 registration during initialization
Hongyong Zang [Mon, 21 Nov 2011 10:56:18 +0000 (18:56 +0800)]
ivshmem: fix PCI BAR2 registration during initialization

Ivshmem cannot work, and the command lspci cannot show ivshmem BAR2 in the guest.
As for pci_register_bar(), parameter MemoryRegion should be s->bar instead of s->ivshmem.

Reviewed-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Hongyong Zang <zanghongyong@huawei.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agomsix: avoid mask updates if mask is unchanged
Michael S. Tsirkin [Mon, 21 Nov 2011 16:57:50 +0000 (18:57 +0200)]
msix: avoid mask updates if mask is unchanged

Check pending bit only if vector mask status changed.
This is not really important for qemu.git but helps
fix a bug in qemu-kvm.git.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agomsix: Prevent bogus mask updates on MMIO accesses
Michael S. Tsirkin [Mon, 21 Nov 2011 16:57:31 +0000 (18:57 +0200)]
msix: Prevent bogus mask updates on MMIO accesses

>From: Jan Kiszka <jan.kiszka@siemens.com>

Only accesses to the MSI-X table must trigger a call to
msix_handle_mask_update, otherwise the vector
value might be out of range.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agomsix: track function masked in pci device state
Michael S. Tsirkin [Mon, 21 Nov 2011 16:57:21 +0000 (18:57 +0200)]
msix: track function masked in pci device state

Only go over the table when function is masked.
This is not really important for qemu.git but helps
fix a bug in qemu-kvm.git.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoInclude zlib.h using #include <>
Stefan Weil [Sun, 20 Nov 2011 11:34:30 +0000 (12:34 +0100)]
Include zlib.h using #include <>

zlib.h is not a local include file, therefore it should be included
using <> instead of "".

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years ago9p: pass dotl flags to the unlinkat method
Paolo Bonzini [Fri, 18 Nov 2011 16:35:38 +0000 (17:35 +0100)]
9p: pass dotl flags to the unlinkat method

AT_REMOVEDIR is not defined on all systems.  Pass the raw flags from the
9p protocol, which are always there.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years ago9p: allow compiling the dummy virtio-9p-handle.c code on Linux
Paolo Bonzini [Fri, 18 Nov 2011 16:35:37 +0000 (17:35 +0100)]
9p: allow compiling the dummy virtio-9p-handle.c code on Linux

Avoid a conflict on the definition of struct file_handle by
using a replacement name.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoqed: add migration blocker (v2)
Anthony Liguori [Mon, 14 Nov 2011 21:09:47 +0000 (15:09 -0600)]
qed: add migration blocker (v2)

Now when you try to migrate with qed, you get:

(qemu) migrate tcp:localhost:1025
Block format 'qed' used by device 'ide0-hd0' does not support feature 'live migration'
(qemu)

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoqcow2: implement bdrv_invalidate_cache (v2)
Anthony Liguori [Mon, 14 Nov 2011 21:09:46 +0000 (15:09 -0600)]
qcow2: implement bdrv_invalidate_cache (v2)

We don't reopen the actual file, but instead invoke the close and open routines.
We specifically ignore the backing file since it's contents are read-only and
therefore immutable.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoblock: allow migration to work with image files (v3)
Anthony Liguori [Mon, 14 Nov 2011 21:09:45 +0000 (15:09 -0600)]
block: allow migration to work with image files (v3)

Image files have two types of data: immutable data that describes things like
image size, backing files, etc. and mutable data that includes offset and
reference count tables.

Today, image formats aggressively cache mutable data to improve performance.  In
some cases, this happens before a guest even starts.  When dealing with live
migration, since a file is open on two machines, the caching of meta data can
lead to data corruption.

This patch addresses this by introducing a mechanism to invalidate any cached
mutable data a block driver may have which is then used by the live migration
code.

NB, this still requires coherent shared storage.  Addressing migration without
coherent shared storage (i.e. NFS) requires additional work.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoivshmem: use migration blockers to prevent live migration in peer mode (v2)
Anthony Liguori [Mon, 14 Nov 2011 21:09:44 +0000 (15:09 -0600)]
ivshmem: use migration blockers to prevent live migration in peer mode (v2)

Now when you try to migrate with ivshmem, you get a proper QMP error:

(qemu) migrate tcp:localhost:1025
Migration is disabled when using feature 'peer mode' in device 'ivshmem'
(qemu)

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agomigrate: add migration blockers
Anthony Liguori [Mon, 14 Nov 2011 21:09:43 +0000 (15:09 -0600)]
migrate: add migration blockers

This lets different subsystems register an Error that is thrown whenever
migration is attempted.  This works nicely because it gracefully supports
things like hotplug.

Right now, if multiple errors are registered, only one of them is reported.
I expect that for 1.1, we'll extend query-migrate to return all of the reasons
why migration is disabled at any given point in time.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoMerge remote-tracking branch 'kraxel/usb.31' into staging
Anthony Liguori [Mon, 21 Nov 2011 20:44:04 +0000 (14:44 -0600)]
Merge remote-tracking branch 'kraxel/usb.31' into staging

12 years agoMerge remote-tracking branch 'origin/master' into staging
Anthony Liguori [Mon, 21 Nov 2011 20:36:55 +0000 (14:36 -0600)]
Merge remote-tracking branch 'origin/master' into staging

12 years agousb-linux: fix /proc/bus/usb/devices scan
Gerd Hoffmann [Fri, 11 Nov 2011 16:14:15 +0000 (17:14 +0100)]
usb-linux: fix /proc/bus/usb/devices scan

Commit 0c402e5abb8c2755390eee864b43a98280fc2453 is incomplete
and misses one of the two function pointer calls in
usb_host_scan_dev().  Add the additional port handling logic
to the other call too.

Spotted by Coverity.

Cc: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agoehci: add assert
Gerd Hoffmann [Wed, 9 Nov 2011 11:20:20 +0000 (12:20 +0100)]
ehci: add assert

Coverity thinks q could be NULL there and warns.
I believe it can't be NULL there.
Add assert to prove it.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agousb-storage: don't try to send the status early.
Gerd Hoffmann [Mon, 21 Nov 2011 13:01:26 +0000 (14:01 +0100)]
usb-storage: don't try to send the status early.

Until recently all scsi commands sent to scsi-disk did either transfer
data or finished instantly.  The correct implementation of
SYNCRONIZE_CACHE changed the picture though, and usb-storage needs
a fix to handle that case correctly.

12 years agousb-storage: drop result from device state.
Gerd Hoffmann [Mon, 21 Nov 2011 10:41:30 +0000 (11:41 +0100)]
usb-storage: drop result from device state.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agousb-storage: drop tag from device state.
Gerd Hoffmann [Mon, 21 Nov 2011 10:36:17 +0000 (11:36 +0100)]
usb-storage: drop tag from device state.

scsi keeps track of the tag in SCSIRequest,
no need to store a separate copy.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agousb-storage: fill status in complete callback.
Gerd Hoffmann [Mon, 21 Nov 2011 10:29:27 +0000 (11:29 +0100)]
usb-storage: fill status in complete callback.

Put status word into device state, fill it in command_complete, have
usb_msd_send_status just send it out.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agousb-storage: move status debug message to usb_msd_send_status.
Gerd Hoffmann [Mon, 21 Nov 2011 10:17:59 +0000 (11:17 +0100)]
usb-storage: move status debug message to usb_msd_send_status.

usb_msd_send_status can be called from different code paths, move the
debug message into the function to make sure it is printed
unconditionally.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agox86: fix pcmpestrm and pcmpistrm
Blue Swirl [Sun, 13 Nov 2011 11:11:52 +0000 (11:11 +0000)]
x86: fix pcmpestrm and pcmpistrm

Fix obvious typos (decrement and off-by-one error) in pcmpestrm and pcmpistrm
which resulted in infinite loop. Reported by Frank Mehnert,
spotted also by Coverity (bug 84752853).

Reported-by: Frank Mehnert <frank.mehnert@oracle.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoloader: Fix read_targphys() to behave when read() fails
Markus Armbruster [Wed, 16 Nov 2011 18:41:56 +0000 (19:41 +0100)]
loader: Fix read_targphys() to behave when read() fails

Happily passes (size_t)-1 to rom_add_blob_fixed(), which promptly dies
attempting to malloc that much.  Spotted by Coverity.

Bonus fix for ROMs larger than INT_MAX bytes: return ssize_t instead
of int.  Bug can't bite, because the only user load_aout() limits ROM
size to an int value.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoImprove "ta 0" shutdown
Fabien Chouteau [Thu, 3 Nov 2011 15:10:04 +0000 (16:10 +0100)]
Improve "ta 0" shutdown

This patch replace the previous implementation with this simplified and
more complete version (no shutdown when psret == 1).

Signed-off-by: Fabien Chouteau <chouteau@adacore.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agogdbstub: Fix memory leak
Stefan Weil [Tue, 18 Oct 2011 20:25:38 +0000 (22:25 +0200)]
gdbstub: Fix memory leak

cppcheck report:
  gdbstub.c:1781: error: Memory leak: s

Rearranging of the code avoids the leak.

v2:
Replace the g_malloc0() by g_new0() (suggested by Stuart Brady).

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotcg-sparc: Fix set-but-not used warnings.
Richard Henderson [Wed, 9 Nov 2011 18:03:35 +0000 (10:03 -0800)]
tcg-sparc: Fix set-but-not used warnings.

In both cases, val is computed, but then not used in the
subsequent line, which then re-computes the quantity in
a different type (int32_t vs unsigned long).

Keep the computation type that's been working so far.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoMerge branch 's390-1.0' of git://repo.or.cz/qemu/agraf
Blue Swirl [Sat, 19 Nov 2011 11:17:58 +0000 (11:17 +0000)]
Merge branch 's390-1.0' of git://repo.or.cz/qemu/agraf

* 's390-1.0' of git://repo.or.cz/qemu/agraf:
  s390x: initialize virtio dev region
  tcg: Use TCGReg for standard tcg-target entry points.
  tcg: Standardize on TCGReg as the enum for hard registers
  s390x: Add shutdown for TCG s390-virtio machine
  s390: Fix cpu shutdown for KVM
  s390: fix short kernel command lines
  s390: fix reset hypercall to reset the status
  s390x: implement SIGP restart and shutdown
  s390x: implement rrbe instruction properly
  s390x: update R and C bits in storage key
  s390x: make ipte 31-bit aware
  s390x: add ldeb instruction

12 years agoMerge branch 'ppc-1.0' of git://repo.or.cz/qemu/agraf
Blue Swirl [Sat, 19 Nov 2011 11:17:11 +0000 (11:17 +0000)]
Merge branch 'ppc-1.0' of git://repo.or.cz/qemu/agraf

* 'ppc-1.0' of git://repo.or.cz/qemu/agraf:
  pseries: Fix qdev.id handling in the VIO bus code
  pseries: Allow kernel's early debug output to work
  pseries: Default reg for vty should be SPAPR_VTY_BASE_ADDRESS
  pseries: Check we have a chardev in spapr_vty_init()
  pseries: Fix buggy spapr_vio_find_by_reg()
  pseries: Correct RAM size check for SLOF
  PPC: Fix for the gdb single step problem on an rfi instruction
  tcg-ppc64: Fix compile errors for userspace only builds with gcc 4.6
  pseries: Fix initialization of sPAPREnvironment structure

12 years agoMerge remote-tracking branch 'kwolf/block-stable' into staging
Anthony Liguori [Fri, 18 Nov 2011 19:30:08 +0000 (13:30 -0600)]
Merge remote-tracking branch 'kwolf/block-stable' into staging

12 years agoMerge remote-tracking branch 'qmp/queue/qmp-1.0' into staging
Anthony Liguori [Fri, 18 Nov 2011 19:23:38 +0000 (13:23 -0600)]
Merge remote-tracking branch 'qmp/queue/qmp-1.0' into staging

12 years agofmodaudio: Remove unused variable 'bits16' (reported by cppcheck)
Stefan Weil [Fri, 18 Nov 2011 17:16:20 +0000 (18:16 +0100)]
fmodaudio: Remove unused variable 'bits16' (reported by cppcheck)

The variable is assigned a value which is never used,
so remove variable and assignment.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: malc <av1474@comtv.ru>
12 years agopseries: Fix qdev.id handling in the VIO bus code
Michael Ellerman [Tue, 15 Nov 2011 18:53:13 +0000 (18:53 +0000)]
pseries: Fix qdev.id handling in the VIO bus code

When the user creates a device on the command line with -device, they
can specify the id, using id=foo. Currently the VIO bus code overwrites
this id with it's own value. We should only set qdev.id if it is not
already set by the user.

The device tree code uses qdev.id for the device tree node name, however
we can't rely on the user specifiying the id using proper device tree
syntax, ie. device@reg. So separate the device tree node name from the
qdev.id, but use the same syntax, so they will match by default.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agopseries: Allow kernel's early debug output to work
David Gibson [Sun, 13 Nov 2011 17:19:01 +0000 (17:19 +0000)]
pseries: Allow kernel's early debug output to work

The PAPR specification defines a virtual TTY/console interface for guest
OSes to use via the H_PUT_TERM_CHAR and H_GET_TERM_CHAR hypercalls.  There
can be multiple virtual ttys, so these take a "termno" parameter.  This
encodes which vty to use as the 'reg' property on the device tree node
associated with that vty.

However, with the early debug options enabled, the Linux kernel will
attempt debugging output through the vty very early, before it has read
the device tree.  In this case it always uses a termno of 0.  This works
on the existing PowerVM hypervisor, so we assume there must be a hack /
feature in there which interprets termno==0 to mean the default primary
console.

To help with debugging kernels, including existing distribution kernels,
this patch implements a similar feature / hack in qemu.  If termno==0
is supplied to H_{GET,PUT}_TERM_CHAR, they use the first available vty
device instead.

We need to be careful in the case that the user has manually created
an spapr-vty at address 0. So first we search for the specified reg and
only if that doesn't match do we fall back.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agopseries: Default reg for vty should be SPAPR_VTY_BASE_ADDRESS
Michael Ellerman [Sun, 13 Nov 2011 17:19:00 +0000 (17:19 +0000)]
pseries: Default reg for vty should be SPAPR_VTY_BASE_ADDRESS

In commit b4a78527359a4540d84d4cdf629d01cbb262f698 ("Place pseries vty
devices at addresses more similar to existing machines"), we changed the
default reg for the vty to 0x30000000, however we didn't update the default
value for a user specified vty device. Fix that.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agopseries: Check we have a chardev in spapr_vty_init()
Michael Ellerman [Sun, 13 Nov 2011 17:18:59 +0000 (17:18 +0000)]
pseries: Check we have a chardev in spapr_vty_init()

If qemu is run like:

 qemu-system-ppc64 -nodefaults -device spapr-vty

We end up in spapr_vty_init() with dev->chardev == NULL. Currently
that leads to a segfault because we unconditionally call
qemu_chr_add_handlers().

Although we could make that call conditional, I think a spapr-vty
without a chardev is basically useless so fail the init. This is
similar to what the serial code does for example.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agopseries: Fix buggy spapr_vio_find_by_reg()
David Gibson [Sun, 13 Nov 2011 17:18:58 +0000 (17:18 +0000)]
pseries: Fix buggy spapr_vio_find_by_reg()

The spapr_vio_find_by_reg() function in hw/spapr_vio.c is supposed to find
the device structure for a PAPR virtual IO device with the given reg value,
and return NULL if none exists.

It does the first ok, but if no device with that reg exists, it just
returns the last device traversed in the list.  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 RAM size check for SLOF
David Gibson [Sun, 13 Nov 2011 17:18:57 +0000 (17:18 +0000)]
pseries: Correct RAM size check for SLOF

The SLOF firmware used on the pseries machine needs a reasonable amount of
(guest) RAM in order to run, so we have a check in the machine init
function to check that this is available.  However, SLOF runs in real mode
(MMU off) which means it can only actually access the RMA (Real Mode Area),
not all of RAM.  In many cases the RMA is the same as all RAM, but when
running with Book3S HV KVM on PowerPC 970, the RMA must be especially
allocated to be (host) physically contiguous.  In this case, the RMA size
is determined by what the host admin allocated at boot time, and will
usually be less than the whole guest RAM size.

This patch corrects the test to see if SLOF has enough memory for this
case.

In addition, more recent versions of SLOF that were committed earlier don't
need quite as much memory as earlier versions.  Therefore, this patch also
reduces the amount of RAM we require to run SLOF.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agoscsi-block: always use SG_IO for MMC devices
Paolo Bonzini [Mon, 14 Nov 2011 13:31:52 +0000 (14:31 +0100)]
scsi-block: always use SG_IO for MMC devices

CD burning messes up the state of the host page cache and host block
device.  Just pass all operations down to the device, even though that
might have slightly worse performance.  Everything else just is not
reliable in combination with burning.

Reported-by: Thomas Schmitt <scdbackup@gmx.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi: pass down REQUEST SENSE to the device when there is no stored sense
Paolo Bonzini [Mon, 14 Nov 2011 13:31:51 +0000 (14:31 +0100)]
scsi: pass down REQUEST SENSE to the device when there is no stored sense

This will let scsi-block/scsi-generic report progress on long
operations.

Reported-by: Thomas Schmitt <scdbackup@gmxbackup.net>
Tested-by: Thomas Schmitt <scdbackup@gmxbackup.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi: remove block descriptors from CDs
Paolo Bonzini [Mon, 14 Nov 2011 13:31:50 +0000 (14:31 +0100)]
scsi: remove block descriptors from CDs

Reported-by: Thomas Schmitt <scdbackup@gmx.net>
Tested-by: Thomas Schmitt <scdbackup@gmx.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi: fix parsing of allocation length field
Paolo Bonzini [Mon, 14 Nov 2011 13:31:49 +0000 (14:31 +0100)]
scsi: fix parsing of allocation length field

- several MMC commands were parsed wrong by QEMU because their allocation
length/parameter list length is placed in a non-standard position in
the CDB (i.e. it is different from most commands with the same value in
bits 5-7).

- SEND VOLUME TAG length was multiplied by 40 which is not in SMC.  The
parameter list length is between 32 and 40 bytes.  Same for MEDIUM SCAN
(spec found at http://ldkelley.com/SCSI2/SCSI2-16.html but not in any of
the PDFs I have here).

- READ_POSITION (SSC) conflicts with PRE_FETCH (SBC).  READ_POSITION's
transfer length is not hardcoded to 20 in SSC; for PRE_FETCH cmd->xfer
should be 0.  Both fixed.

- FORMAT MEDIUM (the SSC name for FORMAT UNIT) was missing.  The FORMAT
UNIT command is still somewhat broken for block devices because its
parameter list length is not in the CDB.  However it works for CD/DVD
drives, which mandate the length of the payload.

- fixed wrong sign-extensions for 32-bit fields (for the LBA field,
this affects disks >1 TB).

- several other SBC or SSC commands were missing or parsed wrong.

- some commands were not in the list of "write" commands.

Reported-by: Thomas Schmitt <scdbackup@gmx.net>
Tested-by: Thomas Schmitt <scdbackup@gmx.net> (MMC bits only)
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi: update list of commands
Paolo Bonzini [Mon, 14 Nov 2011 13:31:48 +0000 (14:31 +0100)]
scsi: update list of commands

Add more commands and their names, and remove SEEK(6) which is obsolete.
Instead, use SET_CAPACITY which is still in SSC.

Tested-by: Thomas Schmitt <scdbackup@gmx.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoatapi: kill MODE SENSE(6), fix MODE SENSE(10)
Paolo Bonzini [Mon, 14 Nov 2011 13:31:47 +0000 (14:31 +0100)]
atapi: kill MODE SENSE(6), fix MODE SENSE(10)

Mode page 2A of emulated ATAPI DVD-ROM should have page length 0x14
like SCSI CD-ROM, rather than 0x12.

Mode page length is off by 8, as it should contain the length of the
payload after the first two bytes.

MODE SENSE(6) should be thrown out of ATAPI DVD-ROM emulation.  It is
not specified in the ATAPI list of MMC-2, and MMC-5 prescribes to use
MODE SENSE(10).  Anyway, its implementation is wrong.

Reported-by: Thomas Schmitt <scdbackup@gmx.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi-disk: guess geometry
Paolo Bonzini [Tue, 15 Nov 2011 15:57:50 +0000 (16:57 +0100)]
scsi-disk: guess geometry

Old operating systems rely on correct geometry to convert from CHS
addresses to LBA.  Providing correct data is necessary for them to boot.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi: fix fw path
Paolo Bonzini [Tue, 15 Nov 2011 16:36:38 +0000 (17:36 +0100)]
scsi: fix fw path

The pre-1.0 firmware path for SCSI devices already included the LUN
using the suffix argument to add_boot_device_path.  I missed that when
making channel and LUN customizable.  Avoid that it is included twice, and
convert the colons to commas for consistency with other kinds of devices

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoDocumentation: Add section about iSCSI LUNS to qemu-doc
Ronnie Sahlberg [Sat, 12 Nov 2011 00:06:30 +0000 (11:06 +1100)]
Documentation: Add section about iSCSI LUNS to qemu-doc

Add a new section about using iSCSI LUNs with qemu
and provide a short example on how to set up a target and access it
using the built-in initiator

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoMakefile: fix qga dependencies
Michael S. Tsirkin [Wed, 16 Nov 2011 21:58:31 +0000 (23:58 +0200)]
Makefile: fix qga dependencies

.c files include .h files, so .o depends on .h,
and the linked result depends on .o.
We got it wrong for qga rules, fix it up.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
12 years agoMakefile: dependency fix
Michael S. Tsirkin [Wed, 16 Nov 2011 21:58:24 +0000 (23:58 +0200)]
Makefile: dependency fix

qga/guest-agent-commands.c includes qga-qmp-commands.h,
but it was missing in its dependencies. Add it in QGALIB_GEN.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>