From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57345) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YqNgr-0004Ht-KL for qemu-devel@nongnu.org; Thu, 07 May 2015 11:26:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YqNgo-0002HE-Ep for qemu-devel@nongnu.org; Thu, 07 May 2015 11:26:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38285) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YqNgo-0002H9-AV for qemu-devel@nongnu.org; Thu, 07 May 2015 11:26:18 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id E8E828EA57 for ; Thu, 7 May 2015 15:26:17 +0000 (UTC) From: Paolo Bonzini Date: Thu, 7 May 2015 17:26:13 +0200 Message-Id: <1431012374-14113-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH] qemu-nbd: return EROFS for discard on a read-only export List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, mreitz@redhat.com This is consistent with the handling of writes. Signed-off-by: Paolo Bonzini --- nbd.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nbd.c b/nbd.c index cb1b9bb..eea8c51 100644 --- a/nbd.c +++ b/nbd.c @@ -1325,6 +1325,12 @@ static void nbd_trip(void *opaque) break; case NBD_CMD_TRIM: TRACE("Request type is TRIM"); + if (exp->nbdflags & NBD_FLAG_READ_ONLY) { + TRACE("Server is read-only, return error"); + reply.error = EROFS; + goto error_reply; + } + ret = blk_co_discard(exp->blk, (request.from + exp->dev_offset) / BDRV_SECTOR_SIZE, request.len / BDRV_SECTOR_SIZE); -- 2.3.5