From nobody Thu Apr 25 04:01:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1570188931; cv=none; d=zoho.com; s=zohoarc; b=bysa6ZGacgKMLKrFfeEsSvhaksJv9JduJ0kBRwpI4i9TQjlJZNulV9RaesBpFQdXof0FHvDF+Pv5FyiWjlAfljZmBvpn4H1Y/bMKNxMJIfizdLp5a5qrXicEnBk5iuoPC6sTqf/BmCi6CUXO5K18N4uhSnSYTHuNoFyDdI6ccL0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570188931; 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:ARC-Authentication-Results; bh=WkLQYz7587q/fcTYPLiEhq3mDXKn9K46OyABQrdav1k=; b=E61jVxS96DeWs28JlWJDyMVCY0wzbqMYJO4qL3+DTNmS/5mOLZgNxwn2Z0M/8g8WqV93ItZz/WUm5C9R7e1wnViDCpwtToeImPsyRhZ3wqcExTAutG97HYmBWt8WFsBHNoVZydC0t6K+xBu7PvNnh9oOay1TRd9FN3IVHNGcf4o= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15701889315881021.3231736300567; Fri, 4 Oct 2019 04:35:31 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5735E105794E; Fri, 4 Oct 2019 11:35:29 +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 1A742601A3; Fri, 4 Oct 2019 11:35:29 +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 AE2FB180B536; Fri, 4 Oct 2019 11:35:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x94BZFwb016112 for ; Fri, 4 Oct 2019 07:35:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id 530365D6B7; Fri, 4 Oct 2019 11:35:15 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.43.2.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id A7CD55D6B2; Fri, 4 Oct 2019 11:35:14 +0000 (UTC) From: Pavel Mores To: pmores@redhat.com, libvir-list@redhat.com Date: Fri, 4 Oct 2019 13:35:09 +0200 Message-Id: <20191004113509.29243-2-pmores@redhat.com> In-Reply-To: <20191004113509.29243-1-pmores@redhat.com> References: <20191004113509.29243-1-pmores@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 1/1] fixed handling of sourceless disks in 'domblkinfo' cmd 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.64]); Fri, 04 Oct 2019 11:35:29 +0000 (UTC) Content-Type: text/plain; charset="utf-8" virDomainGetBlockInfo() returns error if called on a disk with no source (a sourceless disk might be a removable media drive with no media in it, for instance an empty CDROM or floppy drive). So far this caused the virsh domblkinfo --all command to abort and ignore any remaining (not yet displayed) disk devices. This patch fixes the problem by first checking for existence of a element in the corresponding XML. If none is found, we avoid calling virDomainGetBlockInfo() altogether as we know it's bound to fail in that case. https://bugzilla.redhat.com/show_bug.cgi?id=3D1619625 Signed-off-by: Pavel Mores Reviewed-by: J=C3=A1n Tomko --- tools/virsh-domain-monitor.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index 0e2c4191d7..b69283b2da 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -507,20 +507,27 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd) protocol =3D virXPathString("string(./source/@protocol)", ctxt= ); target =3D virXPathString("string(./target/@dev)", ctxt); =20 - rc =3D virDomainGetBlockInfo(dom, target, &info, 0); - - if (rc < 0) { - /* If protocol is present that's an indication of a networ= ked - * storage device which cannot provide statistics, so gene= rate - * 0 based data and get the next disk. */ - if (protocol && !active && - virGetLastErrorCode() =3D=3D VIR_ERR_INTERNAL_ERROR && - virGetLastErrorDomain() =3D=3D VIR_FROM_STORAGE) { - memset(&info, 0, sizeof(info)); - vshResetLibvirtError(); - } else { - goto cleanup; + if (virXPathBoolean("boolean(./source)", ctxt) =3D=3D 1) { + + rc =3D virDomainGetBlockInfo(dom, target, &info, 0); + + if (rc < 0) { + /* If protocol is present that's an indication of a + * networked storage device which cannot provide stati= stics, + * so generate 0 based data and get the next disk. */ + if (protocol && !active && + virGetLastErrorCode() =3D=3D VIR_ERR_INTERNAL_ERRO= R && + virGetLastErrorDomain() =3D=3D VIR_FROM_STORAGE) { + memset(&info, 0, sizeof(info)); + vshResetLibvirtError(); + } else { + goto cleanup; + } } + } else { + /* if we don't call virDomainGetBlockInfo() who clears 'in= fo' + * we have to do it manually */ + memset(&info, 0, sizeof(info)); } =20 if (!cmdDomblkinfoGet(ctl, &info, &cap, &alloc, &phy, human)) --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list