[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v4 6/8] nbd/client: refactor nbd_receive_starttl
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v4 6/8] nbd/client: refactor nbd_receive_starttls |
Date: |
Thu, 19 Oct 2017 14:31:54 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 |
On 10/14/2017 08:01 PM, Eric Blake wrote:
> From: Vladimir Sementsov-Ogievskiy <address@hidden>
>
> Split out nbd_request_simple_option to be reused for structured reply
> option.
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
> Signed-off-by: Eric Blake <address@hidden>
>
> +static int nbd_request_simple_option(QIOChannel *ioc, int opt, Error **errp)
> +{
> + nbd_opt_reply reply;
> +
> + if (nbd_send_option_request(ioc, opt, 0, NULL, errp) < 0) {
> + return -1;
> + }
> +
> + if (nbd_receive_option_reply(ioc, opt, &reply, errp) < 0) {
> + return -1;
> + }
> +
> + if (reply.length != 0) {
> + error_setg(errp, "Option %d ('%s') response length is %" PRIu32
> + " (it should be zero)", opt, nbd_opt_lookup(opt),
> + reply.length);
> + nbd_send_opt_abort(ioc);
> + return -1;
> + }
> +
> + if (reply.type == NBD_REP_ERR_UNSUP) {
> + return 0;
> + }
Oops, these two conditions are swapped. A non-zero reply length is
perfectly acceptable if the server is sending NBD_REP_ERR_UNSUP with an
error message (as is the case with old qemu server, new qemu client).
We can only enforce non-zero length...
> +
> + if (reply.type != NBD_REP_ACK) {
> + error_setg(errp, "Server rejected request for option %d (%s) "
> + "with reply %" PRIx32 " (%s)", opt, nbd_opt_lookup(opt),
> + reply.type, nbd_rep_lookup(reply.type));
> + nbd_send_opt_abort(ioc);
> + return -1;
> + }
> +
...here, after we know we got an ACK.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature
- Re: [Qemu-devel] [PATCH v4 4/8] nbd: Minimal structured read for server, (continued)
Re: [Qemu-devel] [PATCH v4 4/8] nbd: Minimal structured read for server, Eric Blake, 2017/10/16
[Qemu-devel] [PATCH v4 8/8] nbd: Move nbd_read() to common header, Eric Blake, 2017/10/14
[Qemu-devel] [PATCH v4 5/8] nbd/server: Include human-readable message in structured errors, Eric Blake, 2017/10/14
[Qemu-devel] [PATCH v4 6/8] nbd/client: refactor nbd_receive_starttls, Eric Blake, 2017/10/14
[Qemu-devel] [PATCH v4 7/8] nbd/client: prepare nbd_receive_reply for structured reply, Eric Blake, 2017/10/14
[Qemu-devel] [PATCH v4 RFC 9/8] nbd: Minimal structured read for client, Vladimir Sementsov-Ogievskiy, 2017/10/17