From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, vsementsov@virtuozzo.com,
Paolo Bonzini <pbonzini@redhat.com>
Subject: [Qemu-devel] [PATCH v2 1/6] nbd/server: Hoist nbd_reject_length() earlier
Date: Wed, 10 Jan 2018 17:08:20 -0600 [thread overview]
Message-ID: <20180110230825.18321-2-eblake@redhat.com> (raw)
In-Reply-To: <20180110230825.18321-1-eblake@redhat.com>
No semantic change, but will make it easier for an upcoming patch
to refactor code without having to add forward declarations.
Signed-off-by: Eric Blake <eblake@redhat.com>
---
nbd/server.c | 56 ++++++++++++++++++++++++++++----------------------------
1 file changed, 28 insertions(+), 28 deletions(-)
diff --git a/nbd/server.c b/nbd/server.c
index 6cf2eeb2c1..d3b457c337 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -348,6 +348,34 @@ static int nbd_negotiate_send_info(NBDClient *client, uint32_t opt,
return 0;
}
+/* nbd_reject_length: Handle any unexpected payload.
+ * @fatal requests that we quit talking to the client, even if we are able
+ * to successfully send an error to the guest.
+ * Return:
+ * -errno transmission error occurred or @fatal was requested, errp is set
+ * 0 error message successfully sent to client, errp is not set
+ */
+static int nbd_reject_length(NBDClient *client, uint32_t length,
+ uint32_t option, bool fatal, Error **errp)
+{
+ int ret;
+
+ assert(length);
+ if (nbd_drop(client->ioc, length, errp) < 0) {
+ return -EIO;
+ }
+ ret = nbd_negotiate_send_rep_err(client->ioc, NBD_REP_ERR_INVALID,
+ option, errp,
+ "option '%s' should have zero length",
+ nbd_opt_lookup(option));
+ if (fatal && !ret) {
+ error_setg(errp, "option '%s' should have zero length",
+ nbd_opt_lookup(option));
+ return -EINVAL;
+ }
+ return ret;
+}
+
/* Handle NBD_OPT_INFO and NBD_OPT_GO.
* Return -errno on error, 0 if ready for next option, and 1 to move
* into transmission phase. */
@@ -570,34 +598,6 @@ static QIOChannel *nbd_negotiate_handle_starttls(NBDClient *client,
return QIO_CHANNEL(tioc);
}
-/* nbd_reject_length: Handle any unexpected payload.
- * @fatal requests that we quit talking to the client, even if we are able
- * to successfully send an error to the guest.
- * Return:
- * -errno transmission error occurred or @fatal was requested, errp is set
- * 0 error message successfully sent to client, errp is not set
- */
-static int nbd_reject_length(NBDClient *client, uint32_t length,
- uint32_t option, bool fatal, Error **errp)
-{
- int ret;
-
- assert(length);
- if (nbd_drop(client->ioc, length, errp) < 0) {
- return -EIO;
- }
- ret = nbd_negotiate_send_rep_err(client->ioc, NBD_REP_ERR_INVALID,
- option, errp,
- "option '%s' should have zero length",
- nbd_opt_lookup(option));
- if (fatal && !ret) {
- error_setg(errp, "option '%s' should have zero length",
- nbd_opt_lookup(option));
- return -EINVAL;
- }
- return ret;
-}
-
/* nbd_negotiate_options
* Process all NBD_OPT_* client option commands, during fixed newstyle
* negotiation.
--
2.14.3
next prev parent reply other threads:[~2018-01-10 23:08 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-10 23:08 [Qemu-devel] [PATCH v2 0/6] NBD server refactoring before BLOCK_STATUS Eric Blake
2018-01-10 23:08 ` Eric Blake [this message]
2018-01-11 17:31 ` [Qemu-devel] [PATCH v2 1/6] nbd/server: Hoist nbd_reject_length() earlier Vladimir Sementsov-Ogievskiy
2018-01-10 23:08 ` [Qemu-devel] [PATCH v2 2/6] nbd/server: refactor negotiation functions parameters Eric Blake
2018-01-11 17:55 ` Vladimir Sementsov-Ogievskiy
2018-01-11 19:54 ` Eric Blake
2018-01-12 10:18 ` Vladimir Sementsov-Ogievskiy
2018-01-12 14:34 ` Eric Blake
2018-01-10 23:08 ` [Qemu-devel] [PATCH v2 3/6] nbd/server: Better error for NBD_OPT_EXPORT_NAME failure Eric Blake
2018-01-11 17:34 ` Vladimir Sementsov-Ogievskiy
2018-01-10 23:08 ` [Qemu-devel] [PATCH v2 4/6] nbd/server: Add va_list form of nbd_negotiate_send_rep_err() Eric Blake
2018-01-11 18:05 ` Vladimir Sementsov-Ogievskiy
2018-01-11 19:58 ` Eric Blake
2018-01-10 23:08 ` [Qemu-devel] [PATCH v2 5/6] nbd/server: Add helper functions for parsing option payload Eric Blake
2018-01-12 10:20 ` Vladimir Sementsov-Ogievskiy
2018-01-12 14:37 ` Eric Blake
2018-01-10 23:08 ` [Qemu-devel] [PATCH v2 6/6] nbd/server: structurize option reply sending 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=20180110230825.18321-2-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).