From nobody Wed May 1 03:17:14 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 1528302438008880.3769813114798; Wed, 6 Jun 2018 09:27:18 -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 EF94B81119; Wed, 6 Jun 2018 16:27:15 +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 924313001A6C; Wed, 6 Jun 2018 16:27:15 +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 B9CC91800FD8; Wed, 6 Jun 2018 16:27:14 +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 w56GQjti002035 for ; Wed, 6 Jun 2018 12:26:45 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2A63860476; Wed, 6 Jun 2018 16:26:45 +0000 (UTC) Received: from mx1.redhat.com (ext-mx15.extmail.prod.ext.phx2.redhat.com [10.5.110.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 23A7F60474 for ; Wed, 6 Jun 2018 16:26:40 +0000 (UTC) Received: from m50-111.126.com (m50-111.126.com [123.125.50.111]) by mx1.redhat.com (Postfix) with ESMTP id 29AE530832C2 for ; Wed, 6 Jun 2018 16:26:34 +0000 (UTC) Received: from localhost.localdomain (unknown [112.80.212.133]) by smtp5 (Coremail) with SMTP id jtKowACHRvu2ChhbtzcfAA--.88S3; Thu, 07 Jun 2018 00:26:31 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id; bh=fPzujEioE5lhmJewm6 sub4o0YdBk6kpXAuMOFvbTUZs=; b=dwWRrRYEwLXmsqQvMqGR5UyAmrag14oR1M fOHV6B4KHz5d+sGKWpifrThoUrTyUoOC0mpiUEpibnv+33ZSonl4WQKftXxP/RKX LGSHvBd1IpVd2mOqt+p3WIUEQAsBRybSEMuMYliUS01Ac6gS4tgW6wi92zgVFcQg PC0r7Rkac= From: Chen Hanxiao To: libvir-list@redhat.com Date: Thu, 7 Jun 2018 00:22:19 +0800 Message-Id: <20180606162220.17689-2-chen_han_xiao@126.com> In-Reply-To: <20180606162220.17689-1-chen_han_xiao@126.com> References: <20180606162220.17689-1-chen_han_xiao@126.com> X-CM-TRANSID: jtKowACHRvu2ChhbtzcfAA--.88S3 X-Coremail-Antispam: 1Uf129KBjvJXoW3Jr47KF4DWF1xuF4fXw4kXrb_yoW7Aw15pF 4SqF9rZw1fXFnxWrs3Zw1FgF1DKw1kCr18Kwsag340kFsrAws7Wrn3Ja4rZa4kXrW7JF4Y 9F9Iqa4xG3WxAFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zRKXdbUUUUU= X-Originating-IP: [112.80.212.133] X-CM-SenderInfo: xfkh0spkdqs5xldrqiyswou0bp/1tbikhddrlpD5LY0VAAAsd X-Greylist: Sender passed SPF test, ACL 227 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Wed, 06 Jun 2018 16:26:39 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Wed, 06 Jun 2018 16:26:39 +0000 (UTC) for IP:'123.125.50.111' DOMAIN:'m50-111.126.com' HELO:'m50-111.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) 123.125.50.111 m50-111.126.com 123.125.50.111 m50-111.126.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.44 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Chen Hanxiao Subject: [libvirt] [PATCH 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.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.28]); Wed, 06 Jun 2018 16:27:16 +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 --- tools/virsh-domain-monitor.c | 82 +++++++++++++++++++++++++++--------- tools/virsh.pod | 5 ++- 2 files changed, 67 insertions(+), 20 deletions(-) diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index 39cb2ce7f0..6a2dd72b45 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -390,7 +390,6 @@ 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, .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.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 03:17:14 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 1528302428612447.48586018570654; Wed, 6 Jun 2018 09:27:08 -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 F01195D68D; Wed, 6 Jun 2018 16:27:05 +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 7A8A65D728; Wed, 6 Jun 2018 16:27:05 +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 A8FFE4A469; Wed, 6 Jun 2018 16:27:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w56GQgME002017 for ; Wed, 6 Jun 2018 12:26:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9983A3001A6C; Wed, 6 Jun 2018 16:26:42 +0000 (UTC) Received: from mx1.redhat.com (ext-mx05.extmail.prod.ext.phx2.redhat.com [10.5.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 933AA3001A72 for ; Wed, 6 Jun 2018 16:26:42 +0000 (UTC) Received: from m50-111.126.com (m50-111.126.com [123.125.50.111]) by mx1.redhat.com (Postfix) with ESMTP id 1FF3523E6E4 for ; Wed, 6 Jun 2018 16:26:38 +0000 (UTC) Received: from localhost.localdomain (unknown [112.80.212.133]) by smtp5 (Coremail) with SMTP id jtKowACHRvu2ChhbtzcfAA--.88S4; Thu, 07 Jun 2018 00:26:32 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id; bh=z2JEAfcAO28yYK/xsh oWC4BxvOWT0k36VCLp/hmvJ3A=; b=fGeNgo07VbYWeV4G4zfTvMuV0Kdv+km6rs CeesgYKGhx1Yvp1sdJhYJR9S7/04ukJjXHnXRYzc9wosxcayEIxrbscoB1k/fmuX aBCdcV7vrcT2MOmpvwm1U67N6PfL9W/yS+FAZvCsIBXfTED7ew1Sh2U3rapKAe7S X+5ah6bfU= From: Chen Hanxiao To: libvir-list@redhat.com Date: Thu, 7 Jun 2018 00:22:20 +0800 Message-Id: <20180606162220.17689-3-chen_han_xiao@126.com> In-Reply-To: <20180606162220.17689-1-chen_han_xiao@126.com> References: <20180606162220.17689-1-chen_han_xiao@126.com> X-CM-TRANSID: jtKowACHRvu2ChhbtzcfAA--.88S4 X-Coremail-Antispam: 1Uf129KBjvdXoWrZF48ZFy7JFyDJFWkKF18Grg_yoWxKFc_J3 WIqa48XrW5XFnay3y0qF48ury8uw48Gr1jkasIgrWYyw4DJwsYkasFqrZ8tr17XFW2kFy3 CFnxta18JFs7tjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7xRRSoGPUUUUU== X-Originating-IP: [112.80.212.133] X-CM-SenderInfo: xfkh0spkdqs5xldrqiyswou0bp/1tbi6xhdrlpD5rzwcQAAsC X-Greylist: Sender passed SPF test, ACL 227 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 06 Jun 2018 16:26:41 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 06 Jun 2018 16:26:41 +0000 (UTC) for IP:'123.125.50.111' DOMAIN:'m50-111.126.com' HELO:'m50-111.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) 123.125.50.111 m50-111.126.com 123.125.50.111 m50-111.126.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.29 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-loop: libvir-list@redhat.com Cc: Chen Hanxiao Subject: [libvirt] [PATCH 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.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.39]); Wed, 06 Jun 2018 16:27:07 +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.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list