All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Roth <mdroth@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: qemu-stable@nongnu.org, Eric Blake <eblake@redhat.com>
Subject: [Qemu-devel] [PATCH 71/97] nbd/client: Send NBD_CMD_DISC if open fails after connect
Date: Mon,  1 Apr 2019 15:59:45 -0500	[thread overview]
Message-ID: <20190401210011.16009-72-mdroth@linux.vnet.ibm.com> (raw)
In-Reply-To: <20190401210011.16009-1-mdroth@linux.vnet.ibm.com>

From: Eric Blake <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>
Message-Id: <20181130023232.3079982-4-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
(cherry picked from commit c688e6ca7b41a105241054853d250df64addbf8f)
*drop functional dep. on 6c2e581d4d7
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
 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

  parent reply	other threads:[~2019-04-01 21:04 UTC|newest]

Thread overview: 107+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-01 20:58 [Qemu-devel] [PATCH 00/97] Patch Round-up for stable 3.0.1, freeze on 2019-04-08 Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 01/97] target/arm: Fix sign of sve_cmpeq_ppzw/sve_cmpne_ppzw Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 02/97] target/arm: Fix typo in do_sat_addsub_64 Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 03/97] target/arm: Reorganize SVE WHILE Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 04/97] target/arm: Fix typo in helper_sve_movz_d Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 05/97] target/arm: Fix typo in helper_sve_ld1hss_r Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 06/97] target/arm: Fix sign-extension in sve do_ldr/do_str Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 07/97] target/arm: Fix offset for LD1R instructions Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 08/97] target/arm: Fix offset scaling for LD_zprr and ST_zprr Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 09/97] target/arm: Reformat integer register dump Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 10/97] target/arm: Dump SVE state if enabled Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 11/97] target/arm: Add sve-max-vq cpu property to -cpu max Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 12/97] spapr_cpu_core: vmstate_[un]register per-CPU data from (un)realizefn Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 13/97] target/arm: Adjust FPCR_MASK for FZ16 Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 14/97] target/arm: Ignore float_flag_input_denormal from fp_status_f16 Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 15/97] target/arm: Use fp_status_fp16 for do_fmpa_zpzzz_h Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 16/97] target/arm: Use FZ not FZ16 for SVE FCVT single-half and double-half Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 17/97] block/qapi: Fix memory leak in qmp_query_blockstats() Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 18/97] mirror: Fail gracefully for source == target Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 19/97] qemu-img: fix regression copying secrets during convert Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 20/97] nvme: Fix nvme_init error handling Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 21/97] aio-posix: Don't count ctx->notifier as progress when polling Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 22/97] aio: Do aio_notify_accept only during blocking aio_poll Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 23/97] monitor: fix oob command leak Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 24/97] vnc: fix memleak of the "vnc-worker-output" name Michael Roth
2019-04-01 20:58 ` [Qemu-devel] [PATCH 25/97] i386: Disable TOPOEXT by default on "-cpu host" Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 26/97] block: for jobs, do not clear user_paused until after the resume Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 27/97] block: iotest to catch abort on forced blockjob cancel Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 28/97] virtio: update MemoryRegionCaches when guest negotiates features Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 29/97] target/xtensa: fix FPU2000 bugs Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 30/97] kvm: add call to qemu_add_opts() for -overcommit option Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 31/97] slirp: Add sanity check for str option length Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 32/97] vhost: fix invalid downcast Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 33/97] pc: acpi: revert back to 1 SRAT entry for hotpluggable area Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 34/97] tests: update acpi expected files Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 35/97] block: Fix use after free error in bdrv_open_inherit() Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 36/97] job: Fix nested aio_poll() hanging in job_txn_apply Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 37/97] target/xtensa: fix s32c1i TCGMemOp flags Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 38/97] nbd/server: fix bitmap export Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 39/97] clean up callback when del virtqueue Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 40/97] block/rbd: pull out qemu_rbd_convert_options Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 41/97] block/rbd: Attempt to parse legacy filenames Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 42/97] block/rbd: add iotest for rbd legacy keyvalue filename parsing Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 43/97] block/rbd: add deprecation documentation for filename keyvalue pairs Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 44/97] target/arm: Fix cpu_get_tb_cpu_state() for non-SVE CPUs Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 45/97] ne2000: fix possible out of bound access in ne2000_receive Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 46/97] rtl8139: fix possible out of bound access Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 47/97] pcnet: fix possible buffer overflow Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 48/97] net: ignore packet size greater than INT_MAX Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 49/97] virt: Suppress external aborts on virt-2.10 and earlier Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 50/97] virtio: do not take address of packed members Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 51/97] block-backend: Set werror/rerror defaults in blk_new() Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 52/97] target/arm: Correct condition for v8M callee stack push Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 53/97] nbd/server: fix NBD_CMD_CACHE Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 54/97] intel_iommu: introduce vtd_reset_caches() Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 55/97] intel_iommu: better handling of dmar state switch Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 56/97] nbd: fix NBD_FLAG_SEND_CACHE value Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 57/97] migration: Stop postcopy fault thread before notifying Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 58/97] vhost-scsi: prevent using uninitialized vqs Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 59/97] target/xtensa: drop num_[core_]regs from dc232b/dc233c configs Michael Roth
2019-04-01 21:19   ` Max Filippov
2019-04-01 23:28     ` Michael Roth
2019-04-01 23:42       ` Max Filippov
2019-04-01 20:59 ` [Qemu-devel] [PATCH 60/97] make-release: add skiboot .version file Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 61/97] net: drop too large packet early Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 62/97] fdc: fix segfault in fdctrl_stop_transfer() when DMA is disabled Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 63/97] qemu-img: Fix typo Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 64/97] qemu-img: Fix leak Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 65/97] fmops: fix off-by-one in AR_TABLE and DR_TABLE array size Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 66/97] vfio-helpers: Fix qemu_vfio_open_pci() crash Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 67/97] i2c: Move typedef of bitbang_i2c_interface to i2c.h Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 68/97] i2c: Add a length check to the SMBus write handling Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 69/97] nbd/server: Advertise all contexts in response to bare LIST Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 70/97] nbd/client: Make x-dirty-bitmap more reliable Michael Roth
2019-04-01 20:59 ` Michael Roth [this message]
2019-04-01 20:59 ` [Qemu-devel] [PATCH 72/97] mirror: fix dead-lock Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 73/97] iotests: simple mirror test with kvm on 1G image Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 74/97] iotests: make 235 work on s390 (and others) Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 75/97] Changes requirement for "vsubsbs" instruction Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 76/97] pcie: set link state inactive/active after hot unplug/plug Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 77/97] pc:piix4: Update smbus I/O space after a migration Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 78/97] hw/s390x: Fix bad mask in time2tod() Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 79/97] linux-user: write(fd, NULL, 0) parity with linux's treatment of same Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 80/97] linux-user: make pwrite64/pread64(fd, NULL, 0, offset) return 0 Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 81/97] s390x: Return specification exception for unimplemented diag 308 subcodes Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 82/97] exec.c: Don't reallocate IOMMUNotifiers that are in use Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 83/97] tpm: Zero-init structure to avoid uninitialized variables in valgrind log Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 84/97] tpm: use loop iterator to set sts data field Michael Roth
2019-04-01 20:59 ` [Qemu-devel] [PATCH 85/97] tpm: Make sure new locality passed to tpm_tis_prep_abort() is valid Michael Roth
2019-04-01 21:00 ` [Qemu-devel] [PATCH 86/97] tpm: Make sure the locality received from backend " Michael Roth
2019-04-01 21:00 ` [Qemu-devel] [PATCH 87/97] block: Fix invalidate_cache error path for parent activation Michael Roth
2019-04-01 21:00 ` [Qemu-devel] [PATCH 88/97] acpi: Make TPM 2.0 with TIS available as MSFT0101 Michael Roth
2019-04-01 21:00 ` [Qemu-devel] [PATCH 89/97] hw/rdma: another clang compilation fix Michael Roth
2019-04-01 21:00 ` [Qemu-devel] [PATCH 90/97] slirp: check sscanf result when emulating ident Michael Roth
2019-04-01 21:00 ` [Qemu-devel] [PATCH 91/97] tpm_tis: fix loop that cancels any seizure by a lower locality Michael Roth
2019-04-01 21:00 ` [Qemu-devel] [PATCH 92/97] bitmap: Update count after a merge Michael Roth
2019-04-01 21:00 ` [Qemu-devel] [PATCH 93/97] qga: update docs with systemd suspend support info Michael Roth
2019-04-01 21:00 ` [Qemu-devel] [PATCH 94/97] nvme: fix out-of-bounds access to the CMB Michael Roth
2019-04-01 21:00 ` [Qemu-devel] [PATCH 95/97] 9p: fix QEMU crash when renaming files Michael Roth
2019-04-01 21:00 ` [Qemu-devel] [PATCH 96/97] usb-mtp: outlaw slashes in filenames Michael Roth
2019-04-01 21:00 ` [Qemu-devel] [PATCH 97/97] usb-mtp: use O_NOFOLLOW and O_CLOEXEC Michael Roth
2019-04-02 16:22 ` [Qemu-devel] [Qemu-stable] [PATCH 00/97] Patch Round-up for stable 3.0.1, freeze on 2019-04-08 Cole Robinson
2019-04-04 21:28   ` Michael Roth
2019-04-04 22:31 ` [Qemu-devel] " Philippe Mathieu-Daudé
2019-04-04 22:31   ` Philippe Mathieu-Daudé
2019-04-05 20:28   ` Michael Roth
2019-04-05 20:28     ` Michael Roth

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=20190401210011.16009-72-mdroth@linux.vnet.ibm.com \
    --to=mdroth@linux.vnet.ibm.com \
    --cc=eblake@redhat.com \
    --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.