]> git.ipfire.org Git - thirdparty/qemu.git/commit
iscsi: Fix divide-by-zero regression on raw SG devices
authorEric Blake <eblake@redhat.com>
Wed, 7 Sep 2016 21:27:20 +0000 (16:27 -0500)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Wed, 2 Nov 2016 21:53:21 +0000 (16:53 -0500)
commitd40d148feb7e7c45fdb36adb47b1f34467845460
treef981a11d9ff7b7ab21af013e0493053bd8edd467
parentf9856029d59f4c6a580ebbf03d81c4016c19696a
iscsi: Fix divide-by-zero regression on raw SG devices

When qemu uses iscsi devices in sg mode, iscsilun->block_size
is left at 0.  Prior to commits cf081fca and similar, when
block limits were tracked in sectors, this did not matter:
various block limits were just left at 0.  But when we started
scaling by block size, this caused SIGFPE.

Then, in a later patch, commit a5b8dd2c added an assertion to
bdrv_open_common() that request_alignment is always non-zero;
which was not true for SG mode.  Rather than relax that assertion,
we can just provide a sane value (we don't know of any SG device
with a block size smaller than qemu's default sizing of 512 bytes).

One possible solution for SG mode is to just blindly skip ALL
of iscsi_refresh_limits(), since we already short circuit so
many other things in sg mode.  But this patch takes a slightly
more conservative approach, and merely guarantees that scaling
will succeed, while still using multiples of the original size
where possible.  Resulting limits may still be zero in SG mode
(that is, we mostly only fix block_size used as a denominator
or which affect assertions, not all uses).

Reported-by: Holger Schranz <holger@fam-schranz.de>
Signed-off-by: Eric Blake <eblake@redhat.com>
CC: qemu-stable@nongnu.org
Message-Id: <1473283640-15756-1-git-send-email-eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 95eaa78537c734fa3cb3373d47ba8c0099a36ff0)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
block/iscsi.c