From nobody Wed May 14 07:22:50 2025 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