Struct shadow_rs::host::host::Host

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

A simulated Host.

Fields§

§params: HostParameters

Implementations§

source§

impl Host

source

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

§Safety

dns must be a valid pointer, and must outlive the returned Host.

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 upstream_router_borrow_mut(&self) -> impl DerefMut<Target = Router> + '_

source

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

source

pub fn tracker_borrow_mut(&self) -> Option<impl DerefMut<Target = Tracker> + '_>

source

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

source

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

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 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 boot(&self)

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 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.

source

pub fn notify_router_has_packets(&self)

Call to trigger the forwarding of packets from the router to the network interface.

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 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.

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§

impl IsSend for Host

Host must be Send.

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> 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, 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

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,