From nobody Mon Feb 9 04:31:48 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 1494944187147486.6178494097071; Tue, 16 May 2017 07:16:27 -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 67CC480492; Tue, 16 May 2017 14:15:51 +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 C1A1A7D97C; Tue, 16 May 2017 14:15:35 +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 1E29B180BAFA; Tue, 16 May 2017 14:15:13 +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 v4GE4eNY027897 for ; Tue, 16 May 2017 10:04:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id B3A1B860E4; Tue, 16 May 2017 14:04:40 +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 3C074860E0 for ; Tue, 16 May 2017 14:04:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 67CC480492 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.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 67CC480492 From: Michal Privoznik To: libvir-list@redhat.com Date: Tue, 16 May 2017 16:03:59 +0200 Message-Id: <9920c5b27004b45826f6458d340d2a4f08864dcb.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 19/31] virnetclientstream: Introduce virNetClientStreamHandleHole 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.28]); Tue, 16 May 2017 14:16:24 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This is a function that handles an incoming STREAM_HOLE packet. Even though it is not wired up yet, it will be soon. At the beginning do couple of checks whether server plays nicely and sent us a STREAM_HOLE packed only after we've enabled sparse streams. Then decodes the message payload to see how big the hole is and stores it in passed @length argument. Signed-off-by: Michal Privoznik Reviewed-by: John Ferlan --- src/rpc/virnetclientstream.c | 96 ++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 96 insertions(+) diff --git a/src/rpc/virnetclientstream.c b/src/rpc/virnetclientstream.c index 9005e6be9..2f4f92a96 100644 --- a/src/rpc/virnetclientstream.c +++ b/src/rpc/virnetclientstream.c @@ -55,6 +55,7 @@ struct _virNetClientStream { bool incomingEOF; =20 bool allowSkip; + long long holeLength; /* Size of incoming hole in stream. */ =20 virNetClientStreamEventCallback cb; void *cbOpaque; @@ -356,6 +357,101 @@ int virNetClientStreamSendPacket(virNetClientStreamPt= r st, return -1; } =20 + +static int +virNetClientStreamSetHole(virNetClientStreamPtr st, + long long length, + unsigned int flags) +{ + virCheckFlags(0, -1); + + /* Shouldn't happen, But it's better to safe than sorry. */ + if (st->holeLength) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unprocessed hole of size %lld already in the que= ue"), + st->holeLength); + return -1; + } + + st->holeLength +=3D length; + return 0; +} + + +/** + * virNetClientStreamHandleHole: + * @client: client + * @st: stream + * + * Called whenever current message processed in the stream is + * VIR_NET_STREAM_HOLE. The stream @st is expected to be locked + * already. + * + * Returns: 0 on success, + * -1 otherwise. + */ +static int ATTRIBUTE_UNUSED +virNetClientStreamHandleHole(virNetClientPtr client, + virNetClientStreamPtr st) +{ + virNetMessagePtr msg; + virNetStreamHole data; + int ret =3D -1; + + VIR_DEBUG("client=3D%p st=3D%p", client, st); + + msg =3D st->rx; + memset(&data, 0, sizeof(data)); + + /* We should not be called unless there's VIR_NET_STREAM_HOLE + * message at the head of the list. But doesn't hurt to check */ + if (!msg) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("No message in the queue")); + goto cleanup; + } + + if (msg->header.type !=3D VIR_NET_STREAM_HOLE) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid message prog=3D%d type=3D%d serial=3D%u = proc=3D%d"), + msg->header.prog, + msg->header.type, + msg->header.serial, + msg->header.proc); + goto cleanup; + } + + /* Server should not send us VIR_NET_STREAM_HOLE unless we + * have requested so. But does not hurt to check ... */ + if (!st->allowSkip) { + virReportError(VIR_ERR_RPC, "%s", + _("Unexpected stream hole")); + goto cleanup; + } + + if (virNetMessageDecodePayload(msg, + (xdrproc_t) xdr_virNetStreamHole, + &data) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Malformed stream hole packet")); + goto cleanup; + } + + virNetMessageQueueServe(&st->rx); + virNetMessageFree(msg); + + if (virNetClientStreamSetHole(st, data.length, data.flags) < 0) + goto cleanup; + + ret =3D 0; + cleanup: + if (ret < 0) { + /* Abort stream? */ + } + return ret; +} + + int virNetClientStreamRecvPacket(virNetClientStreamPtr st, virNetClientPtr client, char *data, --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list