From 0d61029d7eea7b3e22f9fcfdc17c13c3e17f330b Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Fri, 11 Sep 2020 11:28:58 +0200 Subject: [PATCH] depot_deploy: move affinity to sub node The initial implementation of the affinity configuration in "depot_deploy: support affinity configuration" added the affinity location attributes to the node of the deploy config. This patch moves the information into a dedicated sub node as done by the init configuration. So the context of the attributes 'xpos', 'ypos', 'width' and 'height' becomes clear. It also fixes a usability issue in Sculpt that occurred during testing: When configuring multiple components with custom affinities, the resources dialog of later components would wrongly display the state of earlier components instead of displaying the fresh (default) state. The resulting configuration would then not match the displayed information. This is fixed by resetting the dialog state. As another minor cosmetic change, the patch adds a line break in front of copied or nodes. Issue #3597 --- repos/gems/src/app/depot_deploy/child.h | 42 +++++++++---------- .../src/app/sculpt_manager/model/component.h | 25 +++++++++-- .../app/sculpt_manager/model/runtime_state.h | 5 +-- .../app/sculpt_manager/view/popup_dialog.h | 1 + .../app/sculpt_manager/view/resource_dialog.h | 5 +-- 5 files changed, 45 insertions(+), 33 deletions(-) diff --git a/repos/gems/src/app/depot_deploy/child.h b/repos/gems/src/app/depot_deploy/child.h index 8dde3a7288..3d98d07733 100644 --- a/repos/gems/src/app/depot_deploy/child.h +++ b/repos/gems/src/app/depot_deploy/child.h @@ -134,6 +134,7 @@ class Depot_deploy::Child : public List_model::Element Xml_node const sub_node = from_node.sub_node(sub_node_type.string()); sub_node.with_raw_node([&] (char const *start, size_t length) { + xml.append("\n\t\t"); xml.append(start, length); }); } @@ -368,32 +369,29 @@ void Depot_deploy::Child::gen_start_node(Xml_generator &xml, Xml_node common, xml.attribute("quantum", cpu_quota); }); - /* location handling */ + /* affinity-location handling */ bool const affinity_from_launcher = _defined_by_launcher() - && (_launcher_xml->xml().has_attribute("xpos") || - _launcher_xml->xml().has_attribute("ypos")); - bool const affinity_from_start = _start_xml->xml().has_attribute("xpos") - || _start_xml->xml().has_attribute("ypos"); - if (affinity_from_start || affinity_from_launcher) { - long xpos = 0, ypos = 0; - unsigned width = 1, height = 1; + && _launcher_xml->xml().has_sub_node("affinity"); - if (affinity_from_launcher) { - xpos = _launcher_xml->xml().attribute_value("xpos", xpos); - ypos = _launcher_xml->xml().attribute_value("ypos", ypos); - width = _launcher_xml->xml().attribute_value("width", width); - height = _launcher_xml->xml().attribute_value("height", height); - } - xpos = _start_xml->xml().attribute_value("xpos", xpos); - ypos = _start_xml->xml().attribute_value("ypos", ypos); - width = _start_xml->xml().attribute_value("width", width); - height = _start_xml->xml().attribute_value("height", height); + bool const affinity_from_start = _start_xml->xml().has_sub_node("affinity"); + + if (affinity_from_start || affinity_from_launcher) { + + Affinity::Location location { }; + + if (affinity_from_launcher) + _launcher_xml->xml().with_sub_node("affinity", [&] (Xml_node node) { + location = Affinity::Location::from_xml(node); }); + + if (affinity_from_start) + _start_xml->xml().with_sub_node("affinity", [&] (Xml_node node) { + location = Affinity::Location::from_xml(node); }); xml.node("affinity", [&] () { - xml.attribute("xpos", xpos); - xml.attribute("ypos", ypos); - xml.attribute("width", width); - xml.attribute("height", height); + xml.attribute("xpos", location.xpos()); + xml.attribute("ypos", location.ypos()); + xml.attribute("width", location.width()); + xml.attribute("height", location.height()); }); } diff --git a/repos/gems/src/app/sculpt_manager/model/component.h b/repos/gems/src/app/sculpt_manager/model/component.h index 59ff5d2c08..e1e003028d 100644 --- a/repos/gems/src/app/sculpt_manager/model/component.h +++ b/repos/gems/src/app/sculpt_manager/model/component.h @@ -37,10 +37,10 @@ struct Sculpt::Component : Noncopyable uint64_t ram { }; size_t caps { }; - Affinity::Space const affinity_space; - Affinity::Location affinity_location { 0, 0, - affinity_space.width(), - affinity_space.height() }; + Affinity::Space const affinity_space; + Affinity::Location affinity_location { 0, 0, + affinity_space.width(), + affinity_space.height() }; bool blueprint_known = false; @@ -75,6 +75,23 @@ struct Sculpt::Component : Noncopyable }); } + void gen_affinity_xml(Xml_generator &xml) const + { + bool const all_cpus = affinity_space.width() == affinity_location.width() + && affinity_space.height() == affinity_location.height(); + + /* omit node if all CPUs are used by the component */ + if (all_cpus) + return; + + xml.node("affinity", [&] () { + xml.attribute("xpos", affinity_location.xpos()); + xml.attribute("ypos", affinity_location.ypos()); + xml.attribute("width", affinity_location.width()); + xml.attribute("height", affinity_location.height()); + }); + } + bool all_routes_defined() const { bool result = true; diff --git a/repos/gems/src/app/sculpt_manager/model/runtime_state.h b/repos/gems/src/app/sculpt_manager/model/runtime_state.h index a0be27e46b..6c2e6cbedd 100644 --- a/repos/gems/src/app/sculpt_manager/model/runtime_state.h +++ b/repos/gems/src/app/sculpt_manager/model/runtime_state.h @@ -154,10 +154,7 @@ class Sculpt::Runtime_state : public Runtime_info if (construction.constructed()) { xml.attribute("pkg", construction->path); - xml.attribute("xpos", construction->affinity_location.xpos()); - xml.attribute("ypos", construction->affinity_location.ypos()); - xml.attribute("width", construction->affinity_location.width()); - xml.attribute("height", construction->affinity_location.height()); + construction->gen_affinity_xml(xml); xml.node("route", [&] () { construction->routes.for_each([&] (Route const &route) { diff --git a/repos/gems/src/app/sculpt_manager/view/popup_dialog.h b/repos/gems/src/app/sculpt_manager/view/popup_dialog.h index 6a21c21f65..ac99fd98ff 100644 --- a/repos/gems/src/app/sculpt_manager/view/popup_dialog.h +++ b/repos/gems/src/app/sculpt_manager/view/popup_dialog.h @@ -406,6 +406,7 @@ struct Sculpt::Popup_dialog : Dialog _selected_user = User(); _selected_route.destruct(); _menu._level = 0; + _resources.destruct(); } Popup_dialog(Env &env, Refresh &refresh, diff --git a/repos/gems/src/app/sculpt_manager/view/resource_dialog.h b/repos/gems/src/app/sculpt_manager/view/resource_dialog.h index 6492336aba..3679ab704b 100644 --- a/repos/gems/src/app/sculpt_manager/view/resource_dialog.h +++ b/repos/gems/src/app/sculpt_manager/view/resource_dialog.h @@ -33,9 +33,8 @@ struct Sculpt::Resource_dialog : Noncopyable, Dialog Hoverable_item _space_item { }; - Resource_dialog(Affinity::Space space, - Affinity::Location loc) - : _space(space), _location(loc) + Resource_dialog(Affinity::Space space, Affinity::Location location) + : _space(space), _location(location) { } void _gen_affinity_entry(Xml_generator &, Start_name const &) const;