| <link rel="stylesheet" href="../style.css" /> |
| |
| [TOC] |
| # fuchsia.component.runner |
| |
| <div class="fidl-version-div"><span class="fidl-attribute fidl-version">Added: 7</span></div> |
| |
| |
| ## **PROTOCOLS** |
| |
| ## ComponentController {#ComponentController} |
| *Defined in [fuchsia.component.runner/component_runner.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.component.runner/component_runner.fidl;l=183)* |
| <p>A protocol for binding and controlling the lifetime of a component instance |
| started using <code>ComponentRunner.Start()</code>. The component manager is the |
| intended direct client of this protocol.</p> |
| <p>When the controlled component instance terminates or becomes inaccessible |
| for any reason, the server closes the connection with an epitaph.</p> |
| <p>LIFECYCLE</p> |
| <p>A component may exist in one of two states: <code>Started</code>, or <code>Stopped</code>. The |
| component is <code>Started</code> from the time <code>ComponentRunner.Start()</code> is called |
| until the ComponentRunner closes the ComponentController handle. The |
| component then transitions to <code>Stopped</code>.</p> |
| <p>Component manager uses ComponentController to terminate a component in two |
| steps:</p> |
| <ol> |
| <li>Component manager calls <code>Stop()</code> to indicate that the ComponentRunner |
| should stop a component's execution and close this connection with an |
| epitaph.</li> |
| <li>If after some time the ComponentController is not closed, component |
| manager calls <code>Kill()</code> to indicate that the ComponentRunner must halt a |
| component's execution immediately, and then close this connection with |
| an epitaph. The component manager may wait some period of time after |
| calling <code>Kill()</code> before closing the ComponentController channel, but |
| makes no guarantees it will wait or for how long.</li> |
| </ol> |
| <p>Component manager first waits for the ComponentController to close, and |
| then tears down the namespace it hosts for the stopped component. Component |
| manager may call <code>Kill()</code> without first having called <code>Stop()</code>.</p> |
| <p>EPITAPH</p> |
| <p>This protocol sends a FIDL epitaph to indicate that the component instance |
| has been terminated. The component runner is expected to clean up all |
| resources attributed to the component before closing the connection.</p> |
| <p>The following epitaphs may be sent by the server on error:</p> |
| <ul> |
| <li><code>ZX_OK</code>: The component exited successfully, typically because the |
| component was asked to stop or it decided independently to exit.</li> |
| <li><code>INVALID_ARGUMENTS</code>: |
| <ul> |
| <li><code>start_info.resolved_url</code> is not supported by this |
| runner;</li> |
| <li><code>start_info</code> contains missing or invalid arguments.</li> |
| </ul> |
| </li> |
| <li><code>INSTANCE_CANNOT_START</code>: The runner could not start the component. |
| For example, a critical part of the program could not be found or |
| loaded, or the referenced binary was invalid for this runner.</li> |
| <li><code>RESOURCE_UNAVAILABLE</code>: The component could not be launched due to |
| lack of resources.</li> |
| <li><code>INTERNAL</code>: An unexpected internal runner error was encountered.</li> |
| <li><code>INSTANCE_DIED</code>: The component instance was started but |
| subsequently terminated with an error.</li> |
| <li>Other status codes (e.g. <code>ZX_ERR_PEER_CLOSED</code>) may indicate a failure |
| of the component runner itself. The component manager may respond to such |
| failures by terminating the component runner's job to ensure system |
| stability.</li> |
| </ul> |
| |
| |
| ### Kill {#ComponentController.Kill} |
| |
| <p>Stop this component instance immediately.</p> |
| <p>The ComponentRunner must immediately kill the component instance, and |
| then close this connection with an epitaph. After the connection |
| closes, component manager considers this component instance to be |
| Stopped and the component's namespace will be torn down.</p> |
| <p>In some cases Kill() may be issued before Stop(), but that is not |
| guaranteed.</p> |
| |
| |
| |
| #### Request {#ComponentController.Kill_Request} |
| |
| <EMPTY> |
| |
| |
| ### OnPublishDiagnostics {#ComponentController.OnPublishDiagnostics} |
| |
| <p>Event for runners to publish diagnostics to the platform.</p> |
| <p>This event signals to the platform that the runner for this |
| component is publishing diagnostics about the runtime of the |
| component. The component manager may optionally expose this data |
| to clients.</p> |
| |
| |
| |
| |
| #### Response {#ComponentController.OnPublishDiagnostics_Response} |
| |
| <table> |
| <tr><th>Name</th><th>Type</th></tr> |
| <tr> |
| <td><code>payload</code></td> |
| <td> |
| <code><a class='link' href='../fuchsia.diagnostics.types/'>fuchsia.diagnostics.types</a>/<a class='link' href='../fuchsia.diagnostics.types/#ComponentDiagnostics'>ComponentDiagnostics</a></code> |
| </td> |
| </tr> |
| </table> |
| |
| ### Stop {#ComponentController.Stop} |
| |
| <p>Request to stop the component instance.</p> |
| <p>After stopping the component instance, the server should close this |
| connection with an epitaph. After the connection |
| closes, component manager considers this component instance to be |
| Stopped and the component's namespace will be torn down.</p> |
| |
| |
| |
| #### Request {#ComponentController.Stop_Request} |
| |
| <EMPTY> |
| |
| |
| ## ComponentRunner {#ComponentRunner} |
| *Defined in [fuchsia.component.runner/component_runner.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.component.runner/component_runner.fidl;l=27)* |
| <p>A protocol used for running components.</p> |
| <p>This protocol is implemented by components which provide a runtime |
| environment for other components.</p> |
| <p>Note: The component manager is the only intended direct client of this |
| interface.</p> |
| |
| |
| ### Start {#ComponentRunner.Start} |
| |
| <p>Start running a component instance described by <code>start_info</code>.</p> |
| <p>Component manager binds and uses <code>controller</code> to control the |
| lifetime of the newly started component instance.</p> |
| <p>Errors are delivered as epitaphs over the <code>ComponentController</code> |
| protocol. In the event of an error, the runner must ensure that |
| resources are cleaned up.</p> |
| <p>Errors:</p> |
| |
| |
| |
| #### Request {#ComponentRunner.Start_Request} |
| |
| <table> |
| <tr><th>Name</th><th>Type</th></tr> |
| <tr> |
| <td><code>start_info</code></td> |
| <td> |
| <code><a class='link' href='#ComponentStartInfo'>ComponentStartInfo</a></code> |
| </td> |
| </tr> |
| <tr> |
| <td><code>controller</code></td> |
| <td> |
| <code>server_end<<a class='link' href='#ComponentController'>ComponentController</a>></code> |
| </td> |
| </tr> |
| </table> |
| |
| |
| |
| |
| |
| ## **TABLES** |
| |
| ### ComponentNamespaceEntry [resource](/fuchsia-src/reference/fidl/language/language.md#value-vs-resource){:.fidl-attribute} {#ComponentNamespaceEntry data-text="ComponentNamespaceEntry"} |
| |
| |
| *Defined in [fuchsia.component.runner/component_runner.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.component.runner/component_runner.fidl;l=48)* |
| <p>A single component namespace entry, which describes a namespace mount point |
| (<code>path</code>) and the directory backing it (<code>directory</code>). This type is usually |
| composed inside a vector. See <code>ComponentStartInfo.ns</code> for more details.</p> |
| |
| <table> |
| <tr><th>Ordinal</th><th>Field</th><th>Type</th><th>Description</th></tr> |
| <tr id="ComponentNamespaceEntry.path"> |
| <td><h3 id="ComponentNamespaceEntry.path" class="add-link hide-from-toc">1</h3></td> |
| <td><code>path</code></td> |
| <td> |
| <code>string[1024]</code> |
| </td> |
| <td><p>The mount point for the directory, including a |
| leading slash. For example: "/pkg", "/svc", or "/config/data".</p> |
| </td> |
| </tr> |
| <tr id="ComponentNamespaceEntry.directory"> |
| <td><h3 id="ComponentNamespaceEntry.directory" class="add-link hide-from-toc">2</h3></td> |
| <td><code>directory</code></td> |
| <td> |
| <code><a class='link' href='../fuchsia.io/'>fuchsia.io</a>/<a class='link' href='../fuchsia.io/#Directory'>Directory</a></code> |
| </td> |
| <td><p>The directory mounted at the above <code>path</code>.</p> |
| </td> |
| </tr> |
| </table> |
| |
| ### ComponentStartInfo [resource](/fuchsia-src/reference/fidl/language/language.md#value-vs-resource){:.fidl-attribute} {#ComponentStartInfo data-text="ComponentStartInfo"} |
| |
| |
| *Defined in [fuchsia.component.runner/component_runner.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.component.runner/component_runner.fidl;l=58)* |
| <p>Parameters for starting a new component instance.</p> |
| |
| <table> |
| <tr><th>Ordinal</th><th>Field</th><th>Type</th><th>Description</th></tr> |
| <tr id="ComponentStartInfo.resolved_url"> |
| <td><h3 id="ComponentStartInfo.resolved_url" class="add-link hide-from-toc">1</h3></td> |
| <td><code>resolved_url</code></td> |
| <td> |
| <code><a class='link' href='../fuchsia.url/'>fuchsia.url</a>/<a class='link' href='../fuchsia.url/#Url'>Url</a></code> |
| </td> |
| <td><p>The resolved URL of the component.</p> |
| <p>This is the canonical URL obtained by the component resolver after |
| following redirects and resolving relative paths.</p> |
| </td> |
| </tr> |
| <tr id="ComponentStartInfo.program"> |
| <td><h3 id="ComponentStartInfo.program" class="add-link hide-from-toc">2</h3></td> |
| <td><code>program</code></td> |
| <td> |
| <code><a class='link' href='../fuchsia.data/'>fuchsia.data</a>/<a class='link' href='../fuchsia.data/#Dictionary'>Dictionary</a></code> |
| </td> |
| <td><p>The component's program declaration. |
| This information originates from <code>ComponentDecl.program</code>.</p> |
| </td> |
| </tr> |
| <tr id="ComponentStartInfo.ns"> |
| <td><h3 id="ComponentStartInfo.ns" class="add-link hide-from-toc">3</h3></td> |
| <td><code>ns</code></td> |
| <td> |
| <code>vector<<a class='link' href='#ComponentNamespaceEntry'>ComponentNamespaceEntry</a>>[32]</code> |
| </td> |
| <td><p>The namespace to provide to the component instance.</p> |
| <p>A namespace specifies the set of directories that a component instance |
| receives at start-up. Through the namespace directories, a component |
| may access capabilities available to it. The contents of the namespace |
| are mainly determined by the component's <code>use</code> declarations but may |
| also contain additional capabilities automatically provided by the |
| framework.</p> |
| <p>By convention, a component's namespace typically contains some or all |
| of the following directories:</p> |
| <ul> |
| <li>"/svc": A directory containing services that the component requested |
| to use via its "import" declarations.</li> |
| <li>"/pkg": A directory containing the component's package, including its |
| binaries, libraries, and other assets.</li> |
| </ul> |
| <p>The mount points specified in each entry must be unique and |
| non-overlapping. For example, [{"/foo", ..}, {"/foo/bar", ..}] is |
| invalid.</p> |
| </td> |
| </tr> |
| <tr id="ComponentStartInfo.outgoing_dir"> |
| <td><h3 id="ComponentStartInfo.outgoing_dir" class="add-link hide-from-toc">4</h3></td> |
| <td><code>outgoing_dir</code></td> |
| <td> |
| <code>server_end<<a class='link' href='../fuchsia.io/'>fuchsia.io</a>/<a class='link' href='../fuchsia.io/#Directory'>Directory</a>></code> |
| </td> |
| <td><p>The directory this component serves.</p> |
| </td> |
| </tr> |
| <tr id="ComponentStartInfo.runtime_dir"> |
| <td><h3 id="ComponentStartInfo.runtime_dir" class="add-link hide-from-toc">5</h3></td> |
| <td><code>runtime_dir</code></td> |
| <td> |
| <code>server_end<<a class='link' href='../fuchsia.io/'>fuchsia.io</a>/<a class='link' href='../fuchsia.io/#Directory'>Directory</a>></code> |
| </td> |
| <td><p>The directory served by the runner to present runtime information about |
| the component. The runner must either serve it, or drop it to avoid |
| blocking any consumers indefinitely.</p> |
| </td> |
| </tr> |
| <tr id="ComponentStartInfo.numbered_handles"> |
| <td><h3 id="ComponentStartInfo.numbered_handles" class="add-link hide-from-toc">6</h3></td> |
| <td><code>numbered_handles</code></td> |
| <td> |
| <code>vector<<a class='link' href='../fuchsia.process/'>fuchsia.process</a>/<a class='link' href='../fuchsia.process/#HandleInfo'>HandleInfo</a>>[128]</code> |
| </td> |
| <td><p>The numbered handles that were passed to the component.</p> |
| <p>If the component does not support numbered handles, the runner is expected |
| to close the handles.</p> |
| </td> |
| </tr> |
| <tr id="ComponentStartInfo.encoded_config"> |
| <td><h3 id="ComponentStartInfo.encoded_config" class="add-link hide-from-toc">7</h3></td> |
| <td><code>encoded_config</code></td> |
| <td> |
| <code><a class='link' href='../fuchsia.mem/'>fuchsia.mem</a>/<a class='link' href='../fuchsia.mem/#Data'>Data</a></code> |
| </td> |
| <td><p>Binary representation of the component's configuration.</p> |
| <h1>Layout</h1> |
| <p>The first 2 bytes of the data should be interpreted as an unsigned 16-bit |
| little-endian integer which denotes the number of bytes following it that |
| contain the configuration checksum. After the checksum, all the remaining |
| bytes are a persistent FIDL message of a top-level struct. The struct's |
| fields match the configuration fields of the component's compiled manifest |
| in the same order.</p> |
| </td> |
| </tr> |
| <tr id="ComponentStartInfo.break_on_start"> |
| <td><h3 id="ComponentStartInfo.break_on_start" class="add-link hide-from-toc">8</h3></td> |
| <td><code>break_on_start</code></td> |
| <td> |
| <code>handle<eventpair></code> |
| </td> |
| <td><p>An eventpair that debuggers can use to defer the launch of the component.</p> |
| <p>For example, ELF runners hold off from creating processes in the component |
| until ZX_EVENTPAIR_PEER_CLOSED is signaled on this eventpair. They also |
| ensure that runtime_dir is served before waiting on this eventpair. |
| ELF debuggers can query the runtime_dir to decide whether to attach before |
| they drop the other side of the eventpair, which is sent in the payload of |
| the DebugStarted event in fuchsia.sys2.events.</p> |
| </td> |
| </tr> |
| </table> |
| |
| |
| |
| |
| ## **CONSTANTS** |
| |
| <table> |
| <tr><th>Name</th><th>Value</th><th>Type</th><th>Description</th></tr> |
| <tr id="MAX_HANDLE_COUNT"> |
| <td><a href="https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.component.runner/component_runner.fidl;l=17">MAX_HANDLE_COUNT</a></td> |
| <td> |
| <code>128</code> |
| </td> |
| <td><code>uint32</code></td> |
| <td></td> |
| </tr> |
| <tr id="MAX_NAMESPACE_COUNT"> |
| <td><a href="https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.component.runner/component_runner.fidl;l=16">MAX_NAMESPACE_COUNT</a></td> |
| <td> |
| <code>32</code> |
| </td> |
| <td><code>uint32</code></td> |
| <td></td> |
| </tr> |
| </table> |