From nobody Tue Feb 10 09:24:58 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1638891370; cv=none; d=zohomail.com; s=zohoarc; b=CQTiza0H1C+yZXOJGDmjhJTVUAHNEFFshgw3vTuEHs0dpcD8wax/BlPnvaEF8N41zqNemleLkccetYrBQIF/7katSQuGFvlxD7JGwNEq5QOO7xI8WGk36ucHt8NAVsq9X+wIB4x7z8I3R0cfUntodYFBsMJmLdZuLXtihluSnRY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638891370; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=R/9a0eVi06yjUyn+RW4dLjC1fNSnpVIik0+U9J09PhU=; b=lyrcwf8h30tkhAqb0NlHyUuf0QApFkU3DToK1h1+LDOkQXXZ/TAFfs8pH6BWtd+AWSqkFGuAH2/UUUP+87k8WOiFYCrLWNLhITzMbUVmwWWsqsKAZQIvMKjsTwaUYRtobiKxQXXNoEez3ietKuQB/pEYk25oknHOSmec3k3snVw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1638891370071910.2048221005891; Tue, 7 Dec 2021 07:36:10 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-348-uhL_ish4PG-jVksUwZBWEQ-1; Tue, 07 Dec 2021 10:36:04 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 69B8681EE74; Tue, 7 Dec 2021 15:35:57 +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 4B47419D9D; Tue, 7 Dec 2021 15:35: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 162824CA9B; Tue, 7 Dec 2021 15:35:57 +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 1B7FZsDA023989 for ; Tue, 7 Dec 2021 10:35:54 -0500 Received: by smtp.corp.redhat.com (Postfix) id 61214694D8; Tue, 7 Dec 2021 15:35:54 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id DDF85694D7 for ; Tue, 7 Dec 2021 15:35:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638891369; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=R/9a0eVi06yjUyn+RW4dLjC1fNSnpVIik0+U9J09PhU=; b=h7WANUcd4a4YcpbMYe184Xi0aUI8R5koF3TmydTCdcrDZ8AXdMrFVZGszrCkGQwGvIl2UJ J2Noac+h4wtBK5Al5OflKVg0zwlH+yF82tB6JVO7GLAUgTOLOcH35qRQ+kod14CREJsEFg CEZJgZotZsQmti3krhzkWdcfT2xgafs= X-MC-Unique: uhL_ish4PG-jVksUwZBWEQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/3] rpc: Introduce virNetClientStreamInData() Date: Tue, 7 Dec 2021 16:34:41 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1638891370927100001 Content-Type: text/plain; charset="utf-8" The aim of this function is to look at a virNetClientStream and tell whether the incoming packet (if there's one) contains data (type VIR_NET_STREAM) or a hole (type VIR_NET_STREAM_HOLE) and how big the section is. This function will be called from the remote driver in one of future commits. Signed-off-by: Michal Privoznik Reviewed-by: Martin Kletzander --- src/libvirt_remote.syms | 1 + src/rpc/virnetclientstream.c | 61 ++++++++++++++++++++++++++++++++++++ src/rpc/virnetclientstream.h | 4 +++ 3 files changed, 66 insertions(+) diff --git a/src/libvirt_remote.syms b/src/libvirt_remote.syms index 942e1013a6..07d22e368b 100644 --- a/src/libvirt_remote.syms +++ b/src/libvirt_remote.syms @@ -66,6 +66,7 @@ virNetClientStreamEOF; virNetClientStreamEventAddCallback; virNetClientStreamEventRemoveCallback; virNetClientStreamEventUpdateCallback; +virNetClientStreamInData; virNetClientStreamMatches; virNetClientStreamNew; virNetClientStreamQueuePacket; diff --git a/src/rpc/virnetclientstream.c b/src/rpc/virnetclientstream.c index 1ba6167a1d..ffc702cdc3 100644 --- a/src/rpc/virnetclientstream.c +++ b/src/rpc/virnetclientstream.c @@ -801,3 +801,64 @@ bool virNetClientStreamEOF(virNetClientStream *st) { return st->incomingEOF; } + + +int virNetClientStreamInData(virNetClientStream *st, + int *inData, + long long *length) +{ + int ret =3D 0; + virNetMessage *msg =3D NULL; + + if (!st->allowSkip) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("Holes are not supported with this stream")); + return -1; + } + + virObjectLock(st); + + if (virNetClientStreamCheckState(st) < 0) + goto cleanup; + + msg =3D st->rx; + + if (!msg) { + /* No incoming message. This means that the stream is at its end. = In + * this case, virStreamInData() should set both inData and length = to + * zero and return success. */ + *inData =3D 0; + *length =3D 0; + } else if (msg->header.type =3D=3D VIR_NET_STREAM) { + *inData =3D 1; + *length =3D msg->bufferLength - msg->bufferOffset; + } else if (msg->header.type =3D=3D VIR_NET_STREAM_HOLE) { + *inData =3D 0; + + if (st->holeLength =3D=3D 0 && + virNetClientStreamHandleHole(NULL, st) < 0) + goto cleanup; + + *length =3D st->holeLength; + st->holeLength =3D 0; + + /* virNetClientStreamHandleHole() called above did pop the message= from + * the queue (and freed it). Instead of trying to push it back let= 's + * just signal to the caller what we did. */ + ret =3D 1; + goto cleanup; + } else { + 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; + } + + ret =3D 0; + cleanup: + virObjectUnlock(st); + return ret; +} diff --git a/src/rpc/virnetclientstream.h b/src/rpc/virnetclientstream.h index e16d6e4a9a..7428843f9b 100644 --- a/src/rpc/virnetclientstream.h +++ b/src/rpc/virnetclientstream.h @@ -90,3 +90,7 @@ int virNetClientStreamEventRemoveCallback(virNetClientStr= eam *st); =20 bool virNetClientStreamEOF(virNetClientStream *st) ATTRIBUTE_NONNULL(1); + +int virNetClientStreamInData(virNetClientStream *st, + int *inData, + long long *length); --=20 2.32.0