mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-20 11:39:14 +00:00
base: add Child_policy::Route::Diag flag
The 'diag' flag can be defined by a target node of a route in init's configuration. It is propagated as session argument to the server, which may evaluate the flag to enable diagnostic output for the corresponding session. Issue #2398
This commit is contained in:
parent
3670f7735d
commit
aea5d03691
@ -86,7 +86,8 @@ struct Genode::Child_policy
|
||||
struct Route
|
||||
{
|
||||
Service &service;
|
||||
Session_label const label;
|
||||
Session::Label const label;
|
||||
Session::Diag const diag;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -543,7 +544,7 @@ class Genode::Child : protected Rpc_object<Parent>,
|
||||
_env_service.construct(_child, route.service);
|
||||
_connection.construct(*_env_service, _child._id_space, _client_id,
|
||||
_args, _child._policy.filter_session_affinity(Affinity()),
|
||||
route.label);
|
||||
route.label, route.diag);
|
||||
}
|
||||
catch (Parent::Service_denied) {
|
||||
error(_child._policy.name(), ": ", _service_name(), " "
|
||||
|
@ -39,7 +39,8 @@ struct Genode::Local_connection_base : Noncopyable
|
||||
|
||||
private:
|
||||
|
||||
static Args _init_args(Args const &args, size_t const &ram_quota)
|
||||
static Args _init_args(Args const &args, size_t const &ram_quota,
|
||||
Session::Diag diag)
|
||||
{
|
||||
/* copy original arguments into modifiable buffer */
|
||||
char buf[Args::capacity()];
|
||||
@ -47,6 +48,7 @@ struct Genode::Local_connection_base : Noncopyable
|
||||
|
||||
Arg_string::set_arg(buf, sizeof(buf), "ram_quota",
|
||||
String<64>(ram_quota).string());
|
||||
Arg_string::set_arg(buf, sizeof(buf), "diag", diag.enabled);
|
||||
|
||||
/* return result as a copy */
|
||||
return Args(Cstring(buf));
|
||||
@ -58,13 +60,15 @@ struct Genode::Local_connection_base : Noncopyable
|
||||
Id_space<Parent::Client> &id_space,
|
||||
Parent::Client::Id id,
|
||||
Args const &args, Affinity const &affinity,
|
||||
Session_label const &label,
|
||||
Session::Label const &label,
|
||||
Session::Diag diag,
|
||||
size_t ram_quota)
|
||||
{
|
||||
enum { NUM_ATTEMPTS = 10 };
|
||||
for (unsigned i = 0; i < NUM_ATTEMPTS; i++) {
|
||||
_session_state.construct(service, id_space, id, label,
|
||||
_init_args(args, ram_quota), affinity);
|
||||
_init_args(args, ram_quota, diag),
|
||||
affinity);
|
||||
|
||||
_session_state->service().initiate_request(*_session_state);
|
||||
|
||||
@ -143,10 +147,12 @@ class Genode::Local_connection : Local_connection_base
|
||||
Local_connection(Service &service, Id_space<Parent::Client> &id_space,
|
||||
Parent::Client::Id id, Args const &args,
|
||||
Affinity const &affinity,
|
||||
Session_label const &label = Session_label())
|
||||
Session::Label const &label = Session_label(),
|
||||
Session::Diag diag = { false })
|
||||
:
|
||||
Local_connection_base(service, id_space, id, args, affinity,
|
||||
label.valid() ? label : label_from_args(args.string()),
|
||||
diag,
|
||||
CONNECTION::RAM_QUOTA)
|
||||
{
|
||||
service.wakeup();
|
||||
|
@ -138,8 +138,8 @@ Child_policy::Route Child::_resolve_session_request(Child_policy &policy,
|
||||
try {
|
||||
|
||||
Session_state::Args args(argbuf);
|
||||
return Child_policy::Route {
|
||||
policy.resolve_session_request(name, args), label };
|
||||
return { policy.resolve_session_request(name, args), label,
|
||||
session_diag_from_args(argbuf) };
|
||||
}
|
||||
catch (Parent::Service_denied) { }
|
||||
|
||||
@ -187,6 +187,9 @@ Session_capability Child::session(Parent::Client::Id id,
|
||||
Child_policy::Route route = _resolve_session_request(_policy, name.string(), argbuf);
|
||||
Service &service = route.service;
|
||||
|
||||
/* propagate diag flag */
|
||||
Arg_string::set_arg(argbuf, sizeof(argbuf), "diag", route.diag.enabled);
|
||||
|
||||
Session_state &session =
|
||||
create_session(_policy.name(), service, route.label,
|
||||
_session_factory, _id_space, id, argbuf, filtered_affinity);
|
||||
|
@ -441,12 +441,15 @@ Init::Child::Route Init::Child::resolve_session_request(Service::Name const &ser
|
||||
Label const target_label =
|
||||
target.attribute_value("label", Label(label.string()));
|
||||
|
||||
Session::Diag const
|
||||
target_diag { target.attribute_value("diag", false) };
|
||||
|
||||
if (target.has_type("parent")) {
|
||||
|
||||
Parent_service *service = nullptr;
|
||||
|
||||
if ((service = find_service(_parent_services, service_name)))
|
||||
return Route { *service, target_label };
|
||||
return Route { *service, target_label, target_diag };
|
||||
|
||||
if (service && service->abandoned())
|
||||
throw Parent::Service_denied();
|
||||
@ -475,7 +478,7 @@ Init::Child::Route Init::Child::resolve_session_request(Service::Name const &ser
|
||||
throw Parent::Service_denied();
|
||||
|
||||
if (service)
|
||||
return Route { *service, target_label };
|
||||
return Route { *service, target_label, target_diag };
|
||||
|
||||
if (!service_wildcard) {
|
||||
warning(name(), ": lookup to child "
|
||||
@ -495,7 +498,7 @@ Init::Child::Route Init::Child::resolve_session_request(Service::Name const &ser
|
||||
Routed_service *service = nullptr;
|
||||
|
||||
if ((service = find_service(_child_services, service_name)))
|
||||
return Route { *service, target_label };
|
||||
return Route { *service, target_label, target_diag };
|
||||
|
||||
if (!service_wildcard) {
|
||||
warning(name(), ": lookup for service "
|
||||
|
Loading…
Reference in New Issue
Block a user