From nobody Wed May 15 19:42:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1689785526417943.921932679666; Wed, 19 Jul 2023 09:52:06 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.566001.884668 (Exim 4.92) (envelope-from ) id 1qMAOv-0001VA-7a; Wed, 19 Jul 2023 16:51:45 +0000 Received: by outflank-mailman (output) from mailman id 566001.884668; Wed, 19 Jul 2023 16:51:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qMAOv-0001V3-3q; Wed, 19 Jul 2023 16:51:45 +0000 Received: by outflank-mailman (input) for mailman id 566001; Wed, 19 Jul 2023 16:51:44 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qMAOu-0001Uv-1b for xen-devel@lists.xenproject.org; Wed, 19 Jul 2023 16:51:44 +0000 Received: from mailhost.m5p.com (mailhost.m5p.com [74.104.188.4]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 889ccc0f-2654-11ee-8611-37d641c3527e; Wed, 19 Jul 2023 18:51:41 +0200 (CEST) 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 36JGpFdc034017 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 19 Jul 2023 12:51:21 -0400 (EDT) (envelope-from ehem@m5p.com) Received: (from ehem@localhost) by m5p.com (8.16.1/8.15.2/Submit) id 36JGpFiH034016; Wed, 19 Jul 2023 09:51:15 -0700 (PDT) (envelope-from ehem) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 889ccc0f-2654-11ee-8611-37d641c3527e Message-Id: <8561fa647a637e78b67a5a9f01f6d93d6a1de2cd.1689779749.git.ehem+xen@m5p.com> In-Reply-To: References: From: Elliott Mitchell To: xen-devel@lists.xenproject.org Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross Date: Mon, 10 Jul 2023 15:55:30 -0700 Subject: [PATCH 1/7] tools/utils: cleanup formatting of libxlutil.h X-Spam-Status: No, score=2.5 required=10.0 tests=DATE_IN_PAST_96_XX, KHOP_HELO_FCRDNS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mattapan.m5p.com X-ZM-MESSAGEID: 1689785528629100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Some arguments included a name, but not all did. Now use "cfg" for all uses of XLU_Config * and "list" for uses of XLU_ConfigList *. Also fix some spaces missing from xlu_cfg_get_defbool()'s prototype. Rename the "b" argument of xlu_cfg_get_defbool() to "value_r". Similar to other functions this is where the returned value is stored. Signed-off-by: Elliott Mitchell --- tools/include/libxlutil.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tools/include/libxlutil.h b/tools/include/libxlutil.h index 4dd3c5e92b..fcbe41b15a 100644 --- a/tools/include/libxlutil.h +++ b/tools/include/libxlutil.h @@ -40,12 +40,12 @@ XLU_Config *xlu_cfg_init(FILE *report, const char *repo= rt_filename); /* report_filename is copied; report is saved and must remain valid * until the Config is destroyed. */ =20 -int xlu_cfg_readfile(XLU_Config*, const char *real_filename); -int xlu_cfg_readdata(XLU_Config*, const char *data, int length); +int xlu_cfg_readfile(XLU_Config *cfg, const char *real_filename); +int xlu_cfg_readdata(XLU_Config *cfg, const char *data, int length); /* If these fail, then it is undefined behaviour to call xlu_cfg_get_... * functions. You have to just xlu_cfg_destroy. */ =20 -void xlu_cfg_destroy(XLU_Config*); +void xlu_cfg_destroy(XLU_Config *cfg); =20 =20 /* All of the following print warnings to "report" if there is a problem. @@ -56,26 +56,26 @@ void xlu_cfg_destroy(XLU_Config*); * ERANGE value out of range (from strtol) */ =20 -int xlu_cfg_get_string(const XLU_Config*, const char *n, const char **valu= e_r, - int dont_warn); +int xlu_cfg_get_string(const XLU_Config *cfg, const char *n, + const char **value_r, int dont_warn); /* free/strdup version */ int xlu_cfg_replace_string(const XLU_Config *cfg, const char *n, char **value_r, int dont_warn); -int xlu_cfg_get_long(const XLU_Config*, const char *n, long *value_r, +int xlu_cfg_get_long(const XLU_Config *cfg, const char *n, long *value_r, int dont_warn); -int xlu_cfg_get_bounded_long(const XLU_Config*, const char *n, long min, +int xlu_cfg_get_bounded_long(const XLU_Config *cfg, const char *n, long mi= n, long max, long *value_r, int dont_warn); -int xlu_cfg_get_defbool(const XLU_Config*, const char *n, libxl_defbool *b, - int dont_warn); +int xlu_cfg_get_defbool(const XLU_Config *cfg, const char *n, + libxl_defbool *value_r, int dont_warn); =20 -int xlu_cfg_get_list(const XLU_Config*, const char *n, +int xlu_cfg_get_list(const XLU_Config *cfg, const char *n, XLU_ConfigList **list_r /* may be 0 */, int *entries_r /* may be 0 */, int dont_warn); /* there is no need to free *list_r; lifetime is that of the XLU_Config = */ int xlu_cfg_get_list_as_string_list(const XLU_Config *cfg, const char *n, libxl_string_list *sl, int dont_warn); -const char *xlu_cfg_get_listitem(const XLU_ConfigList*, int entry); +const char *xlu_cfg_get_listitem(const XLU_ConfigList *list, int entry); /* xlu_cfg_get_listitem cannot fail, except that if entry is * out of range it returns 0 (not setting errno) */ =20 --=20 2.30.2 From nobody Wed May 15 19:42:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1689785556478435.93220837533477; Wed, 19 Jul 2023 09:52:36 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.566017.884678 (Exim 4.92) (envelope-from ) id 1qMAPT-000211-H8; Wed, 19 Jul 2023 16:52:19 +0000 Received: by outflank-mailman (output) from mailman id 566017.884678; Wed, 19 Jul 2023 16:52:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qMAPT-00020t-Ds; Wed, 19 Jul 2023 16:52:19 +0000 Received: by outflank-mailman (input) for mailman id 566017; Wed, 19 Jul 2023 16:52:18 +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 1qMAPS-0001nm-5n for xen-devel@lists.xenproject.org; Wed, 19 Jul 2023 16:52:18 +0000 Received: from mailhost.m5p.com (mailhost.m5p.com [74.104.188.4]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 9db68d44-2654-11ee-b23a-6b7b168915f2; Wed, 19 Jul 2023 18:52:16 +0200 (CEST) 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 36JGq7Lk034023 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 19 Jul 2023 12:52:13 -0400 (EDT) (envelope-from ehem@m5p.com) Received: (from ehem@localhost) by m5p.com (8.16.1/8.15.2/Submit) id 36JGq7Tc034022; Wed, 19 Jul 2023 09:52:07 -0700 (PDT) (envelope-from ehem) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 9db68d44-2654-11ee-b23a-6b7b168915f2 Message-Id: <075a60a09c7f99e2d51e5cc4d63aa892dcb75f82.1689779749.git.ehem+xen@m5p.com> In-Reply-To: References: From: Elliott Mitchell To: xen-devel@lists.xenproject.org Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross Date: Wed, 12 Jul 2023 23:29:59 -0700 Subject: [PATCH 2/7] tools/utils: rename "n" arguments to "key" X-Spam-Status: No, score=2.5 required=10.0 tests=DATE_IN_PAST_96_XX, KHOP_HELO_FCRDNS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mattapan.m5p.com X-ZM-MESSAGEID: 1689785556792100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Hopefully make it clearer to others this is the key associated with the storage value to retrieve. Signed-off-by: Elliott Mitchell --- tools/include/libxlutil.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/include/libxlutil.h b/tools/include/libxlutil.h index fcbe41b15a..0ce66c2096 100644 --- a/tools/include/libxlutil.h +++ b/tools/include/libxlutil.h @@ -56,24 +56,24 @@ void xlu_cfg_destroy(XLU_Config *cfg); * ERANGE value out of range (from strtol) */ =20 -int xlu_cfg_get_string(const XLU_Config *cfg, const char *n, +int xlu_cfg_get_string(const XLU_Config *cfg, const char *key, const char **value_r, int dont_warn); /* free/strdup version */ -int xlu_cfg_replace_string(const XLU_Config *cfg, const char *n, +int xlu_cfg_replace_string(const XLU_Config *cfg, const char *key, char **value_r, int dont_warn); -int xlu_cfg_get_long(const XLU_Config *cfg, const char *n, long *value_r, +int xlu_cfg_get_long(const XLU_Config *cfg, const char *key, long *value_r, int dont_warn); -int xlu_cfg_get_bounded_long(const XLU_Config *cfg, const char *n, long mi= n, +int xlu_cfg_get_bounded_long(const XLU_Config *cfg, const char *key, long = min, long max, long *value_r, int dont_warn); -int xlu_cfg_get_defbool(const XLU_Config *cfg, const char *n, +int xlu_cfg_get_defbool(const XLU_Config *cfg, const char *key, libxl_defbool *value_r, int dont_warn); =20 -int xlu_cfg_get_list(const XLU_Config *cfg, const char *n, +int xlu_cfg_get_list(const XLU_Config *cfg, const char *key, XLU_ConfigList **list_r /* may be 0 */, int *entries_r /* may be 0 */, int dont_warn); /* there is no need to free *list_r; lifetime is that of the XLU_Config = */ -int xlu_cfg_get_list_as_string_list(const XLU_Config *cfg, const char *n, +int xlu_cfg_get_list_as_string_list(const XLU_Config *cfg, const char *key, libxl_string_list *sl, int dont_warn); const char *xlu_cfg_get_listitem(const XLU_ConfigList *list, int entry); /* xlu_cfg_get_listitem cannot fail, except that if entry is --=20 2.30.2 From nobody Wed May 15 19:42:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1689785856394826.9999073453191; Wed, 19 Jul 2023 09:57:36 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.566078.884709 (Exim 4.92) (envelope-from ) id 1qMAUL-0003ym-Jq; Wed, 19 Jul 2023 16:57:21 +0000 Received: by outflank-mailman (output) from mailman id 566078.884709; Wed, 19 Jul 2023 16:57:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qMAUL-0003yf-Du; Wed, 19 Jul 2023 16:57:21 +0000 Received: by outflank-mailman (input) for mailman id 566078; Wed, 19 Jul 2023 16:57:19 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qMAQT-0001Uv-5W for xen-devel@lists.xenproject.org; Wed, 19 Jul 2023 16:53:21 +0000 Received: from mailhost.m5p.com (mailhost.m5p.com [74.104.188.4]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id c2feaa43-2654-11ee-8611-37d641c3527e; Wed, 19 Jul 2023 18:53:19 +0200 (CEST) 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 36JGqxYS034041 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 19 Jul 2023 12:53:05 -0400 (EDT) (envelope-from ehem@m5p.com) Received: (from ehem@localhost) by m5p.com (8.16.1/8.15.2/Submit) id 36JGqxCQ034040; Wed, 19 Jul 2023 09:52:59 -0700 (PDT) (envelope-from ehem) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: c2feaa43-2654-11ee-8611-37d641c3527e Message-Id: <6f482f3d54989e4ccce1b651db750c2e789a8886.1689779749.git.ehem+xen@m5p.com> In-Reply-To: References: From: Elliott Mitchell To: xen-devel@lists.xenproject.org Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross Date: Sun, 9 Jul 2023 16:06:30 -0700 Subject: [PATCH 3/7] tools/utils: move XLU_Operation to libxlu_cfg_i.h.h X-Spam-Status: No, score=2.5 required=10.0 tests=DATE_IN_PAST_96_XX, KHOP_HELO_FCRDNS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mattapan.m5p.com X-ZM-MESSAGEID: 1689785856965100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This enumerated value is never used outside of the lowest layer of the configuration parser. As such, move to the internal header. Fixes: a30910bfd7 ("libxlu: Handle +=3D in config files") Signed-off-by: Elliott Mitchell --- I'm unsure whether this is fixing a30910bfd7. Placing XLU_Operation in libxlutil.h was certainly erroneous, but it is quite unlikely to directly result in actual bugs. --- tools/include/libxlutil.h | 5 ----- tools/libs/util/libxlu_cfg_i.h | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/include/libxlutil.h b/tools/include/libxlutil.h index 0ce66c2096..de57ca4200 100644 --- a/tools/include/libxlutil.h +++ b/tools/include/libxlutil.h @@ -25,11 +25,6 @@ enum XLU_ConfigValueType { XLU_LIST, }; =20 -enum XLU_Operation { - XLU_OP_ASSIGNMENT =3D 0, - XLU_OP_ADDITION, -}; - /* Unless otherwise stated, all functions return an errno value. */ typedef struct XLU_Config XLU_Config; typedef struct XLU_ConfigList XLU_ConfigList; diff --git a/tools/libs/util/libxlu_cfg_i.h b/tools/libs/util/libxlu_cfg_i.h index 4217f5b28d..3d1e4ed568 100644 --- a/tools/libs/util/libxlu_cfg_i.h +++ b/tools/libs/util/libxlu_cfg_i.h @@ -21,6 +21,11 @@ #include "libxlu_internal.h" #include "libxlu_cfg_y.h" =20 +enum XLU_Operation { + XLU_OP_ASSIGNMENT =3D 0, + XLU_OP_ADDITION, +}; + void xlu__cfg_set_free(XLU_ConfigSetting *set); void xlu__cfg_set_store(CfgParseContext*, char *name, enum XLU_Operation op, --=20 2.30.2 From nobody Wed May 15 19:42:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1689785861801390.11134685725165; Wed, 19 Jul 2023 09:57:41 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.566085.884718 (Exim 4.92) (envelope-from ) id 1qMAUM-0004H9-PH; Wed, 19 Jul 2023 16:57:22 +0000 Received: by outflank-mailman (output) from mailman id 566085.884718; Wed, 19 Jul 2023 16:57:22 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qMAUM-0004Gc-Ky; Wed, 19 Jul 2023 16:57:22 +0000 Received: by outflank-mailman (input) for mailman id 566085; Wed, 19 Jul 2023 16:57:21 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qMAR9-0001Uv-8S for xen-devel@lists.xenproject.org; Wed, 19 Jul 2023 16:54:03 +0000 Received: from mailhost.m5p.com (mailhost.m5p.com [74.104.188.4]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id dc0ad879-2654-11ee-8611-37d641c3527e; Wed, 19 Jul 2023 18:54:01 +0200 (CEST) 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 36JGrquc034047 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 19 Jul 2023 12:53:57 -0400 (EDT) (envelope-from ehem@m5p.com) Received: (from ehem@localhost) by m5p.com (8.16.1/8.15.2/Submit) id 36JGrqGx034046; Wed, 19 Jul 2023 09:53:52 -0700 (PDT) (envelope-from ehem) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: dc0ad879-2654-11ee-8611-37d641c3527e Message-Id: In-Reply-To: References: From: Elliott Mitchell To: xen-devel@lists.xenproject.org Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross Date: Thu, 13 Jul 2023 19:01:19 -0700 Subject: [PATCH 4/7] tools/utils: introduce xlu_cfg_printf() function X-Spam-Status: No, score=2.5 required=10.0 tests=DATE_IN_PAST_96_XX, KHOP_HELO_FCRDNS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mattapan.m5p.com X-ZM-MESSAGEID: 1689785863318100003 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Isolate the lower layer configuration handling from the upper layer. Now only the lowest layer of configuration handling looks inside XLU_Config. Also make error messages a bit more consistent. Now PCI device parsing will report filename. Signed-off-by: Elliott Mitchell --- Someone else can decide where xlu__disk_err() should have its linebreaks and indentation. That string isn't very good. I'm wondering about the return codes. *printf() can return errors, but so many places are ignoring them. If the output is a console the errors are fairly unlikely, but full storage does happen. --- tools/libs/util/libxlu_cfg.c | 25 +++++++++++++++++++++++++ tools/libs/util/libxlu_disk.c | 14 +++++--------- tools/libs/util/libxlu_internal.h | 9 +++------ tools/libs/util/libxlu_pci.c | 3 +-- tools/libs/util/libxlu_vif.c | 4 +--- 5 files changed, 35 insertions(+), 20 deletions(-) diff --git a/tools/libs/util/libxlu_cfg.c b/tools/libs/util/libxlu_cfg.c index 874f5abfb9..b2947cbfc9 100644 --- a/tools/libs/util/libxlu_cfg.c +++ b/tools/libs/util/libxlu_cfg.c @@ -18,12 +18,19 @@ #define _GNU_SOURCE =20 #include +#include =20 #include "libxlu_internal.h" #include "libxlu_cfg_y.h" #include "libxlu_cfg_l.h" #include "libxlu_cfg_i.h" =20 +struct XLU_Config { + XLU_ConfigSetting *settings; + FILE *report; + char *config_source; +}; + XLU_Config *xlu_cfg_init(FILE *report, const char *report_source) { XLU_Config *cfg; =20 @@ -703,6 +710,24 @@ void xlu__cfg_yyerror(YYLTYPE *loc, CfgParseContext *c= tx, char const *msg) { if (!ctx->err) ctx->err=3D EINVAL; } =20 +int xlu_cfg_printf(XLU_Config *cfg, const char *format, ...) +{ + va_list args; + int ret; + + if (!cfg || !cfg->report) + return EFAULT; + + fwrite(cfg->config_source, 1, strlen(cfg->config_source), cfg->report); + fwrite(": ", 2, 1, cfg->report); + + va_start(args, format); + ret =3D vfprintf(cfg->report, format, args); + va_end(args); + + return ret; +} + /* * Local variables: * mode: C diff --git a/tools/libs/util/libxlu_disk.c b/tools/libs/util/libxlu_disk.c index 1de16a6a06..a4d08ab7e9 100644 --- a/tools/libs/util/libxlu_disk.c +++ b/tools/libs/util/libxlu_disk.c @@ -5,13 +5,10 @@ =20 void xlu__disk_err(DiskParseContext *dpc, const char *erroneous, const char *message) { - fprintf(dpc->cfg->report, - "%s: config parsing error in disk specification: %s" - "%s%s%s" - " in `%s'\n", - dpc->cfg->config_source, message, - erroneous?": near `":"", erroneous?erroneous:"", erroneous?"'"= :"", - dpc->spec); + xlu_cfg_printf(dpc->cfg, + "config parsing error in disk specification: %s%s%s%s in `%s'\= n", + message, erroneous?": near `":"", erroneous?erroneous:"", + erroneous?"'":"", dpc->spec); if (!dpc->err) dpc->err=3D EINVAL; } =20 @@ -29,8 +26,7 @@ static int dpc_prep(DiskParseContext *dpc, const char *sp= ec) { return 0; =20 fail: - fprintf(dpc->cfg->report, "cannot init disk scanner: %s\n", - strerror(errno)); + xlu_cfg_printf(dpc->cfg, "cannot init disk scanner: %s\n", strerror(er= rno)); return e; } =20 diff --git a/tools/libs/util/libxlu_internal.h b/tools/libs/util/libxlu_int= ernal.h index 1f7559ecd9..2ef5eb7f5e 100644 --- a/tools/libs/util/libxlu_internal.h +++ b/tools/libs/util/libxlu_internal.h @@ -57,12 +57,6 @@ typedef struct XLU_ConfigSetting { /* transparent */ int lineno; } XLU_ConfigSetting; =20 -struct XLU_Config { - XLU_ConfigSetting *settings; - FILE *report; - char *config_source; -}; - typedef struct { XLU_Config *cfg; int err, lexerrlineno, likely_python; @@ -73,6 +67,9 @@ typedef struct { #define STRINGIFY(x) #x #define TOSTRING(x) STRINGIFY(x) =20 +extern int xlu_cfg_printf(XLU_Config *cfg, const char *format, ...) + __attribute__((__format__ (__printf__, 2, 3))); + #endif /*LIBXLU_INTERNAL_H*/ =20 /* diff --git a/tools/libs/util/libxlu_pci.c b/tools/libs/util/libxlu_pci.c index 294482c6d7..d6abbc1c1f 100644 --- a/tools/libs/util/libxlu_pci.c +++ b/tools/libs/util/libxlu_pci.c @@ -5,8 +5,7 @@ #include "libxlu_internal.h" =20 =20 -#define XLU__PCI_ERR(_c, _x, _a...) \ - if((_c) && (_c)->report) fprintf((_c)->report, _x, ##_a) +#define XLU__PCI_ERR(_c, _x, _a...) xlu_cfg_printf((_c), _x, ##_a) =20 static int parse_bdf(libxl_device_pci *pci, const char *str, const char **= endp) { diff --git a/tools/libs/util/libxlu_vif.c b/tools/libs/util/libxlu_vif.c index ccf0cbdf57..93c449e213 100644 --- a/tools/libs/util/libxlu_vif.c +++ b/tools/libs/util/libxlu_vif.c @@ -6,9 +6,7 @@ static const char *vif_bytes_per_sec_re =3D "^[0-9]+[GMK]?[= Bb]/s$"; static const char *vif_internal_usec_re =3D "^[0-9]+[mu]?s?$"; =20 static void xlu__vif_err(XLU_Config *cfg, const char *msg, const char *rat= e) { - fprintf(cfg->report, - "%s: config parsing error in vif: %s in `%s'\n", - cfg->config_source, msg, rate); + xlu_cfg_printf(cfg, "config parsing error in vif: %s in `%s'\n", msg, = rate); } =20 static int vif_parse_rate_bytes_per_sec(XLU_Config *cfg, const char *bytes, --=20 2.30.2 From nobody Wed May 15 19:42:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1689785729370843.50116172407; Wed, 19 Jul 2023 09:55:29 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.566042.884687 (Exim 4.92) (envelope-from ) id 1qMAS1-0002hr-UX; Wed, 19 Jul 2023 16:54:57 +0000 Received: by outflank-mailman (output) from mailman id 566042.884687; Wed, 19 Jul 2023 16:54:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qMAS1-0002hR-RH; Wed, 19 Jul 2023 16:54:57 +0000 Received: by outflank-mailman (input) for mailman id 566042; Wed, 19 Jul 2023 16:54:57 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qMAS1-0002h2-Be for xen-devel@lists.xenproject.org; Wed, 19 Jul 2023 16:54:57 +0000 Received: from mailhost.m5p.com (mailhost.m5p.com [74.104.188.4]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id fc26784e-2654-11ee-8611-37d641c3527e; Wed, 19 Jul 2023 18:54:55 +0200 (CEST) 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 36JGsiRV034053 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 19 Jul 2023 12:54:50 -0400 (EDT) (envelope-from ehem@m5p.com) Received: (from ehem@localhost) by m5p.com (8.16.1/8.15.2/Submit) id 36JGsig4034052; Wed, 19 Jul 2023 09:54:44 -0700 (PDT) (envelope-from ehem) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: fc26784e-2654-11ee-8611-37d641c3527e Message-Id: In-Reply-To: References: From: Elliott Mitchell To: xen-devel@lists.xenproject.org Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross Date: Tue, 18 Jul 2023 16:31:34 -0700 Subject: [PATCH 5/7] tools/utils: move XLU_ConfigSetting & xlu__cfg_set_free() to libxl_cfg.c X-Spam-Status: No, score=1.2 required=10.0 tests=DATE_IN_PAST_12_24, KHOP_HELO_FCRDNS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mattapan.m5p.com X-ZM-MESSAGEID: 1689785730474100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" XLU_ConfigSetting is only used inside libxl_cfg.c, so no need for it in the internal header. Similarly, xlu__cfg_set_free() is no longer used outside libxl_cfg.c, so remove from header and redeclare static. Signed-off-by: Elliott Mitchell --- tools/libs/util/libxlu_cfg.c | 10 +++++++++- tools/libs/util/libxlu_cfg_i.h | 1 - tools/libs/util/libxlu_internal.h | 8 -------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/tools/libs/util/libxlu_cfg.c b/tools/libs/util/libxlu_cfg.c index b2947cbfc9..2979d775a6 100644 --- a/tools/libs/util/libxlu_cfg.c +++ b/tools/libs/util/libxlu_cfg.c @@ -25,6 +25,14 @@ #include "libxlu_cfg_l.h" #include "libxlu_cfg_i.h" =20 +typedef struct XLU_ConfigSetting { /* transparent */ + struct XLU_ConfigSetting *next; + char *name; + XLU_ConfigValue *value; + enum XLU_Operation op; + int lineno; +} XLU_ConfigSetting; + struct XLU_Config { XLU_ConfigSetting *settings; FILE *report; @@ -155,7 +163,7 @@ void xlu__cfg_value_free(XLU_ConfigValue *value) free(value); } =20 -void xlu__cfg_set_free(XLU_ConfigSetting *set) { +static void xlu__cfg_set_free(XLU_ConfigSetting *set) { if (!set) return; free(set->name); xlu__cfg_value_free(set->value); diff --git a/tools/libs/util/libxlu_cfg_i.h b/tools/libs/util/libxlu_cfg_i.h index 3d1e4ed568..7193867422 100644 --- a/tools/libs/util/libxlu_cfg_i.h +++ b/tools/libs/util/libxlu_cfg_i.h @@ -26,7 +26,6 @@ enum XLU_Operation { XLU_OP_ADDITION, }; =20 -void xlu__cfg_set_free(XLU_ConfigSetting *set); void xlu__cfg_set_store(CfgParseContext*, char *name, enum XLU_Operation op, XLU_ConfigValue *val, int lineno); diff --git a/tools/libs/util/libxlu_internal.h b/tools/libs/util/libxlu_int= ernal.h index 2ef5eb7f5e..97303391c6 100644 --- a/tools/libs/util/libxlu_internal.h +++ b/tools/libs/util/libxlu_internal.h @@ -49,14 +49,6 @@ struct XLU_ConfigValue { YYLTYPE loc; }; =20 -typedef struct XLU_ConfigSetting { /* transparent */ - struct XLU_ConfigSetting *next; - char *name; - XLU_ConfigValue *value; - enum XLU_Operation op; - int lineno; -} XLU_ConfigSetting; - typedef struct { XLU_Config *cfg; int err, lexerrlineno, likely_python; --=20 2.30.2 From nobody Wed May 15 19:42:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1689785775724173.4862093049544; Wed, 19 Jul 2023 09:56:15 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.566056.884697 (Exim 4.92) (envelope-from ) id 1qMASq-0003Fd-6M; Wed, 19 Jul 2023 16:55:48 +0000 Received: by outflank-mailman (output) from mailman id 566056.884697; Wed, 19 Jul 2023 16:55:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qMASq-0003FW-3b; Wed, 19 Jul 2023 16:55:48 +0000 Received: by outflank-mailman (input) for mailman id 566056; Wed, 19 Jul 2023 16:55:46 +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 1qMASo-00037w-F6 for xen-devel@lists.xenproject.org; Wed, 19 Jul 2023 16:55:46 +0000 Received: from mailhost.m5p.com (mailhost.m5p.com [74.104.188.4]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 1a4a14f1-2655-11ee-b23a-6b7b168915f2; Wed, 19 Jul 2023 18:55:45 +0200 (CEST) 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 36JGtauS034072 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 19 Jul 2023 12:55:42 -0400 (EDT) (envelope-from ehem@m5p.com) Received: (from ehem@localhost) by m5p.com (8.16.1/8.15.2/Submit) id 36JGtaU7034071; Wed, 19 Jul 2023 09:55:36 -0700 (PDT) (envelope-from ehem) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 1a4a14f1-2655-11ee-b23a-6b7b168915f2 Message-Id: <4b72ad7c94e325f21849037cfe96eeb0723fa138.1689779749.git.ehem+xen@m5p.com> In-Reply-To: References: From: Elliott Mitchell To: xen-devel@lists.xenproject.org Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross Date: Tue, 18 Jul 2023 22:02:48 -0700 Subject: [PATCH 6/7] tools/utils: remove libxlu_cfg_i.h from libxlu_disk.c X-Spam-Status: No, score=1.5 required=10.0 tests=DATE_IN_PAST_06_12, KHOP_HELO_FCRDNS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mattapan.m5p.com X-ZM-MESSAGEID: 1689785778207100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The upper layer disk string parser doesn't need the internals of the lower layer file parser. Split the layers apart. This is viable due to the lower-layer internals having been removed from libxlu_internals.h. Signed-off-by: Elliott Mitchell --- tools/libs/util/libxlu_disk.c | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/libs/util/libxlu_disk.c b/tools/libs/util/libxlu_disk.c index a4d08ab7e9..92da9bd3b1 100644 --- a/tools/libs/util/libxlu_disk.c +++ b/tools/libs/util/libxlu_disk.c @@ -1,7 +1,6 @@ #include "libxlu_internal.h" #include "libxlu_disk_l.h" #include "libxlu_disk_i.h" -#include "libxlu_cfg_i.h" =20 void xlu__disk_err(DiskParseContext *dpc, const char *erroneous, const char *message) { --=20 2.30.2 From nobody Wed May 15 19:42:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1689785860943896.4921643900062; Wed, 19 Jul 2023 09:57:40 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.566092.884728 (Exim 4.92) (envelope-from ) id 1qMAUO-0004Xx-11; Wed, 19 Jul 2023 16:57:24 +0000 Received: by outflank-mailman (output) from mailman id 566092.884728; Wed, 19 Jul 2023 16:57:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qMAUN-0004Xk-TA; Wed, 19 Jul 2023 16:57:23 +0000 Received: by outflank-mailman (input) for mailman id 566092; Wed, 19 Jul 2023 16:57:22 +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 1qMATe-00037w-B5 for xen-devel@lists.xenproject.org; Wed, 19 Jul 2023 16:56:38 +0000 Received: from mailhost.m5p.com (mailhost.m5p.com [74.104.188.4]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 392a26b5-2655-11ee-b23a-6b7b168915f2; Wed, 19 Jul 2023 18:56:37 +0200 (CEST) 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 36JGuSsM034084 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 19 Jul 2023 12:56:34 -0400 (EDT) (envelope-from ehem@m5p.com) Received: (from ehem@localhost) by m5p.com (8.16.1/8.15.2/Submit) id 36JGuSMU034083; Wed, 19 Jul 2023 09:56:28 -0700 (PDT) (envelope-from ehem) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 392a26b5-2655-11ee-b23a-6b7b168915f2 Message-Id: <56c1d2d7360945f5507817585c8303ad46072aee.1689779749.git.ehem+xen@m5p.com> In-Reply-To: References: From: Elliott Mitchell To: xen-devel@lists.xenproject.org Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross Date: Tue, 18 Jul 2023 23:07:20 -0700 Subject: [PATCH 7/7] tools/utils: move remaining lower-layer data from libxlu_internal.h X-Spam-Status: No, score=1.5 required=10.0 tests=DATE_IN_PAST_06_12, KHOP_HELO_FCRDNS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mattapan.m5p.com X-ZM-MESSAGEID: 1689785862918100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Correcting the order of #includes and data type declarations allows the remaining lower-layer structures to move to libxlu_cfg_i.h. Now libxlu_internal.h is purely generalized routines meant to be shared between all layers. Signed-off-by: Elliott Mitchell --- tools/libs/util/libxlu_cfg.c | 2 +- tools/libs/util/libxlu_cfg_i.h | 31 +++++++++++++++++++++++++++++++ tools/libs/util/libxlu_internal.h | 30 ------------------------------ 3 files changed, 32 insertions(+), 31 deletions(-) diff --git a/tools/libs/util/libxlu_cfg.c b/tools/libs/util/libxlu_cfg.c index 2979d775a6..2913c99478 100644 --- a/tools/libs/util/libxlu_cfg.c +++ b/tools/libs/util/libxlu_cfg.c @@ -21,9 +21,9 @@ #include =20 #include "libxlu_internal.h" +#include "libxlu_cfg_i.h" #include "libxlu_cfg_y.h" #include "libxlu_cfg_l.h" -#include "libxlu_cfg_i.h" =20 typedef struct XLU_ConfigSetting { /* transparent */ struct XLU_ConfigSetting *next; diff --git a/tools/libs/util/libxlu_cfg_i.h b/tools/libs/util/libxlu_cfg_i.h index 7193867422..1c6a44b60f 100644 --- a/tools/libs/util/libxlu_cfg_i.h +++ b/tools/libs/util/libxlu_cfg_i.h @@ -19,6 +19,37 @@ #define LIBXLU_CFG_I_H =20 #include "libxlu_internal.h" + +struct XLU_ConfigList { + int avalues; /* available slots */ + int nvalues; /* actual occupied slots */ + XLU_ConfigValue **values; +}; + +typedef struct YYLTYPE +{ + int first_line; + int first_column; + int last_line; + int last_column; +} YYLTYPE; +#define YYLTYPE_IS_DECLARED + +struct XLU_ConfigValue { + enum XLU_ConfigValueType type; + union { + char *string; + XLU_ConfigList list; + } u; + YYLTYPE loc; +}; + +typedef struct { + XLU_Config *cfg; + int err, lexerrlineno, likely_python; + void *scanner; +} CfgParseContext; + #include "libxlu_cfg_y.h" =20 enum XLU_Operation { diff --git a/tools/libs/util/libxlu_internal.h b/tools/libs/util/libxlu_int= ernal.h index 97303391c6..7cbb2e632d 100644 --- a/tools/libs/util/libxlu_internal.h +++ b/tools/libs/util/libxlu_internal.h @@ -25,36 +25,6 @@ =20 #include "libxlutil.h" =20 -struct XLU_ConfigList { - int avalues; /* available slots */ - int nvalues; /* actual occupied slots */ - XLU_ConfigValue **values; -}; - -typedef struct YYLTYPE -{ - int first_line; - int first_column; - int last_line; - int last_column; -} YYLTYPE; -#define YYLTYPE_IS_DECLARED - -struct XLU_ConfigValue { - enum XLU_ConfigValueType type; - union { - char *string; - XLU_ConfigList list; - } u; - YYLTYPE loc; -}; - -typedef struct { - XLU_Config *cfg; - int err, lexerrlineno, likely_python; - void *scanner; -} CfgParseContext; - =20 #define STRINGIFY(x) #x #define TOSTRING(x) STRINGIFY(x) --=20 2.30.2