From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C5A46C433F5 for ; Mon, 27 Dec 2021 15:56:56 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.252010.433023 (Exim 4.92) (envelope-from ) id 1n1sMY-00014e-TA; Mon, 27 Dec 2021 15:56:38 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 252010.433023; Mon, 27 Dec 2021 15:56:38 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n1sMY-00014U-PX; Mon, 27 Dec 2021 15:56:38 +0000 Received: by outflank-mailman (input) for mailman id 252010; Mon, 27 Dec 2021 15:56:37 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n1sMX-0007zI-Ea for xen-devel@lists.xenproject.org; Mon, 27 Dec 2021 15:56:37 +0000 Received: from mailhost.m5p.com (mailhost.m5p.com [74.104.188.4]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 9163f135-672d-11ec-9e60-abaf8a552007; Mon, 27 Dec 2021 16:56:36 +0100 (CET) Received: from m5p.com (mailhost.m5p.com [IPv6:2001:470:1f07:15ff:0:0:0:f7]) by mailhost.m5p.com (8.16.1/8.15.2) with ESMTPS id 1BRFuO2j054498 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Mon, 27 Dec 2021 10:56:32 -0500 (EST) (envelope-from ehem@m5p.com) Received: (from ehem@localhost) by m5p.com (8.16.1/8.15.2/Submit) id 1BRFuOhH054497; Mon, 27 Dec 2021 07:56:24 -0800 (PST) (envelope-from ehem) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 9163f135-672d-11ec-9e60-abaf8a552007 Message-Id: In-Reply-To: References: From: Elliott Mitchell To: xen-devel@lists.xenproject.org Cc: Wei Liu Cc: Anthony PERARD Date: Thu, 17 Dec 2020 17:42:42 -0800 Subject: [PATCH 3/5] tools/xl: Rename printf_info()/list_domains_details() to dump_by_...() printf_info()/list_domains_details() had been serving fairly similar purposes. Increase their consistency (add file-handle and output_format arguments to list_domains_details(), reorder arguments) and then rename to better reflect their functionality. Both were simply outputting full domain information. As this is more of a dump operation, "dump" is a better name. Signed-off-by: Elliott Mitchell --- tools/xl/xl.h | 8 ++++++++ tools/xl/xl_info.c | 30 ++++++++++++++++-------------- tools/xl/xl_misc.c | 5 +---- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/tools/xl/xl.h b/tools/xl/xl.h index 720adb0048..be5f4e11fe 100644 --- a/tools/xl/xl.h +++ b/tools/xl/xl.h @@ -300,6 +300,14 @@ typedef enum { DOMAIN_RESTART_SOFT_RESET, /* Soft reset should be performed */ } domain_restart_type; +extern void dump_by_config(enum output_format output_format, + FILE *fh, + const libxl_domain_config *d_config, + int domid); +extern void dump_by_dominfo_list(enum output_format output_format, + FILE *fh, + const libxl_dominfo info[], + int nb_domain); extern void printf_info_sexp(int domid, const libxl_domain_config *d_config, FILE *fh); extern void apply_global_affinity_masks(libxl_domain_type type, libxl_bitmap *vcpu_affinity_array, diff --git a/tools/xl/xl_info.c b/tools/xl/xl_info.c index 23d82ce2a2..3647468420 100644 --- a/tools/xl/xl_info.c +++ b/tools/xl/xl_info.c @@ -94,12 +94,10 @@ out: return s; } -void printf_info(enum output_format output_format, - int domid, - libxl_domain_config *d_config, FILE *fh); -void printf_info(enum output_format output_format, - int domid, - libxl_domain_config *d_config, FILE *fh) +void dump_by_config(enum output_format output_format, + FILE *fh, + const libxl_domain_config *const d_config, + int domid) { if (output_format == OUTPUT_FORMAT_SXP) return printf_info_sexp(domid, d_config, fh); @@ -442,7 +440,10 @@ static void list_domains(bool verbose, bool context, bool claim, bool numa, libxl_physinfo_dispose(&physinfo); } -static void list_domains_details(const libxl_dominfo *info, int nb_domain) +void dump_by_dominfo_list(enum output_format output_format, + FILE *fh, + const libxl_dominfo info[], + int nb_domain) { libxl_domain_config d_config; @@ -453,7 +454,7 @@ static void list_domains_details(const libxl_dominfo *info, int nb_domain) const char *buf; libxl_yajl_length yajl_len = 0; - if (default_output_format == OUTPUT_FORMAT_JSON) { + if (output_format == OUTPUT_FORMAT_JSON) { hand = libxl_yajl_gen_alloc(NULL); if (!hand) { fprintf(stderr, "unable to allocate JSON generator\n"); @@ -472,16 +473,16 @@ static void list_domains_details(const libxl_dominfo *info, int nb_domain) &d_config, NULL); if (rc) continue; - if (default_output_format == OUTPUT_FORMAT_JSON) + if (output_format == OUTPUT_FORMAT_JSON) s = printf_info_one_json(hand, info[i].domid, &d_config); else - printf_info_sexp(info[i].domid, &d_config, stdout); + printf_info_sexp(info[i].domid, &d_config, fh); libxl_domain_config_dispose(&d_config); if (s != yajl_gen_status_ok) goto out; } - if (default_output_format == OUTPUT_FORMAT_JSON) { + if (output_format == OUTPUT_FORMAT_JSON) { s = yajl_gen_array_close(hand); if (s != yajl_gen_status_ok) goto out; @@ -490,11 +491,12 @@ static void list_domains_details(const libxl_dominfo *info, int nb_domain) if (s != yajl_gen_status_ok) goto out; - puts(buf); + fputs(buf, fh); + fputc('\n', fh); } out: - if (default_output_format == OUTPUT_FORMAT_JSON) { + if (output_format == OUTPUT_FORMAT_JSON) { yajl_gen_free(hand); if (s != yajl_gen_status_ok) fprintf(stderr, @@ -571,7 +573,7 @@ int main_list(int argc, char **argv) } if (details) - list_domains_details(info, nb_domain); + dump_by_dominfo_list(default_output_format, stdout, info, nb_domain); else list_domains(verbose, context, false /* claim */, numa, cpupool, info, nb_domain); diff --git a/tools/xl/xl_misc.c b/tools/xl/xl_misc.c index 08f0fb6dc9..bcf178762b 100644 --- a/tools/xl/xl_misc.c +++ b/tools/xl/xl_misc.c @@ -256,9 +256,6 @@ int main_dump_core(int argc, char **argv) return EXIT_SUCCESS; } -extern void printf_info(enum output_format output_format, - int domid, - libxl_domain_config *d_config, FILE *fh); int main_config_update(int argc, char **argv) { uint32_t domid; @@ -344,7 +341,7 @@ int main_config_update(int argc, char **argv) parse_config_data(filename, config_data, config_len, &d_config); if (debug || dryrun_only) - printf_info(default_output_format, -1, &d_config, stdout); + dump_by_config(default_output_format, stdout, &d_config, -1); if (!dryrun_only) { fprintf(stderr, "setting dom%u configuration\n", domid); -- 2.30.2