aboutsummaryrefslogtreecommitdiff
path: root/nbd
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2016-05-11 16:39:36 -0600
committerPaolo Bonzini <pbonzini@redhat.com>2016-06-16 18:39:05 +0200
commit63d5ef869e5e57de4875cd64b6f197cbb5763adf (patch)
tree8525f172624d6526fe0666616dc68aeecb3e82f1 /nbd
parent2cb347493c5a0c3634dc13942ba65fdcefbcd34b (diff)
downloadqemu-63d5ef869e5e57de4875cd64b6f197cbb5763adf.zip
qemu-63d5ef869e5e57de4875cd64b6f197cbb5763adf.tar.gz
qemu-63d5ef869e5e57de4875cd64b6f197cbb5763adf.tar.bz2
nbd: Quit server after any write error
We should never ignore failure from nbd_negotiate_send_rep(); if we are unable to write to the client, then it is not worth trying to continue the negotiation. Fortunately, the problem is not too severe - chances are that the errors being ignored here (mainly inability to write the reply to the client) are indications of a closed connection or something similar, which will also affect the next attempt to interact with the client and eventually reach a point where the errors are detected to end the loop. Signed-off-by: Eric Blake <eblake@redhat.com> Message-Id: <1463006384-7734-4-git-send-email-eblake@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'nbd')
-rw-r--r--nbd/server.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/nbd/server.c b/nbd/server.c
index d95266d..d14b874 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -334,7 +334,10 @@ static QIOChannel *nbd_negotiate_handle_starttls(NBDClient *client,
return NULL;
}
- nbd_negotiate_send_rep(client->ioc, NBD_REP_ACK, NBD_OPT_STARTTLS);
+ if (nbd_negotiate_send_rep(client->ioc, NBD_REP_ACK,
+ NBD_OPT_STARTTLS) < 0) {
+ return NULL;
+ }
tioc = qio_channel_tls_new_server(ioc,
client->tlscreds,
@@ -460,8 +463,11 @@ static int nbd_negotiate_options(NBDClient *client)
if (nbd_negotiate_drop_sync(client->ioc, length) != length) {
return -EIO;
}
- nbd_negotiate_send_rep(client->ioc, NBD_REP_ERR_TLS_REQD,
- clientflags);
+ ret = nbd_negotiate_send_rep(client->ioc, NBD_REP_ERR_TLS_REQD,
+ clientflags);
+ if (ret < 0) {
+ return ret;
+ }
break;
}
} else if (fixedNewstyle) {
@@ -485,12 +491,17 @@ static int nbd_negotiate_options(NBDClient *client)
}
if (client->tlscreds) {
TRACE("TLS already enabled");
- nbd_negotiate_send_rep(client->ioc, NBD_REP_ERR_INVALID,
- clientflags);
+ ret = nbd_negotiate_send_rep(client->ioc,
+ NBD_REP_ERR_INVALID,
+ clientflags);
} else {
TRACE("TLS not configured");
- nbd_negotiate_send_rep(client->ioc, NBD_REP_ERR_POLICY,
- clientflags);
+ ret = nbd_negotiate_send_rep(client->ioc,
+ NBD_REP_ERR_POLICY,
+ clientflags);
+ }
+ if (ret < 0) {
+ return ret;
}
break;
default:
@@ -498,8 +509,11 @@ static int nbd_negotiate_options(NBDClient *client)
if (nbd_negotiate_drop_sync(client->ioc, length) != length) {
return -EIO;
}
- nbd_negotiate_send_rep(client->ioc, NBD_REP_ERR_UNSUP,
- clientflags);
+ ret = nbd_negotiate_send_rep(client->ioc, NBD_REP_ERR_UNSUP,
+ clientflags);
+ if (ret < 0) {
+ return ret;
+ }
break;
}
} else {