From nobody Sun May 5 12:46:20 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 1528345374795799.7054493657881; Wed, 6 Jun 2018 21:22:54 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DB5073086244; Thu, 7 Jun 2018 04:22:53 +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 A07A460BEC; Thu, 7 Jun 2018 04:22:53 +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 5EA994CA80; Thu, 7 Jun 2018 04:22:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w574Mdhr013192 for ; Thu, 7 Jun 2018 00:22:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id A9AE8608F3; Thu, 7 Jun 2018 04:22:39 +0000 (UTC) Received: from mx1.redhat.com (ext-mx17.extmail.prod.ext.phx2.redhat.com [10.5.110.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9B9CC608F2 for ; Thu, 7 Jun 2018 04:22:33 +0000 (UTC) Received: from m15-113.126.com (m15-113.126.com [220.181.15.113]) by mx1.redhat.com (Postfix) with ESMTP id 994D130C10EE for ; Thu, 7 Jun 2018 04:22:30 +0000 (UTC) Received: from localhost.localdomain (unknown [58.213.111.46]) by smtp3 (Coremail) with SMTP id DcmowAB37OX7shhblJ8zAA--.20974S3; Thu, 07 Jun 2018 12:22:28 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id; bh=dbhw3JkdWSUdTu2J81 Yj7b5eryLax8nKzx6WZhe65Ig=; b=CG4Cjxsz4zvI9aJSc2r1kDbMpdN132EvdT kCHB4ATSYMB2MmHmAaPL+z1MOH4pAAiNvK6LAIoudb4o6YkvwQfYKC9KteV+sNlu HptCwZF1zPNLrODTLeSViny0O+zIkh1/gji4BEjr3bPpStOgZcmYzb9JogQAQvL4 uU7ndclAA= From: Chen Hanxiao To: libvir-list@redhat.com Date: Thu, 7 Jun 2018 12:19:18 +0800 Message-Id: <20180607041919.13577-2-chen_han_xiao@126.com> In-Reply-To: <20180607041919.13577-1-chen_han_xiao@126.com> References: <20180607041919.13577-1-chen_han_xiao@126.com> X-CM-TRANSID: DcmowAB37OX7shhblJ8zAA--.20974S3 X-Coremail-Antispam: 1Uf129KBjvJXoW3Gr4UZFy8tr4rCryrtFWDArb_yoW7CFy8pF 4SqF9rZw1fXFnxWrn3Zw1FgFn8Kwn5Cr18Kwsag340kF1DAws7Wrn3J34rZa4kXrW7JF4Y 9FnIqa4xC3WxAFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UJkuxUUUUU= X-Originating-IP: [58.213.111.46] X-CM-SenderInfo: xfkh0spkdqs5xldrqiyswou0bp/1tbiFgRerlpD5yyOtwAAsJ X-Greylist: Sender passed SPF test, ACL 227 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Thu, 07 Jun 2018 04:22:32 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Thu, 07 Jun 2018 04:22:32 +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.1 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, 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.46 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Chen Hanxiao Subject: [libvirt] [PATCH v1.1 1/2] cmdDomblkinfo: introduce --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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Thu, 07 Jun 2018 04:22:54 +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 --------------------------------------------------- hda 42949672960 9878110208 9878110208 vda 10737418240 10736439296 10737418240 Signed-off-by: Chen Hanxiao --- v1.1: fix self-test tools/virsh-domain-monitor.c | 84 +++++++++++++++++++++++++++--------- tools/virsh.pod | 5 ++- 2 files changed, 68 insertions(+), 21 deletions(-) diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index 39cb2ce7f0..fe31838e30 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -389,8 +389,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") }, @@ -398,6 +397,10 @@ 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 @@ -408,38 +411,79 @@ 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; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 - if (vshCommandOptStringReq(ctl, cmd, "device", &device) < 0) + all =3D vshCommandOptBool(cmd, "all"); + if (!all && vshCommandOptStringQuiet(ctl, cmd, "device", &device) <=3D= 0) { + vshError(ctl, "command 'domblkinfo' requires option"); goto cleanup; + } =20 - if (virDomainGetBlockInfo(dom, device, &info, 0) < 0) - goto cleanup; + if (all) { + if (virshDomainGetXML(ctl, cmd, 0, &xmldoc, &ctxt) < 0) + goto cleanup; =20 - human =3D vshCommandOptBool(cmd, "human"); + ndisks =3D virXPathNodeSet("./devices/disk", ctxt, &disks); + if (ndisks < 0) + goto cleanup; =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); + vshPrintExtra(ctl, "%-10s %-15s %-15s %-15s\n", _("Target"), + _("Capacity"), _("Allocation"), _("Physical")); + vshPrintExtra(ctl, "-----------------------------" + "----------------------\n"); + + for (i =3D 0; i < ndisks; i++) { + ctxt->node =3D disks[i]; + target =3D virXPathString("string(./target/@dev)", ctxt); + + if (virDomainGetBlockInfo(dom, target, &info, 0) < 0) + goto cleanup; + + vshPrint(ctl, "%-10s %-15llu %-15llu %-15llu\n", target, + info.capacity, info.allocation, info.physical); + + VIR_FREE(target); + } + } else if (device) { + if (virDomainGetBlockInfo(dom, device, &info, 0) < 0) + goto cleanup; + + human =3D vshCommandOptBool(cmd, "human"); + + if (!human) { + vshPrint(ctl, "%-15s %llu\n", _("Capacity:"), info.capacity); + vshPrint(ctl, "%-15s %llu\n", _("Allocation:"), info.allocatio= n); + 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); + } } =20 ret =3D true; =20 cleanup: + VIR_FREE(target); + VIR_FREE(disks); + xmlXPathFreeContext(ctxt); + xmlFreeDoc(xmldoc); virshDomainFree(dom); return ret; } diff --git a/tools/virsh.pod b/tools/virsh.pod index 3f3314a87e..584defa201 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<--human>] } [I<--all>] =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 Sun May 5 12:46:20 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 1528345369807300.82343459316814; Wed, 6 Jun 2018 21:22:49 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 35D5F81101; Thu, 7 Jun 2018 04:22:48 +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 F1EF310694CE; Thu, 7 Jun 2018 04:22:47 +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 6A49C4CA82; Thu, 7 Jun 2018 04:22:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w574MaE2013174 for ; Thu, 7 Jun 2018 00:22:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id A001E608F3; Thu, 7 Jun 2018 04:22:36 +0000 (UTC) Received: from mx1.redhat.com (ext-mx20.extmail.prod.ext.phx2.redhat.com [10.5.110.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 93691608F2 for ; Thu, 7 Jun 2018 04:22:34 +0000 (UTC) Received: from m15-113.126.com (m15-113.126.com [220.181.15.113]) by mx1.redhat.com (Postfix) with ESMTP id A50BA3086243 for ; Thu, 7 Jun 2018 04:22:30 +0000 (UTC) Received: from localhost.localdomain (unknown [58.213.111.46]) by smtp3 (Coremail) with SMTP id DcmowAB37OX7shhblJ8zAA--.20974S4; Thu, 07 Jun 2018 12:22:28 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id; bh=TIekxFqlNMpfKGn+Cv rM0pJjbnFJIZTbugQuC0ymK/Q=; b=Da2aBZL2OZQzF2ivq+CJzjdCfNklGVI8Na nKnkSmuYmTkQa7zBfFWuMF8LaTl1FnQrlpNTWNmo+bH5pawxfY8gsSN4LpS9braY 30mU1iSdsMIxG+eLfVxHzJQwOfpGpp7NRU6UhwrwALHks6xcuxk7SQzQkXraxLEW URKWdWPpQ= From: Chen Hanxiao To: libvir-list@redhat.com Date: Thu, 7 Jun 2018 12:19:19 +0800 Message-Id: <20180607041919.13577-3-chen_han_xiao@126.com> In-Reply-To: <20180607041919.13577-1-chen_han_xiao@126.com> References: <20180607041919.13577-1-chen_han_xiao@126.com> X-CM-TRANSID: DcmowAB37OX7shhblJ8zAA--.20974S4 X-Coremail-Antispam: 1Uf129KBjvdXoWrZF48ZFy7JFyDJFWkKF18Grg_yoWxKFc_J3 WIqa48XrW5XFnay3y0qF48ury8uw48Gr1jkasIgrW5tw4DJwsYkasFqrZ8tr17XFW2kFy3 CFnxta18JFs7tjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUbE4i5UUUUU== X-Originating-IP: [58.213.111.46] X-CM-SenderInfo: xfkh0spkdqs5xldrqiyswou0bp/1tbi6wRerlpD5sMSvAAAsN X-Greylist: Sender passed SPF test, ACL 227 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Thu, 07 Jun 2018 04:22:32 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Thu, 07 Jun 2018 04:22:32 +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.1 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, 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.49 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Chen Hanxiao Subject: [libvirt] [PATCH v1.1 2/2] 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.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 07 Jun 2018 04:22:48 +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 --- docs/news.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/news.xml b/docs/news.xml index c45850f625..daee3aa6b7 100644 --- a/docs/news.xml +++ b/docs/news.xml @@ -123,6 +123,14 @@ secret-event, pool-event and nodedev-event) + + + cmdDomblkinfo: introduce --all to show all block devices info + + + Add option --all to show all block deviecs info in one command. + +
--=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list