Eric Blake
1104d83c72
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>
2017-11-09 10:10:17 -06:00
..
2017-08-09 04:22:13 +03:00
2017-07-18 05:49:01 -05:00
2017-11-02 11:46:41 +00:00
2017-09-22 10:46:25 +08:00
2017-10-16 13:29:49 +02:00
2017-10-11 15:15:17 -03:00
2017-08-11 13:23:19 +02:00
2017-09-01 12:51:04 +02:00
2017-11-09 10:10:17 -06:00
2017-07-11 17:45:00 +02:00
2017-07-20 10:10:28 +01:00
2017-10-11 15:15:17 -03:00
2017-10-16 20:57:06 +03:00
2016-06-07 18:19:24 +03:00
2017-03-02 07:14:27 +02:00
2017-05-03 12:29:40 +02:00
2017-10-16 13:29:49 +02:00
2016-10-26 08:29:01 -07:00
2017-09-04 10:45:19 +01:00
2017-09-04 10:45:19 +01:00
2017-09-04 10:45:19 +01:00
2017-08-02 00:13:26 +03:00
2017-10-20 13:32:10 +02:00
2017-09-26 09:11:23 +03:00
2016-10-14 10:06:47 +11:00
2017-10-20 13:32:10 +02:00
2016-09-23 13:36:09 +02:00
2017-06-20 14:31:33 +02:00
2017-09-04 13:09:11 +02:00
2017-06-20 14:31:31 +02:00
2017-09-04 13:09:12 +02:00
2017-07-24 13:35:11 +02:00
2017-06-20 14:31:31 +02:00
2016-09-08 17:57:32 +04:00
2017-09-04 13:09:13 +02:00
2017-06-20 14:31:31 +02:00
2017-09-04 10:45:19 +01:00
2016-10-28 18:17:24 +03:00
2017-07-17 15:41:30 -03:00
2017-01-31 10:10:13 +11:00
2017-09-19 18:21:32 +02:00
2016-06-07 18:19:24 +03:00
2017-03-01 11:51:28 +04:00
2017-03-01 11:51:28 +04:00
2017-03-01 11:51:05 +04:00
2017-10-20 13:32:10 +02:00
2016-06-07 18:19:24 +03:00
2017-05-09 09:14:40 +02:00
2017-10-16 13:29:49 +02:00
2017-03-01 11:51:04 +04:00
2017-03-01 11:51:28 +04:00
2016-06-07 18:19:24 +03:00
2017-08-10 14:33:43 +01:00
2016-06-20 16:38:13 +02:00
2017-09-05 13:21:58 +01:00
2016-06-07 18:19:24 +03:00
2017-02-21 11:14:07 +00:00
2017-02-21 11:14:07 +00:00
2017-10-20 13:32:10 +02:00
2017-03-01 11:51:05 +04:00
2016-06-07 18:19:24 +03:00
2017-01-31 10:10:13 +11:00
2017-10-20 13:32:10 +02:00
2017-10-20 13:32:10 +02:00
2017-10-20 13:32:10 +02:00
2016-06-07 18:19:24 +03:00
2017-10-29 14:06:16 +01:00
2017-06-15 11:04:05 +02:00
2017-10-29 14:06:16 +01:00
2016-06-07 18:19:24 +03:00
2017-09-15 09:05:19 +02:00
2017-05-11 11:08:40 +02:00
2017-10-16 13:29:49 +02:00
2016-06-07 18:19:24 +03:00
2016-10-19 10:09:24 +01:00
2017-10-20 13:32:10 +02:00
2017-10-20 13:32:10 +02:00
2017-09-19 16:19:39 +02:00
2017-03-01 00:09:28 +04:00
2016-10-24 16:26:53 +01:00
2017-03-01 00:09:28 +04:00
2017-10-15 05:54:44 +03:00
2017-06-16 18:44:55 +03:00
2017-10-24 13:53:41 -07:00
2017-09-04 13:09:13 +02:00
2017-04-26 14:42:31 +01:00
2016-06-07 18:19:24 +03:00
2016-10-28 09:36:58 +11:00
2017-08-01 17:27:33 +02:00
2016-10-28 09:38:27 +11:00
2016-10-16 12:04:15 +11:00
2017-10-20 13:32:10 +02:00
2017-03-14 13:28:29 +01:00
2017-03-14 13:28:29 +01:00
2016-10-24 16:26:54 +01:00
2016-06-07 18:19:24 +03:00
2017-01-10 08:49:59 -08:00
2016-06-17 15:23:51 +01:00
2017-05-24 16:38:51 -04:00
2017-05-24 16:38:51 -04:00
2016-09-13 19:13:32 +02:00
2017-07-14 11:04:34 +02:00
2017-05-31 16:04:05 +02:00
2016-09-28 17:11:23 +01:00
2017-07-11 17:44:56 +02:00
2016-12-21 14:26:26 +00:00
2016-10-19 10:23:55 +01:00
2016-12-22 09:24:59 +00:00
2016-09-19 16:30:45 +01:00
2016-06-13 12:41:17 +01:00
2016-07-04 10:46:59 +01:00
2017-02-23 20:35:36 +01:00
2017-10-20 13:32:10 +02:00
2017-10-20 13:32:10 +02:00
2017-10-06 16:28:58 +02:00
2017-09-15 09:05:19 +02:00
2016-10-26 08:29:00 -07:00
2017-03-01 00:09:28 +04:00
2017-05-09 09:14:40 +02:00
2017-09-05 13:21:58 +01:00
2017-01-26 10:26:18 +00:00
2017-09-05 22:34:40 +02:00
2017-06-19 14:56:29 +02:00
2016-08-19 12:44:11 +01:00
2016-06-07 18:19:24 +03:00
2017-08-30 18:23:25 +02:00
2017-03-22 19:24:34 +01:00
2017-09-04 13:09:13 +02:00
2017-07-17 15:41:30 -03:00
2016-08-03 18:44:56 +02:00
2017-05-09 09:13:51 +02:00
2017-09-15 09:05:18 +02:00
2016-06-16 18:39:03 +02:00
2016-10-06 18:04:13 +02:00
2017-06-20 14:31:31 +02:00
2017-06-20 14:31:31 +02:00
2017-09-04 13:09:13 +02:00
2017-09-04 13:09:13 +02:00
2016-06-07 18:19:24 +03:00
2017-05-11 11:08:41 +02:00
2017-01-31 10:10:14 +11:00
2017-09-04 13:09:13 +02:00
2017-09-04 13:09:13 +02:00
2017-02-21 11:14:07 +00:00
2017-09-05 18:12:21 +02:00
2016-06-07 18:19:24 +03:00
2016-11-11 20:53:23 +08:00
2017-03-07 16:07:47 +01:00
2017-09-27 11:44:18 +01:00
2016-06-07 18:19:24 +03:00
2017-06-20 14:31:31 +02:00
2016-06-07 18:19:24 +03:00
2017-05-18 18:04:54 +02:00
2016-06-07 18:19:24 +03:00
2016-06-07 18:19:24 +03:00
2017-03-01 11:51:29 +04:00
2016-06-07 18:19:24 +03:00
2017-09-15 09:05:18 +02:00
2017-09-15 09:05:18 +02:00
2017-10-12 16:57:42 +02:00
2017-09-05 19:31:13 +01:00
2017-03-27 21:15:31 +02:00
2017-10-20 13:32:10 +02:00
2017-10-20 13:32:10 +02:00
2017-10-20 13:32:10 +02:00
2017-06-30 11:03:45 +01:00
2016-10-28 09:36:58 +11:00
2017-09-19 14:09:31 +02:00
2017-10-20 13:32:10 +02:00
2017-10-20 13:32:10 +02:00
2016-06-07 18:19:24 +03:00
2016-06-20 16:38:13 +02:00