From: Eric Blake <eblake@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 5/6] nbd/server: Add helper functions for parsing option payload
Date: Fri, 12 Jan 2018 08:37:45 -0600 [thread overview]
Message-ID: <ec35cf28-6e7c-efed-a5d9-dd5a501d8800@redhat.com> (raw)
In-Reply-To: <76132a6d-3d2f-92ba-d05d-93c20dbe9025@virtuozzo.com>
[-- Attachment #1: Type: text/plain, Size: 3575 bytes --]
On 01/12/2018 04:20 AM, Vladimir Sementsov-Ogievskiy wrote:
> 11.01.2018 02:08, Eric Blake wrote:
>> Rather than making every callsite perform length sanity checks
>> and error reporting, add the helper functions nbd_opt_read()
>> and nbd_opt_drop() that use the length stored in the client
>> struct; also add an assertion that optlen is reduced to zero
>> after each option is handled.
>>
>> Note that the call in nbd_negotiate_handle_export_name() does
>> not use the new helper (in part because the server cannot
>> reply to NBD_OPT_EXPORT_NAME - it either succeeds or the
>> connection drops).
>>
>>
>> +/* Drop remainder of the current option, after sending a reply with
>
> looks a bit weird: actually you drop the remainder _before_ sending a
> reply)
Good catch. I'll fix it with s/after/and/
>
>> + * the given error type and message. Return -errno on read or write
>
> also, unrelated note, -errno is always forced to -EIO, because of
> nbd_read realization.
> and this note applies to many other places here. It is correct (EIO is
> errno, why not?),
> but it may be not bad to note it somewhere..
Someday nbd_read() might fail with something other than EIO (ESHUTDOWN,
perhaps?), in which case leaving this documented as -errno would be
better than hardcoding that EIO is the only failure for now.
>> @@ -812,14 +819,9 @@ static int nbd_negotiate_options(NBDClient
>> *client, uint16_t myflags,
>> break;
>>
>> default:
>> - if (nbd_drop(client->ioc, length, errp) < 0) {
>> - return -EIO;
>> - }
>> - ret = nbd_negotiate_send_rep_err(client,
>> - NBD_REP_ERR_UNSUP,
>> errp,
>> - "Unsupported option
>> 0x%"
>> - PRIx32 " (%s)", option,
>> -
>> nbd_opt_lookup(option));
>> + ret = nbd_opt_drop(client, NBD_REP_ERR_UNSUP, errp,
>> + "Unsupported option 0x%" PRIx32 "
>> (%s)",
>> + option, nbd_opt_lookup(option));
>> break;
>> }
>> } else {
>> @@ -842,6 +844,7 @@ static int nbd_negotiate_options(NBDClient
>> *client, uint16_t myflags,
>> if (ret < 0) {
>> return ret;
>> }
>> + assert(!client->optlen);
>
> isn't it from 2/6?
No, this is a second instance of the assertion, the one that applies
between each option (which I couldn't do in 2/6 because not all options
were manipulating optlen back then). Maybe I can tweak the commit
messages to make that more obvious.
>
>> }
>> }
>>
>
> anyway,
>
> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Thanks for the careful attention to detail.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]
next prev parent reply other threads:[~2018-01-12 14:37 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 ` [Qemu-devel] [PATCH v2 1/6] nbd/server: Hoist nbd_reject_length() earlier Eric Blake
2018-01-11 17:31 ` 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 [this message]
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=ec35cf28-6e7c-efed-a5d9-dd5a501d8800@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).