Skip to main content

to_legacy_backend_json

Function to_legacy_backend_json 

Source
pub fn to_legacy_backend_json(config: &Config) -> Result<String, Error>
Expand description

Serializes config as JSON in the form it had before Config::backend existed.

Config::backend is left out. In its place, at the same position in the object, are the fifteen separate backend keys that a serialized configuration carried before, under the names and in the order it carried them, each with a value computed from config. Config::record_host_inputs, which the legacy form never had, is left out too, and reads back as false: this form serves only DBT, whose launcher collects no host inputs. So is Config::guest_may_inherit_a_terminal, which is read only where BackendCapabilities::host_timed_signals_are_physical holds, false for DBT, and Config::in_guest_detlog_forward_policy and Config::in_guest_site_patching_off, which is unset for DBT, and Config::launch_image, which came after it. So is Config::target_timeslice_syscalls_only, added after this form froze; DBT runs without a PMU maximum, where the option has no effect. So are Config::futex_wake_yields, Config::scheduler_turn_cost, Config::cap_preemption_charge and Config::virtual_timeout, also added after this form froze, which hermit run refuses with the DBT backend, and Config::replaying, set only by hermit replay, which runs only on the ptrace backend. So is Config::inherited_seccomp, added after this form froze, which reads back as unknown, and Config::virtual_cpus, which hermit run refuses with the DBT backend and reads back as unset. So is Config::in_guest_reserved_signals, empty for DBT (it is set only for in-guest runs), which reads back as empty, and Config::in_guest_refuses_host_timed_producers and Config::in_guest_signal_delivery, false for DBT, which read back as false. So is Config::notice_host_network_abstract_binds, added after this form froze, which reads back as false: DBT’s runtime then prints no notice for an abstract AF_UNIX bind. So is Config::eager_lone_preemptions, added after this form froze, which has no effect without a PMU timer and reads back as false. So is Config::standard_stream_aliases, added after this form froze, set only for KVM, which reads back as unset. Every other field is serialized exactly as serde_json::to_string(config) serializes it.

A standalone DBT run (one with no coordinator) reads its configuration from HERMIT_DBT_DETCONFIG in this form or in the versioned envelope of encode_backend_config_json. hermit run --backend=dbt writes neither: it launches DBT coordinated, and the runtime receives the typed Config through the coordinator’s first RPC frame.

Read the result with from_legacy_backend_json, which recovers Config::backend from the fifteen keys. A plain Config deserialization ignores the keys and gives the field its serde default.