class Node
Defined at line 195 of file ../../src/devices/bin/driver_manager/node.h
Definitions for OfferTransport, NodeOffer, ToFidl, and CreateCompositeOffer are now in
node_types.h
Public Members
static duration kNeighborAlertCooldown
static duration kPingHealthCheckDeadline
static duration kFastHealthCheckDeadline
static duration kDeepHealthCheckDeadline
static duration kHealthCheckBackstopSlack
Public Methods
bool HasDriverComponent ()
NodeShutdownBridge
Exposed for testing.
Defined at line 230 of file ../../src/devices/bin/driver_manager/node.h
bool HasDriverComponentController ()
Defined at line 243 of file ../../src/devices/bin/driver_manager/node.h
bool IsComposite ()
Defined at line 312 of file ../../src/devices/bin/driver_manager/node.h
zx::event DuplicatePowerToken ()
Returns a duplicate of the node's power element token, if available.
If the node has no power token, this will return an invalid zx::event.
Defined at line 336 of file ../../src/devices/bin/driver_manager/node.h
std::optional<zx::eventpair> TakeStartupLease ()
Defined at line 346 of file ../../src/devices/bin/driver_manager/node.h
void set_startup_lease_for_testing (std::optional<zx::eventpair> lease)
Exposed for testing.
Defined at line 349 of file ../../src/devices/bin/driver_manager/node.h
Node * GetPrimaryParent ()
Exposed for testing.
Defined at line 354 of file ../../src/devices/bin/driver_manager/node.h
void SetupDevfsForRootNode (std::shared_ptr<Devfs> & devfs)
This should be used on the root node. Install the root node at the top of the devfs filesystem.
Defined at line 366 of file ../../src/devices/bin/driver_manager/node.h
void Node (std::string_viewname,std::weak_ptr<Node>parent,NodeManager *node_manager,async_dispatcher_t *dispatcher,std::map<std::string, zx::event>node_token_overrides)
Defined at line 369 of file ../../src/devices/bin/driver_manager/node.cc
void AddToDevfsForTesting (Devnode & parent)
This is exposed for testing. Setup this node's devfs nodes.
Defined at line 371 of file ../../src/devices/bin/driver_manager/node.h
NodeState GetNodeState ()
Defined at line 383 of file ../../src/devices/bin/driver_manager/node.h
const std::string & name ()
Defined at line 385 of file ../../src/devices/bin/driver_manager/node.h
NodeType type ()
Defined at line 387 of file ../../src/devices/bin/driver_manager/node.h
void Node (std::string_viewname,std::unordered_map<std::string, std::weak_ptr<Node>>parents,std::vector<std::string>parents_names,NodeManager *node_manager,async_dispatcher_t *dispatcher,uint32_tprimary_index,std::map<std::string, zx::event>node_token_overrides)
Defined at line 387 of file ../../src/devices/bin/driver_manager/node.cc
const DriverHost * driver_host ()
Defined at line 391 of file ../../src/devices/bin/driver_manager/node.h
DriverHost * driver_host ()
Defined at line 399 of file ../../src/devices/bin/driver_manager/node.h
bool quarantined ()
Defined at line 409 of file ../../src/devices/bin/driver_manager/node.h
std::span<const std::weak_ptr<Node>> parents ()
Defined at line 411 of file ../../src/devices/bin/driver_manager/node.h
const std::list<std::shared_ptr<Node>> & children ()
Defined at line 421 of file ../../src/devices/bin/driver_manager/node.h
const std::vector<fuchsia_driver_framework::NodeSymbol> & symbols ()
Defined at line 425 of file ../../src/devices/bin/driver_manager/node.h
size_t properties_size ()
Returns the node properties of the node and its parents if the node is a composite node.
See properties of the Composite struct for more info.
Defined at line 429 of file ../../src/devices/bin/driver_manager/node.h
void ~Node ()
Defined at line 669 of file ../../src/devices/bin/driver_manager/node.cc
zx::result<std::shared_ptr<Node>> CreateCompositeNode (std::string_viewnode_name,std::vector<std::weak_ptr<Resource>>dependencies,std::vector<std::string>parents_names,const std::vector<fuchsia_driver_framework::NodePropertyEntry2> &parent_properties,NodeManager *driver_binder,async_dispatcher_t *dispatcher,std::string_viewdriver_host_name_for_colocation,uint32_tprimary_index,std::map<std::string, zx::event>node_token_overrides)
Defined at line 495 of file ../../src/devices/bin/driver_manager/node.cc
void OnNodeServerUnbound (fidl::UnbindInfo info)
This is called when |node_ref_| is unbound from the dispatcher.
Defined at line 1753 of file ../../src/devices/bin/driver_manager/node.cc
void OnBind ()
Defined at line 775 of file ../../src/devices/bin/driver_manager/node.cc
void OnMatchError (zx_status_t status)
Defined at line 838 of file ../../src/devices/bin/driver_manager/node.cc
void OnStartError (zx_status_t status)
Defined at line 842 of file ../../src/devices/bin/driver_manager/node.cc
void SearchNamespaceSvcDirForEntry (fidl::ClientEnd<fuchsia_io::Directory>svc_dir,std::string_viewentry_name,fit::callback<void (zx::result<fidl::ClientEnd<fuchsia_io::Directory>>)>cb)
Manually scans the directory entries in a namespace to find a specific protocol.
We do this manual scan rather than just attempting to `Open` the protocol directly
because `Open` is asynchronous and may not fail immediately if the protocol is
missing. By verifying its existence first, we avoid relying on a silent failure
or hanging behavior when a custom power topology isn't provided.
Defined at line 1995 of file ../../src/devices/bin/driver_manager/node.cc
void RemoveResource (const std::shared_ptr<Resource> & resource)
Defined at line 1736 of file ../../src/devices/bin/driver_manager/node.cc
void InitializeSelfResource (std::vector<fuchsia_driver_framework::NodeProperty2>properties,std::vector<NodeOffer>offers,std::optional<fuchsia_driver_framework::BusInfo>bus_info)
Defined at line 1744 of file ../../src/devices/bin/driver_manager/node.cc
void Remove (RemovalSet removal_set, NodeRemovalTracker * removal_tracker)
Begin the removal process for a Node. This function ensures that a Node is
only removed after all of its children are removed. It also ensures that
a Node is only removed after the driver that is bound to it has been stopped.
This is safe to call multiple times.
There are multiple reasons a Node's removal will be started:
- The system is being stopped.
- The Node had an unexpected error or disconnect
During a system stop, Remove is expected to be called twice:
once with |removal_set| == kPackage, and once with |removal_set| == kAll.
Errors and disconnects that are unrecoverable should call Remove(kAll, nullptr).
Defined at line 1118 of file ../../src/devices/bin/driver_manager/node.cc
void AddChild (fuchsia_driver_framework::NodeAddArgsargs,fidl::ServerEnd<fuchsia_driver_framework::NodeController>controller,fidl::ServerEnd<fuchsia_driver_framework::Node>node,AddNodeResultCallbackcallback)
`callback` is invoked once the node has finished being added or an error
has occurred.
Defined at line 1634 of file ../../src/devices/bin/driver_manager/node.cc
void AddToParents ()
Add this Node to its parents. This should be called when the node is created. Exposed for
testing.
Defined at line 916 of file ../../src/devices/bin/driver_manager/node.cc
void SetController (fidl::ServerEnd<fuchsia_driver_framework::NodeController> controller)
Defined at line 927 of file ../../src/devices/bin/driver_manager/node.cc
void SetOwnedByParent (fidl::ServerEnd<fuchsia_driver_framework::Node> node_ref)
Defined at line 937 of file ../../src/devices/bin/driver_manager/node.cc
void RestartNode ()
Begins the process of restarting the node. Restarting a node includes stopping and removing
all children nodes, stopping the driver that is bound to the node, and asking the NodeManager
to bind the node again. The restart operation is very similar to the Remove operation, the
difference being once the children are removed, and the driver stopped, we don't remove the
node from the topology but instead bind the node again.
Defined at line 1122 of file ../../src/devices/bin/driver_manager/node.cc
void QuarantineNode ()
Begins the process of quarantining the node. This is basically performing a Remove,
but instead of removing the node from the topology, we keep it in a stopped state so that it
can be orphaned if its driver is ever disabled. That way new drivers can be bound to the node.
Defined at line 1140 of file ../../src/devices/bin/driver_manager/node.cc
void RemoveCompositeNodeForRebind (fit::callback<void (zx::result<>)> completer)
TODO(https://fxbug.dev/42082343): Handle the case in which this function is called during node
removal.
Defined at line 1174 of file ../../src/devices/bin/driver_manager/node.cc
void RestartNodeWithRematch (std::optional<std::string> restart_driver_url_suffix, fit::callback<void (zx::result<>)> completer)
Restarting a node WithRematch, means that instead of re-using the currently bound driver,
another MatchDriver call will be made into the driver index to find a new driver to bind.
Defined at line 1156 of file ../../src/devices/bin/driver_manager/node.cc
void RestartNodeWithRematch ()
Defined at line 1168 of file ../../src/devices/bin/driver_manager/node.cc
void StartDriver (fuchsia_component_runner::wire::ComponentStartInfostart_info,fidl::ServerEnd<fuchsia_component_runner::ComponentController>component_controller,fit::callback<void (zx::result<>)>cb)
Defined at line 2074 of file ../../src/devices/bin/driver_manager/node.cc
void SetController (fidl::ClientEnd<fuchsia_component::Controller> component_controller)
ComponentOwner
Defined at line 766 of file ../../src/devices/bin/driver_manager/node.cc
void OnComponentStarted (const std::weak_ptr<BootupTracker> &bootup_tracker,const std::string &moniker,zx::result<StartedComponent>component)
Defined at line 2623 of file ../../src/devices/bin/driver_manager/node.cc
void RequestStartComponent (fuchsia_process::wire::HandleInfostartup_handle,const std::string &moniker,const std::weak_ptr<BootupTracker> &bootup_tracker)
Defined at line 2651 of file ../../src/devices/bin/driver_manager/node.cc
bool EvaluateRematchFlags (fuchsia_driver_development::RestartRematchFlags rematch_flags, std::string_view requested_url)
Evaluates the given rematch_flags against the node. Returns true if rematch should take place,
false otherwise. Rematching is done based on the node type and url both matching:
For node type, if the node is a composite, the rematch flags must contain the flag
for the composite variant that the node is. No validation for non-composites.
For the url, rematch takes place if either:
- the url matches the requested_url and the 'requested' flag is available.
- the url does not match and the 'non_requested' flag is available.
Defined at line 2975 of file ../../src/devices/bin/driver_manager/node.cc
std::string MakeTopologicalPath (bool deduplicate)
Creates the node's topological path by combining each primary parent's name together,
separated by '/'.
E.g: dev/sys/topo/path
Defined at line 727 of file ../../src/devices/bin/driver_manager/node.cc
std::string MakeComponentMoniker ()
Make the node's component moniker by making the topological path and then replacing
characters not allowed by the component framework.
E.g: dev.sys.topo.path
Defined at line 740 of file ../../src/devices/bin/driver_manager/node.cc
void SetShouldDestroy ()
Defined at line 771 of file ../../src/devices/bin/driver_manager/node.cc
void CompleteBind (zx::result<> result)
Invoked when a bind sequence has been completed. It allows us to reply to outstanding bind
requests that may have originated from the node.
Defined at line 863 of file ../../src/devices/bin/driver_manager/node.cc
NodeShutdownCoordinator & GetNodeShutdownCoordinator ()
Defined at line 941 of file ../../src/devices/bin/driver_manager/node.cc
std::map<std::string, zx::event> DuplicateTokenOverrides (const std::map<std::string, zx::event> & overrides)
Creates a duplicate copy of the given map of node power token overrides.
Defined at line 445 of file ../../src/devices/bin/driver_manager/node.cc
void SetSubtreeDictionaryRef (std::optional<fuchsia_component_sandbox::CapabilityId> subtree_dictionary_ref)
Defined at line 447 of file ../../src/devices/bin/driver_manager/node.h
void set_dictionary_ref (std::optional<fuchsia_component_sandbox::CapabilityId> ref)
Defined at line 455 of file ../../src/devices/bin/driver_manager/node.h
bool IsHermeticPowerTest ()
Returns true if this node or subtree is operating within a hermetic power test,
indicated by active dictionary, power dependency, CPU token, or node power token overrides.
Defined at line 458 of file ../../src/devices/bin/driver_manager/node.cc
void SetPowerDependencyOverrides (std::optional<std::vector<fuchsia_power_broker::LevelDependency>> power_dependency_overrides)
Sets the power dependency overrides for this node. These overrides will be
used instead of the default power dependencies when the driver is started.
This is primarily intended for use in tests via the driver restart flow,
allowing tests to provide isolated or custom dependencies.
Defined at line 463 of file ../../src/devices/bin/driver_manager/node.h
void MarkAsCompositeParent ()
Defined at line 468 of file ../../src/devices/bin/driver_manager/node.h
void UnmarkAsCompositeParent ()
Defined at line 470 of file ../../src/devices/bin/driver_manager/node.h
bool HasSubtreeDictionaryRef ()
Defined at line 472 of file ../../src/devices/bin/driver_manager/node.h
bool SkipInjectedOffers ()
Defined at line 474 of file ../../src/devices/bin/driver_manager/node.h
std::optional<fuchsia_component_sandbox::DictionaryRef> TakeDictionary ()
Defined at line 476 of file ../../src/devices/bin/driver_manager/node.h
void SetCpuTokenOverride (std::optional<zx::event> token)
Sets the CPU token override for this node. This token will be used to
create a dependency on the CPU power element when the driver is started.
Like SetPowerDependencyOverrides, this is primarily meant for test scenarios.
Defined at line 485 of file ../../src/devices/bin/driver_manager/node.h
void SetNodeTokenOverrides (std::map<std::string, zx::event> node_token_overrides)
Sets power token overrides for target child/composite nodes.
Defined at line 490 of file ../../src/devices/bin/driver_manager/node.h
bool HasActivePowerElement ()
Returns true if any of the following are true:
* node has a regular power elements is bound
* node has a power element override
Defined at line 514 of file ../../src/devices/bin/driver_manager/node.h
void UpdateBoundStateForTesting (bool bound, bool has_power_element)
Exposed for testing.
Defined at line 522 of file ../../src/devices/bin/driver_manager/node.h
const Collection & collection ()
Defined at line 531 of file ../../src/devices/bin/driver_manager/node.h
const fuchsia_driver_framework::DriverPackageType & driver_package_type ()
Defined at line 533 of file ../../src/devices/bin/driver_manager/node.h
DevfsDevice & devfs_device ()
Defined at line 537 of file ../../src/devices/bin/driver_manager/node.h
bool can_multibind_composites ()
Defined at line 539 of file ../../src/devices/bin/driver_manager/node.h
void set_collection (Collection collection)
Defined at line 545 of file ../../src/devices/bin/driver_manager/node.h
void set_driver_package_type (fuchsia_driver_framework::DriverPackageType driver_package_type)
Defined at line 547 of file ../../src/devices/bin/driver_manager/node.h
void set_symbols (std::vector<fuchsia_driver_framework::NodeSymbol> symbols)
Defined at line 551 of file ../../src/devices/bin/driver_manager/node.h
void set_can_multibind_composites (bool can_multibind_composites)
Defined at line 555 of file ../../src/devices/bin/driver_manager/node.h
void set_driver_host_name_for_colocation (std::string_view name)
Defined at line 559 of file ../../src/devices/bin/driver_manager/node.h
std::optional<zx_koid_t> token_koid ()
Defined at line 563 of file ../../src/devices/bin/driver_manager/node.h
ShutdownIntent shutdown_intent ()
Defined at line 570 of file ../../src/devices/bin/driver_manager/node.h
bool is_bound ()
Defined at line 572 of file ../../src/devices/bin/driver_manager/node.h
bool is_running ()
Defined at line 579 of file ../../src/devices/bin/driver_manager/node.h
const std::vector<std::shared_ptr<Resource>> & provided_resources ()
Exposed for testing.
Defined at line 588 of file ../../src/devices/bin/driver_manager/node.h
void add_provided_resource_for_testing (std::shared_ptr<Resource> resource)
Defined at line 591 of file ../../src/devices/bin/driver_manager/node.h
const std::optional<HealthCheckRecord> & last_health_check ()
Defined at line 702 of file ../../src/devices/bin/driver_manager/node.h
const std::string & driver_url ()
Defined at line 703 of file ../../src/devices/bin/driver_manager/node.cc
const std::vector<NodeOffer> & offers ()
Defined at line 3179 of file ../../src/devices/bin/driver_manager/node.cc
std::optional<std::vector<fuchsia_driver_framework::NodeProperty2>> GetNodeProperties (std::string_view parent_name)
Returns the node properties of the node or the node's parent if the node is a composite node.
Returns std::nullopt if the node is a non-composite and `parent_name` is not "default".
Returns std::nullopt if the parent node cannot be found.
See `properties_` property for more info.
Defined at line 3159 of file ../../src/devices/bin/driver_manager/node.cc
fuchsia_driver_framework::NodePropertyDictionary2 GetNodePropertyDict ()
Defined at line 3184 of file ../../src/devices/bin/driver_manager/node.cc
void PrepareDictionary (fit::callback<void (zx::result<>)> callback)
Defined at line 2778 of file ../../src/devices/bin/driver_manager/node.cc
std::vector<fuchsia_driver_framework::BusInfo> GetBusTopology ()
Defined at line 1316 of file ../../src/devices/bin/driver_manager/node.cc
std::optional<std::shared_ptr<Resource>> GetSelfResource ()
Defined at line 3177 of file ../../src/devices/bin/driver_manager/node.cc
zx::duration HealthCheckBackstopDeadline (fuchsia_driver_framework::HealthCheckRequest level)
Returns the per-level deadline plus kHealthCheckBackstopSlack, i.e. how long RunHealthCheck
waits for the driver host before completing the check with TIMEOUT itself. Levels unknown to
driver_manager get the DEEP deadline, the longest one.
Defined at line 3360 of file ../../src/devices/bin/driver_manager/node.cc
void RunHealthCheck (fuchsia_driver_framework::HealthCheckRequest request, fit::callback<void (fit::result<fuchsia_driver_framework::HealthCheckError, fuchsia_driver_framework::HealthCheckResponse>)> cb)
Forwards |request| to this node's driver if, and only if, it is running. A node that is
unbound, still binding, stopped or whose driver host is gone is not forwarded to; |cb| is
invoked synchronously with INVALID_STATE instead, and nothing is cached.
driver_host applies the per-level deadline to the driver's dispatcher, but if the driver host
process itself is wedged its reply never comes. RunHealthCheck therefore also arms a backstop
timer (HealthCheckBackstopDeadline) on driver_manager's dispatcher: when it fires first, |cb|
is completed with TIMEOUT and a synthetic DRIVER_HOST_TIMEOUT condition is cached; a reply
that arrives after that is ignored. |cb| is invoked exactly once either way.
Defined at line 3387 of file ../../src/devices/bin/driver_manager/node.cc
void OnHealthAlert (fuchsia_driver_framework::HealthAlert alert)
Handles a health alert reported by this node's driver. self_fault records the details and
pings the parents.
upstream_neighbor_fault sweeps the bound parents (what the reporter depends on);
downstream_neighbor_fault sweeps the bound children (what depends on the reporter).
Alerts with an unknown variant are logged and ignored.
Defined at line 3691 of file ../../src/devices/bin/driver_manager/node.cc
Records
Friends
class PendingNodeManager
class DriverRunner
class ComponentControllerConnection
class DriverHostConnection