From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: Eric Blake <eblake@redhat.com>, qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>,
Kevin Wolf <kwolf@redhat.com>, Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH for-2.11] nbd: Don't crash when server reports NBD_CMD_READ failure
Date: Mon, 13 Nov 2017 14:37:13 +0300 [thread overview]
Message-ID: <0f61ba9c-439d-eab7-6657-d8088b9adf96@virtuozzo.com> (raw)
In-Reply-To: <20171112013936.5942-1-eblake@redhat.com>
12.11.2017 04:39, Eric Blake wrote:
> If a server fails a read, for example with EIO, but the connection
> is still live, then we would crash trying to print a non-existent
> error message. Bug introduced in commit f140e300.
>
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
> block/nbd-client.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/block/nbd-client.c b/block/nbd-client.c
> index b44d4d4a01..5f3375a970 100644
> --- a/block/nbd-client.c
> +++ b/block/nbd-client.c
> @@ -78,7 +78,7 @@ static coroutine_fn void nbd_read_reply_entry(void *opaque)
> while (!s->quit) {
> assert(s->reply.handle == 0);
> ret = nbd_receive_reply(s->ioc, &s->reply, &local_err);
hmm.
/* nbd_receive_reply
* Returns 1 on success
* 0 on eof, when no data was read (errp is not set)
* negative errno on failure (errp is set)
*/
int nbd_receive_reply(QIOChannel *ioc, NBDReply *reply, Error **errp)
- looks like errp should be set if ret < 0. may be the function should
be fixed?
- don't you think that this function returns transferred server error?
it doesn't.
> - if (ret < 0) {
> + if (local_err) {
> error_report_err(local_err);
> }
> if (ret <= 0) {
> @@ -681,7 +681,7 @@ int nbd_client_co_preadv(BlockDriverState *bs, uint64_t offset,
>
> ret = nbd_co_receive_cmdread_reply(client, request.handle, offset, qiov,
> &local_err);
> - if (ret < 0) {
> + if (local_err) {
> error_report_err(local_err);
> }
> return ret;
but here, it looks like you are right. My first attempt was to store
server error to ret and
server error msg to errp (bad idea, as I can see now), but you proposed
to do not print every server error msg and
deleted this functionality. And now we have a set of functions which can
return ret < 0
and not set errp.. It looks very confusing, I think. Better solution is
to refactor this somehow,
may be not mixing server-error-reply with local normal errors..
For now, for second chunk:
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
--
Best regards,
Vladimir
next prev parent reply other threads:[~2017-11-13 11:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-12 1:39 [Qemu-devel] [PATCH for-2.11] nbd: Don't crash when server reports NBD_CMD_READ failure Eric Blake
2017-11-13 11:37 ` Vladimir Sementsov-Ogievskiy [this message]
2017-11-13 14:45 ` Eric Blake
2017-11-13 14:55 ` Vladimir Sementsov-Ogievskiy
2017-11-13 18:20 ` Eric Blake
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=0f61ba9c-439d-eab7-6657-d8088b9adf96@virtuozzo.com \
--to=vsementsov@virtuozzo.com \
--cc=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@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 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).