From nobody Sat May 4 17:43:49 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1535009240220461.41604591401347; Thu, 23 Aug 2018 00:27:20 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 828FF3082A25; Thu, 23 Aug 2018 07:27:17 +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 7A125A74FF; Thu, 23 Aug 2018 07:27:16 +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 622BF18005D0; Thu, 23 Aug 2018 07:27:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7N7RCpt029416 for ; Thu, 23 Aug 2018 03:27:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id DCDD62026E0E; Thu, 23 Aug 2018 07:27:12 +0000 (UTC) Received: from hansolo.nay.redhat.com (wlan-69-196.nay.redhat.com [10.66.69.196]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A0172026DE4; Thu, 23 Aug 2018 07:27:08 +0000 (UTC) From: Han Han To: libvir-list@redhat.com Date: Thu, 23 Aug 2018 15:27:04 +0800 Message-Id: <20180823072704.9438-1-hhan@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: Han Han Subject: [libvirt] [PATCH v3] virsh: Don't break loop of domblkinfo for disks 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Thu, 23 Aug 2018 07:27:18 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Fix logical error in v2: https://www.redhat.com/archives/libvir-list/2018-A= ugust/msg01358.html https://bugzilla.redhat.com/show_bug.cgi?id=3D1619625 --all option is added to cmdDomblkinfo since commit 62c39193 allowing to show all block devices info. Reset error when empty source in case error breaks the loop of domblkinfo for disks. Signed-off-by: Han Han --- tools/virsh-domain-monitor.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index b9b4f9739b..ecb98d4128 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -475,6 +475,7 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd) int ndisks; size_t i; xmlNodePtr *disks =3D NULL; + char *source =3D NULL; char *target =3D NULL; char *protocol =3D NULL; =20 @@ -505,18 +506,20 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd) =20 for (i =3D 0; i < ndisks; i++) { ctxt->node =3D disks[i]; + source =3D virXPathString("string(./source)", ctxt); protocol =3D virXPathString("string(./source/@protocol)", ctxt= ); target =3D virXPathString("string(./target/@dev)", ctxt); =20 rc =3D virDomainGetBlockInfo(dom, target, &info, 0); =20 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 && + /* For the case of empty cdrom, networked disk which cannot + * provide statistics, generate 0 based data and get the n= ext + * disk. + */ + if (!source || (protocol && !active && virGetLastErrorCode() =3D=3D VIR_ERR_INTERNAL_ERROR && - virGetLastErrorDomain() =3D=3D VIR_FROM_STORAGE) { + virGetLastErrorDomain() =3D=3D VIR_FROM_STORAGE)) { memset(&info, 0, sizeof(info)); vshResetLibvirtError(); } else { @@ -526,6 +529,7 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd) =20 cmdDomblkinfoPrint(ctl, &info, target, human, false); =20 + VIR_FREE(source); VIR_FREE(target); VIR_FREE(protocol); } @@ -540,6 +544,7 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd) =20 cleanup: virshDomainFree(dom); + VIR_FREE(source); VIR_FREE(target); VIR_FREE(protocol); VIR_FREE(disks); --=20 2.18.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list