From nobody Sun Feb 8 17:46:30 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 1494944102813568.9713268002399; Tue, 16 May 2017 07:15:02 -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 A2DB6804F1; Tue, 16 May 2017 14:14:08 +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 4731C7FB6C; Tue, 16 May 2017 14:13:57 +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 0307D180BAF1; Tue, 16 May 2017 14:13:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v4GE4OaM027712 for ; Tue, 16 May 2017 10:04:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 45213860E9; Tue, 16 May 2017 14:04:24 +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 C15C1860E6 for ; Tue, 16 May 2017 14:04:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A2DB6804F1 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.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 A2DB6804F1 From: Michal Privoznik To: libvir-list@redhat.com Date: Tue, 16 May 2017 16:03:46 +0200 Message-Id: <2f9f360e5fd90323e64863e5eb0a0a12f8926e36.1494943031.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 06/31] Introduce virStreamRecvHole 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.27]); Tue, 16 May 2017 14:15:00 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This function is basically a counterpart for virStreamSendHole(). If one side of a stream called virStreamSendHole() the other should call virStreamRecvHole() to get the size of the hole. Signed-off-by: Michal Privoznik Reviewed-by: John Ferlan --- include/libvirt/libvirt-stream.h | 4 ++++ src/driver-stream.h | 6 ++++++ src/libvirt-stream.c | 44 ++++++++++++++++++++++++++++++++++++= ++++ src/libvirt_public.syms | 1 + 4 files changed, 55 insertions(+) diff --git a/include/libvirt/libvirt-stream.h b/include/libvirt/libvirt-str= eam.h index 14c9af142..feaa8ad64 100644 --- a/include/libvirt/libvirt-stream.h +++ b/include/libvirt/libvirt-stream.h @@ -54,6 +54,10 @@ int virStreamSendHole(virStreamPtr st, long long length, unsigned int flags); =20 +int virStreamRecvHole(virStreamPtr, + long long *length, + unsigned int flags); + =20 /** * virStreamSourceFunc: diff --git a/src/driver-stream.h b/src/driver-stream.h index 0a5201431..0fb56ebd2 100644 --- a/src/driver-stream.h +++ b/src/driver-stream.h @@ -46,6 +46,11 @@ typedef int long long length, unsigned int flags); =20 +typedef int +(*virDrvStreamRecvHole)(virStreamPtr st, + long long *length, + unsigned int flags); + typedef int (*virDrvStreamEventAddCallback)(virStreamPtr stream, int events, @@ -74,6 +79,7 @@ struct _virStreamDriver { virDrvStreamRecv streamRecv; virDrvStreamRecvFlags streamRecvFlags; virDrvStreamSendHole streamSendHole; + virDrvStreamRecvHole streamRecvHole; virDrvStreamEventAddCallback streamEventAddCallback; virDrvStreamEventUpdateCallback streamEventUpdateCallback; virDrvStreamEventRemoveCallback streamEventRemoveCallback; diff --git a/src/libvirt-stream.c b/src/libvirt-stream.c index a09896dcd..dc0dc9ea3 100644 --- a/src/libvirt-stream.c +++ b/src/libvirt-stream.c @@ -405,6 +405,50 @@ virStreamSendHole(virStreamPtr stream, } =20 =20 +/** + * virStreamRecvHole: + * @stream: pointer to the stream object + * @length: number of bytes to skip + * @flags: extra flags; not used yet, so callers should always pass 0 + * + * This API is used to determine the @length in bytes of the + * empty space to be created in a @stream's target file when + * uploading or downloading sparsely populated files. This is the + * counterpart to virStreamSendHole(). + * + * Returns 0 on success, + * -1 on error or when there's currently no hole in the stream + */ +int +virStreamRecvHole(virStreamPtr stream, + long long *length, + unsigned int flags) +{ + VIR_DEBUG("stream=3D%p, length=3D%p flags=3D%x", + stream, length, flags); + + virResetLastError(); + + virCheckStreamReturn(stream, -1); + virCheckNonNullArgReturn(length, -1); + + if (stream->driver && + stream->driver->streamRecvHole) { + int ret; + ret =3D (stream->driver->streamRecvHole)(stream, length, flags); + if (ret < 0) + goto error; + return ret; + } + + virReportUnsupportedError(); + + error: + virDispatchError(stream->conn); + return -1; +} + + /** * virStreamSendAll: * @stream: pointer to the stream object diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 3be7cc6a0..b73cc8af1 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -762,6 +762,7 @@ LIBVIRT_3.1.0 { LIBVIRT_3.4.0 { global: virStreamRecvFlags; + virStreamRecvHole; virStreamSendHole; } LIBVIRT_3.1.0; =20 --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list