When a length of a file is defined, the responsible thread to send
stream is finishing inappropriately. It is happening because there is
wrong conditional which compares an offset with the length and because
of that the code throws ENOSPC error.
To test it:
virsh# vol-upload ... --length N
Signed-off-by: Julio Faracco <jcfaracco(a)gmail.com>
---
src/remote/remote_daemon_stream.c | 24 ++++++++++++------------
src/util/virfdstream.c | 5 +----
2 files changed, 13 insertions(+), 16 deletions(-)
diff --git a/src/remote/remote_daemon_stream.c b/src/remote/remote_daemon_stream.c
index 4dd3af9e0..998e82a83 100644
--- a/src/remote/remote_daemon_stream.c
+++ b/src/remote/remote_daemon_stream.c
@@ -549,21 +549,21 @@ daemonStreamHandleWriteData(virNetServerClientPtr client,
} else if (ret == -2) {
/* Blocking, so indicate we have more todo later */
return 1;
- } else {
- virNetMessageError rerr;
+ } else if (ret) {
+ virNetMessageError rerr;
- memset(&rerr, 0, sizeof(rerr));
+ memset(&rerr, 0, sizeof(rerr));
- VIR_INFO("Stream send failed");
- stream->closed = true;
- virStreamEventRemoveCallback(stream->st);
- virStreamAbort(stream->st);
+ VIR_INFO("Stream send failed");
+ stream->closed = true;
+ virStreamEventRemoveCallback(stream->st);
+ virStreamAbort(stream->st);
- return virNetServerProgramSendReplyError(stream->prog,
- client,
- msg,
- &rerr,
- &msg->header);
+ return virNetServerProgramSendReplyError(stream->prog,
+ client,
+ msg,
+ &rerr,
+ &msg->header);
}
return 0;
diff --git a/src/util/virfdstream.c b/src/util/virfdstream.c
index be40379a9..c3198c768 100644
--- a/src/util/virfdstream.c
+++ b/src/util/virfdstream.c
@@ -627,9 +627,6 @@ virFDStreamThread(void *opaque)
if (got < 0)
goto error;
- if (got == 0)
- break;
-
total += got;
}
@@ -783,7 +780,7 @@ static int virFDStreamWrite(virStreamPtr st, const char *bytes, size_t
nbytes)
virObjectLock(fdst);
if (fdst->length) {
- if (fdst->length == fdst->offset) {
+ if (fdst->offset > fdst->length) {
virReportSystemError(ENOSPC, "%s",
_("cannot write to stream"));
virObjectUnlock(fdst);
--
2.14.1