Received: from eggs.gnu.org ([2001:4830:134:3::10]:36272) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UygMZ-0003aP-OD for qemu-devel@nongnu.org; Mon, 15 Jul 2013 06:50:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UygMV-0002DR-0b for qemu-devel@nongnu.org; Mon, 15 Jul 2013 06:50:39 -0400 Received: from mx.ipv6.kamp.de ([2a02:248:0:51::16]:48670 helo=mx01.kamp.de) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1UygMU-0002D3-M0 for qemu-devel@nongnu.org; Mon, 15 Jul 2013 06:50:34 -0400 From: Peter Lieven Date: Mon, 15 Jul 2013 12:49:33 +0200 Message-Id: <1373885375-13601-3-git-send-email-pl@kamp.de> In-Reply-To: <1373885375-13601-1-git-send-email-pl@kamp.de> References: <1373885375-13601-1-git-send-email-pl@kamp.de> Subject: [Qemu-devel] [PATCH 2/4] iscsi: add .bdrv_get_info List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, pbonzini@redhat.com, Peter Lieven , ronniesahlberg@gmail.com, stefanha@redhat.com this is used to reveal max_unmap and discard_zeroes capabilities. Signed-off-by: Peter Lieven --- block/iscsi.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/block/iscsi.c b/block/iscsi.c index 2b8fab9..74a35b9 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -927,6 +927,11 @@ retry: return 0; } +static bool iscsi_discard_zeroes(IscsiLun *iscsilun) +{ + return iscsilun->lbprz && iscsilun->lbpu; +} + static int coroutine_fn iscsi_co_write_zeroes(BlockDriverState *bs, int64_t sector_num, int nb_sectors) @@ -937,8 +942,7 @@ coroutine_fn iscsi_co_write_zeroes(BlockDriverState *bs, int64_t sector_num, return -EINVAL; } - if (!iscsilun->lbprz || !iscsilun->lbpu || - !(bs->open_flags & BDRV_O_UNMAP)) { + if (!iscsi_discard_zeroes(iscsilun) || !(bs->open_flags & BDRV_O_UNMAP)) { /* fall back to writev */ return -ENOTSUP; } @@ -1468,6 +1472,16 @@ out: return ret; } +static int iscsi_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) +{ + IscsiLun *iscsilun = bs->opaque; + + bdi->max_unmap = sector_lun2qemu(iscsilun->max_unmap, iscsilun); + bdi->discard_zeroes = iscsi_discard_zeroes(iscsilun); + + return 0; +} + static QEMUOptionParameter iscsi_create_options[] = { { .name = BLOCK_OPT_SIZE, @@ -1488,6 +1502,7 @@ static BlockDriver bdrv_iscsi = { .create_options = iscsi_create_options, .bdrv_getlength = iscsi_getlength, + .bdrv_get_info = iscsi_get_info, .bdrv_truncate = iscsi_truncate, .bdrv_co_is_allocated = iscsi_co_is_allocated, -- 1.7.9.5