From: Ronnie Sahlberg Date: Sat, 26 May 2012 04:56:41 +0000 (+1000) Subject: ISCSI: force use of sg for SMC and SSC devices X-Git-Tag: TizenStudio_2.0_p2.3.2~208^2~3915^2~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=622695a4585a786fdcd53852c7af87ed0af1af80;p=sdk%2Femulator%2Fqemu.git ISCSI: force use of sg for SMC and SSC devices If the device we open is a SMC or SSC device, then force the use of sg. We dont have any medium changer or tape emulation so only passthrough via real sg or scsi-generic via iscsi would work anyway. Forcing sg also makes qemu skip trying to read from the device to guess the image format by reading from the device (find_image_format()). SMC devices do not implement READ6/10/12/16 so it is not possible to read from them (SSC have different CDBs). With this patch I can successfully manage a SMC device wiht iscsi in passthrough mode. Signed-off-by: Ronnie Sahlberg [Added TYPE_TAPE handling - Paolo] Signed-off-by: Paolo Bonzini --- diff --git a/block/iscsi.c b/block/iscsi.c index 029739e..ac65277 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -1022,6 +1022,16 @@ static int iscsi_open(BlockDriverState *bs, const char *filename, int flags) if (iscsi_url != NULL) { iscsi_destroy_url(iscsi_url); } + + /* Medium changer or tape. We dont have any emulation for this so this must + * be sg ioctl compatible. We force it to be sg, otherwise qemu will try + * to read from the device to guess the image format. + */ + if (iscsilun->type == TYPE_MEDIUM_CHANGER || + iscsilun->type == TYPE_TAPE) { + bs->sg = 1; + } + return 0; failed: