From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:59423) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T6LNM-0005M0-M7 for qemu-devel@nongnu.org; Tue, 28 Aug 2012 08:58:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T6LNL-0001Hj-KU for qemu-devel@nongnu.org; Tue, 28 Aug 2012 08:58:36 -0400 Received: from mail-yw0-f45.google.com ([209.85.213.45]:62235) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T6LNL-0001Hb-Fa for qemu-devel@nongnu.org; Tue, 28 Aug 2012 08:58:35 -0400 Received: by yhpp34 with SMTP id p34so1065932yhp.4 for ; Tue, 28 Aug 2012 05:58:35 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Tue, 28 Aug 2012 14:52:19 +0200 Message-Id: <1346158339-14431-5-git-send-email-pbonzini@redhat.com> In-Reply-To: <1346158339-14431-1-git-send-email-pbonzini@redhat.com> References: <1346158339-14431-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH for 1.2 4/4] iscsi: Set number of blocks to 0 for blank CDROM devices List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com, Ronnie Sahlberg From: Ronnie Sahlberg The number of blocks of the device is used to compute the device size in bdrv_getlength()/iscsi_getlength(). For MMC devices, the ReturnedLogicalBlockAddress in the READCAPACITY10 has a special meaning when it is 0. In this case it does not mean that LBA 0 is the last accessible LBA, and thus the device has 1 readable block, but instead it means that the disc is blank and there are no readable blocks. This change ensures that when the iSCSI LUN is loaded with a blank DVD-R disk or similar that bdrv_getlength() will return the correct size of the device as 0 bytes. Signed-off-by: Ronnie Sahlberg --- block/iscsi.c | 7 ++++++- 1 file modificato, 6 inserzioni(+). 1 rimozione(-) diff --git a/block/iscsi.c b/block/iscsi.c index 4828b83..0b96165 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -721,7 +721,12 @@ iscsi_readcapacity10_cb(struct iscsi_context *iscsi, int status, } itask->iscsilun->block_size = rc10->block_size; - itask->iscsilun->num_blocks = rc10->lba + 1; + if (rc10->lba == 0) { + /* blank disk loaded */ + itask->iscsilun->num_blocks = 0; + } else { + itask->iscsilun->num_blocks = rc10->lba + 1; + } itask->bs->total_sectors = itask->iscsilun->num_blocks * itask->iscsilun->block_size / BDRV_SECTOR_SIZE ; -- 1.7.11.2