[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-stable] [PATCH 71/97] nbd/client: Send NBD_CMD_DISC if open fails
From: |
Michael Roth |
Subject: |
[Qemu-stable] [PATCH 71/97] nbd/client: Send NBD_CMD_DISC if open fails after connect |
Date: |
Mon, 1 Apr 2019 15:59:45 -0500 |
From: Eric Blake <address@hidden>
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 <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Vladimir Sementsov-Ogievskiy <address@hidden>
(cherry picked from commit c688e6ca7b41a105241054853d250df64addbf8f)
*drop functional dep. on 6c2e581d4d7
Signed-off-by: Michael Roth <address@hidden>
---
block/nbd-client.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/block/nbd-client.c b/block/nbd-client.c
index f8c42a6996..1b7b5b0a88 100644
--- a/block/nbd-client.c
+++ b/block/nbd-client.c
@@ -995,13 +995,15 @@ 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 &&
!bdrv_is_read_only(bs)) {
error_setg(errp,
"request for write access conflicts with read-only export");
- return -EACCES;
+ ret = -EACCES;
+ goto fail;
}
if (client->info.flags & NBD_FLAG_SEND_FUA) {
bs->supported_write_flags = BDRV_REQ_FUA;
@@ -1029,4 +1031,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.1
- [Qemu-stable] [PATCH 58/97] vhost-scsi: prevent using uninitialized vqs, (continued)
- [Qemu-stable] [PATCH 04/97] target/arm: Fix typo in helper_sve_movz_d, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 64/97] qemu-img: Fix leak, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 66/97] vfio-helpers: Fix qemu_vfio_open_pci() crash, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 69/97] nbd/server: Advertise all contexts in response to bare LIST, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 70/97] nbd/client: Make x-dirty-bitmap more reliable, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 71/97] nbd/client: Send NBD_CMD_DISC if open fails after connect,
Michael Roth <=
- [Qemu-stable] [PATCH 73/97] iotests: simple mirror test with kvm on 1G image, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 68/97] i2c: Add a length check to the SMBus write handling, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 76/97] pcie: set link state inactive/active after hot unplug/plug, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 75/97] Changes requirement for "vsubsbs" instruction, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 79/97] linux-user: write(fd, NULL, 0) parity with linux's treatment of same, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 80/97] linux-user: make pwrite64/pread64(fd, NULL, 0, offset) return 0, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 82/97] exec.c: Don't reallocate IOMMUNotifiers that are in use, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 86/97] tpm: Make sure the locality received from backend is valid, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 07/97] target/arm: Fix offset for LD1R instructions, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 85/97] tpm: Make sure new locality passed to tpm_tis_prep_abort() is valid, Michael Roth, 2019/04/01