On Thu, Nov 09, 2017 at 10:59:34AM -0600, Eric Blake wrote: > The NBD spec says that clients should not try to write/trim to > an export advertised as read-only by the server. But we failed > to check that, and would allow the block layer to use NBD with > BDRV_O_RDWR even when the server is read-only, which meant we > were depending on the server sending a proper EPERM failure for > various commands, and also exposes a leaky abstraction: using > qemu-io in read-write mode would succeed on 'w -z 0 0' because > of local short-circuiting logic, but 'w 0 0' would send a > request over the wire (where it then depends on the server, and > fails at least for qemu-nbd but might pass for other NBD > implementations). > > With this patch, a client MUST request read-only mode to access > a server that is doing a read-only export, or else it will get > a message like: > > can't open device nbd://localhost:10809/foo: request for write access > conflicts with read-only export
Nice one! This caught 3 bugs in the nbdkit test suite where we were opening the connection for write to a read-only server instance, and it happened to work because the test did not write anything. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW