From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:57315) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T2CQa-0003PO-Cl for qemu-devel@nongnu.org; Thu, 16 Aug 2012 22:36:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T2CQZ-0005ZV-7w for qemu-devel@nongnu.org; Thu, 16 Aug 2012 22:36:48 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:55211) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T2CQZ-0005Vz-1p for qemu-devel@nongnu.org; Thu, 16 Aug 2012 22:36:47 -0400 Received: by mail-pb0-f45.google.com with SMTP id rp12so2601939pbb.4 for ; Thu, 16 Aug 2012 19:36:46 -0700 (PDT) From: Ronnie Sahlberg Date: Fri, 17 Aug 2012 12:36:21 +1000 Message-Id: <1345170981-7738-3-git-send-email-ronniesahlberg@gmail.com> In-Reply-To: <1345170981-7738-1-git-send-email-ronniesahlberg@gmail.com> References: <1345170981-7738-1-git-send-email-ronniesahlberg@gmail.com> Subject: [Qemu-devel] [PATCH 2/2] ISCSI: Force scsi-generic for MMC with blank disks List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: kwolf@redhat.com, qemu-devel@nongnu.org, pbonzini@redhat.com Cc: Ronnie Sahlberg There is no bdrv_* API for the commands for burning a blank MMC disk so when iSCSI LUNs are specified and the LUN is a MMC device with 0 available blocks. This is a blank disk so force scsi generic. This allows the guest to talk directly to the target to burn data on the disk. Signed-off-by: Ronnie Sahlberg --- block/iscsi.c | 13 +++++++++++-- 1 files changed, 11 insertions(+), 2 deletions(-) diff --git a/block/iscsi.c b/block/iscsi.c index fb420ea..ca53afa 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -1017,10 +1017,19 @@ static int iscsi_open(BlockDriverState *bs, const char *filename, int flags) /* 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. + * MMC device with no blocks contain a blank disk so force them to use sg + * too. */ - if (iscsilun->type == TYPE_MEDIUM_CHANGER || - iscsilun->type == TYPE_TAPE) { + switch (iscsilun->type) { + case TYPE_ROM: + if (iscsilun->num_blocks > 0) { + break; + } + case TYPE_MEDIUM_CHANGER: + case TYPE_TAPE: bs->sg = 1; + default: + break; } ret = 0; -- 1.7.3.1