diff options
author | Eric Blake <eblake@redhat.com> | 2017-11-08 15:56:58 -0600 |
---|---|---|
committer | Eric Blake <eblake@redhat.com> | 2017-11-09 10:10:17 -0600 |
commit | 1104d83c726d2b20f9cec7b99ab3570a2fdbd46d (patch) | |
tree | db4d3801912ff80f01f23d158c346060a25e255b /tests/qemu-iotests/140 | |
parent | e659fb3b9904b89f817e5f1d158f247be1bcc862 (diff) | |
download | qemu-1104d83c726d2b20f9cec7b99ab3570a2fdbd46d.zip qemu-1104d83c726d2b20f9cec7b99ab3570a2fdbd46d.tar.gz qemu-1104d83c726d2b20f9cec7b99ab3570a2fdbd46d.tar.bz2 |
nbd-client: Refuse read-only client with BDRV_O_RDWR
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
It is no longer possible to even attempt writes over the wire
(including the corner case of 0-length writes), because the block
layer enforces the explicit read-only request; this matches the
behavior of qcow2 when backed by a read-only POSIX file.
Fix several iotests to comply with the new behavior (since
qemu-nbd of an internal snapshot, as well as nbd-server-add over QMP,
default to a read-only export, we must tell blockdev-add/qemu-io to
set up a read-only client).
CC: qemu-stable@nongnu.org
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20171108215703.9295-3-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Diffstat (limited to 'tests/qemu-iotests/140')
-rwxr-xr-x | tests/qemu-iotests/140 | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/qemu-iotests/140 b/tests/qemu-iotests/140 index f89d0d6..a8fc951 100755 --- a/tests/qemu-iotests/140 +++ b/tests/qemu-iotests/140 @@ -78,7 +78,7 @@ _send_qemu_cmd $QEMU_HANDLE \ 'arguments': { 'device': 'drv' }}" \ 'return' -$QEMU_IO_PROG -f raw -c 'read -P 42 0 64k' \ +$QEMU_IO_PROG -f raw -r -c 'read -P 42 0 64k' \ "nbd+unix:///drv?socket=$TEST_DIR/nbd" 2>&1 \ | _filter_qemu_io | _filter_nbd @@ -87,7 +87,7 @@ _send_qemu_cmd $QEMU_HANDLE \ 'arguments': { 'device': 'drv' }}" \ 'return' -$QEMU_IO_PROG -f raw -c close \ +$QEMU_IO_PROG -f raw -r -c close \ "nbd+unix:///drv?socket=$TEST_DIR/nbd" 2>&1 \ | _filter_qemu_io | _filter_nbd |