From nobody Sun Feb 8 22:20:45 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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=1594151232; cv=none; d=zohomail.com; s=zohoarc; b=exMAVVqgmg9Hviz8WkimovHmgAnyH07LA1SkWKTUVaruajcFbglk0DwR+591Ze/HxK1nmEF7jxtDzd9knKLRKPWHWz0722+LQebvjnkF+V58RHZU6rkSlf8ArY2NXCDrbfunzD5xWsLDOwWV1j5ZxS6Pn50G0smZxNIpAm3aqTk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594151232; 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=oJwGgicHT5DSnbDTMP8tRq5T4VqBcs4+kQT162r6SmNYJtuQPyFZk6fpRc51Ia+dNAzrO0aBzicrO15XKdO3MfqOvnvmpyBVlg/zC6iUQhPDpxfDuZyaGhoN/fxHSTCL8jtGxuRfprpox5fkbbRzFJAtf1QfOv/38BuPYki/ZmU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 159415123243476.26196013579022; Tue, 7 Jul 2020 12:47:12 -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-3-R96dXebGNZq0shon5ZHZWQ-1; Tue, 07 Jul 2020 15:47:09 -0400 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 9E3F28015FA; Tue, 7 Jul 2020 19:47:02 +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 79AE719D7D; Tue, 7 Jul 2020 19:47:02 +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 4AD06833A3; Tue, 7 Jul 2020 19:47:02 +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 067Jknk9031512 for ; Tue, 7 Jul 2020 15:46:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 14F02797F0; Tue, 7 Jul 2020 19:46:49 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 88E4F797EF for ; Tue, 7 Jul 2020 19:46:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594151231; 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=D7/wquKwWabFeElCL8b2PSJHZTBFYsqzcKcNZXoIx/FAWjL587tMIWgOMVIROdgiAcg60w v7VbHqULx6rso1Uq7uc1NgcvPjxIq+JXK4npRk0wGoaDQyi8uemK5bdRVdm65f6XPOCRWY uh79HcWMxRu7aS7jwxC7C7DQBgY2DGs= X-MC-Unique: R96dXebGNZq0shon5ZHZWQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 10/17] virsh: Pass virshStreamCallbackDataPtr to virshStreamSink() and virshStreamSkip() Date: Tue, 7 Jul 2020 21:46:28 +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.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) 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 Reviewed-by: Peter Krempa --- 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