summaryrefslogtreecommitdiffstats
path: root/libvirt-override-virStream.py
diff options
context:
space:
mode:
authorCole Robinson <crobinso@redhat.com>2011-06-14 16:07:43 -0400
committerCole Robinson <crobinso@redhat.com>2011-06-21 10:08:47 -0400
commitfa47dad041bf9878702724dba9d0ca4152fab928 (patch)
tree13b08cdead9ee6312e7116d0ea1f3f5f578aee97 /libvirt-override-virStream.py
parent8f2990bffe64b6d9392abd60a2bdc6da3a9aeafd (diff)
downloadlibvirt-python-split-fa47dad041bf9878702724dba9d0ca4152fab928.tar.gz
libvirt-python-split-fa47dad041bf9878702724dba9d0ca4152fab928.tar.xz
libvirt-python-split-fa47dad041bf9878702724dba9d0ca4152fab928.zip
python: Implement virStreamSend/Recv
The return values for the python version are different that the C version of virStreamSend: on success we return a string, an error raises an exception, and if the stream would block we return int(-2). We need to do this since strings aren't passed by reference in python.
Diffstat (limited to 'libvirt-override-virStream.py')
-rw-r--r--libvirt-override-virStream.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/libvirt-override-virStream.py b/libvirt-override-virStream.py
index 56f1df5..f8a1d0b 100644
--- a/libvirt-override-virStream.py
+++ b/libvirt-override-virStream.py
@@ -24,3 +24,38 @@
cbData = {"stream": self, "cb" : cb, "opaque" : opaque}
ret = libvirtmod.virStreamEventAddCallback(self._o, events, cbData)
if ret == -1: raise libvirtError ('virStreamEventAddCallback() failed')
+
+ def recv(self, nbytes):
+ """Write a series of bytes to the stream. This method may
+ block the calling application for an arbitrary amount
+ of time.
+
+ Errors are not guaranteed to be reported synchronously
+ with the call, but may instead be delayed until a
+ subsequent call.
+
+ On success, the received data is returned. On failure, an
+ exception is raised. If the stream is a NONBLOCK stream and
+ the request would block, integer -2 is returned.
+ """
+ ret = libvirtmod.virStreamRecv(self._o, nbytes)
+ if ret == None: raise libvirtError ('virStreamRecv() failed')
+ return ret
+
+ def send(self, data):
+ """Write a series of bytes to the stream. This method may
+ block the calling application for an arbitrary amount
+ of time. Once an application has finished sending data
+ it should call virStreamFinish to wait for successful
+ confirmation from the driver, or detect any error
+
+ This method may not be used if a stream source has been
+ registered
+
+ Errors are not guaranteed to be reported synchronously
+ with the call, but may instead be delayed until a
+ subsequent call.
+ """
+ ret = libvirtmod.virStreamSend(self._o, data, len(data))
+ if ret == -1: raise libvirtError ('virStreamSend() failed')
+ return ret