From nobody Fri May 16 10:51:32 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1495549700454305.0485111895731; Tue, 23 May 2017 07:28:20 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0FB87285B1; Tue, 23 May 2017 14:28:18 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8BAD251DF8; Tue, 23 May 2017 14:28:16 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 30FF14A48C; Tue, 23 May 2017 14:28:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v4NEQLID028670 for ; Tue, 23 May 2017 10:26:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6C3137814F; Tue, 23 May 2017 14:26:21 +0000 (UTC) Received: from moe.brq.redhat.com (dhcp129-131.brq.redhat.com [10.34.129.131]) by smtp.corp.redhat.com (Postfix) with ESMTP id E9C137BCB0 for ; Tue, 23 May 2017 14:26:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0FB87285B1 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 0FB87285B1 From: Michal Privoznik To: libvir-list@redhat.com Date: Tue, 23 May 2017 16:26:09 +0200 Message-Id: <2e4cb221228e4927aa4eca90be87708921c85f11.1495549496.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [libvirt-python][PATCH v2 2/4] virStream: Introduce virStreamRecvFlags X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 23 May 2017 14:28:19 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Yet again, we need a custom wrapper over virStreamRecvFlags because our generator is not capable of generating it. Signed-off-by: Michal Privoznik --- generator.py | 1 + libvirt-override-virStream.py | 18 ++++++++++++++++++ libvirt-override.c | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+) diff --git a/generator.py b/generator.py index ca1df35..0e07fc8 100755 --- a/generator.py +++ b/generator.py @@ -545,6 +545,7 @@ skip_function =3D ( '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 =20 'virConnectUnregisterCloseCallback', # overridden in virConnect.py 'virConnectRegisterCloseCallback', # overridden in virConnect.py diff --git a/libvirt-override-virStream.py b/libvirt-override-virStream.py index 62c1328..66d2bf6 100644 --- a/libvirt-override-virStream.py +++ b/libvirt-override-virStream.py @@ -146,3 +146,21 @@ ret =3D libvirtmod.virStreamSendHole(self._o, length, flags) if ret =3D=3D -1: raise libvirtError('virStreamSendHole() failed') return ret + + def recvFlags(self, nbytes, flags =3D 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 =3D libvirtmod.virStreamRecvFlags(self._o, nbytes, flags) + if ret is None: raise libvirtError ('virStreamRecvFlags() failed') + return ret diff --git a/libvirt-override.c b/libvirt-override.c index a6ef49e..0abfc37 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -9519,6 +9519,44 @@ libvirt_virStreamSendHole(PyObject *self ATTRIBUTE_U= NUSED, return libvirt_intWrap(ret); } =20 + +static PyObject * +libvirt_virStreamRecvFlags(PyObject *self ATTRIBUTE_UNUSED, + PyObject *args) +{ + PyObject *pyobj_stream; + PyObject *rv; + virStreamPtr stream; + char *buf =3D NULL; + size_t nbytes; + unsigned int flags; + int ret; + + if (!PyArg_ParseTuple(args, (char *) "OkI:virStreamRecvFlags", + &pyobj_stream, &nbytes, &flags)) + return NULL; + + stream =3D PyvirStream_Get(pyobj_stream); + + if (VIR_ALLOC_N(buf, nbytes + 1) < 0) + return PyErr_NoMemory(); + + LIBVIRT_BEGIN_ALLOW_THREADS; + ret =3D virStreamRecvFlags(stream, buf, nbytes, flags); + LIBVIRT_END_ALLOW_THREADS; + + buf[ret > -1 ? ret : 0] =3D '\0'; + DEBUG("StreamRecvFlags ret=3D%d strlen=3D%d\n", ret, (int) strlen(buf)= ); + + if (ret =3D=3D -2 || ret =3D=3D -3) + return libvirt_intWrap(ret); + if (ret < 0) + return VIR_PY_NONE; + rv =3D libvirt_charPtrSizeWrap((char *) buf, (Py_ssize_t) ret); + VIR_FREE(buf); + return rv; +} + #endif /* LIBVIR_CHECK_VERSION(3, 4, 0) */ =20 =20 @@ -9749,6 +9787,7 @@ static PyMethodDef libvirtMethods[] =3D { #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_VARAR= GS, NULL}, #endif /* LIBVIR_CHECK_VERSION(3, 4, 0) */ {NULL, NULL, 0, NULL} }; --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list