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 2/6] nbd/server: refactor negotiation functions parameters
Date: Fri, 12 Jan 2018 08:34:09 -0600 [thread overview]
Message-ID: <d40e657a-61b7-face-d07e-86c95537c78d@redhat.com> (raw)
In-Reply-To: <e8c317c0-9650-e0fb-d30d-ea0490698ce6@virtuozzo.com>
[-- Attachment #1: Type: text/plain, Size: 1808 bytes --]
On 01/12/2018 04:18 AM, Vladimir Sementsov-Ogievskiy wrote:
>>> hmm, should not it be at the end of nbd_negotiate() ? Looks OK anyway.
>> Sure, I'll squash this in, for no real change in behavior:
>>
>> diff --git i/nbd/server.c w/nbd/server.c
>> index c22d5e6ecf..3fd145592e 100644
>> --- i/nbd/server.c
>> +++ w/nbd/server.c
>> @@ -902,6 +902,7 @@ static coroutine_fn int nbd_negotiate(NBDClient
>> *client, Error **errp)
>> }
>> }
>>
>> + assert(!client->optlen);
>> trace_nbd_negotiate_success();
>>
This says that after all negotiation is complete, optlen is 0 (so in
reality, it is only checking NBD_OPT_GO and NBD_OPT_EXPORT_NAME - since
those are the only two options that can end negotiation). But it does
not check state in between individual options during the actual
negotiation. Also, this is the only spot in the code that can check
that optlen is 0 even for old-style connections (where we do not call
nbd_negotiate_options), so it's a nice spot to prove that when we move
into transmission phase, we aren't stranding any unread data from
handshake phase.
>
>
> or, even better, in nbd_negotiate_options. and you actually do it in 5/6.
Whereas that is stating that optlen is 0 after every option that does
not return early (not possible in this patch, because we need the
nbd_opt_read() helper in 5/6 that clears optlen as we go) - and
meanwhile does NOT cover the places that return early (NBD_OPT_GO and
NBD_OPT_EXPORT_NAME, which we caught here). So we need both assertions
at the end of the series, and I'm comfortable with introducing them in
separate patches.
--
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:34 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 [this message]
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=d40e657a-61b7-face-d07e-86c95537c78d@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).