From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: vsementsov@virtuozzo.com, jsnow@redhat.com,
qemu-stable@nongnu.org, Kevin Wolf <kwolf@redhat.com>,
Max Reitz <mreitz@redhat.com>,
"open list:Network Block Dev..." <qemu-block@nongnu.org>
Subject: [Qemu-devel] [PATCH 3/3] nbd/client: Send NBD_CMD_DISC if open fails after connect
Date: Thu, 29 Nov 2018 20:32:32 -0600 [thread overview]
Message-ID: <20181130023232.3079982-4-eblake@redhat.com> (raw)
In-Reply-To: <20181130023232.3079982-1-eblake@redhat.com>
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>
---
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;
+ }
}
--
2.17.2
next prev parent reply other threads:[~2018-11-30 2:32 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 ` Eric Blake [this message]
2018-11-30 8:29 ` [Qemu-devel] [PATCH 3/3] nbd/client: Send NBD_CMD_DISC if open fails after connect Vladimir Sementsov-Ogievskiy
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=20181130023232.3079982-4-eblake@redhat.com \
--to=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 \
--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).