All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] qemu-nbd: return EROFS for discard on a read-only export
@ 2015-05-07 15:26 Paolo Bonzini
  2015-05-07 15:26 ` [Qemu-devel] [PATCH] qemu-nbd: only send a limited number of errno codes on the wire Paolo Bonzini
  2015-05-08 12:43 ` [Qemu-devel] [PATCH] qemu-nbd: return EROFS for discard on a read-only export Max Reitz
  0 siblings, 2 replies; 12+ messages in thread
From: Paolo Bonzini @ 2015-05-07 15:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, mreitz

This is consistent with the handling of writes.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 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

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2015-05-08 13:02 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-07 15:26 [Qemu-devel] [PATCH] qemu-nbd: return EROFS for discard on a read-only export Paolo Bonzini
2015-05-07 15:26 ` [Qemu-devel] [PATCH] qemu-nbd: only send a limited number of errno codes on the wire Paolo Bonzini
2015-05-07 17:01   ` Eric Blake
2015-05-07 17:06     ` Paolo Bonzini
2015-05-08  6:45   ` Markus Armbruster
2015-05-08  8:30     ` Paolo Bonzini
2015-05-08  9:32       ` Markus Armbruster
2015-05-08  9:40         ` Paolo Bonzini
2015-05-08 10:04           ` Markus Armbruster
2015-05-08 12:45   ` Max Reitz
2015-05-08 13:01     ` Max Reitz
2015-05-08 12:43 ` [Qemu-devel] [PATCH] qemu-nbd: return EROFS for discard on a read-only export Max Reitz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.