Propagate session diag flag to core

This commit restores the diag feature for selecting diagnostic output of
services provided by core. This feature became unavailable with commit
"base: remove dependency from deprecated APIs", which hard-wired the
diag flag for core services to false.

To control this feature, three possible policies can be expressed in a
routing target of init's configuration:

* Forcing silence by specifying 'diag="no"'
* Enabling diagnostics by specifying 'diag="yes"'
* Forwarding the preference of the client by omitting the 'diag'
  attribute

Fixes #3962
This commit is contained in:
Norman Feske
2020-12-02 10:30:22 +01:00
parent 36eeab6df2
commit a0fb944721
19 changed files with 63 additions and 41 deletions

View File

@ -83,7 +83,8 @@ struct Genode::Child_policy
* \throw Service_denied
*/
virtual Route resolve_session_request(Service::Name const &,
Session_label const &) = 0;
Session_label const &,
Session::Diag) = 0;
/**
* Apply transformations to session arguments
@ -575,7 +576,8 @@ class Genode::Child : protected Rpc_object<Parent>,
try {
Child_policy::Route const route =
_child._policy.resolve_session_request(_service_name(),
label_from_args(_args.string()));
label_from_args(_args.string()),
session_diag_from_args(_args.string()));
_env_service.construct(_child, route.service);
_connection.construct(*_env_service, _child._id_space, _client_id,
_args, _child._policy.filter_session_affinity(Affinity()),

View File

@ -68,7 +68,7 @@ struct Genode::Local_connection_base : Noncopyable
{
enum { NUM_ATTEMPTS = 10 };
for (unsigned i = 0; i < NUM_ATTEMPTS; i++) {
_session_state.construct(service, id_space, id, label,
_session_state.construct(service, id_space, id, label, diag,
_init_args(args, resources, diag),
affinity);

View File

@ -65,6 +65,7 @@ class Genode::Session_state : public Parent::Client, public Parent::Server
Reconstructible<Id_space<Parent::Client>::Element> _id_at_client;
Session::Label const _label;
Session::Diag const _diag;
Args _args;
Affinity _affinity;
@ -138,6 +139,7 @@ class Genode::Session_state : public Parent::Client, public Parent::Server
Id_space<Parent::Client> &client_id_space,
Parent::Client::Id client_id,
Session::Label const &label,
Session::Diag diag,
Args const &args,
Affinity const &affinity);
@ -179,6 +181,8 @@ class Genode::Session_state : public Parent::Client, public Parent::Server
Args const &args() const { return _args; }
Session::Diag diag() const { return _diag; }
Affinity const &affinity() const { return _affinity; }
void generate_session_request(Xml_generator &) const;

View File

@ -92,8 +92,8 @@ _ZN6Genode13Registry_base7_insertERNS0_7ElementE T
_ZN6Genode13Registry_base7_removeERNS0_7ElementE T
_ZN6Genode13Registry_base9_for_eachERNS0_15Untyped_functorE T
_ZN6Genode13Session_state7destroyEv T
_ZN6Genode13Session_stateC1ERNS_7ServiceERNS_8Id_spaceINS_6Parent6ClientEEENS6_2IdERKNS_13Session_labelERKNS_6StringILm256EEERKNS_8AffinityE T
_ZN6Genode13Session_stateC2ERNS_7ServiceERNS_8Id_spaceINS_6Parent6ClientEEENS6_2IdERKNS_13Session_labelERKNS_6StringILm256EEERKNS_8AffinityE T
_ZN6Genode13Session_stateC1ERNS_7ServiceERNS_8Id_spaceINS_6Parent6ClientEEENS6_2IdERKNS_13Session_labelENS_7Session4DiagERKNS_6StringILm256EEERKNS_8AffinityE T
_ZN6Genode13Session_stateC2ERNS_7ServiceERNS_8Id_spaceINS_6Parent6ClientEEENS6_2IdERKNS_13Session_labelENS_7Session4DiagERKNS_6StringILm256EEERKNS_8AffinityE T
_ZN6Genode13Shared_objectC1ERNS_3EnvERNS_9AllocatorEPKcNS0_4BindENS0_4KeepE T
_ZN6Genode13Shared_objectC2ERNS_3EnvERNS_9AllocatorEPKcNS0_4BindENS0_4KeepE T
_ZN6Genode13Shared_objectD1Ev T

View File

@ -146,7 +146,8 @@ class Core_child : public Child_policy
Name name() const override { return "init"; }
Route resolve_session_request(Service::Name const &name,
Session_label const &label) override
Session_label const &label,
Session::Diag const diag) override
{
Service *service = nullptr;
_services.for_each([&] (Service &s) {
@ -158,7 +159,7 @@ class Core_child : public Child_policy
return Route { .service = *service,
.label = label,
.diag = Session::Diag() };
.diag = diag };
}
void init(Pd_session &session, Capability<Pd_session> cap) override

View File

@ -100,13 +100,13 @@ void Child::session_sigh(Signal_context_capability sigh)
*/
Session_state &
create_session(Child_policy::Name const &child_name, Service &service,
Session_label const &label,
Session_label const &label, Session::Diag diag,
Session_state::Factory &factory, Id_space<Parent::Client> &id_space,
Parent::Client::Id id, Session_state::Args const &args,
Affinity const &affinity)
{
try {
return service.create_session(factory, id_space, id, label, args, affinity); }
return service.create_session(factory, id_space, id, label, diag, args, affinity); }
catch (Insufficient_ram_quota) {
error(child_name, " requested session with insufficient RAM quota");
@ -174,7 +174,9 @@ Session_capability Child::session(Parent::Client::Id id,
Arg_string::set_arg(argbuf, sizeof(argbuf), "ram_quota", forward_ram_quota.value);
/* may throw a 'Service_denied' exception */
Child_policy::Route route = _policy.resolve_session_request(name.string(), label);
Child_policy::Route route =
_policy.resolve_session_request(name.string(), label,
session_diag_from_args(argbuf));
Service &service = route.service;
@ -182,7 +184,7 @@ Session_capability Child::session(Parent::Client::Id id,
Arg_string::set_arg(argbuf, sizeof(argbuf), "diag", route.diag.enabled);
Session_state &session =
create_session(_policy.name(), service, route.label,
create_session(_policy.name(), service, route.label, route.diag,
_session_factory, _id_space, id, argbuf, filtered_affinity);
_policy.session_state_changed();

View File

@ -172,6 +172,7 @@ Session_state::Session_state(Service &service,
Id_space<Parent::Client> &client_id_space,
Parent::Client::Id client_id,
Session::Label const &label,
Session::Diag const diag,
Args const &args,
Affinity const &affinity)
:
@ -179,5 +180,5 @@ Session_state::Session_state(Service &service,
_donated_ram_quota(ram_quota_from_args(args.string())),
_donated_cap_quota(cap_quota_from_args(args.string())),
_id_at_client(*this, client_id_space, client_id),
_label(label), _args(args), _affinity(affinity)
_label(label), _diag(diag), _args(args), _affinity(affinity)
{ }

View File

@ -230,11 +230,12 @@ class Test_child_policy : public Child_policy
}
Route resolve_session_request(Service::Name const &name,
Session_label const &label) override
Session_label const &label,
Session::Diag const diag) override
{
return Route { .service = _matching_service(name),
.label = label,
.diag = Session::Diag() };
.diag = diag };
}
};