Skip to main content

Host

Struct Host 

Source
pub struct Host {
    pub params: HostParameters,
    /* private fields */
}
Expand description

A simulated Host.

Fields§

§params: HostParameters

Implementations§

Source§

impl Host

Source

pub fn new( params: HostParameters, host_root_path: &Path, raw_cpu_freq_khz: u64, manager_shmem: &ShMemBlock<'_, ManagerShmem>, preload_paths: Arc<Vec<PathBuf>>, ) -> Self

Source

pub fn root(&self) -> &Root

Source

pub fn data_dir_path(&self) -> &Path

Source

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, )

Source

pub fn add_and_schedule_forked_process( &self, host: &Host, process: RootedRc<RootedRefCell<Process>>, )

Source

pub fn resume(&self, pid: ProcessId, tid: ThreadId)

Source

pub fn process_borrow( &self, id: ProcessId, ) -> Option<impl Deref<Target = RootedRc<RootedRefCell<Process>>> + '_>

Source

pub fn process_remove( &self, id: ProcessId, ) -> Option<RootedRc<RootedRefCell<Process>>>

Remove the given process from the Host, if it exists.

Source

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.

Source

pub fn cpu_borrow(&self) -> impl Deref<Target = Cpu> + '_

Source

pub fn cpu_borrow_mut(&self) -> impl DerefMut<Target = Cpu> + '_

Source

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.

Source

pub fn id(&self) -> HostId

Source

pub fn name(&self) -> &str

Source

pub fn default_ip(&self) -> Ipv4Addr

Source

pub fn abstract_unix_namespace( &self, ) -> impl Deref<Target = Arc<AtomicRefCell<AbstractUnixNamespace>>> + '_

Source

pub fn log_level(&self) -> Option<LevelFilter>

Source

pub fn network_namespace_borrow( &self, ) -> impl Deref<Target = NetworkNamespace> + '_

Source

pub fn futextable_borrow(&self) -> impl Deref<Target = FutexTable> + '_

Source

pub fn futextable_borrow_mut(&self) -> impl DerefMut<Target = FutexTable> + '_

Source

pub fn fcntl_lock_table_borrow( &self, ) -> impl Deref<Target = FcntlLockTable> + '_

Source

pub fn fcntl_lock_table_borrow_mut( &self, ) -> impl DerefMut<Target = FcntlLockTable> + '_

Source

pub fn bw_up_kiBps(&self) -> u64

Source

pub fn bw_down_kiBps(&self) -> u64

Source

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.

Source

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.

Source

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 to another host for internet-bound packets).

WARNING: This is not reentrant. Do not allow this to be called recursively. Nothing in add_data_source() can call back into this method, including socket code called in any indirect way from here.

Source

pub fn random_mut(&self) -> impl DerefMut<Target = Xoshiro256PlusPlus> + '_

Source

pub fn get_new_event_id(&self) -> u64

Source

pub fn get_new_thread_id(&self) -> ThreadId

Source

pub fn get_new_packet_id(&self) -> u64

Source

pub fn get_next_deterministic_sequence_value(&self) -> u64

Source

pub fn get_next_packet_priority(&self) -> FifoPacketPriority

Source

pub fn continue_execution_timer(&self)

Source

pub fn stop_execution_timer(&self)

Source

pub fn schedule_task_at_emulated_time( &self, task: TaskRef, t: EmulatedTime, ) -> bool

Source

pub fn schedule_task_with_delay(&self, task: TaskRef, t: SimulationTime) -> bool

Source

pub fn event_queue(&self) -> &Arc<Mutex<EventQueue>> ⓘ

Source

pub fn push_local_event(&self, event: Event) -> bool

Source

pub fn shutdown(&self)

Shut down the host. This should be called while Worker has the active host set.

Source

pub fn free_all_applications(&self)

Source

pub fn execute(&self, until: EmulatedTime)

Source

pub fn next_event_time(&self) -> Option<EmulatedTime>

Source

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.

Source

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.

Source

pub fn has_thread(&self, virtual_tid: ThreadId) -> bool

Returns true if the host has a process that contains the specified thread.

Source

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.

Source

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.

Source

pub fn shim_shmem_lock_borrow( &self, ) -> Option<impl Deref<Target = HostShmemProtected> + '_>

Source

pub fn shim_shmem_lock_borrow_mut( &self, ) -> Option<impl DerefMut<Target = HostShmemProtected> + '_>

Source

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.

Source

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.

Source

pub fn preload_paths(&self) -> &[PathBuf]

Paths of libraries that should be preloaded into managed processes.

Trait Implementations§

Source§

impl Debug for Host

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Host

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl IsSend for Host

Host must be Send.

Auto Trait Implementations§

§

impl !Freeze for Host

§

impl !RefUnwindSafe for Host

§

impl !Sync for Host

§

impl !UnwindSafe for Host

§

impl Send for Host

§

impl Unpin for Host

§

impl UnsafeUnpin for Host

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Host for T
where T: Debug + Send,

Source§

impl<T> Host for T
where T: Debug + Send + 'static,

Source§

impl<T> Host for T
where T: Host + Host,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> NoTypeInference for T

Source§

type This = T

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.