From nobody Sun Feb 8 22:01:06 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.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 207.211.31.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=1594151246; cv=none; d=zohomail.com; s=zohoarc; b=CosqznBEw4s6jkuk0YLv9gHaAIUngkOFFmCLxSHAhycgGzF7JzOPCqJ4DykW7moLPlo8Palhmxa7gSHeiyXvG6tUmo+dlUT8vA1NCuLVVB6sU5v0gKG2rqDjk4hiqA2SwLBoCXfu2BDPgikPvBUyHiw/bFl5U0B8eaEEKOVTSeE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594151246; 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=VH0FjIZGt3K9Ui/jhHXn2ef8AveiYTyS9AkEcc7gjClV2siYExFJlQUM84//3aJpF1OQt+JMaRjsLybe8J54hoPRWKZ0l4HPnCloXrHL6TRjtAifZvU3fPM34C7iWnz+A1BNFkE213GSctxDMSPYr099eKxpLUPHFfgPw8IEgqE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.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 [207.211.31.120]) by mx.zohomail.com with SMTPS id 1594151246325587.241604105107; Tue, 7 Jul 2020 12:47:26 -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-417-Uy95LJO0May433QpY65IDQ-1; Tue, 07 Jul 2020 15:47:23 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 93A4AEC1A2; Tue, 7 Jul 2020 19:47:17 +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 7326260CD0; Tue, 7 Jul 2020 19:47:17 +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 4555A93F7F; Tue, 7 Jul 2020 19:47:17 +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 067Jkq1o031556 for ; Tue, 7 Jul 2020 15:46:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 87F63797F0; Tue, 7 Jul 2020 19:46:52 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 074C4797F3 for ; Tue, 7 Jul 2020 19:46:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594151245; 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=HvnOHFCi3If+tN3DrNghVDzLfGzpQO1e596bpjcmwfiDLlLc/Kh0FKDzNJbkavKCeSC1Qz WR+cTEqsNSO8zAvI6Wo++Hv+yhKmU9xyzUHnnIQs1cbh0pkS3d0cu7W0dna7wehADGgBoh 5Xnv8s+nE1e94DDzbBfufmExE2NfHik= X-MC-Unique: Uy95LJO0May433QpY65IDQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 14/17] virshStreamInData: Handle block devices Date: Tue, 7 Jul 2020 21:46:32 +0200 Message-Id: <2733dd941d5a7b831a456b36343e8ed70eae223e.1594150891.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.12 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