Skip to main content

Module guest_log

Module guest_log 

Source
Expand description

Detcore’s warnings from inside the guest, printed by the coordinator.

WHY THIS IS NEEDED. Where Detcore runs in the guest’s own process (DBT, SaBRe, in-guest LiteInst and in-guest-trap), nothing printed its tracing events: a warning that ptrace and KVM print at the default level was lost.

One mechanism serves every such runtime. The runtime installs subscriber with the one synchronous coordinator request it already has for Tool callbacks (the one shared open file control uses). The subscriber sends each WARN and ERROR event as one GlobalRequest::GuestLog, and the coordinator emits it again with the event’s own level and target (emit). So the run’s own filter decides, per target, exactly as it does for ptrace’s events, and the line reads as ptrace’s does, without span context.

WHY ONLY WARN AND ERROR. Verification compares every INFO record, and a guest record printed when it arrives would land at a host-timed place among the run’s ordered records. Warnings and errors are not compared, and they are what a default run prints. DETLOG records, which are INFO or DEBUG, keep their own ordered and counted channels (crate::detlog, or the runtime’s own, OwnChannel).

A runtime with its own channel (OwnChannel) runs it at the run’s own level, so it sends nothing: its channel already has every event the run prints.

An event that cannot be sent (outside a Tool callback, while another request of the process is in flight, or from inside the send itself) is counted, per address space. The next request that gets through carries the count, which the coordinator prints as a warning; Detcore also sends any count still held when a thread exits, at exit_group, before an exec (prepare_exec, every exec path), before an injected exit_group and at an unrecoverable shutdown (flush_unsent), and last in each thread’s exit hook, through the hook’s own connection (flush_unsent_through). A process killed where its runtime runs no exit hook, or a warning after its last such point, leaves a count that cannot be reported. (DBT with no coordinator prints its warnings on its own diagnostic channel instead.) Nothing is written to the guest’s own descriptors, and formatting uses only Rust’s allocator (see detcore/clippy.toml for the C library calls that would use the guest’s heap).

Structs§

GuestLogRecord
One Detcore event from inside the guest.
OwnChannel
A runtime’s own channel for its events: DBT’s, which carries its DETLOG records through tracing (where other runtimes use crate::detlog’s forwarder), to its protected verification evidence or to its diagnostic output, at the level the run asked for. It takes every event up to max_level, exactly as the runtime’s own subscriber did. A subscriber with an own channel sends nothing to the coordinator: events above the run’s level are not printed there either.

Functions§

install
Installs subscriber as this process’s global default. Returns false, and changes nothing, when the process already has a global subscriber.
level_code
The number this module gives level: 1 for ERROR up to 5 for TRACE.
subscriber
The subscriber an in-guest runtime installs as its global default: it sends WARN and ERROR events through call, and writes every event up to its level to own, when the runtime has one.

Type Aliases§

CoordinatorCall
An in-guest runtime’s one synchronous request to Detcore’s global state from inside a Tool callback: it sends the request and waits for the answer, and refuses with an error where it cannot send. The runtime’s shared open file transport sends through the same function.