From 89ffc4857609377a9c6db817301927b07785de2c Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Mon, 1 Mar 2021 16:06:35 +0100 Subject: [PATCH] depot_deploy: integrate shim and adapt sculpt Issue #3837 Issue #4029 --- repos/gems/recipes/pkg/sculpt/archives | 1 + repos/gems/run/depot_deploy.run | 2 + repos/gems/src/app/depot_deploy/child.h | 57 +++++++++++++++++++++++-- 3 files changed, 56 insertions(+), 4 deletions(-) diff --git a/repos/gems/recipes/pkg/sculpt/archives b/repos/gems/recipes/pkg/sculpt/archives index 0c9a8f5c42..b0b25774c8 100644 --- a/repos/gems/recipes/pkg/sculpt/archives +++ b/repos/gems/recipes/pkg/sculpt/archives @@ -46,3 +46,4 @@ _/src/fs_query _/src/fs_tool _/src/text_area _/src/sandbox +_/src/shim diff --git a/repos/gems/run/depot_deploy.run b/repos/gems/run/depot_deploy.run index f9a8842b07..a39155ea41 100644 --- a/repos/gems/run/depot_deploy.run +++ b/repos/gems/run/depot_deploy.run @@ -9,6 +9,7 @@ import_from_depot [depot_user]/src/[base_src] \ [depot_user]/src/init \ [depot_user]/src/vfs_ttf \ [depot_user]/src/libc \ + [depot_user]/src/shim \ [depot_user]/raw/ttf-bitstream-vera-minimal create_tar_from_depot_binaries [run_dir]/genode/depot.tar \ @@ -251,6 +252,7 @@ install_config { + diff --git a/repos/gems/src/app/depot_deploy/child.h b/repos/gems/src/app/depot_deploy/child.h index 285f4dcec6..19a96e10fc 100644 --- a/repos/gems/src/app/depot_deploy/child.h +++ b/repos/gems/src/app/depot_deploy/child.h @@ -347,7 +347,22 @@ void Depot_deploy::Child::gen_start_node(Xml_generator &xml, Xml_node common, if (version.valid()) xml.attribute("version", version); - xml.node("binary", [&] () { xml.attribute("name", _binary_name); }); + bool shim_reroute = false; + + /* lookup if PD/CPU service is configured and use shim in such cases */ + if (_start_xml->xml().has_sub_node("route")) { + Xml_node const route = _start_xml->xml().sub_node("route"); + + route.for_each_sub_node("service", [&] (Xml_node const &service) { + if (service.attribute_value("name", Name()) == "PD" || + service.attribute_value("name", Name()) == "CPU") + shim_reroute = true; }); + } + + Binary_name const binary = shim_reroute ? Binary_name("shim") + : _binary_name; + + xml.node("binary", [&] () { xml.attribute("name", binary); }); Number_of_bytes ram = _pkg_ram_quota; if (_defined_by_launcher()) @@ -456,6 +471,8 @@ void Depot_deploy::Child::_gen_routes(Xml_generator &xml, Xml_node common, Depot_rom_server const &cached_depot_rom, Depot_rom_server const &uncached_depot_rom) const { + bool route_binary_to_shim = false; + if (!_pkg_xml.constructed()) return; @@ -466,10 +483,38 @@ void Depot_deploy::Child::_gen_routes(Xml_generator &xml, Xml_node common, */ if (_start_xml->xml().has_sub_node("route")) { Xml_node const route = _start_xml->xml().sub_node("route"); - route.with_raw_content([&] (char const *start, size_t length) { - xml.append(start, length); }); + + route.for_each_sub_node("service", [&] (Xml_node const &service) { + Name const service_name = service.attribute_value("name", Name()); + + /* supplement env-session routes for the shim */ + if (service_name == "PD" || service_name == "CPU") { + route_binary_to_shim = true; + + xml.node("service", [&] () { + xml.attribute("name", service_name); + xml.attribute("unscoped_label", _name); + xml.node("parent", [&] () { }); + }); + } + + service.with_raw_node([&] (char const *start, size_t length) { + xml.append("\n\t\t\t"); + xml.append(start, length); + }); + }); } + /* + * If the subsystem is hosted under a shim, make the shim binary available + */ + if (route_binary_to_shim) + xml.node("service", [&] () { + xml.attribute("name", "ROM"); + xml.attribute("unscoped_label", "shim"); + xml.node("parent", [&] () { + xml.attribute("label", "shim"); }); }); + /* * Add routes given in the launcher definition. */ @@ -545,7 +590,11 @@ void Depot_deploy::Child::_gen_routes(Xml_generator &xml, Xml_node common, xml.node("service", [&] () { xml.attribute("name", "ROM"); - xml.attribute("label_last", label); + + if (route_binary_to_shim && label == _binary_name) + xml.attribute("label", "binary"); + else + xml.attribute("label_last", label); if (cached_depot_rom.valid()) { xml.node("child", [&] () {