[libvirt] [ruby-libvirt] Don't make volume upload zero bytes

The virStreamSourceFunc internal_sendall currently returns the first value passed in from the block, which according the ruby-libvirt docs should be zero: The send block should return an array of 2 elements; the first element should be the return code from the block (-1 for error, 0 otherwise) But according to the libvirt docs of virStreamSourceFunc this indicates EOF: Returns: the number of bytes filled, 0 upon end of file, or -1 upon error So return the size of the buffer to unbreak volume uploads. --- ext/libvirt/stream.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/libvirt/stream.c b/ext/libvirt/stream.c index 1353dc9..c171535 100644 --- a/ext/libvirt/stream.c +++ b/ext/libvirt/stream.c @@ -131,7 +131,7 @@ static int internal_sendall(virStreamPtr RUBY_LIBVIRT_UNUSED(st), char *data, memcpy(data, RSTRING_PTR(buffer), RSTRING_LEN(buffer)); - return NUM2INT(retcode); + return RSTRING_LEN(buffer); } /* -- 2.8.1

On Fri, Jun 10, 2016 at 11:10 AM, Guido Günther <agx@sigxcpu.org> wrote:
The virStreamSourceFunc internal_sendall currently returns the first value passed in from the block, which according the ruby-libvirt docs should be zero:
The send block should return an array of 2 elements; the first element should be the return code from the block (-1 for error, 0 otherwise)
But according to the libvirt docs of virStreamSourceFunc this indicates EOF:
Returns: the number of bytes filled, 0 upon end of file, or -1 upon error
So return the size of the buffer to unbreak volume uploads.
This looks OK to me, so I applied it, thanks. I really should add an example of virStream to the examples on the website; do you happen to have a relatively simple example that I could put up there? Thanks, Chris

On Fri, Jun 10, 2016 at 03:58:09PM -0400, Chris Lalancette wrote:
On Fri, Jun 10, 2016 at 11:10 AM, Guido Günther <agx@sigxcpu.org> wrote:
The virStreamSourceFunc internal_sendall currently returns the first value passed in from the block, which according the ruby-libvirt docs should be zero:
The send block should return an array of 2 elements; the first element should be the return code from the block (-1 for error, 0 otherwise)
But according to the libvirt docs of virStreamSourceFunc this indicates EOF:
Returns: the number of bytes filled, 0 upon end of file, or -1 upon error
So return the size of the buffer to unbreak volume uploads.
This looks OK to me, so I applied it, thanks. I really should add an
Thanks!
example of virStream to the examples on the website; do you happen to have a relatively simple example that I could put up there?
Send via different mail. I've added this as examples/ but feel free to not apply it and use it on the website, whatever fits best. BTW the mirror at https://github.com/libvirt/ruby-libvirt/commits/master does not seem to be updating. Cheers, -- Guido
participants (2)
-
Chris Lalancette
-
Guido Günther