iscsi: Use bs->sg for everything else than disks

The current iscsi block driver code makes the rather arbitrary decision
that TYPE_MEDIUM_CHANGER and TYPE_TAPE devices have bs->sg = 1 and all
other device types are disks.

Instead of this, check for TYPE_DISK to expose the disk interface and
make everything else bs->sg = 1. In particular, this includes devices
with TYPE_STORAGE_ARRAY, which is what LUN 0 of an iscsi target is.
(See https://bugzilla.redhat.com/show_bug.cgi?id=1067784 for the exact
scenario.)

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Benoit Canet <benoit@irqsave.net>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Kevin Wolf 2014-03-05 15:45:00 +01:00
parent 2fa4c042bc
commit f47c3f5a80

View File

@ -1231,12 +1231,11 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags,
bs->total_sectors = sector_lun2qemu(iscsilun->num_blocks, iscsilun); bs->total_sectors = sector_lun2qemu(iscsilun->num_blocks, iscsilun);
bs->request_alignment = iscsilun->block_size; bs->request_alignment = iscsilun->block_size;
/* Medium changer or tape. We dont have any emulation for this so this must /* We don't have any emulation for devices other than disks and CD-ROMs, so
* be sg ioctl compatible. We force it to be sg, otherwise qemu will try * this must be sg ioctl compatible. We force it to be sg, otherwise qemu
* to read from the device to guess the image format. * will try to read from the device to guess the image format.
*/ */
if (iscsilun->type == TYPE_MEDIUM_CHANGER || if (iscsilun->type != TYPE_DISK && iscsilun->type != TYPE_ROM) {
iscsilun->type == TYPE_TAPE) {
bs->sg = 1; bs->sg = 1;
} }