1
0
mirror of https://gitlab.com/libvirt/libvirt-python.git synced 2025-08-02 04:21:59 +03:00

virStream: Introduce virStreamRecvFlags

Yet again, we need a custom wrapper over virStreamRecvFlags
because our generator is not capable of generating it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Michal Privoznik
2017-05-22 08:25:23 +02:00
parent 1f42d8629f
commit 2e4cb22122
3 changed files with 58 additions and 0 deletions

View File

@ -545,6 +545,7 @@ skip_function = (
'virStreamSend', # overridden in libvirt-override-virStream.py
'virStreamRecvHole', # overridden in libvirt-override-virStream.py
'virStreamSendHole', # overridden in libvirt-override-virStream.py
'virStreamRecvFlags', # overridden in libvirt-override-virStream.py
'virConnectUnregisterCloseCallback', # overridden in virConnect.py
'virConnectRegisterCloseCallback', # overridden in virConnect.py

View File

@ -146,3 +146,21 @@
ret = libvirtmod.virStreamSendHole(self._o, length, flags)
if ret == -1: raise libvirtError('virStreamSendHole() failed')
return ret
def recvFlags(self, nbytes, flags = 0):
"""Reads a series of bytes from the stream. This method may
block the calling application for an arbitrary amount
of time. This is just like recv except it has flags
argument.
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.virStreamRecvFlags(self._o, nbytes, flags)
if ret is None: raise libvirtError ('virStreamRecvFlags() failed')
return ret

View File

@ -9519,6 +9519,44 @@ libvirt_virStreamSendHole(PyObject *self ATTRIBUTE_UNUSED,
return libvirt_intWrap(ret);
}
static PyObject *
libvirt_virStreamRecvFlags(PyObject *self ATTRIBUTE_UNUSED,
PyObject *args)
{
PyObject *pyobj_stream;
PyObject *rv;
virStreamPtr stream;
char *buf = NULL;
size_t nbytes;
unsigned int flags;
int ret;
if (!PyArg_ParseTuple(args, (char *) "OkI:virStreamRecvFlags",
&pyobj_stream, &nbytes, &flags))
return NULL;
stream = PyvirStream_Get(pyobj_stream);
if (VIR_ALLOC_N(buf, nbytes + 1) < 0)
return PyErr_NoMemory();
LIBVIRT_BEGIN_ALLOW_THREADS;
ret = virStreamRecvFlags(stream, buf, nbytes, flags);
LIBVIRT_END_ALLOW_THREADS;
buf[ret > -1 ? ret : 0] = '\0';
DEBUG("StreamRecvFlags ret=%d strlen=%d\n", ret, (int) strlen(buf));
if (ret == -2 || ret == -3)
return libvirt_intWrap(ret);
if (ret < 0)
return VIR_PY_NONE;
rv = libvirt_charPtrSizeWrap((char *) buf, (Py_ssize_t) ret);
VIR_FREE(buf);
return rv;
}
#endif /* LIBVIR_CHECK_VERSION(3, 4, 0) */
@ -9749,6 +9787,7 @@ static PyMethodDef libvirtMethods[] = {
#if LIBVIR_CHECK_VERSION(3, 4, 0)
{(char *) "virStreamRecvHole", libvirt_virStreamRecvHole, METH_VARARGS, NULL},
{(char *) "virStreamSendHole", libvirt_virStreamSendHole, METH_VARARGS, NULL},
{(char *) "virStreamRecvFlags", libvirt_virStreamRecvFlags, METH_VARARGS, NULL},
#endif /* LIBVIR_CHECK_VERSION(3, 4, 0) */
{NULL, NULL, 0, NULL}
};