From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, vsementsov@virtuozzo.com, qemu-block@nongnu.org
Subject: [Qemu-devel] [PATCH v6 04/12] nbd/server: Report error for write to read-only export
Date: Fri, 27 Oct 2017 12:40:29 +0200 [thread overview]
Message-ID: <20171027104037.8319-5-eblake@redhat.com> (raw)
In-Reply-To: <20171027104037.8319-1-eblake@redhat.com>
When the server is read-only, we were already reporting an error
message for NBD_CMD_WRITE_ZEROES, but failed to set errp for a
similar NBD_CMD_WRITE. This will matter more once structured
replies allow the server to propagate the errp information back
to the client. While at it, use an error message that makes a
bit more sense if viewed on the client side.
Note that when using qemu-io to test qemu-nbd behavior, it is
rather difficult to convince qemu-io to send protocol violations
(such as a read beyond bounds), because we have a lot of active
checking on the client side that a qemu-io request makes sense
before it ever goes over the wire to the server. The case of a
client attempting a write when the server is started as
'qemu-nbd -r' is one of the few places where we can easily test
error path handling, without having to resort to hacking in known
temporary bugs to either the server or client. [Maybe we want a
future patch to the client to do up-front checking on writes to a
read-only export, the way it does up-front bounds checking; but I
don't see anything in the NBD spec that points to a protocol
violation in our current behavior.]
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
v6: add R-b
v5: new patch
---
nbd/server.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/nbd/server.c b/nbd/server.c
index efb6003364..05ff7470d5 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -1381,6 +1381,7 @@ static coroutine_fn void nbd_trip(void *opaque)
break;
case NBD_CMD_WRITE:
if (exp->nbdflags & NBD_FLAG_READ_ONLY) {
+ error_setg(&local_err, "Export is read-only");
ret = -EROFS;
break;
}
@@ -1398,7 +1399,7 @@ static coroutine_fn void nbd_trip(void *opaque)
break;
case NBD_CMD_WRITE_ZEROES:
if (exp->nbdflags & NBD_FLAG_READ_ONLY) {
- error_setg(&local_err, "Server is read-only, return error");
+ error_setg(&local_err, "Export is read-only");
ret = -EROFS;
break;
}
--
2.13.6
next prev parent reply other threads:[~2017-10-27 10:40 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-27 10:40 [Qemu-devel] [PATCH v6 00/12] nbd minimal structured read Eric Blake
2017-10-27 10:40 ` [Qemu-devel] [PATCH v6 01/12] nbd: Include error names in trace messages Eric Blake
2017-10-27 10:40 ` [Qemu-devel] [PATCH v6 02/12] nbd: Move nbd_errno_to_system_errno() to public header Eric Blake
2017-10-27 10:40 ` [Qemu-devel] [PATCH v6 03/12] nbd: Expose constants and structs for structured read Eric Blake
2017-10-27 10:40 ` Eric Blake [this message]
2017-10-27 10:40 ` [Qemu-devel] [PATCH v6 05/12] nbd/server: Simplify nbd_negotiate_options loop Eric Blake
2017-10-30 16:43 ` Vladimir Sementsov-Ogievskiy
2017-10-27 10:40 ` [Qemu-devel] [PATCH v6 06/12] nbd/server: Refactor zero-length option check Eric Blake
2017-10-30 17:22 ` Vladimir Sementsov-Ogievskiy
2017-10-30 20:11 ` Eric Blake
2017-10-30 20:46 ` Eric Blake
2017-10-27 10:40 ` [Qemu-devel] [PATCH v6 07/12] nbd: Minimal structured read for server Eric Blake
2017-10-30 17:30 ` Vladimir Sementsov-Ogievskiy
2017-10-27 10:40 ` [Qemu-devel] [PATCH v6 08/12] nbd/server: Include human-readable message in structured errors Eric Blake
2017-10-27 10:40 ` [Qemu-devel] [PATCH v6 09/12] nbd/client: refactor nbd_receive_starttls Eric Blake
2017-10-30 17:32 ` Vladimir Sementsov-Ogievskiy
2017-10-27 10:40 ` [Qemu-devel] [PATCH v6 10/12] nbd/client: prepare nbd_receive_reply for structured reply Eric Blake
2017-11-13 19:33 ` Eric Blake
2017-10-27 10:40 ` [Qemu-devel] [PATCH v6 11/12] nbd: Move nbd_read() to common header Eric Blake
2017-10-27 10:40 ` [Qemu-devel] [PATCH v6 12/12] nbd: Minimal structured read for client Eric Blake
2017-10-30 17:55 ` Vladimir Sementsov-Ogievskiy
2017-10-27 10:45 ` [Qemu-devel] [RFC PATCH v6 13/12] tweak test 83 verbosity Eric Blake
2017-10-30 12:34 ` Vladimir Sementsov-Ogievskiy
2017-10-30 13:00 ` Eric Blake
2017-10-30 18:01 ` Vladimir Sementsov-Ogievskiy
2017-10-27 10:59 ` [Qemu-devel] [PATCH v6 00/12] nbd minimal structured read no-reply
2017-10-27 14:59 ` Eric Blake
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171027104037.8319-5-eblake@redhat.com \
--to=eblake@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).