[Libguestfs] [nbdkit PATCH 1/2] nbd: Don't advertise writes if nbdkit is readonly

Eric Blake eblake at redhat.com
Wed Nov 22 02:39:10 UTC 2017


Although nbdkit connections.c currently calls but ignores the
value of nbd_can_write() if the user requested -r, it is still
better to update our internal flags so that nbd_can_write()
gives an answer consistent with how nbd_open() was called.

Signed-off-by: Eric Blake <eblake at redhat.com>
---
 plugins/nbd/nbd.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/plugins/nbd/nbd.c b/plugins/nbd/nbd.c
index df49a1d..b844bf5 100644
--- a/plugins/nbd/nbd.c
+++ b/plugins/nbd/nbd.c
@@ -504,6 +504,8 @@ nbd_open (int readonly)
     nbdkit_error ("unexpected version %#" PRIx64, version);
     goto err;
   }
+  if (readonly)
+    h->flags |= NBD_FLAG_READ_ONLY;

   /* Spawn a dedicated reader thread */
   if ((errno = pthread_mutex_init (&h->write_lock, NULL))) {
-- 
2.13.6




More information about the Libguestfs mailing list