From nobody Mon Feb 9 16:34:55 2026 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; dmarc=fail(p=none dis=none) header.from=arm.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1648130829173333.8632188015114; Thu, 24 Mar 2022 07:07:09 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.294356.500536 (Exim 4.92) (envelope-from ) id 1nXO6x-0006cD-Sh; Thu, 24 Mar 2022 14:06:47 +0000 Received: by outflank-mailman (output) from mailman id 294356.500536; Thu, 24 Mar 2022 14:06:47 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nXO6x-0006bo-OY; Thu, 24 Mar 2022 14:06:47 +0000 Received: by outflank-mailman (input) for mailman id 294356; Thu, 24 Mar 2022 14:06: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 1nXO6w-0006Z2-DZ for xen-devel@lists.xenproject.org; Thu, 24 Mar 2022 14:06:46 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-sth1.inumbo.com (Halon) with ESMTP id a2db43a1-ab7b-11ec-a405-831a346695d4; Thu, 24 Mar 2022 15:06:44 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D44981570; Thu, 24 Mar 2022 07:06:43 -0700 (PDT) Received: from e125770.cambridge.arm.com (e125770.cambridge.arm.com [10.1.195.16]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 02D123F73D; Thu, 24 Mar 2022 07:06:42 -0700 (PDT) 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: a2db43a1-ab7b-11ec-a405-831a346695d4 From: Luca Fancellu To: xen-devel@lists.xenproject.org Cc: bertrand.marquis@arm.com, wei.chen@arm.com, Wei Liu , Anthony PERARD , Juergen Gross Subject: [PATCH v4 1/6] tools/cpupools: Give a name to unnamed cpupools Date: Thu, 24 Mar 2022 14:06:28 +0000 Message-Id: <20220324140633.39674-2-luca.fancellu@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220324140633.39674-1-luca.fancellu@arm.com> References: <20220324140633.39674-1-luca.fancellu@arm.com> X-ZM-MESSAGEID: 1648130830877100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" With the introduction of boot time cpupools, Xen can create many different cpupools at boot time other than cpupool with id 0. Since these newly created cpupools can't have an entry in Xenstore, create the entry using xen-init-dom0 helper with the usual convention: Pool-. Given the change, remove the check for poolid =3D=3D 0 from libxl_cpupoolid_to_name(...). Signed-off-by: Luca Fancellu Reviewed-by: Juergen Gross --- Changes in v4: - no changes Changes in v3: - no changes, add R-by Changes in v2: - Remove unused variable, moved xc_cpupool_infofree ahead to simplify the code, use asprintf (Juergen) --- tools/helpers/xen-init-dom0.c | 35 +++++++++++++++++++++++++++++++++- tools/libs/light/libxl_utils.c | 3 +-- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/tools/helpers/xen-init-dom0.c b/tools/helpers/xen-init-dom0.c index c99224a4b607..84286617790f 100644 --- a/tools/helpers/xen-init-dom0.c +++ b/tools/helpers/xen-init-dom0.c @@ -43,7 +43,9 @@ int main(int argc, char **argv) int rc; struct xs_handle *xsh =3D NULL; xc_interface *xch =3D NULL; - char *domname_string =3D NULL, *domid_string =3D NULL; + char *domname_string =3D NULL, *domid_string =3D NULL, *pool_path, *po= ol_name; + xc_cpupoolinfo_t *xcinfo; + unsigned int pool_id =3D 0; libxl_uuid uuid; =20 /* Accept 0 or 1 argument */ @@ -114,6 +116,37 @@ int main(int argc, char **argv) goto out; } =20 + /* Create an entry in xenstore for each cpupool on the system */ + do { + xcinfo =3D xc_cpupool_getinfo(xch, pool_id); + if (xcinfo !=3D NULL) { + if (xcinfo->cpupool_id !=3D pool_id) + pool_id =3D xcinfo->cpupool_id; + xc_cpupool_infofree(xch, xcinfo); + if (asprintf(&pool_path, "/local/pool/%d/name", pool_id) <=3D = 0) { + fprintf(stderr, "cannot allocate memory for pool path\n"); + rc =3D 1; + goto out; + } + if (asprintf(&pool_name, "Pool-%d", pool_id) <=3D 0) { + fprintf(stderr, "cannot allocate memory for pool name\n"); + rc =3D 1; + goto out_err; + } + pool_id++; + if (!xs_write(xsh, XBT_NULL, pool_path, pool_name, + strlen(pool_name))) { + fprintf(stderr, "cannot set pool name\n"); + rc =3D 1; + } + free(pool_name); +out_err: + free(pool_path); + if ( rc ) + goto out; + } + } while(xcinfo !=3D NULL); + printf("Done setting up Dom0\n"); =20 out: diff --git a/tools/libs/light/libxl_utils.c b/tools/libs/light/libxl_utils.c index b91c2cafa223..81780da3ff40 100644 --- a/tools/libs/light/libxl_utils.c +++ b/tools/libs/light/libxl_utils.c @@ -151,8 +151,7 @@ char *libxl_cpupoolid_to_name(libxl_ctx *ctx, uint32_t = poolid) =20 snprintf(path, sizeof(path), "/local/pool/%d/name", poolid); s =3D xs_read(ctx->xsh, XBT_NULL, path, &len); - if (!s && (poolid =3D=3D 0)) - return strdup("Pool-0"); + return s; } =20 --=20 2.17.1