Message ID | 1431012374-14113-1-git-send-email-pbonzini@redhat.com |
---|---|
State | New |
Headers | show |
On 07.05.2015 17:26, Paolo Bonzini wrote: > This is consistent with the handling of writes. > > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> > --- > nbd.c | 6 ++++++ > 1 file changed, 6 insertions(+) Reviewed-by: Max Reitz <mreitz@redhat.com>
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);
This is consistent with the handling of writes. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> --- nbd.c | 6 ++++++ 1 file changed, 6 insertions(+)