From nobody Sun Feb 8 16:36:16 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; 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 205.139.110.120 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=1593772355; cv=none; d=zohomail.com; s=zohoarc; b=BmXnJ+kxb/7/ZSX5g/n5Ac5Yr/rSp/hWHsog18A9GqdNnJugROaqgCULwzJBrNvWz3eFhZrRdp3LvIBFXv+2hhQ3oBLRnPrjbkeoce/9wmHBC0pU6z9z6m+jwkrsbKoorYEOn/kcR3IPPMCKdp7MMrNPfgLJd4h2esPF0IOOMM8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593772355; 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=Uee6XayEdsGgEj2ZTEA57z0Qt2dko4kss9iNldYC1j8=; b=NTzMYBLhKhChufs8Um43svYolH+9k42IILZsj+t+cZa39/cgCWTIxRQuyye82EDWStQEvAN4lbfvVs0oLxRNo7XmWGjKjKdXT1EGQezEBKuO5OwiWgsznQnLRUEICsC1/wLOWl6duqwR7zWx6++anX4GEy2OwRnYWvRmVwUCf0Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1593772355714950.0676179068548; Fri, 3 Jul 2020 03:32:35 -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-484-EKF5VakBNLu21xGifnbzVw-1; Fri, 03 Jul 2020 06:32:32 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F2504107ACF6; Fri, 3 Jul 2020 10:32:26 +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 D350673FEF; Fri, 3 Jul 2020 10:32:26 +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 9F4C21809563; Fri, 3 Jul 2020 10:32:26 +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 063AT8n5017021 for ; Fri, 3 Jul 2020 06:29:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id A28207BD56; Fri, 3 Jul 2020 10:29:08 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2187E79242 for ; Fri, 3 Jul 2020 10:29:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593772354; 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=Uee6XayEdsGgEj2ZTEA57z0Qt2dko4kss9iNldYC1j8=; b=akGb+z4MGg0dW+SpntrnV7etrYgaRJ3YzYKeYBqca7ycdCxAvJzDjPRaljuG1tfrNA1ooB LDCco7ec8pfNLkzuDQugmmuQV8OESYvSWwXsQ/H0m3dTPwgWSd7+AoQb/+3q/hqQCQMqct O8No2jDkPPEk/raCQhQzp8axxOs5eDU= X-MC-Unique: EKF5VakBNLu21xGifnbzVw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 8/9] virshStreamInData: Handle block devices Date: Fri, 3 Jul 2020 12:28:49 +0200 Message-Id: <151f263a28a4b3bf25b56ab93db46aeb2099cf12.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.79 on 10.5.11.15 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" This is very similar to previous commit. The virshStreamInData() callback is used by virStreamSparseSendAll() to detect whether the file the data is read from is in data or hole section. The SendAll() will then send corresponding type of virStream message to make server create a hole or write actual data. But the callback uses virFileInData() even for block devices, which results in an error. Switch to virFileInDataDetectZeroes() for block devices. Partially resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1852528 Signed-off-by: Michal Privoznik --- tools/virsh-util.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tools/virsh-util.c b/tools/virsh-util.c index 884261eb49..867f69577f 100644 --- a/tools/virsh-util.c +++ b/tools/virsh-util.c @@ -230,12 +230,20 @@ virshStreamInData(virStreamPtr st G_GNUC_UNUSED, virshStreamCallbackDataPtr cbData =3D opaque; vshControl *ctl =3D cbData->ctl; int fd =3D cbData->fd; - int ret; =20 - if ((ret =3D virFileInData(fd, inData, offset)) < 0) - vshError(ctl, "%s", _("Unable to get current position in stream")); + if (cbData->isBlock) { + if (virFileInDataDetectZeroes(fd, inData, offset) < 0) { + vshError(ctl, "%s", _("Unable to get current position in strea= m")); + return -1; + } + } else { + if (virFileInData(fd, inData, offset) < 0) { + vshError(ctl, "%s", _("Unable to get current position in strea= m")); + return -1; + } + } =20 - return ret; + return 0; } =20 =20 --=20 2.26.2