From nobody Mon May 6 11:10:17 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=1569941128; cv=none; d=zoho.com; s=zohoarc; b=iRBYecsOQ6MMEPVn2x2PqvAwIbI2Z3bUxyEvwM8HJA9XEZ2IXCA0+8jn63emZ1LHRQhKlEqa9NaC6bxR8lOLTQeNkPmkQJlivYn938JvW0dzO93ofhbA+tYsQKHNO8MghkHkjZFd2SZv8ubj/ZtyaaIz8HR8PIA0b62HG8N4Yss= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569941128; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=dcqXb8zKfgraW7s2WtGqR2EgjeSU688Q67WszZcBnLE=; b=lcrAanUdQYHIvOSb4kiNkJYYqCLeWNIopc4/fXjo78Mw4UtlFhgjPORPHD6BI6N0yaI1PuZ7kGs8Q3i7IRetLHtwH2n2AAA3XA10glGMQu6uIXhkn4qblp/H6sRZ2LvOYQ8JCBIqHiGUIKvWyLkiruy305mUuYpOxNnXo/Opd9E= 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 156994112853142.2897058277199; Tue, 1 Oct 2019 07:45:28 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 06AC48372F2; Tue, 1 Oct 2019 14:45:27 +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 D15E460624; Tue, 1 Oct 2019 14:45: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 8B4164EE68; Tue, 1 Oct 2019 14:45:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x91EjPbQ031002 for ; Tue, 1 Oct 2019 10:45:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0AF7060166; Tue, 1 Oct 2019 14:45:25 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.43.2.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 586826012D; Tue, 1 Oct 2019 14:45:21 +0000 (UTC) From: Pavel Mores To: libvir-list@redhat.com Date: Tue, 1 Oct 2019 16:45:02 +0200 Message-Id: <20191001144502.17119-1-pmores@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Pavel Mores Subject: [libvirt] [PATCH] virsh: fixed handling of targetless disks (e.g. empty CDROM) 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.68]); Tue, 01 Oct 2019 14:45:27 +0000 (UTC) Content-Type: text/plain; charset="utf-8" virDomainGetBlockInfo() returns error if called on a disk with no target (a targetless disk might be a removable media drive with no media in it, for instance an empty CDROM drive). So far this caused the virsh domblkinfo --all command to abort and ignore any remaining (not yet displayed) disk devices. This patch fixes it by ignoring virDomainGetBlockInfo() errors for CDROM and floppy drives, similar to how it's done for network drives. https://bugzilla.redhat.com/show_bug.cgi?id=3D1619625 Signed-off-by: Pavel Mores --- tools/virsh-domain-monitor.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index 0e2c4191d7..0f495c1a3f 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -473,6 +473,7 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd) char *cap =3D NULL; char *alloc =3D NULL; char *phy =3D NULL; + char *device_type =3D NULL; vshTablePtr table =3D NULL; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) @@ -510,6 +511,8 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd) rc =3D virDomainGetBlockInfo(dom, target, &info, 0); =20 if (rc < 0) { + device_type =3D virXPathString("string(./@device)", ctxt); + /* 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. */ @@ -518,9 +521,16 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd) virGetLastErrorDomain() =3D=3D VIR_FROM_STORAGE) { memset(&info, 0, sizeof(info)); vshResetLibvirtError(); + } else if (device_type !=3D NULL && + (STRCASEEQ(device_type, "cdrom") || + STRCASEEQ(device_type, "floppy"))) { + memset(&info, 0, sizeof(info)); + vshResetLibvirtError(); } else { goto cleanup; } + + VIR_FREE(device_type); } =20 if (!cmdDomblkinfoGet(ctl, &info, &cap, &alloc, &phy, human)) @@ -556,6 +566,7 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd) VIR_FREE(target); VIR_FREE(protocol); VIR_FREE(disks); + VIR_FREE(device_type); xmlXPathFreeContext(ctxt); xmlFreeDoc(xmldoc); return ret; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list