pub struct Host {
pub params: HostParameters,
/* private fields */
}
Expand description
A simulated Host.
Fields§
§params: HostParameters
Implementations§
source§impl Host
impl Host
pub fn new( params: HostParameters, host_root_path: &Path, raw_cpu_freq_khz: u64, manager_shmem: &ShMemBlock<'_, ManagerShmem>, preload_paths: Arc<Vec<PathBuf>>, ) -> Self
pub fn root(&self) -> &Root
pub fn data_dir_path(&self) -> &Path
pub fn add_application( &self, start_time: SimulationTime, shutdown_time: Option<SimulationTime>, shutdown_signal: Signal, plugin_name: CString, plugin_path: CString, argv: Vec<CString>, envv: Vec<CString>, pause_for_debugging: bool, expected_final_state: ProcessFinalState, )
pub fn add_and_schedule_forked_process( &self, host: &Host, process: RootedRc<RootedRefCell<Process>>, )
pub fn resume(&self, pid: ProcessId, tid: ThreadId)
pub fn process_borrow( &self, id: ProcessId, ) -> Option<impl Deref<Target = RootedRc<RootedRefCell<Process>>> + '_>
sourcepub fn process_remove(
&self,
id: ProcessId,
) -> Option<RootedRc<RootedRefCell<Process>>>
pub fn process_remove( &self, id: ProcessId, ) -> Option<RootedRc<RootedRefCell<Process>>>
Remove the given process from the Host, if it exists.
sourcepub fn processes_borrow(
&self,
) -> impl Deref<Target = BTreeMap<ProcessId, RootedRc<RootedRefCell<Process>>>> + '_
pub fn processes_borrow( &self, ) -> impl Deref<Target = BTreeMap<ProcessId, RootedRc<RootedRefCell<Process>>>> + '_
Borrow the set of processes. Generally this should only be used to
iterate over the set of processes. e.g. fetching a specific process
should be done via via process_borrow
.
pub fn cpu_borrow(&self) -> impl Deref<Target = Cpu> + '_
pub fn cpu_borrow_mut(&self) -> impl DerefMut<Target = Cpu> + '_
sourcepub fn info(&self) -> &Arc<HostInfo>
pub fn info(&self) -> &Arc<HostInfo>
Information about the Host. Made available as an Arc for cheap cloning
into, e.g. Worker and ShadowLogger. When there’s no need to clone the
Arc, generally prefer the top-level Host
methods for accessing this
information, which are likely to be more stable.
pub fn id(&self) -> HostId
pub fn name(&self) -> &str
pub fn default_ip(&self) -> Ipv4Addr
pub fn abstract_unix_namespace( &self, ) -> impl Deref<Target = Arc<AtomicRefCell<AbstractUnixNamespace>>> + '_
pub fn log_level(&self) -> Option<LevelFilter>
pub fn upstream_router_borrow_mut(&self) -> impl DerefMut<Target = Router> + '_
pub fn network_namespace_borrow( &self, ) -> impl Deref<Target = NetworkNamespace> + '_
pub fn futextable_borrow(&self) -> impl Deref<Target = FutexTable> + '_
pub fn futextable_borrow_mut(&self) -> impl DerefMut<Target = FutexTable> + '_
pub fn bw_up_kiBps(&self) -> u64
pub fn bw_down_kiBps(&self) -> u64
sourcepub fn interface_borrow_mut(
&self,
addr: Ipv4Addr,
) -> Option<impl DerefMut<Target = NetworkInterface> + '_>
pub fn interface_borrow_mut( &self, addr: Ipv4Addr, ) -> Option<impl DerefMut<Target = NetworkInterface> + '_>
Returns None
if there is no such interface.
Panics if we have shut down.
sourcepub fn interface_borrow(
&self,
addr: Ipv4Addr,
) -> Option<impl Deref<Target = NetworkInterface> + '_>
pub fn interface_borrow( &self, addr: Ipv4Addr, ) -> Option<impl Deref<Target = NetworkInterface> + '_>
Returns None
if there is no such interface.
Panics if we have shut down.
pub fn random_mut(&self) -> impl DerefMut<Target = Xoshiro256PlusPlus> + '_
pub fn get_new_event_id(&self) -> u64
pub fn get_new_thread_id(&self) -> ThreadId
pub fn get_new_packet_id(&self) -> u64
pub fn get_next_deterministic_sequence_value(&self) -> u64
pub fn get_next_packet_priority(&self) -> FifoPacketPriority
pub fn continue_execution_timer(&self)
pub fn stop_execution_timer(&self)
pub fn schedule_task_at_emulated_time( &self, task: TaskRef, t: EmulatedTime, ) -> bool
pub fn schedule_task_with_delay(&self, task: TaskRef, t: SimulationTime) -> bool
pub fn event_queue(&self) -> &Arc<Mutex<EventQueue>>
pub fn push_local_event(&self, event: Event) -> bool
sourcepub fn shutdown(&self)
pub fn shutdown(&self)
Shut down the host. This should be called while Worker
has the active host set.
pub fn free_all_applications(&self)
pub fn execute(&self, until: EmulatedTime)
pub fn next_event_time(&self) -> Option<EmulatedTime>
sourcepub fn shim_shmem(&self) -> &ShMemBlock<'static, HostShmem>
pub fn shim_shmem(&self) -> &ShMemBlock<'static, HostShmem>
The unprotected part of the Host’s shared memory.
Do not try to take the lock of HostShmem::protected
directly.
Instead use Host::lock_shmem
, Host::shim_shmem_lock_borrow
, and
Host::shim_shmem_lock_borrow_mut
.
sourcepub fn thread_cloned_rc(
&self,
virtual_tid: ThreadId,
) -> Option<RootedRc<RootedRefCell<Thread>>>
pub fn thread_cloned_rc( &self, virtual_tid: ThreadId, ) -> Option<RootedRc<RootedRefCell<Thread>>>
Returns the specified thread if it exists. If you already have the thread’s process,
Process::thread_borrow
may be more efficient.
sourcepub fn has_thread(&self, virtual_tid: ThreadId) -> bool
pub fn has_thread(&self, virtual_tid: ThreadId) -> bool
Returns true
if the host has a process that contains the specified thread.
sourcepub fn lock_shmem(&self)
pub fn lock_shmem(&self)
Locks the Host’s shared memory, caching the lock internally.
Dropping the Host before calling Host::unlock_shmem
will panic.
TODO: Consider removing this API once we don’t need to cache the lock for the C API.
sourcepub fn unlock_shmem(&self)
pub fn unlock_shmem(&self)
Panics if there is still an outstanding reference returned by
shim_shmem_lock_borrow
or shim_shmem_lock_borrow_mut
.
pub fn shim_shmem_lock_borrow( &self, ) -> Option<impl Deref<Target = HostShmemProtected> + '_>
pub fn shim_shmem_lock_borrow_mut( &self, ) -> Option<impl DerefMut<Target = HostShmemProtected> + '_>
sourcepub fn tsc(&self) -> &Tsc
pub fn tsc(&self) -> &Tsc
Timestamp Counter emulation for this Host. It ticks at the same rate as the native Timestamp Counter, if we were able to find it.
sourcepub fn get_packet_device(&self, address: Ipv4Addr) -> Ref<'_, dyn PacketDevice>
pub fn get_packet_device(&self, address: Ipv4Addr) -> Ref<'_, dyn PacketDevice>
Get the packet device that handles packets for the given address. This could be the source device from which we forward packets, or the device that will receive and process packets with a given destination address. In the latter case, if the packet destination is not on this host, we return the router to route it to the correct host.
sourcepub fn notify_router_has_packets(&self)
pub fn notify_router_has_packets(&self)
Call to trigger the forwarding of packets from the router to the network interface.
sourcepub fn notify_socket_has_packets(&self, addr: Ipv4Addr, socket: &InetSocket)
pub fn notify_socket_has_packets(&self, addr: Ipv4Addr, socket: &InetSocket)
Call to trigger the forwarding of packets from the network interface to the next hop (either back to the network interface for loopback, or up to the router for internet-bound packets).
WARNING: This is not reentrant. Do not allow this to be called recursively. Nothing in
add_data_source()
or notify()
can call back into this method. This includes any socket
code called in any indirect way from here.
sourcepub fn process_session_id_of_group_id(
&self,
group_id: ProcessId,
) -> Option<ProcessId>
pub fn process_session_id_of_group_id( &self, group_id: ProcessId, ) -> Option<ProcessId>
Returns the Session ID for the given process group ID, if it exists.
sourcepub fn preload_paths(&self) -> &[PathBuf]
pub fn preload_paths(&self) -> &[PathBuf]
Paths of libraries that should be preloaded into managed processes.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Host
impl !RefUnwindSafe for Host
impl Send for Host
impl !Sync for Host
impl Unpin for Host
impl !UnwindSafe for Host
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more