mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-16 07:27:35 +00:00
os/buffered_xml.h: don't copy Xml_node
The public 'xml' const member replaces 'with_xml_node()' and the 'xml()' accessor. Issue #5411
This commit is contained in:
parent
05d69a0bb3
commit
7aefaff646
@ -62,8 +62,7 @@ class Dialog::Runtime : private Sandbox::State_handler
|
||||
Buffered_xml const config { _alloc, "config", [&] (Xml_generator &xml) {
|
||||
_generate_sandbox_config(xml); } };
|
||||
|
||||
config.with_xml_node([&] (Xml_node const &config) {
|
||||
_sandbox.apply_config(config); });
|
||||
_sandbox.apply_config(config.xml);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -77,9 +76,8 @@ class Dialog::Runtime : private Sandbox::State_handler
|
||||
|
||||
bool reconfiguration_needed = false;
|
||||
|
||||
state.with_xml_node([&] (Xml_node state) {
|
||||
if (_runtime.apply_sandbox_state(state))
|
||||
reconfiguration_needed = true; });
|
||||
if (_runtime.apply_sandbox_state(state.xml))
|
||||
reconfiguration_needed = true;
|
||||
|
||||
if (reconfiguration_needed)
|
||||
_update_sandbox_config();
|
||||
|
@ -167,7 +167,7 @@ class Decorator::Config
|
||||
Color result = Color::rgb(68, 75, 95);
|
||||
|
||||
try {
|
||||
Genode::Session_policy policy(title, _buffered_config->xml());
|
||||
Genode::Session_policy policy(title, _buffered_config->xml);
|
||||
result = policy.attribute_value("color", result);
|
||||
|
||||
} catch (Genode::Session_policy::No_policy_defined) { }
|
||||
@ -181,10 +181,10 @@ class Decorator::Config
|
||||
unsigned gradient_percent(Window_title const &title) const
|
||||
{
|
||||
unsigned result =
|
||||
_buffered_config->xml().attribute_value("gradient", 32U);
|
||||
_buffered_config->xml.attribute_value("gradient", 32U);
|
||||
|
||||
try {
|
||||
Genode::Session_policy policy(title, _buffered_config->xml());
|
||||
Genode::Session_policy policy(title, _buffered_config->xml);
|
||||
result = policy.attribute_value("gradient", result);
|
||||
|
||||
} catch (Genode::Session_policy::No_policy_defined) { }
|
||||
|
@ -260,12 +260,12 @@ void Child::gen_start_node(Xml_generator &xml,
|
||||
if (_defined_by_launcher() && !_launcher_xml.constructed())
|
||||
return;
|
||||
|
||||
if (!_pkg_xml->xml().has_sub_node("runtime")) {
|
||||
if (!_pkg_xml->xml.has_sub_node("runtime")) {
|
||||
warning("blueprint for '", _name, "' lacks runtime information");
|
||||
return;
|
||||
}
|
||||
|
||||
Xml_node const runtime = _pkg_xml->xml().sub_node("runtime");
|
||||
Xml_node const runtime = _pkg_xml->xml.sub_node("runtime");
|
||||
|
||||
xml.node("start", [&] () {
|
||||
|
||||
@ -273,13 +273,13 @@ void Child::gen_start_node(Xml_generator &xml,
|
||||
|
||||
unsigned long caps = _pkg_cap_quota;
|
||||
if (_defined_by_launcher())
|
||||
caps = _launcher_xml->xml().attribute_value("caps", caps);
|
||||
caps = _start_xml->xml().attribute_value("caps", caps);
|
||||
caps = _launcher_xml->xml.attribute_value("caps", caps);
|
||||
caps = _start_xml->xml.attribute_value("caps", caps);
|
||||
|
||||
xml.attribute("caps", caps);
|
||||
|
||||
using Version = String<64>;
|
||||
Version const version = _start_xml->xml().attribute_value("version", Version());
|
||||
Version const version = _start_xml->xml.attribute_value("version", Version());
|
||||
if (version.valid())
|
||||
xml.attribute("version", version);
|
||||
|
||||
@ -287,8 +287,8 @@ void Child::gen_start_node(Xml_generator &xml,
|
||||
|
||||
Number_of_bytes ram = _pkg_ram_quota;
|
||||
if (_defined_by_launcher())
|
||||
ram = _launcher_xml->xml().attribute_value("ram", ram);
|
||||
ram = _start_xml->xml().attribute_value("ram", ram);
|
||||
ram = _launcher_xml->xml.attribute_value("ram", ram);
|
||||
ram = _start_xml->xml.attribute_value("ram", ram);
|
||||
|
||||
xml.node("resource", [&] () {
|
||||
xml.attribute("name", "RAM");
|
||||
@ -300,11 +300,11 @@ void Child::gen_start_node(Xml_generator &xml,
|
||||
* the launcher definition (if a launcher is user), or the
|
||||
* blueprint. The former is preferred over the latter.
|
||||
*/
|
||||
if (_start_xml->xml().has_sub_node("config")) {
|
||||
_gen_copy_of_sub_node(xml, _start_xml->xml(), "config");
|
||||
if (_start_xml->xml.has_sub_node("config")) {
|
||||
_gen_copy_of_sub_node(xml, _start_xml->xml, "config");
|
||||
} else {
|
||||
if (_defined_by_launcher() && _launcher_xml->xml().has_sub_node("config")) {
|
||||
_gen_copy_of_sub_node(xml, _launcher_xml->xml(), "config");
|
||||
if (_defined_by_launcher() && _launcher_xml->xml.has_sub_node("config")) {
|
||||
_gen_copy_of_sub_node(xml, _launcher_xml->xml, "config");
|
||||
} else {
|
||||
if (runtime.has_sub_node("config"))
|
||||
_gen_copy_of_sub_node(xml, runtime, "config");
|
||||
@ -343,7 +343,7 @@ void Child::gen_start_node(Xml_generator &xml,
|
||||
|
||||
uint64_t max_timeout_sec = 0;
|
||||
try {
|
||||
Xml_node const runtime = _pkg_xml->xml().sub_node("runtime");
|
||||
Xml_node const runtime = _pkg_xml->xml.sub_node("runtime");
|
||||
|
||||
/*
|
||||
* The check for the <events> node is made only for compatibility with
|
||||
@ -428,8 +428,8 @@ void Child::_gen_routes(Xml_generator &xml,
|
||||
/*
|
||||
* Add routes given in the start node.
|
||||
*/
|
||||
if (_start_xml->xml().has_sub_node("route")) {
|
||||
Xml_node const route = _start_xml->xml().sub_node("route");
|
||||
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); });
|
||||
}
|
||||
@ -437,8 +437,8 @@ void Child::_gen_routes(Xml_generator &xml,
|
||||
/*
|
||||
* Add routes given in the launcher definition.
|
||||
*/
|
||||
if (_launcher_xml.constructed() && _launcher_xml->xml().has_sub_node("route")) {
|
||||
Xml_node const route = _launcher_xml->xml().sub_node("route");
|
||||
if (_launcher_xml.constructed() && _launcher_xml->xml.has_sub_node("route")) {
|
||||
Xml_node const route = _launcher_xml->xml.sub_node("route");
|
||||
route.with_raw_content([&] (char const *start, size_t length) {
|
||||
xml.append(start, length); });
|
||||
}
|
||||
@ -462,7 +462,7 @@ void Child::_gen_routes(Xml_generator &xml,
|
||||
* within the depot.
|
||||
*/
|
||||
if (_config_name.valid()) {
|
||||
_pkg_xml->xml().for_each_sub_node("rom", [&] (Xml_node rom) {
|
||||
_pkg_xml->xml.for_each_sub_node("rom", [&] (Xml_node rom) {
|
||||
|
||||
if (!rom.has_attribute("path"))
|
||||
return;
|
||||
@ -498,7 +498,7 @@ void Child::_gen_routes(Xml_generator &xml,
|
||||
* Add ROM routing rule with the label rewritten to the path within the
|
||||
* depot.
|
||||
*/
|
||||
_pkg_xml->xml().for_each_sub_node("rom", [&] (Xml_node rom) {
|
||||
_pkg_xml->xml.for_each_sub_node("rom", [&] (Xml_node rom) {
|
||||
|
||||
if (!rom.has_attribute("path"))
|
||||
return;
|
||||
@ -534,7 +534,7 @@ bool Child::_defined_by_launcher() const
|
||||
* If the <start> node lacks a 'pkg' attribute, we expect the
|
||||
* policy to be defined by a launcher XML snippet.
|
||||
*/
|
||||
return _start_xml.constructed() && !_start_xml->xml().has_attribute("pkg");
|
||||
return _start_xml.constructed() && !_start_xml->xml.has_attribute("pkg");
|
||||
}
|
||||
|
||||
|
||||
@ -544,9 +544,9 @@ Archive::Path Child::_config_pkg_path() const
|
||||
return Archive::Path(); }
|
||||
|
||||
if (_defined_by_launcher() && _launcher_xml.constructed())
|
||||
return _launcher_xml->xml().attribute_value("pkg", Archive::Path());
|
||||
return _launcher_xml->xml.attribute_value("pkg", Archive::Path());
|
||||
|
||||
return _start_xml->xml().attribute_value("pkg", Archive::Path());
|
||||
return _start_xml->xml.attribute_value("pkg", Archive::Path());
|
||||
}
|
||||
|
||||
|
||||
@ -558,10 +558,10 @@ Child::Launcher_name Child::_launcher_name() const
|
||||
if (!_defined_by_launcher())
|
||||
return Launcher_name();
|
||||
|
||||
if (_start_xml->xml().has_attribute("launcher"))
|
||||
return _start_xml->xml().attribute_value("launcher", Launcher_name());
|
||||
if (_start_xml->xml.has_attribute("launcher"))
|
||||
return _start_xml->xml.attribute_value("launcher", Launcher_name());
|
||||
|
||||
return _start_xml->xml().attribute_value("name", Launcher_name());
|
||||
return _start_xml->xml.attribute_value("name", Launcher_name());
|
||||
}
|
||||
|
||||
|
||||
@ -607,7 +607,7 @@ Child::Child(Allocator &alloc,
|
||||
_skip { start_node.attribute_value("skip", false) },
|
||||
_alloc { alloc },
|
||||
_start_xml { _alloc, start_node },
|
||||
_name { _start_xml->xml().attribute_value("name", Name()) },
|
||||
_name { _start_xml->xml.attribute_value("name", Name()) },
|
||||
_timer { timer },
|
||||
_config_handler { config_handler }
|
||||
{ }
|
||||
@ -674,7 +674,7 @@ void Child::apply_config(Xml_node start_node)
|
||||
if (_skip)
|
||||
return;
|
||||
|
||||
if (!start_node.differs_from(_start_xml->xml()))
|
||||
if (!start_node.differs_from(_start_xml->xml))
|
||||
return;
|
||||
|
||||
Archive::Path const old_pkg_path = _config_pkg_path();
|
||||
@ -736,7 +736,7 @@ void Child::apply_launcher(Launcher_name const &name,
|
||||
if (_launcher_name() != name)
|
||||
return;
|
||||
|
||||
if (_launcher_xml.constructed() && !launcher.differs_from(_launcher_xml->xml()))
|
||||
if (_launcher_xml.constructed() && !launcher.differs_from(_launcher_xml->xml))
|
||||
return;
|
||||
|
||||
_launcher_xml.construct(_alloc, launcher);
|
||||
|
@ -73,15 +73,15 @@ class Depot_deploy::Child : public List_model<Child>::Element
|
||||
* If the <start> node lacks a 'pkg' attribute, we expect the
|
||||
* policy to be defined by a launcher XML snippet.
|
||||
*/
|
||||
return _start_xml.constructed() && !_start_xml->xml().has_attribute("pkg");
|
||||
return _start_xml.constructed() && !_start_xml->xml.has_attribute("pkg");
|
||||
}
|
||||
|
||||
Archive::Path _config_pkg_path() const
|
||||
{
|
||||
if (_defined_by_launcher() && _launcher_xml.constructed())
|
||||
return _launcher_xml->xml().attribute_value("pkg", Archive::Path());
|
||||
return _launcher_xml->xml.attribute_value("pkg", Archive::Path());
|
||||
|
||||
return _start_xml->xml().attribute_value("pkg", Archive::Path());
|
||||
return _start_xml->xml.attribute_value("pkg", Archive::Path());
|
||||
}
|
||||
|
||||
Launcher_name _launcher_name() const
|
||||
@ -89,10 +89,10 @@ class Depot_deploy::Child : public List_model<Child>::Element
|
||||
if (!_defined_by_launcher())
|
||||
return Launcher_name();
|
||||
|
||||
if (_start_xml->xml().has_attribute("launcher"))
|
||||
return _start_xml->xml().attribute_value("launcher", Launcher_name());
|
||||
if (_start_xml->xml.has_attribute("launcher"))
|
||||
return _start_xml->xml.attribute_value("launcher", Launcher_name());
|
||||
|
||||
return _start_xml->xml().attribute_value("name", Launcher_name());
|
||||
return _start_xml->xml.attribute_value("name", Launcher_name());
|
||||
}
|
||||
|
||||
/*
|
||||
@ -156,7 +156,7 @@ class Depot_deploy::Child : public List_model<Child>::Element
|
||||
:
|
||||
_alloc(alloc),
|
||||
_start_xml(_alloc, start_node),
|
||||
_name(_start_xml->xml().attribute_value("name", Name()))
|
||||
_name(_start_xml->xml.attribute_value("name", Name()))
|
||||
{ }
|
||||
|
||||
Name name() const { return _name; }
|
||||
@ -166,7 +166,7 @@ class Depot_deploy::Child : public List_model<Child>::Element
|
||||
*/
|
||||
bool apply_config(Xml_node start_node)
|
||||
{
|
||||
if (!start_node.differs_from(_start_xml->xml()))
|
||||
if (!start_node.differs_from(_start_xml->xml))
|
||||
return false;
|
||||
|
||||
Archive::Path const old_pkg_path = _config_pkg_path();
|
||||
@ -243,7 +243,7 @@ class Depot_deploy::Child : public List_model<Child>::Element
|
||||
if (_launcher_name() != name)
|
||||
return false;
|
||||
|
||||
if (_launcher_xml.constructed() && !launcher.differs_from(_launcher_xml->xml()))
|
||||
if (_launcher_xml.constructed() && !launcher.differs_from(_launcher_xml->xml))
|
||||
return false;
|
||||
|
||||
_launcher_xml.construct(_alloc, launcher);
|
||||
@ -261,11 +261,11 @@ class Depot_deploy::Child : public List_model<Child>::Element
|
||||
Condition const orig_condition = _condition;
|
||||
|
||||
Xml_node launcher_xml = _launcher_xml.constructed()
|
||||
? _launcher_xml->xml()
|
||||
? _launcher_xml->xml
|
||||
: Xml_node("<empty/>");
|
||||
|
||||
if (_start_xml.constructed())
|
||||
_condition = cond_fn(_start_xml->xml(), launcher_xml)
|
||||
_condition = cond_fn(_start_xml->xml, launcher_xml)
|
||||
? SATISFIED : UNSATISFIED;
|
||||
|
||||
return _condition != orig_condition;
|
||||
@ -274,11 +274,11 @@ class Depot_deploy::Child : public List_model<Child>::Element
|
||||
void apply_if_unsatisfied(auto const &fn) const
|
||||
{
|
||||
Xml_node launcher_xml = _launcher_xml.constructed()
|
||||
? _launcher_xml->xml()
|
||||
? _launcher_xml->xml
|
||||
: Xml_node("<empty/>");
|
||||
|
||||
if (_condition == UNSATISFIED && _start_xml.constructed())
|
||||
fn(_start_xml->xml(), launcher_xml, _name);
|
||||
fn(_start_xml->xml, launcher_xml, _name);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -403,15 +403,15 @@ void Depot_deploy::Child::gen_start_node(Xml_generator &xml,
|
||||
if (_defined_by_launcher() && !_launcher_xml.constructed())
|
||||
return;
|
||||
|
||||
if (!_pkg_xml->xml().has_sub_node("runtime")) {
|
||||
if (!_pkg_xml->xml.has_sub_node("runtime")) {
|
||||
warning("blueprint for '", _name, "' lacks runtime information");
|
||||
return;
|
||||
}
|
||||
|
||||
Xml_node const launcher_xml = (_defined_by_launcher())
|
||||
? _launcher_xml->xml() : Xml_node("<empty/>");
|
||||
? _launcher_xml->xml : Xml_node("<empty/>");
|
||||
|
||||
Xml_node const start_xml = _start_xml->xml();
|
||||
Xml_node const start_xml = _start_xml->xml;
|
||||
|
||||
xml.node("start", [&] {
|
||||
|
||||
@ -427,7 +427,7 @@ void Depot_deploy::Child::gen_start_node(Xml_generator &xml,
|
||||
|
||||
{
|
||||
using Version = String<64>;
|
||||
Version const version = _start_xml->xml().attribute_value("version", Version());
|
||||
Version const version = _start_xml->xml.attribute_value("version", Version());
|
||||
if (version.valid())
|
||||
xml.attribute("version", version);
|
||||
}
|
||||
@ -519,7 +519,7 @@ void Depot_deploy::Child::gen_start_node(Xml_generator &xml,
|
||||
}
|
||||
|
||||
/* runtime handling */
|
||||
Xml_node const runtime = _pkg_xml->xml().sub_node("runtime");
|
||||
Xml_node const runtime = _pkg_xml->xml.sub_node("runtime");
|
||||
|
||||
/*
|
||||
* Insert inline '<heartbeat>' node if provided by the start node.
|
||||
@ -605,11 +605,11 @@ void Depot_deploy::Child::gen_monitor_policy_node(Xml_generator &xml) const
|
||||
if (_defined_by_launcher() && !_launcher_xml.constructed())
|
||||
return;
|
||||
|
||||
if (!_pkg_xml->xml().has_sub_node("runtime")) {
|
||||
if (!_pkg_xml->xml.has_sub_node("runtime")) {
|
||||
return;
|
||||
}
|
||||
|
||||
Xml_node const start_xml = _start_xml->xml();
|
||||
Xml_node const start_xml = _start_xml->xml;
|
||||
|
||||
if (start_xml.has_sub_node("monitor")) {
|
||||
Xml_node const monitor = start_xml.sub_node("monitor");
|
||||
@ -636,8 +636,8 @@ void Depot_deploy::Child::_gen_routes(Xml_generator &xml, Xml_node common,
|
||||
/*
|
||||
* Add routes given in the start node.
|
||||
*/
|
||||
if (_start_xml->xml().has_sub_node("route")) {
|
||||
Xml_node const route = _start_xml->xml().sub_node("route");
|
||||
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) {
|
||||
Name const service_name = service.attribute_value("name", Name());
|
||||
@ -673,8 +673,8 @@ void Depot_deploy::Child::_gen_routes(Xml_generator &xml, Xml_node common,
|
||||
/*
|
||||
* Add routes given in the launcher definition.
|
||||
*/
|
||||
if (_launcher_xml.constructed() && _launcher_xml->xml().has_sub_node("route")) {
|
||||
Xml_node const route = _launcher_xml->xml().sub_node("route");
|
||||
if (_launcher_xml.constructed() && _launcher_xml->xml.has_sub_node("route")) {
|
||||
Xml_node const route = _launcher_xml->xml.sub_node("route");
|
||||
route.with_raw_content([&] (char const *start, size_t length) {
|
||||
xml.append(start, length); });
|
||||
}
|
||||
@ -698,7 +698,7 @@ void Depot_deploy::Child::_gen_routes(Xml_generator &xml, Xml_node common,
|
||||
* within the depot.
|
||||
*/
|
||||
if (_config_name.valid()) {
|
||||
_pkg_xml->xml().for_each_sub_node("rom", [&] (Xml_node rom) {
|
||||
_pkg_xml->xml.for_each_sub_node("rom", [&] (Xml_node rom) {
|
||||
|
||||
if (!rom.has_attribute("path"))
|
||||
return;
|
||||
@ -734,7 +734,7 @@ void Depot_deploy::Child::_gen_routes(Xml_generator &xml, Xml_node common,
|
||||
* Add ROM routing rule with the label rewritten to the path within the
|
||||
* depot.
|
||||
*/
|
||||
_pkg_xml->xml().for_each_sub_node("rom", [&] (Xml_node rom) {
|
||||
_pkg_xml->xml.for_each_sub_node("rom", [&] (Xml_node rom) {
|
||||
|
||||
if (!rom.has_attribute("path"))
|
||||
return;
|
||||
|
@ -65,7 +65,7 @@ void Depot_query::Main::_query_image_index(Xml_node const &index_query,
|
||||
if (!from_index.constructed())
|
||||
return;
|
||||
|
||||
from_index->xml().for_each_sub_node("info", [&] (Xml_node const &info) {
|
||||
from_index->xml.for_each_sub_node("info", [&] (Xml_node const &info) {
|
||||
using Text = String<160>;
|
||||
Text const text = info.attribute_value("text", Text());
|
||||
if (text.valid())
|
||||
|
@ -250,7 +250,7 @@ struct Main : Sandbox::Local_service_base::Wakeup, Sandbox::State_handler
|
||||
void update_sandbox_config()
|
||||
{
|
||||
Buffered_xml config { heap, "config", [&] (Xml_generator &xml) { generate_sandbox_config(xml); } };
|
||||
config.with_xml_node([&] (Xml_node const &config) { sandbox.apply_config(config); });
|
||||
sandbox.apply_config(config.xml);
|
||||
}
|
||||
|
||||
void generate_ui_report()
|
||||
@ -574,103 +574,102 @@ void Main::handle_sandbox_state()
|
||||
bool update_sandbox_cfg { false };
|
||||
bool ui_report_changed { false };
|
||||
Number_of_clients num_clients { 0 };
|
||||
sandbox_state.with_xml_node([&] (Xml_node const &sandbox_state) {
|
||||
|
||||
switch (state) {
|
||||
case SETUP_INIT_TRUST_ANCHOR:
|
||||
switch (state) {
|
||||
case SETUP_INIT_TRUST_ANCHOR:
|
||||
|
||||
if (child_succeeded(tresor_init_trust_anchor, sandbox_state)) {
|
||||
set_state(SETUP_TRESOR_INIT);
|
||||
update_sandbox_cfg = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case SETUP_CREATE_IMAGE:
|
||||
|
||||
if (child_succeeded(truncate_file, sandbox_state)) {
|
||||
set_state(SETUP_INIT_TRUST_ANCHOR);
|
||||
update_sandbox_cfg = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case UNLOCK_INIT_TRUST_ANCHOR:
|
||||
{
|
||||
with_exit_code(tresor_init_trust_anchor, sandbox_state, [&] (int code) {
|
||||
if (code)
|
||||
unlock_retry_delay.schedule(Microseconds { 3000000 });
|
||||
else {
|
||||
set_state(UNLOCK_START_TRESOR);
|
||||
update_sandbox_cfg = true;
|
||||
}
|
||||
});
|
||||
break;
|
||||
if (child_succeeded(tresor_init_trust_anchor, sandbox_state.xml)) {
|
||||
set_state(SETUP_TRESOR_INIT);
|
||||
update_sandbox_cfg = true;
|
||||
}
|
||||
case SETUP_TRESOR_INIT:
|
||||
break;
|
||||
|
||||
if (child_succeeded(tresor_init, sandbox_state)) {
|
||||
set_state(SETUP_START_TRESOR);
|
||||
update_sandbox_cfg = true;
|
||||
}
|
||||
break;
|
||||
case SETUP_CREATE_IMAGE:
|
||||
|
||||
case SETUP_START_TRESOR:
|
||||
|
||||
if (child_succeeded(sync_to_tresor_vfs_init, sandbox_state)) {
|
||||
set_state(SETUP_MKE2FS);
|
||||
update_sandbox_cfg = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case UNLOCK_START_TRESOR:
|
||||
|
||||
if (child_succeeded(sync_to_tresor_vfs_init, sandbox_state)) {
|
||||
set_state(UNLOCK_READ_FS_SIZE);
|
||||
update_sandbox_cfg = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case SETUP_MKE2FS:
|
||||
|
||||
if (child_succeeded(mke2fs, sandbox_state)) {
|
||||
set_state(SETUP_READ_FS_SIZE);
|
||||
update_sandbox_cfg = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case UNLOCKED:
|
||||
|
||||
handle_sandbox_state_extend_and_rekey(sandbox_state, update_sandbox_cfg, ui_report_changed);
|
||||
with_child(sandbox_state, rump_vfs, [&] (Xml_node const &child) {
|
||||
child.with_optional_sub_node("provided", [&] (Xml_node const &provided) {
|
||||
provided.for_each_sub_node("session", [&] (Xml_node const &session) {
|
||||
if (session.attribute_value("service", Service_name()) == "File_system")
|
||||
num_clients.value++; }); }); });
|
||||
break;
|
||||
|
||||
case LOCK_PENDING:
|
||||
|
||||
handle_sandbox_state_extend_and_rekey(sandbox_state, update_sandbox_cfg, ui_report_changed);
|
||||
if (extend_state == Extend::INACTIVE && rekey_state == Rekey::INACTIVE) {
|
||||
set_state(START_LOCKING);
|
||||
update_sandbox_cfg = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case START_LOCKING:
|
||||
|
||||
if (child_succeeded(lock_fs_tool, sandbox_state)) {
|
||||
set_state(LOCKING);
|
||||
update_sandbox_cfg = true;
|
||||
}
|
||||
break;
|
||||
|
||||
default: break;
|
||||
if (child_succeeded(truncate_file, sandbox_state.xml)) {
|
||||
set_state(SETUP_INIT_TRUST_ANCHOR);
|
||||
update_sandbox_cfg = true;
|
||||
}
|
||||
sandbox_state.for_each_sub_node("child", [&] (Xml_node const &child) {
|
||||
children.for_each([&] (Child_state &child_state) {
|
||||
if (child_state.apply_child_state_report(child))
|
||||
update_sandbox_cfg = true; }); });
|
||||
});
|
||||
break;
|
||||
|
||||
case UNLOCK_INIT_TRUST_ANCHOR:
|
||||
{
|
||||
with_exit_code(tresor_init_trust_anchor, sandbox_state.xml, [&] (int code) {
|
||||
if (code)
|
||||
unlock_retry_delay.schedule(Microseconds { 3000000 });
|
||||
else {
|
||||
set_state(UNLOCK_START_TRESOR);
|
||||
update_sandbox_cfg = true;
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
case SETUP_TRESOR_INIT:
|
||||
|
||||
if (child_succeeded(tresor_init, sandbox_state.xml)) {
|
||||
set_state(SETUP_START_TRESOR);
|
||||
update_sandbox_cfg = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case SETUP_START_TRESOR:
|
||||
|
||||
if (child_succeeded(sync_to_tresor_vfs_init, sandbox_state.xml)) {
|
||||
set_state(SETUP_MKE2FS);
|
||||
update_sandbox_cfg = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case UNLOCK_START_TRESOR:
|
||||
|
||||
if (child_succeeded(sync_to_tresor_vfs_init, sandbox_state.xml)) {
|
||||
set_state(UNLOCK_READ_FS_SIZE);
|
||||
update_sandbox_cfg = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case SETUP_MKE2FS:
|
||||
|
||||
if (child_succeeded(mke2fs, sandbox_state.xml)) {
|
||||
set_state(SETUP_READ_FS_SIZE);
|
||||
update_sandbox_cfg = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case UNLOCKED:
|
||||
|
||||
handle_sandbox_state_extend_and_rekey(sandbox_state.xml, update_sandbox_cfg, ui_report_changed);
|
||||
with_child(sandbox_state.xml, rump_vfs, [&] (Xml_node const &child) {
|
||||
child.with_optional_sub_node("provided", [&] (Xml_node const &provided) {
|
||||
provided.for_each_sub_node("session", [&] (Xml_node const &session) {
|
||||
if (session.attribute_value("service", Service_name()) == "File_system")
|
||||
num_clients.value++; }); }); });
|
||||
break;
|
||||
|
||||
case LOCK_PENDING:
|
||||
|
||||
handle_sandbox_state_extend_and_rekey(sandbox_state.xml, update_sandbox_cfg, ui_report_changed);
|
||||
if (extend_state == Extend::INACTIVE && rekey_state == Rekey::INACTIVE) {
|
||||
set_state(START_LOCKING);
|
||||
update_sandbox_cfg = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case START_LOCKING:
|
||||
|
||||
if (child_succeeded(lock_fs_tool, sandbox_state.xml)) {
|
||||
set_state(LOCKING);
|
||||
update_sandbox_cfg = true;
|
||||
}
|
||||
break;
|
||||
|
||||
default: break;
|
||||
}
|
||||
sandbox_state.xml.for_each_sub_node("child", [&] (Xml_node const &child) {
|
||||
children.for_each([&] (Child_state &child_state) {
|
||||
if (child_state.apply_child_state_report(child))
|
||||
update_sandbox_cfg = true; }); });
|
||||
|
||||
if (ui_report.num_clients.value != num_clients.value) {
|
||||
ui_report.num_clients.value = num_clients.value;
|
||||
ui_report_changed = true;
|
||||
|
@ -101,7 +101,7 @@ struct Sculpt::Deploy
|
||||
if (!_template.constructed())
|
||||
return;
|
||||
|
||||
Xml_node const deploy = _template->xml();
|
||||
Xml_node const deploy = _template->xml;
|
||||
|
||||
if (deploy.type() == "empty")
|
||||
return;
|
||||
|
@ -113,7 +113,7 @@ class Window_layouter::Layout_rules : Noncopyable
|
||||
}
|
||||
|
||||
if (_config_rules.constructed()) {
|
||||
fn(_config_rules->xml());
|
||||
fn(_config_rules->xml);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -256,7 +256,7 @@ class Window_layouter::Target_list
|
||||
return;
|
||||
|
||||
xml.append("\n");
|
||||
_rules->xml().for_each_sub_node("screen", [&] (Xml_node screen) {
|
||||
_rules->xml.for_each_sub_node("screen", [&] (Xml_node screen) {
|
||||
if (screen_name.valid()) {
|
||||
Target::Name const name =
|
||||
screen.attribute_value("name", Target::Name());
|
||||
@ -273,7 +273,7 @@ class Window_layouter::Target_list
|
||||
if (!screen_name.valid())
|
||||
return;
|
||||
|
||||
_rules->xml().for_each_sub_node("screen", [&] (Xml_node screen) {
|
||||
_rules->xml.for_each_sub_node("screen", [&] (Xml_node screen) {
|
||||
Target::Name const name = screen.attribute_value("name", Target::Name());
|
||||
if (screen_name == name)
|
||||
return;
|
||||
|
@ -31,12 +31,10 @@ class Genode::Buffered_xml
|
||||
|
||||
struct Allocation { char *ptr; size_t size; } const _allocation;
|
||||
|
||||
Xml_node const _xml { _allocation.ptr, _allocation.size };
|
||||
|
||||
/**
|
||||
* \throw Allocator::Out_of_memory
|
||||
*/
|
||||
Allocation _copy_xml_node(Xml_node node)
|
||||
Allocation _copy_xml_node(Xml_node const &node)
|
||||
{
|
||||
Allocation allocation { };
|
||||
|
||||
@ -81,12 +79,14 @@ class Genode::Buffered_xml
|
||||
|
||||
public:
|
||||
|
||||
Xml_node const xml { _allocation.ptr, _allocation.size };
|
||||
|
||||
/**
|
||||
* Constructor for buffering a copy of the specified XML node
|
||||
*
|
||||
* \throw Allocator::Out_of_memory
|
||||
*/
|
||||
Buffered_xml(Allocator &alloc, Xml_node node)
|
||||
Buffered_xml(Allocator &alloc, Xml_node const &node)
|
||||
:
|
||||
_alloc(alloc), _allocation(_copy_xml_node(node))
|
||||
{ }
|
||||
@ -113,16 +113,6 @@ class Genode::Buffered_xml
|
||||
{ }
|
||||
|
||||
~Buffered_xml() { _alloc.free(_allocation.ptr, _allocation.size); }
|
||||
|
||||
/*
|
||||
* \deprecated Use 'with_xml_node' instead
|
||||
*/
|
||||
Xml_node xml() const { return _xml; }
|
||||
|
||||
/**
|
||||
* Call functor 'fn' with 'Xml_node const &' as argument
|
||||
*/
|
||||
void with_xml_node(auto const &fn) const { fn(_xml); }
|
||||
};
|
||||
|
||||
#endif /* _OS__BUFFERED_XML_H_ */
|
||||
|
@ -240,7 +240,7 @@ genode_block_session * ::Root::_create_session(const char * args,
|
||||
throw Service_denied();
|
||||
|
||||
Session_label const label = label_from_args(args);
|
||||
Session_policy const policy(label, _config->xml());
|
||||
Session_policy const policy(label, _config->xml);
|
||||
Session_info::Name const device =
|
||||
policy.attribute_value("device", Session_info::Name());
|
||||
|
||||
|
@ -60,14 +60,14 @@ Sandbox::Child::apply_config(Xml_node start_node)
|
||||
/*
|
||||
* Import new start node if it differs
|
||||
*/
|
||||
if (start_node.differs_from(_start_node->xml())) {
|
||||
if (start_node.differs_from(_start_node->xml)) {
|
||||
|
||||
/*
|
||||
* The <route> node may affect the availability or unavailability
|
||||
* of dependencies.
|
||||
*/
|
||||
start_node.with_optional_sub_node("route", [&] (Xml_node const &route) {
|
||||
_start_node->xml().with_optional_sub_node("route", [&] (Xml_node const &orig) {
|
||||
_start_node->xml.with_optional_sub_node("route", [&] (Xml_node const &orig) {
|
||||
if (route.differs_from(orig)) {
|
||||
_construct_route_model_from_start_node(start_node);
|
||||
_uncertain_dependencies = true; } }); });
|
||||
@ -76,7 +76,7 @@ Sandbox::Child::apply_config(Xml_node start_node)
|
||||
* Determine how the inline config is affected.
|
||||
*/
|
||||
char const * const tag = "config";
|
||||
bool const config_was_present = _start_node->xml().has_sub_node(tag);
|
||||
bool const config_was_present = _start_node->xml.has_sub_node(tag);
|
||||
bool const config_is_present = start_node.has_sub_node(tag);
|
||||
|
||||
if (config_was_present != config_is_present)
|
||||
@ -90,7 +90,7 @@ Sandbox::Child::apply_config(Xml_node start_node)
|
||||
|
||||
if (config_was_present && config_is_present) {
|
||||
|
||||
Xml_node const old_config = _start_node->xml().sub_node(tag);
|
||||
Xml_node const old_config = _start_node->xml.sub_node(tag);
|
||||
Xml_node const new_config = start_node.sub_node(tag);
|
||||
|
||||
if (new_config.differs_from(old_config))
|
||||
@ -196,7 +196,7 @@ void Sandbox::Child::evaluate_dependencies()
|
||||
|
||||
Sandbox::Ram_quota Sandbox::Child::_configured_ram_quota() const
|
||||
{
|
||||
Xml_node const &xml = _start_node->xml();
|
||||
Xml_node const &xml = _start_node->xml;
|
||||
|
||||
Number_of_bytes const default_ram { _default_quota_accessor.default_ram().value };
|
||||
|
||||
@ -218,7 +218,7 @@ Sandbox::Cap_quota Sandbox::Child::_configured_cap_quota() const
|
||||
{
|
||||
size_t const default_caps = _default_quota_accessor.default_caps().value;
|
||||
|
||||
return Cap_quota { _start_node->xml().attribute_value("caps", default_caps) };
|
||||
return Cap_quota { _start_node->xml.attribute_value("caps", default_caps) };
|
||||
}
|
||||
|
||||
|
||||
|
@ -164,14 +164,14 @@ class Sandbox::Child : Child_policy, Routed_service::Wakeup
|
||||
/*
|
||||
* Version attribute of the start node, used to force child restarts.
|
||||
*/
|
||||
Version _version { _start_node->xml().attribute_value("version", Version()) };
|
||||
Version _version { _start_node->xml.attribute_value("version", Version()) };
|
||||
|
||||
bool _uncertain_dependencies = false;
|
||||
|
||||
/*
|
||||
* True if the binary is loaded with ld.lib.so
|
||||
*/
|
||||
bool const _use_ld = _start_node->xml().attribute_value("ld", true);
|
||||
bool const _use_ld = _start_node->xml.attribute_value("ld", true);
|
||||
|
||||
Default_route_accessor &_default_route_accessor;
|
||||
Default_quota_accessor &_default_quota_accessor;
|
||||
@ -198,7 +198,7 @@ class Sandbox::Child : Child_policy, Routed_service::Wakeup
|
||||
}
|
||||
|
||||
using Name = String<64>;
|
||||
Name const _unique_name { _name_from_xml(_start_node->xml()) };
|
||||
Name const _unique_name { _name_from_xml(_start_node->xml) };
|
||||
|
||||
static Binary_name _binary_from_xml(Xml_node start_node,
|
||||
Name const &unique_name)
|
||||
@ -210,7 +210,7 @@ class Sandbox::Child : Child_policy, Routed_service::Wakeup
|
||||
}
|
||||
|
||||
/* updated on configuration update */
|
||||
Binary_name _binary_name { _binary_from_xml(_start_node->xml(), _unique_name) };
|
||||
Binary_name _binary_name { _binary_from_xml(_start_node->xml, _unique_name) };
|
||||
|
||||
/* initialized in constructor, updated by 'apply_config' */
|
||||
bool _heartbeat_enabled;
|
||||
@ -342,8 +342,8 @@ class Sandbox::Child : Child_policy, Routed_service::Wakeup
|
||||
*/
|
||||
void produce_content(char *dst, Genode::size_t dst_len) override
|
||||
{
|
||||
Xml_node config = _child._start_node->xml().has_sub_node("config")
|
||||
? _child._start_node->xml().sub_node("config")
|
||||
Xml_node config = _child._start_node->xml.has_sub_node("config")
|
||||
? _child._start_node->xml.sub_node("config")
|
||||
: Xml_node("<config/>");
|
||||
|
||||
size_t const config_len = config.size();
|
||||
@ -390,7 +390,7 @@ class Sandbox::Child : Child_policy, Routed_service::Wakeup
|
||||
* e.g., constrain physical RAM allocations.
|
||||
*/
|
||||
bool const _managing_system {
|
||||
_start_node->xml().attribute_value("managing_system", false) };
|
||||
_start_node->xml.attribute_value("managing_system", false) };
|
||||
|
||||
/**
|
||||
* Resource request initiated by the child
|
||||
@ -746,7 +746,7 @@ class Sandbox::Child : Child_policy, Routed_service::Wakeup
|
||||
void exit(int exit_value) override
|
||||
{
|
||||
try {
|
||||
if (_start_node->xml().sub_node("exit").attribute_value("propagate", false)) {
|
||||
if (_start_node->xml.sub_node("exit").attribute_value("propagate", false)) {
|
||||
_env.parent().exit(exit_value);
|
||||
return;
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ struct Config_model::Default_route_node : Node
|
||||
|
||||
void update(Xml_node const &xml) override
|
||||
{
|
||||
if (!_default_route.constructed() || _default_route->xml().differs_from(xml))
|
||||
if (!_default_route.constructed() || _default_route->xml.differs_from(xml))
|
||||
_default_route.construct(_alloc, xml);
|
||||
}
|
||||
};
|
||||
|
@ -193,7 +193,7 @@ struct Genode::Sandbox::Library : ::Sandbox::State_reporter::Producer,
|
||||
void _with_default_route(Child::With_xml::Ft const &fn) override
|
||||
{
|
||||
if (_default_route.constructed())
|
||||
fn(_default_route->xml());
|
||||
fn(_default_route->xml);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -234,7 +234,7 @@ class Sandbox::Route_model : Noncopyable
|
||||
_alloc(alloc), _route_node(_alloc, route)
|
||||
{
|
||||
Rule const *at_ptr = nullptr;
|
||||
_route_node.xml().for_each_sub_node([&] (Xml_node const &node) {
|
||||
_route_node.xml.for_each_sub_node([&] (Xml_node const &node) {
|
||||
Rule &rule = *new (_alloc) Rule(_alloc, node);
|
||||
_rules.insert(&rule, at_ptr); /* append */
|
||||
at_ptr = &rule;
|
||||
|
@ -88,7 +88,7 @@ Sandbox::Server::Service::resolve_session_request(Session_label const &label)
|
||||
throw Service_denied();
|
||||
|
||||
try {
|
||||
Session_policy policy(label, _service_node->xml());
|
||||
Session_policy policy(label, _service_node->xml);
|
||||
|
||||
if (!policy.has_sub_node("child"))
|
||||
throw Service_denied();
|
||||
|
@ -101,7 +101,7 @@ class Vfs::Inline_file_system : public Single_file_system
|
||||
{
|
||||
Stat_result const result = Single_file_system::stat(path, out);
|
||||
|
||||
_node.xml().with_raw_content([&] (char const *, size_t size) {
|
||||
_node.xml.with_raw_content([&] (char const *, size_t size) {
|
||||
out.size = size; });
|
||||
|
||||
return result;
|
||||
@ -112,7 +112,7 @@ class Vfs::Inline_file_system : public Single_file_system
|
||||
Vfs::File_io_service::Read_result
|
||||
Vfs::Inline_file_system::Handle::read(Byte_range_ptr const &dst, size_t &out_count)
|
||||
{
|
||||
_fs._node.xml().with_raw_content([&] (char const *start, size_t const len) {
|
||||
_fs._node.xml.with_raw_content([&] (char const *start, size_t const len) {
|
||||
|
||||
/* file read limit is the size of the XML-node content */
|
||||
size_t const max_size = len;
|
||||
|
@ -128,12 +128,9 @@ struct Test::Main : Sandbox::Local_service_base::Wakeup
|
||||
Buffered_xml const config { _heap, "config", [&] (Xml_generator &xml) {
|
||||
_generate_sandbox_config(xml); } };
|
||||
|
||||
config.with_xml_node([&] (Xml_node const &config) {
|
||||
log("generated config: ", config.xml);
|
||||
|
||||
log("generated config: ", config);
|
||||
|
||||
_sandbox.apply_config(config);
|
||||
});
|
||||
_sandbox.apply_config(config.xml);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user