All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: Eric Blake <eblake@redhat.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: "jsnow@redhat.com" <jsnow@redhat.com>,
	"qemu-stable@nongnu.org" <qemu-stable@nongnu.org>,
	Kevin Wolf <kwolf@redhat.com>, Max Reitz <mreitz@redhat.com>,
	"open list:Network Block Dev..." <qemu-block@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH 3/3] nbd/client: Send NBD_CMD_DISC if open fails after connect
Date: Fri, 30 Nov 2018 08:29:29 +0000	[thread overview]
Message-ID: <ae3778cc-5a97-0cc0-c5a0-4c5f070b805d@virtuozzo.com> (raw)
In-Reply-To: <20181130023232.3079982-4-eblake@redhat.com>

30.11.2018 5:32, Eric Blake wrote:
> If nbd_client_init() fails after we are already connected,
> then the server will spam logs with:
> 
> Disconnect client, due to: Unexpected end-of-file before all bytes were read
> 
> unless we gracefully disconnect before closing the connection.
> 
> Ways to trigger this:
> 
> $ opts=driver=nbd,export=foo,server.type=inet,server.host=localhost,server.port=10809
> $  qemu-img map --output=json --image-opts $opts,read-only=off
> $  qemu-img map --output=json --image-opts $opts,x-dirty-bitmap=nosuch:
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>

Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>

> ---
>   block/nbd-client.c | 18 ++++++++++++++++--
>   1 file changed, 16 insertions(+), 2 deletions(-)
> 
> diff --git a/block/nbd-client.c b/block/nbd-client.c
> index e6e27dafa6a..fc5b7eda8ee 100644
> --- a/block/nbd-client.c
> +++ b/block/nbd-client.c
> @@ -995,12 +995,13 @@ int nbd_client_init(BlockDriverState *bs,
>       if (x_dirty_bitmap && !client->info.base_allocation) {
>           error_setg(errp, "requested x-dirty-bitmap %s not found",
>                      x_dirty_bitmap);
> -        return -EINVAL;
> +        ret = -EINVAL;
> +        goto fail;
>       }
>       if (client->info.flags & NBD_FLAG_READ_ONLY) {
>           ret = bdrv_apply_auto_read_only(bs, "NBD export is read-only", errp);
>           if (ret < 0) {
> -            return ret;
> +            goto fail;
>           }
>       }
>       if (client->info.flags & NBD_FLAG_SEND_FUA) {
> @@ -1029,4 +1030,17 @@ int nbd_client_init(BlockDriverState *bs,
> 
>       logout("Established connection with NBD server\n");
>       return 0;
> +
> + fail:
> +    /*
> +     * We have connected, but must fail for other reasons. The
> +     * connection is still blocking; send NBD_CMD_DISC as a courtesy
> +     * to the server.
> +     */
> +    {
> +        NBDRequest request = { .type = NBD_CMD_DISC };
> +
> +        nbd_send_request(client->ioc ?: QIO_CHANNEL(sioc), &request);
> +        return ret;
> +    }
>   }
> 


-- 
Best regards,
Vladimir

  reply	other threads:[~2018-11-30  8:44 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-30  2:32 [Qemu-devel] [PATCH for-3.1? 0/3] NBD dirty bitmap cleanups Eric Blake
2018-11-30  2:32 ` [Qemu-devel] [PATCH 1/3] nbd/server: Advertise all contexts in response to bare LIST Eric Blake
2018-11-30  8:02   ` Vladimir Sementsov-Ogievskiy
2018-11-30  2:32 ` [Qemu-devel] [PATCH 2/3] nbd/client: Make x-dirty-bitmap more reliable Eric Blake
2018-11-30  8:21   ` Vladimir Sementsov-Ogievskiy
2018-11-30  2:32 ` [Qemu-devel] [PATCH 3/3] nbd/client: Send NBD_CMD_DISC if open fails after connect Eric Blake
2018-11-30  8:29   ` Vladimir Sementsov-Ogievskiy [this message]
2018-11-30 15:25 ` [Qemu-devel] [PATCH for-3.1? 0/3] NBD dirty bitmap cleanups Eric Blake
2018-12-03 15:03   ` Peter Maydell

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=ae3778cc-5a97-0cc0-c5a0-4c5f070b805d@virtuozzo.com \
    --to=vsementsov@virtuozzo.com \
    --cc=eblake@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.