From nobody Mon Feb 9 12:25:44 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1638891367; cv=none; d=zohomail.com; s=zohoarc; b=DoqKClDju8o8uebvmbzQFiV0pklY1QpFt7RE8IrMH1D9KqONRxYHPyzqkWcNRnk9fIslxeDYcuGIbmAW6egkHE34adtO7Hou9vu34JMQr60QpWBRBs3nte7IqzYtyhAWeFveCTU+Et9hn0wwBWIZEh1NJUNi7GChxqtAyKPNcso= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638891367; 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=ihbVP+9IfGRooGhoZdbjb0BtWiFa5Sl517i0gcS4JWU=; b=kri9imHYVbYiqD+GjQfyX4KjCUcHPCO9a5RpXGew2HCisgzzch5HOLpLvG1uIDG62b7hgaFuu49rnQ4lmec3dXDWLvovc8tyNR4DPEDlA06lq3m9Zf2/IR1Fig3HHctBpiG86/IFOb72NJYVUvj9bTjbQ4fMgSBLoLDZgenYkIs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 163889136796081.16180372372776; Tue, 7 Dec 2021 07:36:07 -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-559-4IkeMrb-OzCBcjgiX8zXTw-1; Tue, 07 Dec 2021 10:36:04 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C9D4D100C618; Tue, 7 Dec 2021 15:35:55 +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 AD1A35DF2B; Tue, 7 Dec 2021 15:35:55 +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 15D011809CB8; Tue, 7 Dec 2021 15:35:55 +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 1B7FZrGN023984 for ; Tue, 7 Dec 2021 10:35:53 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9152B694D8; Tue, 7 Dec 2021 15:35:53 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1AB86694D7 for ; Tue, 7 Dec 2021 15:35:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638891367; 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=ihbVP+9IfGRooGhoZdbjb0BtWiFa5Sl517i0gcS4JWU=; b=SIcX8zDf7VdKHK2cdQ4g+IFPfJq4jCBqRoJp2RmF5Y/CLQNPs9+LLkKm7OZf9iN4ab/0Tu Yy5Wspizc3RpqniT9swokpAjb3QrCZdXTOE/m1dWyQ1uCpJaiLQxIYsLlytZXQInTxdWrW PIkzm2hH5iRg3kCjsOi6QioAqNUeOcY= X-MC-Unique: 4IkeMrb-OzCBcjgiX8zXTw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/3] virStreamInData: Allow callback to not rewind the stream Date: Tue, 7 Dec 2021 16:34:40 +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.79 on 10.5.11.14 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: 1638891368276100001 Content-Type: text/plain; charset="utf-8" So far, virStreamInData() is effectively a wrapper over virFDStreamInData() which means it deals with files which can be rewind (lseek()-ed) to whatever position we need. And in fact, that's what virFDStreamInData() does - it makes sure that the FD is left unchanged in terms of position in the file. Skipping the hole happens soon after - in daemonStreamHandleRead() when virStreamSendHole() is called. But this is about to change. Soon we will have another implementation where we won't be dealing with FDs but virNetMessage queue and it will be handy to pop message at the beginning of the queue. Implement and document this new behavior. Signed-off-by: Michal Privoznik Reviewed-by: Martin Kletzander --- src/libvirt-stream.c | 9 ++++++++- src/remote/remote_daemon_stream.c | 8 +++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/libvirt-stream.c b/src/libvirt-stream.c index 873d7b1d4e..bacbbfd325 100644 --- a/src/libvirt-stream.c +++ b/src/libvirt-stream.c @@ -505,7 +505,14 @@ virStreamRecvHole(virStreamPtr stream, * hole: @data =3D false, @length > 0 * EOF: @data =3D false, @length =3D 0 * - * Returns 0 on success, + * The position in the underlying stream should not be changed + * upon return from this function, e.g. position in the + * underlying file is kept the same. For streams where this + * condition is impossible to meet, the function can return 1 to + * signal this to a caller. + * + * Returns 0 on success (stream position unchanged), + * 1 on success (stream position changed), * -1 otherwise */ int diff --git a/src/remote/remote_daemon_stream.c b/src/remote/remote_daemon_s= tream.c index 007ad73e27..eb7ed5edf3 100644 --- a/src/remote/remote_daemon_stream.c +++ b/src/remote/remote_daemon_stream.c @@ -894,9 +894,11 @@ daemonStreamHandleRead(virNetServerClient *client, =20 msg =3D NULL; =20 - /* We have successfully sent stream skip to the other side. - * To keep streams in sync seek locally too. */ - virStreamSendHole(stream->st, length, 0); + /* We have successfully sent stream skip to the other side= . To + * keep streams in sync seek locally too (rv =3D=3D 0), un= less it's + * already done (rv =3D=3D 1). */ + if (rv =3D=3D 0) + virStreamSendHole(stream->st, length, 0); /* We're done with this call */ goto done; } --=20 2.32.0