From nobody Mon Apr 29 18:48:39 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; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=126.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 152940251880315.50124407490489; Tue, 19 Jun 2018 03:01:58 -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 A612130832EC; Tue, 19 Jun 2018 10:01:56 +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 6D0A860851; Tue, 19 Jun 2018 10:01:55 +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 0CCF61800538; Tue, 19 Jun 2018 10:01:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5JA1oLM016648 for ; Tue, 19 Jun 2018 06:01:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id D3F075D9C6; Tue, 19 Jun 2018 10:01:50 +0000 (UTC) Received: from mx1.redhat.com (ext-mx13.extmail.prod.ext.phx2.redhat.com [10.5.110.42]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BCBF25D9C5 for ; Tue, 19 Jun 2018 10:01:49 +0000 (UTC) Received: from m15-113.126.com (m15-113.126.com [220.181.15.113]) by mx1.redhat.com (Postfix) with ESMTP id 796FD308212B for ; Tue, 19 Jun 2018 10:01:45 +0000 (UTC) Received: from localhost.localdomain (unknown [58.213.111.46]) by smtp3 (Coremail) with SMTP id DcmowACX_OV41Chb9lyYAw--.65231S3; Tue, 19 Jun 2018 18:01:42 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id; bh=TtRv6Kb5K5oEsAxJs6 dFWmbmt+26PICvfWy1+YXScx8=; b=Q8Qus3CTrAYs8zDaWyk4hR2Kdciuwrr287 8owNKe09zsC7uw6bX8rrXYd1H7sQhrw2zLExB6YOSjlNBv6xtq5aLGhcSaBCEDLQ bSgzbL6roh+Wed9L8r6gevJzio6CdSd2gG8Fyjjsm/j/wNwgGZhkrE0lgwnZJZA0 YD8Ja50as= From: Chen Hanxiao To: libvir-list@redhat.com Date: Tue, 19 Jun 2018 18:01:23 +0800 Message-Id: <20180619100126.28086-2-chen_han_xiao@126.com> In-Reply-To: <20180619100126.28086-1-chen_han_xiao@126.com> References: <20180619100126.28086-1-chen_han_xiao@126.com> X-CM-TRANSID: DcmowACX_OV41Chb9lyYAw--.65231S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7AF47GF1rCw47GFyxXw48Crg_yoW8Kr17pa 1rWFs8uw1xX3ZxXr9Iqw1YgFn8K3s5Jr1jgrs2g340yrsrX3Z2gr1xJ3y5ZFZ5ZrW3AF1U ArnxAFyxKw1Iya7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07Uo7K3UUUUU= X-Originating-IP: [58.213.111.46] X-CM-SenderInfo: xfkh0spkdqs5xldrqiyswou0bp/1tbiFgZqrlpD56c15gAAse X-Greylist: Sender passed SPF test, ACL 227 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Tue, 19 Jun 2018 10:01:47 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Tue, 19 Jun 2018 10:01:47 +0000 (UTC) for IP:'220.181.15.113' DOMAIN:'m15-113.126.com' HELO:'m15-113.126.com' FROM:'chen_han_xiao@126.com' RCPT:'' X-RedHat-Spam-Score: 0.7 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_ANBREP_L2, SPF_PASS) 220.181.15.113 m15-113.126.com 220.181.15.113 m15-113.126.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.42 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Chen Hanxiao Subject: [libvirt] [PATCH v3 1/4] cmdDomblkinfo: introduce helper cmdDomblkinfoPrint 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Tue, 19 Jun 2018 10:01:58 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Chen Hanxiao Introduce helper cmdDomblkinfoPrint for printing. Reviewed-by: John Ferlan Signed-off-by: Chen Hanxiao --- tools/virsh-domain-monitor.c | 39 ++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index 8cbb3db37c..daa86e8310 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -400,6 +400,29 @@ static const vshCmdOptDef opts_domblkinfo[] =3D { {.name =3D NULL} }; =20 +static void +cmdDomblkinfoPrint(vshControl *ctl, + const virDomainBlockInfo *info, + bool human) +{ + if (!human) { + vshPrint(ctl, "%-15s %llu\n", _("Capacity:"), info->capacity); + vshPrint(ctl, "%-15s %llu\n", _("Allocation:"), info->allocation); + vshPrint(ctl, "%-15s %llu\n", _("Physical:"), info->physical); + } else { + double val; + const char *unit; + + val =3D vshPrettyCapacity(info->capacity, &unit); + vshPrint(ctl, "%-15s %-.3lf %s\n", _("Capacity:"), val, unit); + val =3D vshPrettyCapacity(info->allocation, &unit); + vshPrint(ctl, "%-15s %-.3lf %s\n", _("Allocation:"), val, unit); + val =3D vshPrettyCapacity(info->physical, &unit); + vshPrint(ctl, "%-15s %-.3lf %s\n", _("Physical:"), val, unit); + } + +} + static bool cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd) { @@ -420,21 +443,7 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd) =20 human =3D vshCommandOptBool(cmd, "human"); =20 - if (!human) { - vshPrint(ctl, "%-15s %llu\n", _("Capacity:"), info.capacity); - vshPrint(ctl, "%-15s %llu\n", _("Allocation:"), info.allocation); - vshPrint(ctl, "%-15s %llu\n", _("Physical:"), info.physical); - } else { - double val; - const char *unit; - - val =3D vshPrettyCapacity(info.capacity, &unit); - vshPrint(ctl, "%-15s %-.3lf %s\n", _("Capacity:"), val, unit); - val =3D vshPrettyCapacity(info.allocation, &unit); - vshPrint(ctl, "%-15s %-.3lf %s\n", _("Allocation:"), val, unit); - val =3D vshPrettyCapacity(info.physical, &unit); - vshPrint(ctl, "%-15s %-.3lf %s\n", _("Physical:"), val, unit); - } + cmdDomblkinfoPrint(ctl, &info, human); =20 ret =3D true; =20 --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 18:48:39 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; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=126.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15294025322418.70925100302702; Tue, 19 Jun 2018 03:02:12 -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 8CC7A369CD; Tue, 19 Jun 2018 10:02:10 +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 4EE3B608F3; Tue, 19 Jun 2018 10:02:10 +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 D30E41800539; Tue, 19 Jun 2018 10:02:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5JA1xUH016675 for ; Tue, 19 Jun 2018 06:01:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id 61544ABF1E; Tue, 19 Jun 2018 10:01:59 +0000 (UTC) Received: from mx1.redhat.com (ext-mx12.extmail.prod.ext.phx2.redhat.com [10.5.110.41]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 58401ABF11 for ; Tue, 19 Jun 2018 10:01:49 +0000 (UTC) Received: from m15-113.126.com (m15-113.126.com [220.181.15.113]) by mx1.redhat.com (Postfix) with ESMTP id 79DCB3175A3F for ; Tue, 19 Jun 2018 10:01:45 +0000 (UTC) Received: from localhost.localdomain (unknown [58.213.111.46]) by smtp3 (Coremail) with SMTP id DcmowACX_OV41Chb9lyYAw--.65231S4; Tue, 19 Jun 2018 18:01:43 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id; bh=e5Z988JiGqSo3AMTEI ZBmI/CM5w/qLELPY+WMdCRWLM=; b=dC7p2SCmEBE88C7C464rS36TC0Utf9ywEE znpLwwhvJXRnrd4lBU9dlqqqNGToosiyrFqSpCghmodDMnkuIEJYqrsgj81col7X d/VctYrfEpRCFtT/tgXXnaHLozGkpAy+6ZUaeY63L4lntByjGj+eFfGwTPXzSFqB 8gTX4ReC8= From: Chen Hanxiao To: libvir-list@redhat.com Date: Tue, 19 Jun 2018 18:01:24 +0800 Message-Id: <20180619100126.28086-3-chen_han_xiao@126.com> In-Reply-To: <20180619100126.28086-1-chen_han_xiao@126.com> References: <20180619100126.28086-1-chen_han_xiao@126.com> X-CM-TRANSID: DcmowACX_OV41Chb9lyYAw--.65231S4 X-Coremail-Antispam: 1Uf129KBjvJXoWxKryDtF4kWryrKw1xuryxAFb_yoWxtF15pF 4aqF9rZw1fXFn3Wrs3W34YgFn8KwnYkr1rKwnag340vF1DArsrWrn5Aa4rZa45ArW7JF15 uFsIqa4xGw18Aa7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jYwZcUUUUU= X-Originating-IP: [58.213.111.46] X-CM-SenderInfo: xfkh0spkdqs5xldrqiyswou0bp/1tbiaA1qrlpD57LsVwAAsW X-Greylist: Sender passed SPF test, ACL 227 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Tue, 19 Jun 2018 10:01:47 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Tue, 19 Jun 2018 10:01:47 +0000 (UTC) for IP:'220.181.15.113' DOMAIN:'m15-113.126.com' HELO:'m15-113.126.com' FROM:'chen_han_xiao@126.com' RCPT:'' X-RedHat-Spam-Score: 0.7 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_ANBREP_L2, SPF_PASS) 220.181.15.113 m15-113.126.com 220.181.15.113 m15-113.126.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.41 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-loop: libvir-list@redhat.com Cc: Chen Hanxiao Subject: [libvirt] [PATCH v3 2/4] cmdDomblkinfo: add --all to show all block devices info 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 19 Jun 2018 10:02:11 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Chen Hanxiao This patch introduces --all to show all block devices info of guests like: virsh # domblkinfo w08 --all Target Capacity Allocation Physical Reviewed-by: John Ferlan --------------------------------------------------- hda 42949672960 9878110208 9878110208 vda 10737418240 10736439296 10737418240 Target Capacity Allocation Physical --------------------------------------------------- hda 40.000 GiB 9.200 GiB 9.200 GiB vda 10.000 GiB 9.999 GiB 10.000 GiB Signed-off-by: Chen Hanxiao --- v3: check error code on network disk v2: add support --human to --all v1.1: fix self-test tools/virsh-domain-monitor.c | 128 +++++++++++++++++++++++++++++------ tools/virsh.pod | 5 +- 2 files changed, 112 insertions(+), 21 deletions(-) diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index daa86e8310..43e39f79c1 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -388,8 +388,7 @@ static const vshCmdInfo info_domblkinfo[] =3D { static const vshCmdOptDef opts_domblkinfo[] =3D { VIRSH_COMMON_OPT_DOMAIN_FULL(0), {.name =3D "device", - .type =3D VSH_OT_DATA, - .flags =3D VSH_OFLAG_REQ, + .type =3D VSH_OT_STRING, .completer =3D virshDomainDiskTargetCompleter, .help =3D N_("block device") }, @@ -397,30 +396,67 @@ static const vshCmdOptDef opts_domblkinfo[] =3D { .type =3D VSH_OT_BOOL, .help =3D N_("Human readable output") }, + {.name =3D "all", + .type =3D VSH_OT_BOOL, + .help =3D N_("display all block devices info") + }, {.name =3D NULL} }; =20 static void cmdDomblkinfoPrint(vshControl *ctl, const virDomainBlockInfo *info, - bool human) + const char *device, + bool human, bool title) { + char *cap =3D NULL, *alloc =3D NULL, *phy =3D NULL; + + if (title) { + vshPrintExtra(ctl, "%-10s %-15s %-15s %-15s\n", _("Target"), + _("Capacity"), _("Allocation"), _("Physical")); + vshPrintExtra(ctl, "-----------------------------" + "------------------------\n"); + return; + } + if (!human) { - vshPrint(ctl, "%-15s %llu\n", _("Capacity:"), info->capacity); - vshPrint(ctl, "%-15s %llu\n", _("Allocation:"), info->allocation); - vshPrint(ctl, "%-15s %llu\n", _("Physical:"), info->physical); + if (device) { + vshPrint(ctl, "%-10s %-15llu %-15llu %-15llu\n", device, + info->capacity, info->allocation, info->physical); + } else { + vshPrint(ctl, "%-15s %llu\n", _("Capacity:"), info->capacity); + vshPrint(ctl, "%-15s %llu\n", _("Allocation:"), info->allocati= on); + vshPrint(ctl, "%-15s %llu\n", _("Physical:"), info->physical); + } } else { - double val; - const char *unit; - - val =3D vshPrettyCapacity(info->capacity, &unit); - vshPrint(ctl, "%-15s %-.3lf %s\n", _("Capacity:"), val, unit); - val =3D vshPrettyCapacity(info->allocation, &unit); - vshPrint(ctl, "%-15s %-.3lf %s\n", _("Allocation:"), val, unit); - val =3D vshPrettyCapacity(info->physical, &unit); - vshPrint(ctl, "%-15s %-.3lf %s\n", _("Physical:"), val, unit); + double val_cap, val_alloc, val_phy; + const char *unit_cap, *unit_alloc, *unit_phy; + + val_cap =3D vshPrettyCapacity(info->capacity, &unit_cap); + val_alloc =3D vshPrettyCapacity(info->allocation, &unit_alloc); + val_phy =3D vshPrettyCapacity(info->physical, &unit_phy); + if (device) { + if (virAsprintf(&cap, "%.3lf %s", val_cap, unit_cap) < 0 || + virAsprintf(&alloc, "%.3lf %s", val_alloc, unit_alloc) < 0= || + virAsprintf(&phy, "%.3lf %s", val_phy, unit_phy) < 0) + goto cleanup; + + vshPrint(ctl, "%-10s %-15s %-15s %-15s\n", + device, cap, alloc, phy); + } else { + vshPrint(ctl, "%-15s %-.3lf %s\n", _("Capacity:"), + val_cap, unit_cap); + vshPrint(ctl, "%-15s %-.3lf %s\n", _("Allocation:"), + val_alloc, unit_alloc); + vshPrint(ctl, "%-15s %-.3lf %s\n", _("Physical:"), + val_phy, unit_phy); + } } =20 + cleanup: + VIR_FREE(cap); + VIR_FREE(alloc); + VIR_FREE(phy); } =20 static bool @@ -430,25 +466,77 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd) virDomainPtr dom; bool ret =3D false; bool human =3D false; + bool all =3D false; const char *device =3D NULL; + xmlDocPtr xmldoc =3D NULL; + xmlXPathContextPtr ctxt =3D NULL; + int ndisks; + size_t i; + xmlNodePtr *disks =3D NULL; + char *target =3D NULL; + char *protocol =3D NULL; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 - if (vshCommandOptStringReq(ctl, cmd, "device", &device) < 0) - goto cleanup; - - if (virDomainGetBlockInfo(dom, device, &info, 0) < 0) + all =3D vshCommandOptBool(cmd, "all"); + if (!all && vshCommandOptStringQuiet(ctl, cmd, "device", &device) <=3D= 0) { + vshError(ctl, "command 'domblkinfo' requires option"); goto cleanup; + } =20 human =3D vshCommandOptBool(cmd, "human"); =20 - cmdDomblkinfoPrint(ctl, &info, human); + if (all) { + bool active =3D virDomainIsActive(dom) =3D=3D 1; + int rc; + + if (virshDomainGetXML(ctl, cmd, 0, &xmldoc, &ctxt) < 0) + goto cleanup; + + ndisks =3D virXPathNodeSet("./devices/disk", ctxt, &disks); + if (ndisks < 0) + goto cleanup; + + /* print the title */ + cmdDomblkinfoPrint(ctl, NULL, NULL, false, true); + + for (i =3D 0; i < ndisks; i++) { + ctxt->node =3D disks[i]; + protocol =3D virXPathString("string(./source/@protocol)", ctxt= ); + target =3D virXPathString("string(./target/@dev)", ctxt); + + rc =3D virDomainGetBlockInfo(dom, target, &info, 0); + + if (rc < 0) { + if (protocol && !active && + virGetLastErrorCode() =3D=3D VIR_ERR_INTERNAL_ERROR && + virGetLastErrorDomain() =3D=3D VIR_FROM_STORAGE) + memset(&info, 0, sizeof(info)); + else + goto cleanup; + } + + cmdDomblkinfoPrint(ctl, &info, target, human, false); + + VIR_FREE(target); + } + } else { + if (virDomainGetBlockInfo(dom, device, &info, 0) < 0) + goto cleanup; + + cmdDomblkinfoPrint(ctl, &info, NULL, human, false); + } =20 ret =3D true; =20 cleanup: virshDomainFree(dom); + VIR_FREE(target); + VIR_FREE(protocol); + VIR_FREE(disks); + xmlXPathFreeContext(ctxt); + xmlFreeDoc(xmldoc); return ret; } =20 diff --git a/tools/virsh.pod b/tools/virsh.pod index 3f3314a87e..e273011037 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -949,13 +949,16 @@ B command says that a domain was paused due= to I/O error. The B command lists all block devices in error state and the error seen on each of them. =20 -=3Ditem B I I [I<--human>] +=3Ditem B I [I I<--all>] [I<--human>] =20 Get block device size info for a domain. A I corresponds to a unique target name () or source file () for one of the disk devices attached to I (see also B for listing these names). If I<--human> is set, the output will have a human readable output. +If I<--all> is set, the output will be a table showing all block devices +size info associated with I. +The I<--all> option takes precedence of the others. =20 =3Ditem B I [I<--inactive>] [I<--details>] =20 --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 18:48:39 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; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=126.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1529402533143121.42285022394265; Tue, 19 Jun 2018 03:02:13 -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 CA2B8C049D5B; Tue, 19 Jun 2018 10:02:11 +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 7EF9C600C6; Tue, 19 Jun 2018 10:02:11 +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 237E81800537; Tue, 19 Jun 2018 10:02:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5JA1w8o016665 for ; Tue, 19 Jun 2018 06:01:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id B9F8660E37; Tue, 19 Jun 2018 10:01:58 +0000 (UTC) Received: from mx1.redhat.com (ext-mx11.extmail.prod.ext.phx2.redhat.com [10.5.110.40]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A652A60BEC for ; Tue, 19 Jun 2018 10:01:49 +0000 (UTC) Received: from m15-113.126.com (m15-113.126.com [220.181.15.113]) by mx1.redhat.com (Postfix) with ESMTP id 768AA3084029 for ; Tue, 19 Jun 2018 10:01:45 +0000 (UTC) Received: from localhost.localdomain (unknown [58.213.111.46]) by smtp3 (Coremail) with SMTP id DcmowACX_OV41Chb9lyYAw--.65231S5; Tue, 19 Jun 2018 18:01:43 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id; bh=i/R4G/sxo0C+YoPaPi Lm2lySoQhnVVqZSZ6SWqw/SZE=; b=bwyOk3l/O8rKgRI/5rJuQ6M2Hyc1F0VjvQ qeLDAxPFFxubREiVtJDmmjbf/a49eVqbn9BxVfXe2QbcHHpDmnI+39Ni27mqtQWU 1IqCzANlDfeON1dsnDw3GIALBgQH9sF5J+ed0HscDOUT5/DF8i627N4qhdOxluG/ 0YBWLdh4c= From: Chen Hanxiao To: libvir-list@redhat.com Date: Tue, 19 Jun 2018 18:01:25 +0800 Message-Id: <20180619100126.28086-4-chen_han_xiao@126.com> In-Reply-To: <20180619100126.28086-1-chen_han_xiao@126.com> References: <20180619100126.28086-1-chen_han_xiao@126.com> X-CM-TRANSID: DcmowACX_OV41Chb9lyYAw--.65231S5 X-Coremail-Antispam: 1Uf129KBjvJXoWxJF17Cr47Jw4xWr13Kr4rXwb_yoWrGFWDpa n8Xryvvwn3GFnxZrsI934DKFn8K34Ivr1FqFs2g34rArsrurs7WrnIvFyY9Fy5Ar4YyF1U CrnxJ3WxWw10y37anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UXTmgUUUUU= X-Originating-IP: [58.213.111.46] X-CM-SenderInfo: xfkh0spkdqs5xldrqiyswou0bp/1tbitQhqrlpD58-i1AAAs+ X-Greylist: Sender passed SPF test, ACL 227 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Tue, 19 Jun 2018 10:01:47 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Tue, 19 Jun 2018 10:01:47 +0000 (UTC) for IP:'220.181.15.113' DOMAIN:'m15-113.126.com' HELO:'m15-113.126.com' FROM:'chen_han_xiao@126.com' RCPT:'' X-RedHat-Spam-Score: 0.7 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_ANBREP_L2, SPF_PASS) 220.181.15.113 m15-113.126.com 220.181.15.113 m15-113.126.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.40 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Chen Hanxiao Subject: [libvirt] [PATCH v3 3/4] cmdDomblkinfoPrint: support printing "-" for invalid virDomainBlockInfo 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 19 Jun 2018 10:02:12 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Chen Hanxiao For inactive domain, we'll set virDomainBlockInfo to 0 if specific error code got. Print "-" to show the value should be ignored in this scenario. Signed-off-by: Chen Hanxiao --- tools/virsh-domain-monitor.c | 73 ++++++++++++++++++++++++------------ 1 file changed, 49 insertions(+), 24 deletions(-) diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index 43e39f79c1..3acf5450b3 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -410,6 +410,15 @@ cmdDomblkinfoPrint(vshControl *ctl, bool human, bool title) { char *cap =3D NULL, *alloc =3D NULL, *phy =3D NULL; + bool invalid =3D false; + + struct blockInfoText { + char *capacity; + char *allocation; + char *physical; + }; + + struct blockInfoText *blkInfoText =3D NULL; =20 if (title) { vshPrintExtra(ctl, "%-10s %-15s %-15s %-15s\n", _("Target"), @@ -419,15 +428,23 @@ cmdDomblkinfoPrint(vshControl *ctl, return; } =20 - if (!human) { - if (device) { - vshPrint(ctl, "%-10s %-15llu %-15llu %-15llu\n", device, - info->capacity, info->allocation, info->physical); - } else { - vshPrint(ctl, "%-15s %llu\n", _("Capacity:"), info->capacity); - vshPrint(ctl, "%-15s %llu\n", _("Allocation:"), info->allocati= on); - vshPrint(ctl, "%-15s %llu\n", _("Physical:"), info->physical); - } + invalid =3D info->capacity =3D=3D 0 && + info->allocation =3D=3D 0 && + info->physical =3D=3D 0; + blkInfoText =3D vshCalloc(ctl, 1, sizeof(*blkInfoText)); + + if (invalid) { + blkInfoText->capacity =3D vshStrdup(ctl, "-"); + blkInfoText->allocation =3D vshStrdup(ctl, "-"); + blkInfoText->physical =3D vshStrdup(ctl, "-"); + } else if (!human) { + if (virAsprintf(&blkInfoText->capacity, "%llu", + info->capacity) < 0 || + virAsprintf(&blkInfoText->allocation, "%llu", + info->allocation) < 0 || + virAsprintf(&blkInfoText->physical, "%llu", + info->physical) < 0) + goto cleanup; } else { double val_cap, val_alloc, val_phy; const char *unit_cap, *unit_alloc, *unit_phy; @@ -435,28 +452,36 @@ cmdDomblkinfoPrint(vshControl *ctl, val_cap =3D vshPrettyCapacity(info->capacity, &unit_cap); val_alloc =3D vshPrettyCapacity(info->allocation, &unit_alloc); val_phy =3D vshPrettyCapacity(info->physical, &unit_phy); - if (device) { - if (virAsprintf(&cap, "%.3lf %s", val_cap, unit_cap) < 0 || - virAsprintf(&alloc, "%.3lf %s", val_alloc, unit_alloc) < 0= || - virAsprintf(&phy, "%.3lf %s", val_phy, unit_phy) < 0) - goto cleanup; =20 - vshPrint(ctl, "%-10s %-15s %-15s %-15s\n", - device, cap, alloc, phy); - } else { - vshPrint(ctl, "%-15s %-.3lf %s\n", _("Capacity:"), - val_cap, unit_cap); - vshPrint(ctl, "%-15s %-.3lf %s\n", _("Allocation:"), - val_alloc, unit_alloc); - vshPrint(ctl, "%-15s %-.3lf %s\n", _("Physical:"), - val_phy, unit_phy); - } + if (virAsprintf(&blkInfoText->capacity, "%.3lf %s", + val_cap, unit_cap) < 0 || + virAsprintf(&blkInfoText->allocation, "%.3lf %s", + val_alloc, unit_alloc) < 0 || + virAsprintf(&blkInfoText->physical, "%.3lf %s", + val_phy, unit_phy) < 0) + goto cleanup; + } + + if (device) { + vshPrint(ctl, "%-10s %-15s %-15s %-15s\n", device, + blkInfoText->capacity, blkInfoText->allocation, + blkInfoText->physical); + } else { + vshPrint(ctl, "%-15s %s\n", _("Capacity:"), blkInfoText->capacity); + vshPrint(ctl, "%-15s %s\n", _("Allocation:"), blkInfoText->allocat= ion); + vshPrint(ctl, "%-15s %s\n", _("Physical:"), blkInfoText->physical); } =20 cleanup: VIR_FREE(cap); VIR_FREE(alloc); VIR_FREE(phy); + if (blkInfoText) { + VIR_FREE(blkInfoText->capacity); + VIR_FREE(blkInfoText->allocation); + VIR_FREE(blkInfoText->physical); + } + VIR_FREE(blkInfoText); } =20 static bool --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 18:48:39 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; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=126.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1529402524257866.9652521974075; Tue, 19 Jun 2018 03:02:04 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A5D90307C94B; Tue, 19 Jun 2018 10:02:02 +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 66FC630012A7; Tue, 19 Jun 2018 10:02:02 +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 AA7754A46C; Tue, 19 Jun 2018 10:02:01 +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 w5JA1w1c016666 for ; Tue, 19 Jun 2018 06:01:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id C2050600C6; Tue, 19 Jun 2018 10:01:58 +0000 (UTC) Received: from mx1.redhat.com (ext-mx13.extmail.prod.ext.phx2.redhat.com [10.5.110.42]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B8497600C0 for ; Tue, 19 Jun 2018 10:01:49 +0000 (UTC) Received: from m15-113.126.com (m15-113.126.com [220.181.15.113]) by mx1.redhat.com (Postfix) with ESMTP id 7632E308213D for ; Tue, 19 Jun 2018 10:01:46 +0000 (UTC) Received: from localhost.localdomain (unknown [58.213.111.46]) by smtp3 (Coremail) with SMTP id DcmowACX_OV41Chb9lyYAw--.65231S6; Tue, 19 Jun 2018 18:01:43 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id; bh=9Rl3ZQ0xTLVMIzrcS9 smXBDUQnl1lG8GcO1lhs2sDAM=; b=kO4OB84//1eAzQGMG46Tak00+9cwM771KY bUI0YkORTJ1YP3k+SZmCGaY7O6QLV/opGN0FN/beebuRrwNVgnVd+mJ4k1Hp9u92 ZDmloquWPYa6Y2TVUx9rVLmnzYJ0XqL2smx7s11y2xdlhiSZBTTl0euDWq40uCsk vKoCq9hKM= From: Chen Hanxiao To: libvir-list@redhat.com Date: Tue, 19 Jun 2018 18:01:26 +0800 Message-Id: <20180619100126.28086-5-chen_han_xiao@126.com> In-Reply-To: <20180619100126.28086-1-chen_han_xiao@126.com> References: <20180619100126.28086-1-chen_han_xiao@126.com> X-CM-TRANSID: DcmowACX_OV41Chb9lyYAw--.65231S6 X-Coremail-Antispam: 1Uf129KBjvdXoWrZF48ZF4xCw18JFy7GFyDKFg_yoW3twc_Jw 1Iqa48XrWrXFnayFWFqF4rurWUuw48Jw1UKrn0gryYqw4DtwsYyF92qrsYqry7ZFWIyFy3 Zwn3G3WkCrsrtjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU1wSdJUUUUU== X-Originating-IP: [58.213.111.46] X-CM-SenderInfo: xfkh0spkdqs5xldrqiyswou0bp/1tbikQdqrlpD57wnDAAAs7 X-Greylist: Sender passed SPF test, ACL 227 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Tue, 19 Jun 2018 10:01:48 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Tue, 19 Jun 2018 10:01:48 +0000 (UTC) for IP:'220.181.15.113' DOMAIN:'m15-113.126.com' HELO:'m15-113.126.com' FROM:'chen_han_xiao@126.com' RCPT:'' X-RedHat-Spam-Score: 0.7 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_ANBREP_L2, SPF_PASS) 220.181.15.113 m15-113.126.com 220.181.15.113 m15-113.126.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.42 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Chen Hanxiao Subject: [libvirt] [PATCH v3 4/4] news: add cmdDomblkinfo --all option 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.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Tue, 19 Jun 2018 10:02:03 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Chen Hanxiao Update news for cmdDomblkinfo --all option. Signed-off-by: Chen Hanxiao Reviewed-by: John Ferlan --- v3: update descriptions docs/news.xml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/news.xml b/docs/news.xml index 08e5dcbda3..9bf7442047 100644 --- a/docs/news.xml +++ b/docs/news.xml @@ -204,6 +204,16 @@ secret-event, pool-event and nodedev-event) + + + virsh: Add --all to domblkinfo command + + + Alter the domblkinfo command to add the option + --all in order to display the size details of each domain + block device from one command in a output table. + +
--=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list