From nobody Fri May 3 21:00:19 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 1534931193664793.0685008937362; Wed, 22 Aug 2018 02:46:33 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BB90830820CD; Wed, 22 Aug 2018 09:46:31 +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 82F073844; Wed, 22 Aug 2018 09:46:31 +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 003C04BB7F; Wed, 22 Aug 2018 09:46:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7M9kTiQ003898 for ; Wed, 22 Aug 2018 05:46:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id 76A2B2166BB1; Wed, 22 Aug 2018 09:46:29 +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 30D952166BA1; Wed, 22 Aug 2018 09:46:26 +0000 (UTC) From: Han Han To: libvir-list@redhat.com Date: Wed, 22 Aug 2018 17:46:21 +0800 Message-Id: <20180822094621.9017-1-hhan@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Cc: Han Han Subject: [libvirt] [PATCH v2] 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.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Wed, 22 Aug 2018 09:46:32 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index b9b4f9739b..576610f005 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,16 +506,18 @@ 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) { memset(&info, 0, sizeof(info)); @@ -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