From nobody Sun Feb 8 20:17:33 2026 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 1495551963313158.13219585863135; Tue, 23 May 2017 08:06:03 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 871527249C; Tue, 23 May 2017 15:06:00 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 43C127EE7E; Tue, 23 May 2017 15:06:00 +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 E064E180BAF8; Tue, 23 May 2017 15:05:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v4NF5ncP002767 for ; Tue, 23 May 2017 11:05:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 05A5878433; Tue, 23 May 2017 15:05:49 +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 80F4378213 for ; Tue, 23 May 2017 15:05:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 871527249C Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.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 871527249C From: Michal Privoznik To: libvir-list@redhat.com Date: Tue, 23 May 2017 17:05:36 +0200 Message-Id: <049baec59426b87e4576133cb6ea68bb48d379ac.1495551923.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [libvirt-perl][PATCH 2/7] Introduce flags to Stream::recv() 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 23 May 2017 15:06:01 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" At the same time register RECV_STOP_AT_HOLE constant. Signed-off-by: Michal Privoznik --- Changes | 2 ++ Virt.xs | 13 ++++++++++--- lib/Sys/Virt/Stream.pm | 20 ++++++++++++++++---- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/Changes b/Changes index 2e4a99e..b4a493c 100644 --- a/Changes +++ b/Changes @@ -4,6 +4,8 @@ Revision history for perl module Sys::Virt =20 - Add LIST_CAP_MDEV & LIST_CAP_MDEV_TYPES constants - Fix send_all() callback helper + - Introduce flags to Stream::recv() and + register RECV_STOP_AT_HOLE constant =20 3.3.0 2017-05-08 =20 diff --git a/Virt.xs b/Virt.xs index a041c95..498e711 100644 --- a/Virt.xs +++ b/Virt.xs @@ -7874,16 +7874,21 @@ send(st, data, nbytes) =20 =20 int -recv(st, data, nbytes) +recv(st, data, nbytes, flags=3D0) virStreamPtr st; SV *data; size_t nbytes; + unsigned int flags; PREINIT: char *rawdata; CODE: Newx(rawdata, nbytes, char); - if ((RETVAL =3D virStreamRecv(st, rawdata, nbytes)) < 0 && - RETVAL !=3D -2) { + if (flags) + RETVAL =3D virStreamRecvFlags(st, rawdata, nbytes, flags); + else + RETVAL =3D virStreamRecv(st, rawdata, nbytes); + + if (RETVAL !=3D -2 && RETVAL !=3D -3) { Safefree(rawdata); _croak_error(); } @@ -9010,6 +9015,8 @@ BOOT: REGISTER_CONSTANT(VIR_STREAM_EVENT_ERROR, EVENT_ERROR); REGISTER_CONSTANT(VIR_STREAM_EVENT_HANGUP, EVENT_HANGUP); =20 + REGISTER_CONSTANT(VIR_STREAM_RECV_STOP_AT_HOLE, RECV_STOP_AT_HOLE); + =20 =20 stash =3D gv_stashpv( "Sys::Virt::Error", TRUE ); diff --git a/lib/Sys/Virt/Stream.pm b/lib/Sys/Virt/Stream.pm index 4022c84..069895e 100644 --- a/lib/Sys/Virt/Stream.pm +++ b/lib/Sys/Virt/Stream.pm @@ -69,11 +69,23 @@ be called on any stream which has been activated Complete I/O on the stream. Either this function or C must be called on any stream which has been activated =20 -=3Ditem $rv =3D $st->recv($data, $nbytes) +=3Ditem $rv =3D $st->recv($data, $nbytes, $flags=3D0) =20 -Receive upto C<$nbytes> worth of data, copying into C<$data>. -Returns the number of bytes read, or -2 if I/O would block, -or -1 on error. +Receive up to C<$nbytes> worth of data, copying into C<$data>. +Returns the number of bytes read, or -3 if hole is reached and +C<$flags> contains RECV_STOP_AT_HOLE, or -2 if I/O would block, +or -1 on error. The C<$flags> parameter accepts the following +flags: + +=3Dover 4 + +=3Ditem Sys::Virt::Stream::RECV_STOP_AT_HOLE + +If this flag is set, the C function will stop reading from +stream if it has reached a hole. In that case, -3 is returned and +C should be called to get the hole size. + +=3Dback =20 =3Ditem $rv =3D $st->send($data, $nbytes) =20 --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list