|
|
7711c0 |
From fbb8b7e5e064ea6a467119772097242311e65628 Mon Sep 17 00:00:00 2001
|
|
|
7711c0 |
From: John Snow <jsnow@redhat.com>
|
|
|
7711c0 |
Date: Fri, 22 Mar 2019 03:22:40 +0100
|
|
|
7711c0 |
Subject: [PATCH 073/163] nbd/client: Send NBD_CMD_DISC if open fails after
|
|
|
7711c0 |
connect
|
|
|
7711c0 |
|
|
|
7711c0 |
RH-Author: John Snow <jsnow@redhat.com>
|
|
|
7711c0 |
Message-id: <20190322032241.8111-28-jsnow@redhat.com>
|
|
|
7711c0 |
Patchwork-id: 85114
|
|
|
7711c0 |
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 27/28] nbd/client: Send NBD_CMD_DISC if open fails after connect
|
|
|
7711c0 |
Bugzilla: 1691563
|
|
|
7711c0 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
7711c0 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
7711c0 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
7711c0 |
|
|
|
7711c0 |
From: Eric Blake <eblake@redhat.com>
|
|
|
7711c0 |
|
|
|
7711c0 |
If nbd_client_init() fails after we are already connected,
|
|
|
7711c0 |
then the server will spam logs with:
|
|
|
7711c0 |
|
|
|
7711c0 |
Disconnect client, due to: Unexpected end-of-file before all bytes were read
|
|
|
7711c0 |
|
|
|
7711c0 |
unless we gracefully disconnect before closing the connection.
|
|
|
7711c0 |
|
|
|
7711c0 |
Ways to trigger this:
|
|
|
7711c0 |
|
|
|
7711c0 |
$ opts=driver=nbd,export=foo,server.type=inet,server.host=localhost,server.port=10809
|
|
|
7711c0 |
$ qemu-img map --output=json --image-opts $opts,read-only=off
|
|
|
7711c0 |
$ qemu-img map --output=json --image-opts $opts,x-dirty-bitmap=nosuch:
|
|
|
7711c0 |
|
|
|
7711c0 |
Signed-off-by: Eric Blake <eblake@redhat.com>
|
|
|
7711c0 |
Message-Id: <20181130023232.3079982-4-eblake@redhat.com>
|
|
|
7711c0 |
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
|
|
|
7711c0 |
(cherry picked from commit c688e6ca7b41a105241054853d250df64addbf8f)
|
|
|
7711c0 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
7711c0 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
7711c0 |
---
|
|
|
7711c0 |
block/nbd-client.c | 18 ++++++++++++++++--
|
|
|
7711c0 |
1 file changed, 16 insertions(+), 2 deletions(-)
|
|
|
7711c0 |
|
|
|
7711c0 |
diff --git a/block/nbd-client.c b/block/nbd-client.c
|
|
|
7711c0 |
index e6e27da..fc5b7ed 100644
|
|
|
7711c0 |
--- a/block/nbd-client.c
|
|
|
7711c0 |
+++ b/block/nbd-client.c
|
|
|
7711c0 |
@@ -995,12 +995,13 @@ int nbd_client_init(BlockDriverState *bs,
|
|
|
7711c0 |
if (x_dirty_bitmap && !client->info.base_allocation) {
|
|
|
7711c0 |
error_setg(errp, "requested x-dirty-bitmap %s not found",
|
|
|
7711c0 |
x_dirty_bitmap);
|
|
|
7711c0 |
- return -EINVAL;
|
|
|
7711c0 |
+ ret = -EINVAL;
|
|
|
7711c0 |
+ goto fail;
|
|
|
7711c0 |
}
|
|
|
7711c0 |
if (client->info.flags & NBD_FLAG_READ_ONLY) {
|
|
|
7711c0 |
ret = bdrv_apply_auto_read_only(bs, "NBD export is read-only", errp);
|
|
|
7711c0 |
if (ret < 0) {
|
|
|
7711c0 |
- return ret;
|
|
|
7711c0 |
+ goto fail;
|
|
|
7711c0 |
}
|
|
|
7711c0 |
}
|
|
|
7711c0 |
if (client->info.flags & NBD_FLAG_SEND_FUA) {
|
|
|
7711c0 |
@@ -1029,4 +1030,17 @@ int nbd_client_init(BlockDriverState *bs,
|
|
|
7711c0 |
|
|
|
7711c0 |
logout("Established connection with NBD server\n");
|
|
|
7711c0 |
return 0;
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+ fail:
|
|
|
7711c0 |
+ /*
|
|
|
7711c0 |
+ * We have connected, but must fail for other reasons. The
|
|
|
7711c0 |
+ * connection is still blocking; send NBD_CMD_DISC as a courtesy
|
|
|
7711c0 |
+ * to the server.
|
|
|
7711c0 |
+ */
|
|
|
7711c0 |
+ {
|
|
|
7711c0 |
+ NBDRequest request = { .type = NBD_CMD_DISC };
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+ nbd_send_request(client->ioc ?: QIO_CHANNEL(sioc), &request);
|
|
|
7711c0 |
+ return ret;
|
|
|
7711c0 |
+ }
|
|
|
7711c0 |
}
|
|
|
7711c0 |
--
|
|
|
7711c0 |
1.8.3.1
|
|
|
7711c0 |
|