From nobody Sat Feb 7 07:09:54 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496140754652285.91191292491067; Tue, 30 May 2017 03:39:14 -0700 (PDT) Received: from localhost ([::1]:52801 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dFeYT-0007mv-6X for importer@patchew.org; Tue, 30 May 2017 06:39:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59015) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dFeWI-0005q8-Nl for qemu-devel@nongnu.org; Tue, 30 May 2017 06:37:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dFeWH-0001RY-Sb for qemu-devel@nongnu.org; Tue, 30 May 2017 06:36:58 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:31337 helo=relay.sw.ru) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dFeWH-0001Qt-Hg for qemu-devel@nongnu.org; Tue, 30 May 2017 06:36:57 -0400 Received: from kvm.sw.ru (msk-vpn.virtuozzo.com [195.214.232.6]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id v4UAafHd020183; Tue, 30 May 2017 13:36:43 +0300 (MSK) From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Tue, 30 May 2017 13:36:41 +0300 Message-Id: <20170530103641.68891-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.11.1 In-Reply-To: <20170530103641.68891-1-vsementsov@virtuozzo.com> References: <20170530103641.68891-1-vsementsov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: OpenBSD 3.x [fuzzy] X-Received-From: 195.214.232.25 Subject: [Qemu-devel] [PATCH 4/4] qemu-img check: improve dump_human_format_alloc_info X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, armbru@redhat.com, mreitz@redhat.com, den@openvz.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Improve dump_human_format_alloc_info() by specifying format names. Signed-off-by: Vladimir Sementsov-Ogievskiy --- qemu-img.c | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index 55f8c1776c..3c03690a4f 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -560,7 +560,8 @@ static void dump_json_image_check(ImageCheck *check, bo= ol quiet) QDECREF(str); } =20 -static void dump_human_format_alloc_info(BlockFormatAllocInfo *bfai, bool = quiet) +static void dump_human_format_alloc_info(BlockDriverState *bs, + BlockFormatAllocInfo *bfai, bool = quiet) { char *alloc_alloc =3D size_to_str(bfai->alloc_alloc); char *alloc_hole =3D size_to_str(bfai->alloc_hole); @@ -568,13 +569,28 @@ static void dump_human_format_alloc_info(BlockFormatA= llocInfo *bfai, bool quiet) char *hole_alloc =3D size_to_str(bfai->hole_alloc); char *hole_hole =3D size_to_str(bfai->hole_hole); =20 + const char *format =3D bdrv_get_format_name(bs); + const char *f_format =3D + bs->file ? bdrv_get_format_name(bs->file->bs) : "file"; + int format_len, cw; + + if (format =3D=3D NULL) { + format =3D "format"; + } + if (f_format =3D=3D NULL) { + f_format =3D "file"; + } + format_len =3D strlen(format); + cw =3D MAX(10, strlen(f_format) + 6); + qprintf(quiet, "Format allocation info (including metadata):\n" - " file-alloc file-hole after-eof\n" - "format-alloc %10s %10s %10s\n" - "format-hole %10s %10s\n", - alloc_alloc, alloc_hole, alloc_overhead, - hole_alloc, hole_hole); + "%*s %*s-alloc %*s-hole %*s\n" + "%s-alloc %*s %*s %*s\n" + "%s-hole %*s %*s\n", + format_len, "", cw - 6, f_format, cw - 5, f_format, cw, "after= -eof", + format, cw, alloc_alloc, cw, alloc_hole, cw, alloc_overhead, + format, cw, hole_alloc, cw, hole_hole); =20 g_free(alloc_alloc); g_free(alloc_hole); @@ -583,7 +599,8 @@ static void dump_human_format_alloc_info(BlockFormatAll= ocInfo *bfai, bool quiet) g_free(hole_hole); } =20 -static void dump_human_image_check(ImageCheck *check, bool quiet) +static void dump_human_image_check(BlockDriverState *bs, ImageCheck *check, + bool quiet) { if (!(check->corruptions || check->leaks || check->check_errors)) { qprintf(quiet, "No errors were found on the image.\n"); @@ -626,7 +643,7 @@ static void dump_human_image_check(ImageCheck *check, b= ool quiet) } =20 if (check->has_format_alloc_info) { - dump_human_format_alloc_info(check->format_alloc_info, quiet); + dump_human_format_alloc_info(bs, check->format_alloc_info, quiet); } } =20 @@ -840,7 +857,7 @@ static int img_check(int argc, char **argv) if (!ret) { switch (output_format) { case OFORMAT_HUMAN: - dump_human_image_check(check, quiet); + dump_human_image_check(bs, check, quiet); break; case OFORMAT_JSON: dump_json_image_check(check, quiet); --=20 2.11.1