scsi-disk: Improve error messager if can't get version number

More often it is that bdrv_ioctl fails due to not supported by driver or
whatever reason, in this case we should be specific, because "interface
too old" is very confusing.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
scsi: Improve error messages more

Remove the "scsi-block:" prefix for error messages as suggested
by Markus.

Improve the previous patch by making the message the same for both
scsi-block and scsi-generic, including the strerror() output in both
and making an explicit reference to SG_IO.  Also s/can not/cannot/.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
megasas: Implement LD_LIST_QUERY

Newer firmware implement a LD_LIST_QUERY command, and due to a driver
issue no drives might be detected if this command isn't supported.
So add emulation for this command, too.

Cc: qemu-stable@nongnu.org
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
megasas: Enable MSI-X support

MSI-X support has been fixed in qemu, so we can enable it again.

Signed-off-by: Hannes Reinecke <hare@suse.de>
[Do not change VMSTATE_PCI_DEVICE to PCIE. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
megasas: Add MSI support

Some hardware instances do support MSI, so we should do likewise.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
MAINTAINERS: mark megasas as maintained

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
block/iscsi: allow fall back to WRITE SAME without UNMAP

if the iscsi driver receives a write zeroes request with
the BDRV_REQ_MAY_UNMAP flag set it fails with -ENOTSUP
if the iscsi target does not support WRITE SAME with
UNMAP. However, the BDRV_REQ_MAY_UNMAP is only a hint
and writing zeroes with WRITE SAME will still be
better than falling back to writing zeroes with WRITE16.

Signed-off-by: Peter Lieven <pl@kamp.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
block/iscsi: speed up read for unallocated sectors

this patch implements a cache that tracks if a page on the
iscsi target is allocated or not. The cache is implemented in
a way that it allows for false positives
(e.g. pretending a page is allocated, but it isn't), but
no false negatives.

The cached allocation info is then used to speed up the
read process for unallocated sectors by issueing a GET_LBA_STATUS
request for all sectors that are not yet known to be allocated.
If the read request is confirmed to fall into an unallocated
range we directly return zeroes and do not transfer the
data over the wire.

Tests have shown that a relatively small amount of GET_LBA_STATUS
requests happens a vServer boot time to fill the allocation cache
(all those blocks are not queried again).

Not to transfer all the data of unallocated sectors saves a lot
of time, bandwidth and storage I/O load during block jobs or storage
migration and it saves a lot of bandwidth as well for any big sequential
read of the whole disk (e.g. block copy or speed tests) if a significant
number of blocks is unallocated.

Signed-off-by: Peter Lieven <pl@kamp.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
block/iscsi: clarify the meaning of ISCSI_CHECKALLOC_THRES

Signed-off-by: Peter Lieven <pl@kamp.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
block/iscsi: allow cluster_size of 4K and greater

depending on the target the opt_unmap_gran might be as low
as 4K. As we know use this also as a knob to activate the allocationmap
feature lower the barrier. The limit 4K (and not 512) is choosen
to avoid a potentially too big allocationmap.

Signed-off-by: Peter Lieven <pl@kamp.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
[PATCH] block/iscsi: bump year in copyright notice

Signed-off-by: Peter Lieven <pl@kamp.de>
build: Fix per-object variables for Makefile.target

The compiling is done in a subdir, so the extraction of per-object libs
and cflags are referencing objects with ../ prefixed. So prefix the
per-object variables "foo.o-cflags" and "foo.o-libs" to
"../foo.o-cflags" and "../foo.o-libs".

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
build: simplify Makefile.target a bit, use just one rule for softmmu

On win*, we build QEMU_PROGW (GUI) and create a console app QEMU_PROG
from it, while on non-win*, we make only QEMU_PROG using the same
rules as used for QEMU_PROGW on win*.  Make just one rule for building
main executable, and an additional rule for win* to make console app
from it.  Also consolidate tests for $(QEMU_PROGW).

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
[Fix user-mode compilation. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
build: simplify Makefile.target around unnest-vars invocations

No need to save/restore obj-y, we can just build all-obj-y incrementally.

Reviewed-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Makefile: strip tools and modules too

Commit 52ba784d3 replaced $(STRIP_OPT) with $(STRIP) in some
places (for example, Makefile.target), but not all of them.
There are a few places remain in main Makefile which still
uses $(STRIP_OPT).  Replace these places with $(STRIP) too.

While at it, simplify variable pattern substitution of the
surrounding places, change $(patsubst pat,rep,$(var)) into
$(var:pat=rep) which is much easier to read (this is probably
a good idea to do everywhere).

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Cc: Fam Zheng <famz@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Makefile.target: use $(INSTALL_PROG) for installing, not $(INSTALL)

$(INSTALL_PROG) is evaluated to libtool if using libtool, while
$(INSTALL) is not.  Use $(INSTALL_PROG) so that libtool is used
with target too when necessary.  This allows, for example, to
link qemu with shared libcacard.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Cc: Fam Zheng <famz@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Alon Levy <alevy@redhat.com>
Cc: qemu-trivial@nongnu.org
--
This is done on top of previous patch (using $(STRIP)), but it can
be used by its own.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Makefile: use $(INSTALL_LIB) for modules not $(INSTALL_PROG)

We have $(INSTALL_LIB) which is the same as $(INSTALL_PROG) but
uses correct permissions.  Loadable objects (modules) are like
shared libraries, not like programs.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Cc: Fam Zheng <famz@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
build: add support for per-object -cflags and -libs to all rules

This is needed in order to use per-object flags variables.

Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
build: convert some obj-specific CFLAGS to use new foo.o-cflags syntax

Current Makefile system allows using foo.o-cflags variables to store
object-specific CFLAGS.  Convert some usages of old syntax
(using QEMU_CFLAGS += construct) to the new syntax.

Do not touch multifile modules for now, as build system isn't ready for this.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
qcow2: Fix alloc_clusters_noref() overflow detection

If the very first allocation has a length of 0, the free_cluster_index
is still 0 after the for loop, which means that subtracting one from it
will underflow and signal an invalid range of clusters by returning
-EFBIG. However, there is no such range, as its length is 0.

Fix this by preventing underflows on free_cluster_index during the
check.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>