From nobody Sun Feb 8 22:35:20 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-delivery-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=1593772358; cv=none; d=zohomail.com; s=zohoarc; b=VzFBuh9l+x+WIYCi0ETh6UMMzfzxWmQKb66IeiwgfbrorkwZcnLv67uhClVsMVqACUzZHj3imqnCWrCKrs19BISRFmMUbaFqVjNnY72tMz1sG9cCGHT49fkG3SCaV7/3u55w3iNKQSntqvW8Js7SzYpD61jAczVMpuJHKD00SPQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593772358; 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=C3g/PCvVDm0zZJyvtMAZa1Vg0ZtgVdgF8mhfLJiEgos=; b=a4SzYIqOve2um87BKlHzo2ulhW7+GmkXEt9zJv5hpLcEOC79oG53ofnsyDkErYWpjHh8f07QK1pC1IxgX6aq7nElJEuRgPQTghoU0WaDZ0Qiw0N9YrJD8Xprd9d8HJF7nFNhAfA6Z7Wgpi94xLAtjSwI5qGuDoYc+sPt0jlOCFg= 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-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 159377235812632.4138415265229; Fri, 3 Jul 2020 03:32:38 -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-287-ozWmYDjANdSt_1G6G7ntqQ-1; Fri, 03 Jul 2020 06:32:34 -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 BF88E1083E85; Fri, 3 Jul 2020 10:32:28 +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 9FCD62DE71; Fri, 3 Jul 2020 10:32:28 +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 721D06C9D1; Fri, 3 Jul 2020 10:32:28 +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 063AT6CT016989 for ; Fri, 3 Jul 2020 06:29:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0DA0379242; Fri, 3 Jul 2020 10:29:06 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8120B7BD4A for ; Fri, 3 Jul 2020 10:29:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593772356; 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=C3g/PCvVDm0zZJyvtMAZa1Vg0ZtgVdgF8mhfLJiEgos=; b=AJJ1yXb0Yzg+/d573SjfRvrrR3N71XCCQ5fBfjnswvrZwYHKZhoQ2OB/zarTS8sFXujL47 bJ9HopS+WIGaX34sHAEQntR0JvecDVehbxtePxUZUX1QDLdmIRaBVSHPzvbjvh0DWVMHgx HKY/ucsAiQ2Iw+i5f+J6NWeZd8ahWu4= X-MC-Unique: ozWmYDjANdSt_1G6G7ntqQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 5/9] virsh: Track if vol-upload or vol-download work over a block device Date: Fri, 3 Jul 2020 12:28:46 +0200 Message-Id: <61900eb94ac3fe28d33c4c4feb6201b182a39b44.1593771693.git.mprivozn@redhat.com> 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" We can't use virFileInData() with block devices, but we could use new virFileInDataDetectZeroes(). But to decide we need to know if the FD we are reading data from / writing data to is a block device. Store this information in _virshStreamCallbackData. Signed-off-by: Michal Privoznik --- tools/virsh-util.h | 1 + tools/virsh-volume.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/tools/virsh-util.h b/tools/virsh-util.h index 72653d9735..9ef28cfe0a 100644 --- a/tools/virsh-util.h +++ b/tools/virsh-util.h @@ -72,6 +72,7 @@ typedef virshStreamCallbackData *virshStreamCallbackDataP= tr; struct _virshStreamCallbackData { vshControl *ctl; int fd; + bool isBlock; }; =20 int diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c index 5cbc2efb7a..20823e2d10 100644 --- a/tools/virsh-volume.c +++ b/tools/virsh-volume.c @@ -679,6 +679,7 @@ cmdVolUpload(vshControl *ctl, const vshCmd *cmd) virshControlPtr priv =3D ctl->privData; unsigned int flags =3D 0; virshStreamCallbackData cbData; + struct stat sb; =20 if (vshCommandOptULongLong(ctl, cmd, "offset", &offset) < 0) return false; @@ -697,8 +698,14 @@ cmdVolUpload(vshControl *ctl, const vshCmd *cmd) goto cleanup; } =20 + if (fstat(fd, &sb) < 0) { + vshError(ctl, _("unable to stat %s"), file); + goto cleanup; + } + cbData.ctl =3D ctl; cbData.fd =3D fd; + cbData.isBlock =3D !!S_ISBLK(sb.st_mode); =20 if (vshCommandOptBool(cmd, "sparse")) flags |=3D VIR_STORAGE_VOL_UPLOAD_SPARSE_STREAM; @@ -795,6 +802,7 @@ cmdVolDownload(vshControl *ctl, const vshCmd *cmd) virshControlPtr priv =3D ctl->privData; virshStreamCallbackData cbData; unsigned int flags =3D 0; + struct stat sb; =20 if (vshCommandOptULongLong(ctl, cmd, "offset", &offset) < 0) return false; @@ -821,8 +829,14 @@ cmdVolDownload(vshControl *ctl, const vshCmd *cmd) created =3D true; } =20 + if (fstat(fd, &sb) < 0) { + vshError(ctl, _("unable to stat %s"), file); + goto cleanup; + } + cbData.ctl =3D ctl; cbData.fd =3D fd; + cbData.isBlock =3D !!S_ISBLK(sb.st_mode); =20 if (!(st =3D virStreamNew(priv->conn, 0))) { vshError(ctl, _("cannot create a new stream")); --=20 2.26.2