Commit Graph

26 Commits

Author SHA1 Message Date
Geoff Hickey
537933a1e2 don't deregisterAll callbacks when one gets an EOF.
The deregisterAll routine is still called when the connection is
explicitly shut down by calling Disconnect.
2018-06-28 18:00:02 -04:00
Geoff Hickey
2b098b4625
Geoff/dereg callbacks on disconnect (#69)
Deregister all callbacks when disconnecting from libvirt.

Deregister all callbacks when we lose or close the connection to libvirt. This fixes a problem where goroutines with outstanding requests waiting for replies would block forever if the libvirt connection dies, whether because disconnect is called, or the libvirt daemon crashes or restarts.
2018-06-27 18:38:11 -04:00
Geoff Hickey
17c24de803
Merge pull request #63 from YorikSar/streams
Add streams support to libvirt RPC API
2018-05-08 18:10:14 -04:00
Yuriy Taraday
9adcb04498 Fix volume download 2018-05-06 00:56:50 +04:00
Yuriy Taraday
7442c709b1 Extract processIncomingStream func to make requestStream cleaner 2018-05-06 00:56:21 +04:00
Yuriy Taraday
8d6ee20a7c Fix error return when stream send failed 2018-05-05 22:34:13 +04:00
Yuriy Taraday
b27200c99b Better explain what 1<<22-24 means for packet length 2018-05-05 22:27:31 +04:00
Penghui Liao
2d4c9f9f6d
make libvirt error types private
also change ErrIsNotFound to IsNotFound

Signed-off-by: Penghui Liao <liaoishere@gmail.com>
2018-03-24 03:51:25 +08:00
Penghui Liao
482640a285 Add helper function to indicate the error cause
Signed-off-by: Penghui Liao <liaoishere@gmail.com>
2018-03-23 11:14:29 +08:00
Geoff Hickey
95c99e45a2 Deprecate the old pre-generation APIs
- Marked all the remaining old APIs from before the code-generator as
deprecated. These will be removed from the go-libvirt library as soon as
we're moved all the DO code over to use the generated APIs.
- Consolidated a couple of APIs whose implementation was split into
multiple files.
- Removed a couple of Migration-related calls we're no longer using.
2018-03-22 18:12:51 -04:00
Yuriy Taraday
35cd6327cf Don't drain callback channel, just close it and recover
Reverts 07dbf86, adds recovering from writing on eventually closed
channel in callback().
2018-03-01 21:27:02 +04:00
Yuriy Taraday
f960aceaee Factor out sendStream method from requestStream 2018-03-01 20:22:28 +04:00
Yuriy Taraday
81923720d1 Fix golint errors 2018-03-01 10:57:28 +04:00
Yuriy Taraday
81b15d4775 Add input and output streams handling to rpc layer 2018-03-01 10:06:40 +04:00
Yuriy Taraday
bfac3da6dc Treat only StatusError as error, not StatusContinue 2018-03-01 10:06:40 +04:00
Yuriy Taraday
07dbf8603a Drain callback channel when try to deregister it
callback() is blocked on sending into channel otherwise.
2018-03-01 10:06:40 +04:00
Yuriy Taraday
0c23de2f7e Deregister channels in request() method 2018-03-01 10:06:40 +04:00
Yuriy Taraday
f314e95419 Extract sendPacket and getResponse methods from request() 2018-03-01 10:06:40 +04:00
Yuriy Taraday
38a1eeb6c3 Return []byte from encode, use it instead of bytes.Buffer
We only use Buffer for its internal buffer returned by Bytes() outside
encode() anyway, so there's no reason to hold on to whole Buffer object.
2018-02-24 12:08:15 +04:00
Yuriy Taraday
47db3dbbbc Move fetching response from channel to request() method
Also parse error on bad status in request method.
This pattern was scattered all over the place.
2018-02-23 10:36:58 +04:00
Ben LeMasurier
1a220100bd
adds missing mutex around callback map (#54)
We were missing a mutex when retrieving the caller in callback().
Triggered a test failure here: https://travis-ci.org/digitalocean/go-libvirt/jobs/317051310
2017-12-15 12:56:47 -07:00
Ben LeMasurier
165035e03c
prevent connection write collisions (#52)
* prevent connection write collisions

When multiple calls are made on the same connection, it's possible for
the writes to collide with each other. This adds a write mutex when
communicating with the libvirt daemon.
2017-12-07 10:47:52 -07:00
Geoff Hickey
5a6654f07a Generate libvirt constants from libvirt sources.
- Add a yacc-based parser and a hand-written lexer to read the
remote_protocol.x file from libvirt's sources.
- Use the new parser to generate the constants used to communicate with
libvirt.
2017-11-02 19:42:44 -04:00
Ben LeMasurier
e99de2e999
fixes response overwrite bug
This fixes a bug in truncated response payload handling. Payloads
requiring more than one call to `Read()` were overwiting the previous
Read()'s buffer contents. Because we know the response payload size, we
can simply call `io.ReadAll()` rather than looping over calls to
`Read()`.
2016-06-27 12:40:39 -06:00
Ben LeMasurier
65d878e075 Adds test package
This splits out the mock libvirt server for testing within
other packages. Constants from the main libvirt package
have been moved to a separate package, constants, for shared access.
2016-05-20 10:50:10 -06:00
Ben LeMasurier
2ccd33a8df Initial Commit 2016-05-19 19:40:34 -06:00