From patchwork Fri Jul 29 17:53:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?RWR3aW4gVMO2csO2aw==?= X-Patchwork-Id: 12932766 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 7A4E8C00144 for ; Fri, 29 Jul 2022 17:54:33 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.377693.611030 (Exim 4.92) (envelope-from ) id 1oHUBu-0008DU-FL; Fri, 29 Jul 2022 17:54:26 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 377693.611030; Fri, 29 Jul 2022 17:54:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oHUBu-0008DC-BJ; Fri, 29 Jul 2022 17:54:26 +0000 Received: by outflank-mailman (input) for mailman id 377693; Fri, 29 Jul 2022 17:54:25 +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 1oHUBt-0006a9-GD for xen-devel@lists.xenproject.org; Fri, 29 Jul 2022 17:54:25 +0000 Received: from esa6.hc3370-68.iphmx.com (esa6.hc3370-68.iphmx.com [216.71.155.175]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 7a701b24-0f67-11ed-924f-1f966e50362f; Fri, 29 Jul 2022 19:54:24 +0200 (CEST) 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: 7a701b24-0f67-11ed-924f-1f966e50362f DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1659117264; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=l4aF2ey7+PrEkwFig3yeefjykYcLjpth1sMCs1mC3pQ=; b=hvCsb+OGwybB2XLfpDxTsnZw5Glyyn1hIbF/W5fGiODNFapUFOhn+rI1 tPIqLvqR+KMVnAh1m4XsnLoPpZ0irDHDCUSbYoYrSvLtekRoWdx+S3BUs SBQ/+4g3n2drqq/+cWxJqmdOWaK35BT6aIdGN95ncytLunzmbidqzpW1P c=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 2.7 X-MesageID: 76740552 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:1AIS/aCp/oPIfBVW/0rjw5YqxClBgxIJ4kV8jS/XYbTApGh0gzcDn zYfXWyPPfnbMDHze40kPYS/p0gHu5XQmtNmQQY4rX1jcSlH+JHPbTi7wuYcHM8wwunrFh8PA xA2M4GYRCwMZiaA4E3ratANlFEkvYmQXL3wFeXYDS54QA5gWU8JhAlq3uU0meaEu/Dga++2k Y608pa31GONgWYuaDpLsfPb8nuDgdyp0N8mlg1mDRx0lAe2e0k9VPo3Oay3Jn3kdYhYdsbSq zHrlezREsvxpn/BO/v9+lrJWhRiro36ZGBivkF+Sam66iWukwRpukoN2FjwXm8M49mBt4gZJ NygLvVcQy9xVkHHsLx1vxW1j0iSlECJkVPKCSHXjCCd86HJWyL0xqVjU3oTBowd+dd9RlNcq t8qCz9YO3hvh8ruqF66Yuxlh8BlJ8j3JoIP/HpnyFk1D95/H8qFGf+To4YFgnFg3aiiHt6HD yYdQTdjchXGJQFIIFAUIJk/gP2plj/0dDgwRFe9+vRovzCOkVYZPL7FFor6IIGlbsNptByDh DyX4lu+EhtLHYnKodaC2i313bKe9c/hY6oNEJWo+/gsh0ecrkQfAQMbfUG2qv64jgi5Qd03A 1wZ/G8ioLY/8GSvT8LhRFuorXicpBkeVtFMVeog52mwJrH8uljDQDJeF3gYNYJg5JReqSEWO kGhxsvsVTEwi5iuSHeex73TnyHtGho2IjpXDcMbdjfp8+UPsalq0E+eFosyTfbk5jHmMWqum m7X9UDSk51W1JdWjPvjoDgrlhr2/vD0ohgJChI7t45Pxidwf8abaoOh8jA3Bt4Qfd/CHjFtU JXp8vVyDdzi7rnXzURhuM1XQNmUCw+taVUwe2JHEZg77CiK8HW+Z41W6zwWDB43b5dcImSyM BOM41w5CHpv0JyCNPUfXm5MI55ykfiI+SrNDZg4keaikrAuLVTarUmClGab3nz3kVhErJzTz ayzKJ/0ZV5HWPsP8dZDb71CuVPd7nxhmDi7qFGS50jP7Idyk1bPFe5cYAPVMr1RAWHtiFy9z uuz/vCik313ONASqAGNmWLPBTjm9UQGOK0= IronPort-HdrOrdr: A9a23:5Ree6KwmMzrgjpzpiRErKrPwFL1zdoMgy1knxilNoRw8SKKlfq eV7Y0mPH7P+VAssR4b+exoVJPtfZqYz+8R3WBzB8bEYOCFghrKEGgK1+KLqFeMJ8S9zJ846U 4JSdkHNDSaNzlHZKjBjzVQa+xQouW6zA== X-IronPort-AV: E=Sophos;i="5.93,201,1654574400"; d="scan'208";a="76740552" From: =?utf-8?b?RWR3aW4gVMO2csO2aw==?= To: CC: =?utf-8?b?RWR3aW4gVMO2csO2aw==?= , "Christian Lindig" , David Scott , Wei Liu , Anthony PERARD Subject: [PATCH v1 1/7] tools/ocaml/Makefile: do not run ocamldep during make clean Date: Fri, 29 Jul 2022 18:53:24 +0100 Message-ID: <835ba84cf1fb7619fa6672d194aaf279795a5246.1659116941.git.edvin.torok@citrix.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Trying to include .ocamldep.make will cause it to be generated if it doesn't exist. We do not want this during make clean: we would remove it anyway. Speeds up make clean. Before (measured on f732240fd3bac25116151db5ddeb7203b62e85ce, July 2022): ``` Parsing /home/edwin/xen2/tools/ocaml/libs/xl/../../../../tools/libs/light/libxl_types.idl Parsing /home/edwin/xen2/tools/ocaml/libs/xl/../../../../tools/libs/light/libxl_types.idl Parsing /home/edwin/xen2/tools/ocaml/libs/xl/../../../../tools/libs/light/libxl_types.idl Parsing /home/edwin/xen2/tools/ocaml/libs/xl/../../../../tools/libs/light/libxl_types.idl Parsing /home/edwin/xen2/tools/ocaml/libs/xl/../../../../tools/libs/light/libxl_types.idl Performance counter stats for 'make clean -j8 -s' (5 runs): 4.2233 +- 0.0208 seconds time elapsed ( +- 0.49% ) ``` After: ``` perf stat -r 5 --null make clean -j8 -s Performance counter stats for 'make clean -j8 -s' (5 runs): 2.7325 +- 0.0138 seconds time elapsed ( +- 0.51% ) ``` No functional change. Signed-off-by: Edwin Török Acked-by: Christian Lindig > Signed-off-by: Edwin Török --- tools/ocaml/Makefile.rules | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/ocaml/Makefile.rules b/tools/ocaml/Makefile.rules index 7e4db457a1..d368308d9b 100644 --- a/tools/ocaml/Makefile.rules +++ b/tools/ocaml/Makefile.rules @@ -44,8 +44,10 @@ META: META.in ALL_OCAML_OBJ_SOURCES=$(addsuffix .ml, $(ALL_OCAML_OBJS)) +ifneq ($(MAKECMDGOALS),clean) .ocamldep.make: $(ALL_OCAML_OBJ_SOURCES) Makefile $(OCAML_TOPLEVEL)/Makefile.rules $(call quiet-command, $(OCAMLDEP) $(ALL_OCAML_OBJ_SOURCES) *.mli $o,MLDEP,) +endif clean: $(CLEAN_HOOKS) $(Q)rm -f .*.d *.o *.so *.a *.cmo *.cmi *.cma *.cmx *.cmxa *.annot *.spot *.spit $(LIBS) $(PROGRAMS) $(GENERATED_FILES) .ocamldep.make META From patchwork Fri Jul 29 17:53:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?RWR3aW4gVMO2csO2aw==?= X-Patchwork-Id: 12932762 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 6C993C04A68 for ; Fri, 29 Jul 2022 17:54:26 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.377686.610975 (Exim 4.92) (envelope-from ) id 1oHUBe-0006aB-Rr; Fri, 29 Jul 2022 17:54:10 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 377686.610975; Fri, 29 Jul 2022 17:54:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oHUBe-0006a3-Op; Fri, 29 Jul 2022 17:54:10 +0000 Received: by outflank-mailman (input) for mailman id 377686; Fri, 29 Jul 2022 17:54:09 +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 1oHUBd-0006Zx-8z for xen-devel@lists.xenproject.org; Fri, 29 Jul 2022 17:54:09 +0000 Received: from esa1.hc3370-68.iphmx.com (esa1.hc3370-68.iphmx.com [216.71.145.142]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 6f4ca0d9-0f67-11ed-bd2d-47488cf2e6aa; Fri, 29 Jul 2022 19:54:07 +0200 (CEST) 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: 6f4ca0d9-0f67-11ed-bd2d-47488cf2e6aa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1659117246; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0XhqZ8NRblIeCreSrfdQ9yayvs4XLb4vL2XM9dKH9MI=; b=Olub0/TxHoeGYkwVPs1gUqmyLYbi0fhmOLAxAFjNVndFxAbpTMIz3vMB ShbMT33OF7024qTLsXL4WxJlni8CE/i+ZtD0l7rapqwwUHx9WWk2aL4i/ gHl8zoSbUbD+LMFXDLhEKE4OB445VHpKfENz+we7uSmoD0zTzp/t2uOor g=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 2.7 X-MesageID: 77388856 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:HU0/CKv9tOJ6MyKo8h3FoJZFJefnVDVeMUV32f8akzHdYApBsoF/q tZmKTrQa/zZa2rxKIwkatvi8EtV7JOEz4NjTlFurHwwES0W+JbJXdiXEBz9bniYRiHhoOOLz Cm8hv3odp1coqr0/0/1WlTZhSAgk/vOHtIQMcacUghpXwhoVSw9vhxqnu89k+ZAjMOwRgiAo rsemeWGULOe82MyYzl8B56r8ks15qyt4mJA5DTSWNgQ1LPgvyhNZH4gDfnZw0vQGuF8AuO8T uDf+7C1lkuxE8AFU47Nfh7TKyXmc5aKVeS8oiM+t5uK23CukhcawKcjXMfwXG8M49m/c3Kd/ /0W3XC4YV9B0qQhA43xWTEAe811FfUuFLMqvRFTGCFcpqHLWyKE/hlgMK05FaFB1qEqInNFz OQdDRsAS0m9p9u9663uH4GAhux7RCXqFIYWu3UmxjDFF/c2B5vERs0m5/cBgm123JoXW6+DO YxJMlKDbzyZC/FLElobFpM42vuvnH78WzZZtEiUtew85G27IAlZj+e2YIqFJ4LiqcN9nkGWu UvcxVvAWU8/C/ub2R2g4FOyibqa9c/8cN1LT+DpnhJwu3Wfz3IeIAcbXly6pb++kEHWc81bA 1wZ/Gwpt6da3FymSJzxUgO1pFaAvwUAQJxAHusi8gaPx6HIpQGDCQA5oiVpMYJ88pVsHHpzi wHPz4iB6SFTXKO9ZSuxseq3vziLIS0wBmInPBEkdAAu/Iy2yG0stS4jXuqPAYbs0ICkQWyhn mjbxMQtr+5N1JBWjs1X6XiC2mvx/caRE2bZ8y2NBgqYAhVFiJlJjmBCwXzS9r5+IYmQVTFtV 1BUypHFvIji4Xxg/RFhodnh/5nzvp5pyBWG3TZS82AJrlxBAUKLc4FK+y1ZL0x0KMsCcjKBS BaN5FIJv8QIbCf1N/Afj2eN5yMClPKIKDgYfqqMMoomjmZZL2drAx2ClWbPhjuwwSDAYIk0O IuBcNbEMEv2/Z9PlWPuL89AgOBD+8zL7TmMLXwN50j4jOH2ib/8YettDWZimchjsPrd8F2Or 4s32gnj40w3bdASqxL/qeY7RW3m51BibXwqg6S7rtK+Hzc= IronPort-HdrOrdr: A9a23:03lGSq84duHOqchc7HRuk+DgI+orL9Y04lQ7vn2YSXRuHPBw8P re5cjztCWE7gr5N0tBpTntAsW9qDbnhPtICOoqTNCftWvdyQiVxehZhOOIqVDd8m/Fh4pgPM 9bAtBD4bbLbGSS4/yU3ODBKadD/OW6 X-IronPort-AV: E=Sophos;i="5.93,201,1654574400"; d="scan'208";a="77388856" From: =?utf-8?b?RWR3aW4gVMO2csO2aw==?= To: CC: =?utf-8?b?RWR3aW4gVMO2csO2aw==?= , Wei Liu , Anthony PERARD , Christian Lindig , David Scott Subject: [PATCH v1 2/7] tools/ocaml/*/Makefile: generate paths.ml from configure Date: Fri, 29 Jul 2022 18:53:25 +0100 Message-ID: <0752fe6eaa26f244f6fb45b1c3c6b9906deb2aa9.1659116941.git.edvin.torok@citrix.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 paths.ml contains various paths known to configure, and currently is generated via a Makefile rule. Simplify this and generate it through configure, similar to how oxenstored.conf is generated from oxenstored.conf.in. This will allow to reuse the generated file more easily with Dune. No functional change. Signed-off-by: Edwin Török Acked-by: Christian Lindig > --- tools/configure | 4 +++- tools/configure.ac | 2 ++ tools/ocaml/libs/xs/Makefile | 5 ----- tools/ocaml/libs/xs/paths.ml.in | 1 + tools/ocaml/xenstored/Makefile | 5 ----- tools/ocaml/xenstored/paths.ml.in | 4 ++++ 6 files changed, 10 insertions(+), 11 deletions(-) create mode 100644 tools/ocaml/libs/xs/paths.ml.in create mode 100644 tools/ocaml/xenstored/paths.ml.in diff --git a/tools/configure b/tools/configure index a052c186a5..41deb7fb96 100755 --- a/tools/configure +++ b/tools/configure @@ -2453,7 +2453,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu -ac_config_files="$ac_config_files ../config/Tools.mk hotplug/FreeBSD/rc.d/xencommons hotplug/FreeBSD/rc.d/xendriverdomain hotplug/Linux/init.d/sysconfig.xencommons hotplug/Linux/init.d/sysconfig.xendomains hotplug/Linux/init.d/xen-watchdog hotplug/Linux/init.d/xencommons hotplug/Linux/init.d/xendomains hotplug/Linux/init.d/xendriverdomain hotplug/Linux/launch-xenstore hotplug/Linux/vif-setup hotplug/Linux/xen-hotplug-common.sh hotplug/Linux/xendomains hotplug/NetBSD/rc.d/xencommons hotplug/NetBSD/rc.d/xendriverdomain ocaml/xenstored/oxenstored.conf" +ac_config_files="$ac_config_files ../config/Tools.mk hotplug/FreeBSD/rc.d/xencommons hotplug/FreeBSD/rc.d/xendriverdomain hotplug/Linux/init.d/sysconfig.xencommons hotplug/Linux/init.d/sysconfig.xendomains hotplug/Linux/init.d/xen-watchdog hotplug/Linux/init.d/xencommons hotplug/Linux/init.d/xendomains hotplug/Linux/init.d/xendriverdomain hotplug/Linux/launch-xenstore hotplug/Linux/vif-setup hotplug/Linux/xen-hotplug-common.sh hotplug/Linux/xendomains hotplug/NetBSD/rc.d/xencommons hotplug/NetBSD/rc.d/xendriverdomain ocaml/libs/xs/paths.ml ocaml/xenstored/paths.ml ocaml/xenstored/oxenstored.conf" ac_config_headers="$ac_config_headers config.h" @@ -10935,6 +10935,8 @@ do "hotplug/Linux/xendomains") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/xendomains" ;; "hotplug/NetBSD/rc.d/xencommons") CONFIG_FILES="$CONFIG_FILES hotplug/NetBSD/rc.d/xencommons" ;; "hotplug/NetBSD/rc.d/xendriverdomain") CONFIG_FILES="$CONFIG_FILES hotplug/NetBSD/rc.d/xendriverdomain" ;; + "ocaml/libs/xs/paths.ml") CONFIG_FILES="$CONFIG_FILES ocaml/libs/xs/paths.ml" ;; + "ocaml/xenstored/paths.ml") CONFIG_FILES="$CONFIG_FILES ocaml/xenstored/paths.ml" ;; "ocaml/xenstored/oxenstored.conf") CONFIG_FILES="$CONFIG_FILES ocaml/xenstored/oxenstored.conf" ;; "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; "hotplug/Linux/systemd/proc-xen.mount") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/systemd/proc-xen.mount" ;; diff --git a/tools/configure.ac b/tools/configure.ac index 1094d896fc..32cbe6bd3c 100644 --- a/tools/configure.ac +++ b/tools/configure.ac @@ -21,6 +21,8 @@ hotplug/Linux/xen-hotplug-common.sh hotplug/Linux/xendomains hotplug/NetBSD/rc.d/xencommons hotplug/NetBSD/rc.d/xendriverdomain +ocaml/libs/xs/paths.ml +ocaml/xenstored/paths.ml ocaml/xenstored/oxenstored.conf ]) AC_CONFIG_HEADERS([config.h]) diff --git a/tools/ocaml/libs/xs/Makefile b/tools/ocaml/libs/xs/Makefile index e934bbb550..e160e6a711 100644 --- a/tools/ocaml/libs/xs/Makefile +++ b/tools/ocaml/libs/xs/Makefile @@ -44,8 +44,3 @@ uninstall: $(OCAMLFIND) remove -destdir $(OCAMLDESTDIR) xenstore include $(OCAML_TOPLEVEL)/Makefile.rules - -genpath-target = $(call buildmakevars2module,paths.ml) -$(eval $(genpath-target)) - -GENERATED_FILES += paths.ml diff --git a/tools/ocaml/libs/xs/paths.ml.in b/tools/ocaml/libs/xs/paths.ml.in new file mode 100644 index 0000000000..c067f8d012 --- /dev/null +++ b/tools/ocaml/libs/xs/paths.ml.in @@ -0,0 +1 @@ +let xen_run_stored = "@XEN_RUN_STORED@" diff --git a/tools/ocaml/xenstored/Makefile b/tools/ocaml/xenstored/Makefile index 0b5711b507..6f7333926e 100644 --- a/tools/ocaml/xenstored/Makefile +++ b/tools/ocaml/xenstored/Makefile @@ -93,8 +93,3 @@ uninstall: rm -f $(DESTDIR)$(sbindir)/oxenstored include $(OCAML_TOPLEVEL)/Makefile.rules - -genpath-target = $(call buildmakevars2module,paths.ml) -$(eval $(genpath-target)) - -GENERATED_FILES += paths.ml diff --git a/tools/ocaml/xenstored/paths.ml.in b/tools/ocaml/xenstored/paths.ml.in new file mode 100644 index 0000000000..37949dc8f3 --- /dev/null +++ b/tools/ocaml/xenstored/paths.ml.in @@ -0,0 +1,4 @@ +let xen_log_dir = "@XEN_LOG_DIR@" +let xen_config_dir = "@XEN_CONFIG_DIR@" +let xen_run_dir = "@XEN_RUN_DIR@" +let xen_run_stored = "@XEN_RUN_STORED@" From patchwork Fri Jul 29 17:53:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?RWR3aW4gVMO2csO2aw==?= X-Patchwork-Id: 12932764 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 A15BAC19F2D for ; Fri, 29 Jul 2022 17:54:27 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.377691.611019 (Exim 4.92) (envelope-from ) id 1oHUBn-0007jt-2O; Fri, 29 Jul 2022 17:54:19 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 377691.611019; Fri, 29 Jul 2022 17:54: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 1oHUBm-0007jh-Uy; Fri, 29 Jul 2022 17:54:18 +0000 Received: by outflank-mailman (input) for mailman id 377691; Fri, 29 Jul 2022 17:54:17 +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 1oHUBl-0006a9-Bo for xen-devel@lists.xenproject.org; Fri, 29 Jul 2022 17:54:17 +0000 Received: from esa1.hc3370-68.iphmx.com (esa1.hc3370-68.iphmx.com [216.71.145.142]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 75963896-0f67-11ed-924f-1f966e50362f; Fri, 29 Jul 2022 19:54:16 +0200 (CEST) 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: 75963896-0f67-11ed-924f-1f966e50362f DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1659117256; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RkbRUEdOWEaCHa9+/Ptg/amm9wD5Jpr8o1Ls9yYeJ4s=; b=gN5sn3moo+oRFf86iejqDq7FlUjbatC2OJyxQ1g0DRDlFXogVjcZB1ws pMj5OLQg39fqcGR0yHAiNuSSO2kJHKXPw6VgmyHi/Rcr/UjJGINKO1BKN eFj68MGpwU3v3KF6QoF71s3ZDl04OGDQs05d0cv6IY0buWEamcGJZliDT A=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 2.7 X-MesageID: 77388875 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:CWTGF6ooLySU/BLxNlG4Siz64opeBmJ7ZRIvgKrLsJaIsI4StFCzt garIBmBb/aPZWfzftgjbYSyp04G6sSDmIJnGQdppSk2EXgU+JuZCYyVIHmrMnLJJKUvbq7GA +byyDXkBJppJpMJjk71atANlVEliefSAOKU5NfsYkhZXRVjRDoqlSVtkus4hp8AqdWiCkaGt MiaT/f3YTdJ4BYpdDNPg06/gEk35q6q52lJ5gZWic1j5zcyqVFEVPrzGonpR5fIatE8NvK3Q e/F0Ia48gvxl/v6Ior4+lpTWhRiro/6ZWBiuFIPM0SRqkEqShgJ+rQ6LJIhhXJ/0F1lqTzTJ OJl7vRcQS9xVkHFdX90vxNwS0mSNoUekFPLzOTWXWV+ACQqflO1q8iCAn3aMqU80PhLMGYV9 MdBLS4ucFOOiPKz4rmSH7wEasQLdKEHPasas3BkizrYEewnUdbIRKCiCd1whWlqwJoURLCHO pRfOWEHgBfoOnWjPn8aBIw/mqG0gWP4cBVTqU6PpLpx6G/WpOB0+Oeya4qFKoPXLSlTtkiZn Vr50UrDOCwXLNGW7TGI9ky8j/CayEsXX6pNTeblp5aGmma7ymUNBTUMWFC8oP3/jVSxM/pAL 2QE9yxoqrI9nGS7Q9+4UxCmrXqsuh8HR8EWA+A88BuKyKff/0CeHGdsc9JaQIV47olsH2Vsj wLX2YOybdByjFGLYVa36IulqmizAnEQM0wcJiILXQ4n6PC29enfkSnzosZf/L+d14OoSGmtk m3S/UDSlJ1I05dVivzTEUTvxmv1+8OXFlNdChD/BDrN0+9vWGKyi2VEA3D/5O0IEouWR0LpU JMsy5nHt7Bm4X1geUWwrAQx8FKBva/t3MX02wIHInXY323FF4SfVY5R+ipiA0xiL9wJfzTkC GeK514AvMQIZyv2MvUoC25UNyjN5fG6fekJq9iONoYeCnSPXFTvEN5Sib64gDm2zRlEfVAXM paHa8e8ZUsn5VBc5GPvH481jO50rh3SMEuJGvgXOTz7jufFDJNUIJ9ZWGazghcRtv/d+VWNq IoCXyZIoj0GONDDjuDs2dZ7BTg3wbITXPgad+Q/mja/Hzdb IronPort-HdrOrdr: A9a23:BZPhpqzw6gv8Rot2yYapKrPwFL1zdoMgy1knxilNoRw8SKKlfq eV7Y0mPH7P+VAssR4b+exoVJPtfZqYz+8R3WBzB8bEYOCFghrKEGgK1+KLqFeMJ8S9zJ846U 4JSdkHNDSaNzlHZKjBjzVQa+xQouW6zA== X-IronPort-AV: E=Sophos;i="5.93,201,1654574400"; d="scan'208";a="77388875" From: =?utf-8?b?RWR3aW4gVMO2csO2aw==?= To: CC: =?utf-8?b?RWR3aW4gVMO2csO2aw==?= , Wei Liu , Anthony PERARD , Christian Lindig , David Scott Subject: [PATCH v1 3/7] tools/ocaml/*/dune: dune based build system Date: Fri, 29 Jul 2022 18:53:26 +0100 Message-ID: <0f2c08734668626a618767680493a006827e123b.1659116941.git.edvin.torok@citrix.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Based on Christian Lindig's work. Initially this will be used to build unit tests, and to make development easier. Dune supports proper incremental builds and editor integration with merlin/LSP. For now the Makefile based build system is retained too: this is not a hard dependency on Dune. Using version 2.1 of Dune build language here, because that is the one available in Ubuntu Focal (part of the CI here). No functional change. Signed-off-by: Edwin Török Signed-off-by: Edwin Török > Acked-by: Christian Lindig > --- tools/.gitignore | 7 +++++ tools/dune | 5 ++++ tools/dune-project | 1 + tools/ocaml/dune-project | 27 ++++++++++++++++++ tools/ocaml/libs/eventchn/dune | 11 ++++++++ tools/ocaml/libs/mmap/dune | 9 ++++++ tools/ocaml/libs/xb/dune | 10 +++++++ tools/ocaml/libs/xc/dune | 16 +++++++++++ tools/ocaml/libs/xs/dune | 15 ++++++++++ tools/ocaml/xenstored/dune | 51 ++++++++++++++++++++++++++++++++++ 10 files changed, 152 insertions(+) create mode 100644 tools/.gitignore create mode 100644 tools/dune create mode 100644 tools/dune-project create mode 100644 tools/ocaml/dune-project create mode 100644 tools/ocaml/libs/eventchn/dune create mode 100644 tools/ocaml/libs/mmap/dune create mode 100644 tools/ocaml/libs/xb/dune create mode 100644 tools/ocaml/libs/xc/dune create mode 100644 tools/ocaml/libs/xs/dune create mode 100644 tools/ocaml/xenstored/dune diff --git a/tools/.gitignore b/tools/.gitignore new file mode 100644 index 0000000000..c211749a3b --- /dev/null +++ b/tools/.gitignore @@ -0,0 +1,7 @@ +dune-workspace* +_build/ +.merlin +*.h.gch +*.opam +ocaml/*.install +include/_xentoolcore_list.h diff --git a/tools/dune b/tools/dune new file mode 100644 index 0000000000..febbd078f0 --- /dev/null +++ b/tools/dune @@ -0,0 +1,5 @@ +; only look inside ocaml and include subdirectory, speeds up the build +; since dune doesn't need to copy/hash/monitor all the other files +(dirs ocaml) + +(data_only_dirs include libs) diff --git a/tools/dune-project b/tools/dune-project new file mode 100644 index 0000000000..cd8d4e3d86 --- /dev/null +++ b/tools/dune-project @@ -0,0 +1 @@ +(lang dune 2.1) diff --git a/tools/ocaml/dune-project b/tools/ocaml/dune-project new file mode 100644 index 0000000000..1dae7b0acb --- /dev/null +++ b/tools/ocaml/dune-project @@ -0,0 +1,27 @@ +(lang dune 2.1) + +(name xen) + +(formatting (enabled_for dune)) +(generate_opam_files true) + +(maintainers christian.lindig@citrix.com) +(license LGPL) + +(package + (name xen) + (synopsis "Xen interfaces") + (depends + base-unix + (dune (>= 2.1)) + ) +) + +(package + (name xenstored) + (synopsis "In-memory key-value store for the Xen hypervisor") + (depends + base-unix + (dune (>= 2.1)) + ) +) diff --git a/tools/ocaml/libs/eventchn/dune b/tools/ocaml/libs/eventchn/dune new file mode 100644 index 0000000000..4468f2e769 --- /dev/null +++ b/tools/ocaml/libs/eventchn/dune @@ -0,0 +1,11 @@ +(library + (foreign_stubs + (language c) + (names xeneventchn_stubs) + (extra_deps ../../../include/xen/xen.h ../../../libs/evtchn/libxenevtchn.so) + (include_dirs ../../../include)) + (name xeneventchn) + (public_name xen.eventchn) + (libraries unix) + (no_dynlink) + (c_library_flags -lxenevtchn)) diff --git a/tools/ocaml/libs/mmap/dune b/tools/ocaml/libs/mmap/dune new file mode 100644 index 0000000000..57a8ab5b9b --- /dev/null +++ b/tools/ocaml/libs/mmap/dune @@ -0,0 +1,9 @@ +(library + (foreign_stubs + (language c) + (names xenmmap_stubs)) + (name xenmmap) + (public_name xen.mmap) + (libraries unix) + (no_dynlink) + (install_c_headers mmap_stubs)) diff --git a/tools/ocaml/libs/xb/dune b/tools/ocaml/libs/xb/dune new file mode 100644 index 0000000000..13a507ea87 --- /dev/null +++ b/tools/ocaml/libs/xb/dune @@ -0,0 +1,10 @@ +(library + (foreign_stubs + (language c) + (extra_deps ../../../include/xen/xen.h) + (include_dirs ../../../include) + (names xenbus_stubs xs_ring_stubs)) + (name xenbus) + (public_name xen.bus) + (no_dynlink) + (libraries unix xenmmap)) diff --git a/tools/ocaml/libs/xc/dune b/tools/ocaml/libs/xc/dune new file mode 100644 index 0000000000..6f9450cd27 --- /dev/null +++ b/tools/ocaml/libs/xc/dune @@ -0,0 +1,16 @@ +(rule + (with-stdout-to + xenctrl_abi_check.h + (run perl -w %{dep:abi-check} %{dep:xenctrl_stubs.c} %{dep:xenctrl.ml}))) + +(library + (foreign_stubs + (language c) + (names xenctrl_stubs) + (extra_deps ../../../include/xen/xen.h ../../../libs/ctrl/libxenctrl.so) + (include_dirs ../../../include)) + (name xenctrl) + (public_name xen.ctrl) + (libraries unix xenmmap) + (no_dynlink) + (c_library_flags -lxenctrl -lxenguest)) diff --git a/tools/ocaml/libs/xs/dune b/tools/ocaml/libs/xs/dune new file mode 100644 index 0000000000..086259f51d --- /dev/null +++ b/tools/ocaml/libs/xs/dune @@ -0,0 +1,15 @@ +; fallback mode: the files may have been generated by configure already + +(rule + (targets paths.ml) + (deps paths.ml.in) + (mode fallback) + (action + (run ../../../config.status --file=paths.ml))) + +(library + ; avoid conflict with mirage lib: name it differently + (name xenstore_xen) + (public_name xen.store) + (no_dynlink) + (libraries unix xenbus)) diff --git a/tools/ocaml/xenstored/dune b/tools/ocaml/xenstored/dune new file mode 100644 index 0000000000..d71decebcf --- /dev/null +++ b/tools/ocaml/xenstored/dune @@ -0,0 +1,51 @@ +; fallback mode: the files may have been generated by configure already +; also for fallback mode either all files must be present or none +; hence the 2 separate rules here + +(rule + (targets oxenstored.conf) + (deps oxenstored.conf.in) + (mode fallback) + (action + (run ../../config.status --file=oxenstored.conf))) + +(rule + (targets paths.ml) + (deps paths.ml.in) + (mode fallback) + (action + (run ../../config.status --file=paths.ml))) + +(executable + (modes native) + (name xenstored) + (modules + (:standard \ syslog systemd)) + (flags + (:standard -w -52)) + (libraries unix xen.bus xen.mmap xen.ctrl xen.eventchn xenstubs)) + +(install + (package xenstored) + (section sbin) + (files + (xenstored.exe as oxenstored))) + +(install + (package xen) + (section etc) + (files oxenstored.conf)) + +(library + (foreign_stubs + (language c) + (names syslog_stubs systemd_stubs select_stubs) + (extra_deps ../../dune-workspace) + (flags + (:standard -DHAVE_SYSTEMD))) + (modules syslog systemd) + (name xenstubs) + (wrapped false) + (libraries unix) + (no_dynlink) + (c_library_flags -lsystemd)) From patchwork Fri Jul 29 17:53:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?RWR3aW4gVMO2csO2aw==?= X-Patchwork-Id: 12932767 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 D45FCC00144 for ; Fri, 29 Jul 2022 17:54:37 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.377694.611041 (Exim 4.92) (envelope-from ) id 1oHUBw-0000B5-T8; Fri, 29 Jul 2022 17:54:28 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 377694.611041; Fri, 29 Jul 2022 17:54:28 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oHUBw-0000Ad-NR; Fri, 29 Jul 2022 17:54:28 +0000 Received: by outflank-mailman (input) for mailman id 377694; Fri, 29 Jul 2022 17:54:27 +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 1oHUBu-0006Zx-VN for xen-devel@lists.xenproject.org; Fri, 29 Jul 2022 17:54:27 +0000 Received: from esa4.hc3370-68.iphmx.com (esa4.hc3370-68.iphmx.com [216.71.155.144]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 7ac7730c-0f67-11ed-bd2d-47488cf2e6aa; Fri, 29 Jul 2022 19:54:25 +0200 (CEST) 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: 7ac7730c-0f67-11ed-bd2d-47488cf2e6aa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1659117265; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZFznG8baVkBRD0RFiw68lK6To7/I2LLnkXE/qkikiGI=; b=IbLSyBHZFq/3deZHRCWu+D5aONwlTXaGAPXLRFraEJTBi5P8JZ1hFW9+ VGww3rEStcdTrUOKa5R0yWsxF7JjOxIJopjPIn14V6pZfKa75L4wpeyJ/ mIFAdQ9mxKtQpVzJMuWmGwZV0/HbzKRXTHQnlChXyeHQRbkXoyR32DmYh w=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 2.7 X-MesageID: 79518995 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:esanYaOzg4HxfsnvrR2Bl8FynXyQoLVcMsEvi/4bfWQNrUoq0TJTn DBNCDuOM/mPMzT0e4hybYS0/BgGvJ/Sm4JnTwto+SlhQUwRpJueD7x1DKtR0wB+jCHnZBg6h ynLQoCYdKjYdleF+lH3dOCJQUBUjcmgXqD7BPPPJhd/TAplTDZJoR94kqsyj5UAbeKRWmthg vuv5ZyEULOZ82QsaDhMtPjS8EkHUMna41v0gHRvPZing3eG/5UlJMp3Db28KXL+Xr5VEoaSL woU5Ojklo9x105F5uKNyt4XQGVTKlLhFVHmZk5tc7qjmnB/Shkaic7XAha+hXB/0F1ll/gpo DlEWAfZpQ0BZsUgk8xFO/VU/r0X0QSrN9YrLFDm2fF/wXEqfFPH//RTMGMJPbER/8BlIkNB9 uQmLBASO0Xra+KemNpXS8Fpj8UnasLqIJkeqjdryjSx4fQOGM6ZBf+QvJkBgWl21psm8fX2P qL1bRJiYArBZVtTPU0QC7o1nfuyh2m5eDpdwL6QjfVmvjGDnV0suFTrGIXNVuK4WeBcpAWdn F7p4FbbWio0LsPKnFJp9Vrz37SSzEsXQrk6FqC89/NsqE2ewCoUEhJ+fUS/iem0jAi5Qd03A 0Ad5CcGt6U5802vCN7nUHWQsHOC+xIRRddUO+k78x2WjLrZ5R6DAWoJRSIHb8Yp3Oc0TzE30 l6Cn/vyGCdi9raSTBq17ayIpDm/PSwUK24qZiIeSwYBpd75r+kOYgnnF4g5VvTv15usRG+2k 2viQDUCa6s7pvIK6pmZwlD7ijeKtLvrQQ0t2AH3QTfwhu9mX7JJd7BE+HCCs6sRdNvIEwHQ1 JQXs5PAtb5TVPlhgATIGbxQR+/xup5pJRWG2TZS848dGyNBEpJJVaRZ+3lAKUhgKa7okhe5M RaI6Wu9CHK+VUZGjJObgKrrUqzGNYC6SbzYugn8N7KimKRZeg6d5z1JbkWNxW3rm0VEufhhZ MbDKp33XSpFU/sPIN+KqwA1iOVD+8zD7TmLGcCTI+qPitJym0J5uZ9aaQDTP4jVHYuPoRnP8 sY3CvZmPy53CbSmCgGKoNF7ELz/BSJkbXwAg5AIK7Xrz8sPMD1JNsI9Npt7J9U8z/wOyrqgE 7PUchYw9WcTTEbvcW2iAk2PopuzNXqjhRrX5RARAGs= IronPort-HdrOrdr: A9a23:ID6w9KvvymmH4rJE/dy/2VOu7skDTtV00zEX/kB9WHVpmszxra 6TdZMgpGbJYVcqKRcdcL+7WJVoLUmxyXcx2/h1AV7AZniAhILLFvAA0WKK+VSJcEeSygce79 YFT0EXMqyJMbEQt6fHCWeDfOrIuOP3kpyVuQ== X-IronPort-AV: E=Sophos;i="5.93,201,1654574400"; d="scan'208";a="79518995" From: =?utf-8?b?RWR3aW4gVMO2csO2aw==?= To: CC: =?utf-8?b?RWR3aW4gVMO2csO2aw==?= , "Andrew Cooper" , George Dunlap , Jan Beulich , Julien Grall , "Stefano Stabellini" , Wei Liu , Christian Lindig , David Scott , Anthony PERARD Subject: [PATCH v1 4/7] tools/ocaml: Makefile to drive dune Date: Fri, 29 Jul 2022 18:53:27 +0100 Message-ID: <322ec0c9af480e9b8a6246d0a2cdb4e308a5900c.1659116941.git.edvin.torok@citrix.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 create a separate Makefile that can be used to drive dune. Usage: `make -f Makefile.dune` There are some files that need to be created by the Makefile based build system (such as all the C code in $(XEN_ROOT)/tools/libs), and those need to exist before dune runs. Although it'd be possible to automatically call the necessary makefile rules from dune, it wouldn't work reliably: * dune uses sandboxing by default (only files declared or known as dependencies are visible to individual build commands, symlinks/hardlinks are used by dune to implement this) * the dune builds always run in a _build subdir, and calling the makefiles from there would get the wrong XEN_ROOT set * running the make command in the source tree would work, but dune still wouldn't immediately see the build dependencies since they wouldn't have been copied/linked under _build The approach here is to: * use the Makefile to build C-only prerequisites (i.e. most of Xen) * use Dune only to build the OCaml parts once the C prerequisites exist * dune has dependencies declared on the C bits, so if they are missing you will get an error about a missing rule to create them instead of a cryptic compilation error * dune is still optional - the old Makefile based buildsystem is still there for now * use dune exclusively for new code going forward (e.g. OCaml test-suites) The workspace file needs to be generated by make because this currently cannot be generated by dune, and it doesn't support including external files. But could be generated by configure? LD_LIBRARY_PATH needs to be set, because even with -Wl,-rpath executables wouldn't be able to run using the just-built libraries, unless we'd also link all the transitive dependencies of libs. No functional change. Signed-off-by: Edwin Török --- Makefile | 5 ++ tools/ocaml/Makefile.dune | 88 +++++++++++++++++++++++++++++++ tools/ocaml/dune-workspace.dev.in | 2 + tools/ocaml/dune-workspace.in | 18 +++++++ 4 files changed, 113 insertions(+) create mode 100644 tools/ocaml/Makefile.dune create mode 100644 tools/ocaml/dune-workspace.dev.in create mode 100644 tools/ocaml/dune-workspace.in diff --git a/Makefile b/Makefile index b93b22c752..ddb33c3555 100644 --- a/Makefile +++ b/Makefile @@ -68,6 +68,11 @@ build-tools-oxenstored: build-tools-public-headers $(MAKE) -s -C tools/libs $(MAKE) -C tools/ocaml build-tools-oxenstored +.PHONY: build-tools-oxenstored-prepare +build-tools-oxenstored-prepare: build-tools-public-headers + test -f tools/config.status || (cd tools && ./configure --with-xenstored=oxenstored) + $(MAKE) -C tools/libs V= + .PHONY: build-stubdom build-stubdom: mini-os-dir build-tools-public-headers $(MAKE) -C stubdom build diff --git a/tools/ocaml/Makefile.dune b/tools/ocaml/Makefile.dune new file mode 100644 index 0000000000..eca9cac0ca --- /dev/null +++ b/tools/ocaml/Makefile.dune @@ -0,0 +1,88 @@ +XEN_ROOT = $(CURDIR)/../.. +all: dune-all-check + +# Dune by default uses all available CPUs. Make doesn't. +# Query the available CPUs and use all available for any of the make rules we call out to. +# -O is also needed with parallel make such that the build error and the build command causing +# the error are close together and not interspersed with other output +NPROC=$(shell getconf _NPROCESSORS_ONLN) +MAKEN=$(MAKE) -j$(NPROC) -O + +# We want to link and use the Xen libraries built locally +# without installing them system-wide +# (the system-wide one installed from packages will likely be too old and not match the locally +# built one anyway). +# +# Set LIBRARY_PATH and LD_LIBRARY_PATH so that the linker +# finds the proper libraries and the various dune commands +# work (e.g. running tests, utop, etc.). +# +# The Makefile based buildsystem would use -Wl,-rpath-link= here, +# but that only works during linking, not runtime. +# There is a -Wl, -rpath= that can be used, but that only works +# for libraries linked directly to the main executable: +# the dependencies of those libraries won't get found on the rpath +# (the rpath of the executable is apparently not used during that search). +# +# Use environment variables, because that way we don't make any permanent alternations (rpath) +# to the executable, so once installed system-wide it won't refer to build paths anymore. +# +# Dune cannot be used to generate this file: the env-vars stanza doesn't support %{read:}, :include, +# and dune-workspace doesn't support (include) stanzas. +# So for now generate it from this Makefile +# Cannot start with comment, so add auto-generated comment at the end +LIB_DIRS=$(abspath $(wildcard ../libs/*/.)) +LIBRARY_PATH=$(subst $(eval) ,:,$(LIB_DIRS)) +../dune-workspace ../dune-workspace.dev: dune-workspace.in dune-workspace.dev.in Makefile.dune + @( sed -e "s|@LIBRARY_PATH@|$(LIBRARY_PATH)|" <$< \ + && echo "; DO NOT EDIT: autogenerated from ocaml/dune-workspace.in") >../dune-workspace + @cat ../dune-workspace dune-workspace.dev.in >../dune-workspace.dev + +# for location of various libs which moves between Xen versions +include $(XEN_ROOT)/tools/Rules.mk + +XEN_DEPS=$(XEN_libxenctrl)/libxenctrl.so +XEN_DEPS+=$(XEN_libxenevtchn)/libxenevtchn.so +XEN_DEPS+=$(XEN_libxenguest)/libxenguest.so + +# Cannot be generated from dune +# Tell the user how to generate them +../include/xen/xen.h ../config.status $(XEN_DEPS): + echo "Missing C headers or libraries" >&2 + echo "Run make -C $(XEN_ROOT) build-tools-oxenstored-prepare -j$$(nproc)" >&2 + exit 1 + +# dune would refuse to run if there are build artifacts in the source directory +# if we detect anything then run make clean to ensure these are removed +# don't always call 'make clean' because it takes ~1.6s +.PHONY: dune-pre +dune-pre: ../config.status | ../include/xen/xen.h ../dune-workspace $(XEN_DEPS) + $(MAKEN) clean -s + +# Convenience targets +dune-syntax-check: dune-pre + dune build @check + +dune-all-check: dune-pre ../dune-workspace.dev + # Test build with multiple compiler versions + # requires opam switches for each to be already installed + dune build --workspace=../dune-workspace.dev @check @install @runtest + +check: dune-pre + dune runtest --no-buffer + +# approximatively equivalent to Dune 3.0 --release mode +dune-oxenstored: dune-pre + dune build --root .. --ignore-promoted-rules --no-config \ + --profile release --always-show-command-line \ + --promote-install-files --default-target @install + +-include $(XEN_ROOT)/config/Paths.mk + +# skip doc, it'd install an extra LICENSE file that is already installed by other rules +INSTALL_SECTIONS=bin,etc,lib,sbin +dune-install: dune-oxenstored + dune install --destdir=$(DESTDIR) --prefix=$(prefix) --libdir=$(shell ocamlfind printconf destdir) --mandir=$(mandir) --etcdir=$(sysconfdir) --docdir=$(docdir) --sections=$(INSTALL_SECTIONS) + +dune-uninstall: dune-oxenstored + dune uninstall --destdir=$(DESTDIR) --prefix=$(prefix) --libdir=$(shell ocamlfind printconf destdir) --mandir=$(mandir) --etcdir=$(sysconfdir) --docdir=$(docdir) diff --git a/tools/ocaml/dune-workspace.dev.in b/tools/ocaml/dune-workspace.dev.in new file mode 100644 index 0000000000..2ca831a048 --- /dev/null +++ b/tools/ocaml/dune-workspace.dev.in @@ -0,0 +1,2 @@ +(context default) +(context (opam (switch 4.02.3) (profile release))) diff --git a/tools/ocaml/dune-workspace.in b/tools/ocaml/dune-workspace.in new file mode 100644 index 0000000000..c963a6e599 --- /dev/null +++ b/tools/ocaml/dune-workspace.in @@ -0,0 +1,18 @@ +(lang dune 2.1) + +(env + ; we need to support older compilers so don't make deprecation warnings fatal + (dev + (flags (:standard -w -3)) + (env-vars + (LD_LIBRARY_PATH @LIBRARY_PATH@) + (LIBRARY_PATH @LIBRARY_PATH@) + )) + (release + (env-vars + (OCAMLRUNPARAM b) + (LD_LIBRARY_PATH @LIBRARY_PATH@) + (LIBRARY_PATH @LIBRARY_PATH@) + ) + (flags (:standard -strict-sequence -strict-formats -principal -w @18)) + (ocamlopt_flags -nodynlink))) From patchwork Fri Jul 29 17:53:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?RWR3aW4gVMO2csO2aw==?= X-Patchwork-Id: 12932768 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 00E01C19F2A for ; Fri, 29 Jul 2022 17:54:38 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.377699.611052 (Exim 4.92) (envelope-from ) id 1oHUBz-0000dw-9a; Fri, 29 Jul 2022 17:54:31 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 377699.611052; Fri, 29 Jul 2022 17:54:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oHUBz-0000dk-4Q; Fri, 29 Jul 2022 17:54:31 +0000 Received: by outflank-mailman (input) for mailman id 377699; Fri, 29 Jul 2022 17:54:29 +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 1oHUBx-0006Zx-2b for xen-devel@lists.xenproject.org; Fri, 29 Jul 2022 17:54:29 +0000 Received: from esa4.hc3370-68.iphmx.com (esa4.hc3370-68.iphmx.com [216.71.155.144]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 7cbaafe1-0f67-11ed-bd2d-47488cf2e6aa; Fri, 29 Jul 2022 19:54:27 +0200 (CEST) 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: 7cbaafe1-0f67-11ed-bd2d-47488cf2e6aa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1659117266; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Az58JwMLVZkj1Ei7e6Y6lR0AqnGVV5NLUNwkk9VU3V0=; b=Jlhn8u6gWPEbFHlsvTO0RPvDzp6QNPXdL6zm6eZwk0J5ottiP1UHxeQn kjmwQawzfVOWBHL+VmJg9PtADKFPrCZFZoo8mgystQDt9sNgeA0Ge3Ilo KLBduMmrFMfeuQCr8nLLVH4C7aNZqtSyWCYzrZfBYO/rls3Wt+tQJCDzj s=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 2.7 X-MesageID: 79518996 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:S8MQZ6No38QbSrbvrR3Gl8FynXyQoLVcMsEvi/4bfWQNrUol0TYEz mZOWGmDPfaJNGb2fNp2OoXk9EMB6p7Rx9M1SQto+SlhQUwRpJueD7x1DKtR0wB+jCHnZBg6h ynLQoCYdKjYdleF+lH3dOCJQUBUjcmgXqD7BPPPJhd/TAplTDZJoR94kqsyj5UAbeKRWmthg vuv5ZyEULOZ82QsaDhMtPjS8EkHUMna41v0gHRvPZing3eG/5UlJMp3Db28KXL+Xr5VEoaSL woU5Ojklo9x105F5uKNyt4XQGVTKlLhFVHmZk5tc7qjmnB/Shkaic7XAha+hXB/0F1ll/gpo DlEWAfZpQ0BZsUgk8xFO/VU/r0X0QSrN9YrLFDm2fF/wXEqfFPH//RTMGMJPbER/8BlIkNB9 uQmLBASO0Xra+KemNpXS8Fpj8UnasLqIJkeqjdryjSx4fQOGM6ZBf+QvJkBgWl21psm8fX2P qL1bRJiYArBZVtTPU0QC7o1nfuyh2m5eDpdwL6QjfVmvjGDnV0vuFTrGOrIX/KQReJbp2K// Gb432HWAg0aDMPKnFJp9Vrz37SSzEsXQrk6C7mQ5vNsxlqJyQQ7BBQIWHOhrPK+i0r4XMhQQ 2QE9yxroaUs+UiDStjmQwb+sHOCpgQbWddbD6s98g7l90bPy1/HXC5eFGcHMYF48p9tLdA36 rOXt/jVBAFTkoKVdXuY0KW3jzyxIRYRDXBXMEfoUjA5D8nfTJAb10ySH44+QfPt37UZChmrn WnU8XFWa6E7yJdSiv7lpQ2vbyeE/MChc+Ij2unAsotJBCtdbZXtWYGn4EOzAR1ofNfAFQnpU JTpdqGjAAEy4XKlznXlrB0lRu3B2hp8GGS0baRTN5cg7S+x3HWoYJpd5jpzTG8wbJtVIWSyO x+P5lkOjHO2AJdNRfYtC79d9uxwlfSwfTgbfqu8giVyjmhZK1bcoXAGib+41GHxikk8+ZwC1 WOgWZ/1VR4yVPU4pAdass9HjtfHMAhimj6ILX06pjz7uYejiIm9E+tcaQvWNbxkhE5GyS2Mm +ti2wKx4003eIXDjuP/reb/8XhiwaAHOK3L IronPort-HdrOrdr: A9a23:oHPZ1qC5ABWX6+DlHemU55DYdb4zR+YMi2TC1yhKJyC9Ffbo7v xG/c5rsyMc5wxwZJhNo7y90ey7MBbhHP1OkO4s1NWZLWrbUQKTRekIh+bfKn/baknDH4ZmpN 9dmsNFaeEYY2IUsS+D2njbL+od X-IronPort-AV: E=Sophos;i="5.93,201,1654574400"; d="scan'208";a="79518996" From: =?utf-8?b?RWR3aW4gVMO2csO2aw==?= To: CC: =?utf-8?b?RWR3aW4gVMO2csO2aw==?= , "Christian Lindig" , David Scott , Wei Liu , Anthony PERARD Subject: [PATCH v1 5/7] tools/ocaml: fix compiler warnings Date: Fri, 29 Jul 2022 18:53:28 +0100 Message-ID: <23dcc916bff25d0545c167833d99aa73b8a4c8da.1659116941.git.edvin.torok@citrix.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Fix compiler warning about: * unused value * ambiguous documentation comment * non-principal type inference (compiler version dependent) No functional change. Signed-off-by: Edwin Török Acked-by: Christian Lindig > --- tools/ocaml/xenstored/connection.ml | 2 +- tools/ocaml/xenstored/process.ml | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/ocaml/xenstored/connection.ml b/tools/ocaml/xenstored/connection.ml index 65f99ea6f2..a94d47cdc2 100644 --- a/tools/ocaml/xenstored/connection.ml +++ b/tools/ocaml/xenstored/connection.ml @@ -313,7 +313,7 @@ let is_bad con = match con.dom with None -> false | Some dom -> Domain.is_bad_do let has_extra_connection_data con = let has_in = has_input con || has_partial_input con in let has_out = has_output con in - let has_socket = con.dom = None in + let _has_socket = con.dom = None in let has_nondefault_perms = make_perm con.dom <> con.perm in has_in || has_out (* TODO: what about SIGTERM, should use systemd to store FDS diff --git a/tools/ocaml/xenstored/process.ml b/tools/ocaml/xenstored/process.ml index 27790d4a5c..86eed02413 100644 --- a/tools/ocaml/xenstored/process.ml +++ b/tools/ocaml/xenstored/process.ml @@ -59,7 +59,7 @@ let split_one_path data con = let process_watch t cons = let oldroot = t.Transaction.oldroot in - let newroot = Store.get_root t.store in + let newroot = Store.get_root t.Transaction.store in let ops = Transaction.get_paths t |> List.rev in let do_op_watch op cons = let recurse, oldroot, root = match (fst op) with @@ -491,7 +491,7 @@ let transaction_replay c t doms cons = ignore @@ Connection.end_transaction c tid None ) -let do_watch con t _domains cons data = +let do_watch con _t _domains cons data = let (node, token) = match (split None '\000' data) with | [node; token; ""] -> node, token @@ -651,6 +651,7 @@ let maybe_ignore_transaction = function let () = Printexc.record_backtrace true + (** * Nothrow guarantee. *) From patchwork Fri Jul 29 17:53:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?RWR3aW4gVMO2csO2aw==?= X-Patchwork-Id: 12932765 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 BDA60C19F2A for ; Fri, 29 Jul 2022 17:54:26 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.377688.610996 (Exim 4.92) (envelope-from ) id 1oHUBi-00076l-Fc; Fri, 29 Jul 2022 17:54:14 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 377688.610996; Fri, 29 Jul 2022 17:54:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oHUBi-00076c-Bx; Fri, 29 Jul 2022 17:54:14 +0000 Received: by outflank-mailman (input) for mailman id 377688; Fri, 29 Jul 2022 17:54:13 +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 1oHUBg-0006a9-SJ for xen-devel@lists.xenproject.org; Fri, 29 Jul 2022 17:54:12 +0000 Received: from esa2.hc3370-68.iphmx.com (esa2.hc3370-68.iphmx.com [216.71.145.153]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 73981336-0f67-11ed-924f-1f966e50362f; Fri, 29 Jul 2022 19:54:11 +0200 (CEST) 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: 73981336-0f67-11ed-924f-1f966e50362f DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1659117251; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YsqAUruZxEJZb5m63knmpMxcbbh9Lwsahf6qP5J6SRg=; b=csiKeO3Qi3BK7huzdBDZRIfrD21iNnMzO0rF22E5T++Ui8ZVT9tRzwBy y2nSUVUj/bWBsuvmzpY5e5xEqx9ruzhBXOGENRAzIEbPH54lyANAungxW sSjncoCZq4hIek7L3zkruR+dSzBr9Z67/UBY0Uuw5VOA/MLvOxrYBl9t4 M=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 2.7 X-MesageID: 76954909 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23: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 X-IronPort-AV: E=Sophos;i="5.93,201,1654574400"; d="scan'208";a="76954909" From: =?utf-8?b?RWR3aW4gVMO2csO2aw==?= To: CC: =?utf-8?b?RWR3aW4gVMO2csO2aw==?= , "Christian Lindig" , David Scott , Wei Liu , Anthony PERARD Subject: [PATCH v1 6/7] tools/ocaml/libs/xb: hide type of Xb.t Date: Fri, 29 Jul 2022 18:53:29 +0100 Message-ID: <74ab9ad3ed031654fbfc343f299cedba2ebe3ac9.1659116941.git.edvin.torok@citrix.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 The only user of 'xb' that I can find is in-tree oxenstored. Other code (e.g. xenopsd) would use the mirage 'xenstore' implementation instead, so changing the API here shouldn't require anyone to update their code. Hiding the type will make it easier to change the implementation in the future without breaking code that relies on it. No functional change. Signed-off-by: Edwin Török --- tools/ocaml/libs/xb/xb.ml | 3 +++ tools/ocaml/libs/xb/xb.mli | 9 ++------- tools/ocaml/xenstored/connection.ml | 8 ++------ 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/tools/ocaml/libs/xb/xb.ml b/tools/ocaml/libs/xb/xb.ml index 104d319d77..8404ddd8a6 100644 --- a/tools/ocaml/libs/xb/xb.ml +++ b/tools/ocaml/libs/xb/xb.ml @@ -196,6 +196,9 @@ let peek_output con = Queue.peek con.pkt_out let input_len con = Queue.length con.pkt_in let has_in_packet con = Queue.length con.pkt_in > 0 let get_in_packet con = Queue.pop con.pkt_in +let has_partial_input con = match con.partial_in with + | HaveHdr _ -> true + | NoHdr (n, _) -> n < Partial.header_size () let has_more_input con = match con.backend with | Fd _ -> false diff --git a/tools/ocaml/libs/xb/xb.mli b/tools/ocaml/libs/xb/xb.mli index 3a00da6cdd..794e35bb34 100644 --- a/tools/ocaml/libs/xb/xb.mli +++ b/tools/ocaml/libs/xb/xb.mli @@ -66,13 +66,7 @@ type backend_mmap = { type backend_fd = { fd : Unix.file_descr; } type backend = Fd of backend_fd | Xenmmap of backend_mmap type partial_buf = HaveHdr of Partial.pkt | NoHdr of int * bytes -type t = { - backend : backend; - pkt_in : Packet.t Queue.t; - pkt_out : Packet.t Queue.t; - mutable partial_in : partial_buf; - mutable partial_out : string; -} +type t val init_partial_in : unit -> partial_buf val reconnect : t -> unit val queue : t -> Packet.t -> unit @@ -97,6 +91,7 @@ val has_output : t -> bool val peek_output : t -> Packet.t val input_len : t -> int val has_in_packet : t -> bool +val has_partial_input : t -> bool val get_in_packet : t -> Packet.t val has_more_input : t -> bool val is_selectable : t -> bool diff --git a/tools/ocaml/xenstored/connection.ml b/tools/ocaml/xenstored/connection.ml index a94d47cdc2..0ce54cd7f9 100644 --- a/tools/ocaml/xenstored/connection.ml +++ b/tools/ocaml/xenstored/connection.ml @@ -125,9 +125,7 @@ let get_perm con = let set_target con target_domid = con.perm <- Perms.Connection.set_target (get_perm con) ~perms:[Perms.READ; Perms.WRITE] target_domid -let is_backend_mmap con = match con.xb.Xenbus.Xb.backend with - | Xenbus.Xb.Xenmmap _ -> true - | _ -> false +let is_backend_mmap con = Xenbus.Xb.is_mmap con.xb let send_reply con tid rid ty data = if (String.length data) > xenstore_payload_max && (is_backend_mmap con) then @@ -280,9 +278,7 @@ let get_transaction con tid = let do_input con = Xenbus.Xb.input con.xb let has_input con = Xenbus.Xb.has_in_packet con.xb -let has_partial_input con = match con.xb.Xenbus.Xb.partial_in with - | HaveHdr _ -> true - | NoHdr (n, _) -> n < Xenbus.Partial.header_size () +let has_partial_input con = Xenbus.Xb.has_partial_input con.xb let pop_in con = Xenbus.Xb.get_in_packet con.xb let has_more_input con = Xenbus.Xb.has_more_input con.xb From patchwork Fri Jul 29 17:53:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?RWR3aW4gVMO2csO2aw==?= X-Patchwork-Id: 12932763 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 DE9E0C19F2C for ; Fri, 29 Jul 2022 17:54:26 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.377687.610986 (Exim 4.92) (envelope-from ) id 1oHUBg-0006pq-7V; Fri, 29 Jul 2022 17:54:12 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 377687.610986; Fri, 29 Jul 2022 17:54:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oHUBg-0006pj-4g; Fri, 29 Jul 2022 17:54:12 +0000 Received: by outflank-mailman (input) for mailman id 377687; Fri, 29 Jul 2022 17:54:11 +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 1oHUBf-0006a9-6e for xen-devel@lists.xenproject.org; Fri, 29 Jul 2022 17:54:11 +0000 Received: from esa2.hc3370-68.iphmx.com (esa2.hc3370-68.iphmx.com [216.71.145.153]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 71941a78-0f67-11ed-924f-1f966e50362f; Fri, 29 Jul 2022 19:54:09 +0200 (CEST) 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: 71941a78-0f67-11ed-924f-1f966e50362f DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1659117249; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VVD7G2LkVyNCzG/pHfe/kdLkRc8BoThzx8VPlS+iO60=; b=YlqEghSfC2dVITCfFJAh5TgyqqcIvFxtfI9TopN5DDx9N19z1CvPmmDF Oa5m4n6LAajMMLgUdw6X1+teSKVS5ypDt4/NfmgfVueVtg5OAJZLkkDTZ 1JspD7BlueJ01fLM0vC1obExgEb3DOugM1yjjeUyZzndj9iUqqryoR2Vx U=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 2.7 X-MesageID: 76954906 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23: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 X-IronPort-AV: E=Sophos;i="5.93,201,1654574400"; d="scan'208";a="76954906" From: =?utf-8?b?RWR3aW4gVMO2csO2aw==?= To: CC: =?utf-8?b?RWR3aW4gVMO2csO2aw==?= , "Christian Lindig" , David Scott , Wei Liu , Anthony PERARD Subject: [PATCH v1 7/7] tools/ocaml/libs/eventchn: do not leak event channels and OCaml 5.0 compat Date: Fri, 29 Jul 2022 18:53:30 +0100 Message-ID: <6e5fd9edfea379b69682fa538141298fc1bc3110.1659116941.git.edvin.torok@citrix.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Add a finalizer on the event channel value, so that it calls `xenevtchn_close` when the value would be GCed. In practice oxenstored seems to be the only user of this, and it creates a single global event channel only, but freeing this could still be useful when run with OCAMLRUNPARAM=c The code was previously casting a C pointer to an OCaml value, which should be avoided: OCaml 5.0 won't support it. (all "naked" C pointers must be wrapped inside an OCaml value, either an Abstract tag, or Nativeint, see the manual https://ocaml.org/manual/intfc.html#ss:c-outside-head) Signed-off-by: Edwin Török Acked-by: Christian Lindig > --- tools/ocaml/libs/eventchn/xeneventchn_stubs.c | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/tools/ocaml/libs/eventchn/xeneventchn_stubs.c b/tools/ocaml/libs/eventchn/xeneventchn_stubs.c index f889a7a2e4..c0d57e2954 100644 --- a/tools/ocaml/libs/eventchn/xeneventchn_stubs.c +++ b/tools/ocaml/libs/eventchn/xeneventchn_stubs.c @@ -33,7 +33,30 @@ #include #include -#define _H(__h) ((xenevtchn_handle *)(__h)) +/* We want to close the event channel when it is no longer in use, + which can only be done safely with a finalizer. + Event channels are typically long lived, so we don't need tighter control over resource deallocation. + Use a custom block +*/ + +/* Access the xenevtchn_t* part of the OCaml custom block */ +#define _H(__h) (*((xenevtchn_handle**)Data_custom_val(__h))) + +static void stub_evtchn_finalize(value v) +{ + /* docs say to not use any CAMLparam* macros here */ + xenevtchn_close(_H(v)); +} + +static struct custom_operations xenevtchn_ops = { + "xenevtchn", + stub_evtchn_finalize, + custom_compare_default, /* raises Failure, cannot compare */ + custom_hash_default, /* ignored */ + custom_serialize_default, /* raises Failure, can't serialize */ + custom_deserialize_default, /* raises Failure, can't deserialize */ + custom_compare_ext_default /* raises Failure */ +}; CAMLprim value stub_eventchn_init(void) { @@ -48,7 +71,9 @@ CAMLprim value stub_eventchn_init(void) if (xce == NULL) caml_failwith("open failed"); - result = (value)xce; + /* contains file descriptors, trigger full GC at least every 128 allocations */ + result = caml_alloc_custom(&xenevtchn_ops, sizeof(xce), 1, 128); + _H(result) = xce; CAMLreturn(result); }