From nobody Mon Feb 9 03:52:21 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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=1593772352; cv=none; d=zohomail.com; s=zohoarc; b=ZaCktSPRqEcQTeQ3XrRTJoQ7gRRJNsqwcusGupVE9huCotYDCJ5Jq029HKOVaXrv1tyWbI6ttVockruXPLNoEPgBUq3Mp3hbTKnviAZOMcVqfD8+gGdLm3+fhuTF3i8CtElfxGpWZn+0MnC5TlbSdFbgde6NT24hX2aMxnEWFpI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593772352; 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=/UW50IMzLK0fDKp9M0omUd4XLUKGp7krwUQWd6pVmJc=; b=mGSytQJ20JzUDLSVifin2E3fEpF7DIFYhobCm9v0f44MVBcwEArKXjhUdDCmy6SG7Sg7UtVHCDwevcEmuaxVnTIDpswehzjMMAdwKiLEsJ7lXTk8WXNrooIWmD7vY2qKtEoRtbDCm1V9h8yQtd3ORBNIzyXomc+cmSSKxT+kLG4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1593772352777353.6227905890448; Fri, 3 Jul 2020 03:32:32 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-414-3WoRUrpgMCSpbRB9feQbVQ-1; Fri, 03 Jul 2020 06:32:29 -0400 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 03F6D18A8223; Fri, 3 Jul 2020 10:32:24 +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 D96F47611C; Fri, 3 Jul 2020 10:32:23 +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 6D4341809547; Fri, 3 Jul 2020 10:32:23 +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 063AT5S8016984 for ; Fri, 3 Jul 2020 06:29:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2C74E7BD43; Fri, 3 Jul 2020 10:29:05 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9FC0379242 for ; Fri, 3 Jul 2020 10:29:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593772351; 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=/UW50IMzLK0fDKp9M0omUd4XLUKGp7krwUQWd6pVmJc=; b=KfTJgqAB+8lJqWUTVx7XJvxC5IWrLx7YMmO/SCaNN/B5jVqwT8BAKv3wGtihsqDkIB3vUC IZF+/y5waU/KEwWxolyzA8xM6AnebEWoIdLNjQqrf+/3ipGo9doQ+Wm28Pw8l4WsdjqZEY XbGZKsCjWZCN3QoHgRH2ait+nuQRaBU= X-MC-Unique: 3WoRUrpgMCSpbRB9feQbVQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 4/9] virsh: Pass virshStreamCallbackDataPtr to virshStreamSink() and virshStreamSkip() Date: Fri, 3 Jul 2020 12:28:45 +0200 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) Content-Type: text/plain; charset="utf-8" These callback will need to know more that the FD they are working on. Pass the structure that is passed to other stream callbacks (e.g. virshStreamSource() or virshStreamSourceSkip()) instead of inventing a new one. Signed-off-by: Michal Privoznik --- tools/virsh-util.c | 10 +++++----- tools/virsh-volume.c | 6 +++++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/tools/virsh-util.c b/tools/virsh-util.c index 932d6d0849..89f15efd08 100644 --- a/tools/virsh-util.c +++ b/tools/virsh-util.c @@ -146,9 +146,9 @@ virshStreamSink(virStreamPtr st G_GNUC_UNUSED, size_t nbytes, void *opaque) { - int *fd =3D opaque; + virshStreamCallbackDataPtr cbData =3D opaque; =20 - return safewrite(*fd, bytes, nbytes); + return safewrite(cbData->fd, bytes, nbytes); } =20 =20 @@ -186,13 +186,13 @@ virshStreamSkip(virStreamPtr st G_GNUC_UNUSED, long long offset, void *opaque) { - int *fd =3D opaque; + virshStreamCallbackDataPtr cbData =3D opaque; off_t cur; =20 - if ((cur =3D lseek(*fd, offset, SEEK_CUR)) =3D=3D (off_t) -1) + if ((cur =3D lseek(cbData->fd, offset, SEEK_CUR)) =3D=3D (off_t) -1) return -1; =20 - if (ftruncate(*fd, cur) < 0) + if (ftruncate(cbData->fd, cur) < 0) return -1; =20 return 0; diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c index 72394915d8..5cbc2efb7a 100644 --- a/tools/virsh-volume.c +++ b/tools/virsh-volume.c @@ -793,6 +793,7 @@ cmdVolDownload(vshControl *ctl, const vshCmd *cmd) unsigned long long offset =3D 0, length =3D 0; bool created =3D false; virshControlPtr priv =3D ctl->privData; + virshStreamCallbackData cbData; unsigned int flags =3D 0; =20 if (vshCommandOptULongLong(ctl, cmd, "offset", &offset) < 0) @@ -820,6 +821,9 @@ cmdVolDownload(vshControl *ctl, const vshCmd *cmd) created =3D true; } =20 + cbData.ctl =3D ctl; + cbData.fd =3D fd; + if (!(st =3D virStreamNew(priv->conn, 0))) { vshError(ctl, _("cannot create a new stream")); goto cleanup; @@ -830,7 +834,7 @@ cmdVolDownload(vshControl *ctl, const vshCmd *cmd) goto cleanup; } =20 - if (virStreamSparseRecvAll(st, virshStreamSink, virshStreamSkip, &fd) = < 0) { + if (virStreamSparseRecvAll(st, virshStreamSink, virshStreamSkip, &cbDa= ta) < 0) { vshError(ctl, _("cannot receive data from volume %s"), name); goto cleanup; } --=20 2.26.2