From nobody Thu Nov 21 19:22:54 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; dkim=pass; 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=pass(p=quarantine dis=none) header.from=ti.com ARC-Seal: i=1; a=rsa-sha256; t=1724141285; cv=none; d=zohomail.com; s=zohoarc; b=nXv4NleE7ywQlxjQy31SkyYbchoJOHWTwCLUGE0a4E7qOrObTjGFHeGS5ojDmUGIUiV1CQtGC4NrZjHRJ3pPrvOU2XYueVYd9jxnyRTS43/si/w/J+h2LWpfJNSqoUfNARIUKracIljTVfDNApb9IfbN2deqURYfkpu9jnJyrpQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1724141285; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=TeBOwM+tXteEQrANYjoamP9LUorPNZlyzsIFVa/Uvrg=; b=cNQgVH260xDyn0tKAgfJlkaIpjkrWRwMZ3BU0DwBm6mRbGYR1n+Syk2gS2Jqwjf8tTR3OI/KEEb07bgwlYP/BJ0qNkVkFui2hWFmBVEJCQeSkUJnKAfA59Vu3c1Zz9xayea5v4xqO90Mi8FQF3mFV1BaziBFI2crBoKXoyOTXdk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1724141285691623.2268828483831; Tue, 20 Aug 2024 01:08:05 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.780101.1189684 (Exim 4.92) (envelope-from ) id 1sgJu9-00046B-10; Tue, 20 Aug 2024 08:07:49 +0000 Received: by outflank-mailman (output) from mailman id 780101.1189684; Tue, 20 Aug 2024 08:07:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sgJu8-000464-Tl; Tue, 20 Aug 2024 08:07:48 +0000 Received: by outflank-mailman (input) for mailman id 780101; Tue, 20 Aug 2024 08:07:47 +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 1sgJu7-00045y-Mb for xen-devel@lists.xenproject.org; Tue, 20 Aug 2024 08:07:47 +0000 Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 46841b26-5ecb-11ef-8776-851b0ebba9a2; Tue, 20 Aug 2024 10:07:44 +0200 (CEST) Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 47K87fVP115774; Tue, 20 Aug 2024 03:07:41 -0500 Received: from DLEE112.ent.ti.com (dlee112.ent.ti.com [157.170.170.23]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 47K87fSU056773 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 20 Aug 2024 03:07:41 -0500 Received: from DLEE107.ent.ti.com (157.170.170.37) by DLEE112.ent.ti.com (157.170.170.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Tue, 20 Aug 2024 03:07:41 -0500 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DLEE107.ent.ti.com (157.170.170.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Tue, 20 Aug 2024 03:07:41 -0500 Received: from localhost (nightbug.dhcp.ti.com [10.24.72.75]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 47K87der082013; Tue, 20 Aug 2024 03:07:40 -0500 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: 46841b26-5ecb-11ef-8776-851b0ebba9a2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1724141261; bh=TeBOwM+tXteEQrANYjoamP9LUorPNZlyzsIFVa/Uvrg=; h=From:To:CC:Subject:Date; b=Edxz/75f3WrPZh1rysl3J3/V/+EggY9lDXzeZrzox9svaGXTIiDElV+o/+zYeBgUt My+NFdkHOh9ClvB23NLXLfVpZVTf9v5hR1YMMDD2T5v82La5ZQYnpKihCvVizOjTUK 2yr2Z5IaDosVtMTRsPb3+WNLq3SpsYK5+jOleJTQ= From: Amneesh Singh To: CC: , Amneesh Singh Subject: [PATCH v2] tools/helpers/init-dom0less: fix vcpu availability Date: Tue, 20 Aug 2024 13:34:17 +0530 Message-ID: <20240820080416.323725-1-a-singh21@ti.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-ZohoMail-DKIM: pass (identity @ti.com) X-ZM-MESSAGEID: 1724141287831116600 Content-Type: text/plain; charset="utf-8" Currently, writing at cpu//availability in xenstore fails for a couple of reasons: a trailing slash in the path and the fact that cpupool isn't a bitmap but the cpupool id. This patch fixes this by just getting libxl_vcpuinfo for each dom0less domain. Signed-off-by: Amneesh Singh --- tools/helpers/init-dom0less.c | 46 ++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 14 deletions(-) --- v1 -> v2: - check for libxl_list_vcpu failure - skip writing cpu availability to store if the above failure occurs diff --git a/tools/helpers/init-dom0less.c b/tools/helpers/init-dom0less.c index fee9345..722a5af 100644 --- a/tools/helpers/init-dom0less.c +++ b/tools/helpers/init-dom0less.c @@ -99,8 +99,8 @@ static bool do_xs_write_vm(struct xs_handle *xsh, xs_tran= saction_t t, * domain started by xl/libxl. */ static int create_xenstore(struct xs_handle *xsh, - libxl_dominfo *info, libxl_uuid uuid, - evtchn_port_t xenstore_port) + libxl_dominfo *info, libxl_vcpuinfo *vcpuinfo, + libxl_uuid uuid, evtchn_port_t xenstore_port) { domid_t domid; unsigned int i; @@ -167,15 +167,20 @@ retry_transaction: /* /domain */ if (!do_xs_write_dom(xsh, t, domid, "vm", vm_val_str)) goto err; if (!do_xs_write_dom(xsh, t, domid, "name", dom_name_str)) goto err; - if (!do_xs_write_dom(xsh, t, domid, "cpu", "")) goto err; - for (i =3D 0; i < info->vcpu_max_id; i++) { - rc =3D snprintf(cpu_str, STR_MAX_LENGTH, "cpu/%u/availability/", i= ); - if (rc < 0 || rc >=3D STR_MAX_LENGTH) - goto err; - rc =3D -EIO; - if (!do_xs_write_dom(xsh, t, domid, cpu_str, - (info->cpupool & (1 << i)) ? "online" : "offl= ine")) - goto err; + + if (!vcpuinfo) { + fprintf(stderr, "vcpu information unavailable, proceeding without = it\n"); + } else { + if (!do_xs_write_dom(xsh, t, domid, "cpu", "")) goto err; + for (i =3D 0; i <=3D info->vcpu_max_id; i++) { + rc =3D snprintf(cpu_str, STR_MAX_LENGTH, "cpu/%u/availability"= , i); + if (rc < 0 || rc >=3D STR_MAX_LENGTH) + goto err; + rc =3D -EIO; + if (!do_xs_write_dom(xsh, t, domid, cpu_str, + vcpuinfo[i].online ? "online" : "offline")) + goto err; + } } =20 if (!do_xs_write_dom(xsh, t, domid, "memory", "")) goto err; @@ -225,7 +230,8 @@ err: static int init_domain(struct xs_handle *xsh, struct xc_interface_core *xch, xenforeignmemory_handle *xfh, - libxl_dominfo *info) + libxl_dominfo *info, + libxl_vcpuinfo *vcpuinfo) { libxl_uuid uuid; uint64_t xenstore_evtchn, xenstore_pfn; @@ -278,7 +284,7 @@ static int init_domain(struct xs_handle *xsh, if (rc < 0) return rc; =20 - rc =3D create_xenstore(xsh, info, uuid, xenstore_evtchn); + rc =3D create_xenstore(xsh, info, vcpuinfo, uuid, xenstore_evtchn); if (rc) err(1, "writing to xenstore"); =20 @@ -330,14 +336,24 @@ int main(int argc, char **argv) =20 for (i =3D 0; i < nb_vm; i++) { domid_t domid =3D info[i].domid; + libxl_vcpuinfo *vcpuinfo; + int nb_vcpu =3D 0, nr_cpus =3D 0; + =20 /* Don't need to check for Dom0 */ if (!domid) continue; =20 + vcpuinfo =3D libxl_list_vcpu(ctx, domid, &nb_vcpu, &nr_cpus); + + if (!vcpuinfo) { + fprintf(stderr, "libxl_list_vcpu failed.\n"); + nb_vcpu =3D 0; + } + printf("Checking domid: %u\n", domid); if (!domain_exists(xsh, domid)) { - rc =3D init_domain(xsh, xch, xfh, &info[i]); + rc =3D init_domain(xsh, xch, xfh, &info[i], vcpuinfo); if (rc < 0) { fprintf(stderr, "init_domain failed.\n"); goto out; @@ -345,6 +361,8 @@ int main(int argc, char **argv) } else { printf("Domain %u has already been initialized\n", domid); } + + libxl_vcpuinfo_list_free(vcpuinfo, nb_vcpu); } out: libxl_dominfo_list_free(info, nb_vm); --=20 2.34.1