1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
3 Date: Tue, 16 May 2017 12:45:29 +0300
4 Subject: [PATCH] nbd: strict nbd_wr_syncv
6 nbd_wr_syncv is called either from coroutine or from client negotiation
7 code, when socket is in blocking mode. So, -EAGAIN is impossible.
9 Furthermore, EAGAIN is confusing, as, what to read/write again? With
10 EAGAIN as a return code we don't know how much data is already
11 read or written by the function, so in case of EAGAIN the whole
12 communication is broken.
14 Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
15 Message-Id: <20170516094533.6160-2-vsementsov@virtuozzo.com>
16 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
18 nbd/common.c | 11 ++++++-----
19 1 file changed, 6 insertions(+), 5 deletions(-)
21 diff --git a/nbd/common.c b/nbd/common.c
22 index dccbb8e9de..4db45b3ede 100644
26 #include "qapi/error.h"
27 #include "nbd-internal.h"
30 + * The function may be called from coroutine or from non-coroutine context.
31 + * When called from non-coroutine context @ioc must be in blocking mode.
33 ssize_t nbd_wr_syncv(QIOChannel *ioc,
36 @@ -42,11 +46,8 @@ ssize_t nbd_wr_syncv(QIOChannel *ioc,
37 len = qio_channel_writev(ioc, local_iov, nlocal_iov, &local_err);
39 if (len == QIO_CHANNEL_ERR_BLOCK) {
40 - if (qemu_in_coroutine()) {
41 - qio_channel_yield(ioc, do_read ? G_IO_IN : G_IO_OUT);
45 + assert(qemu_in_coroutine());
46 + qio_channel_yield(ioc, do_read ? G_IO_IN : G_IO_OUT);