pub struct IoQueueFaultConfig {
    pub io_completion_queue_faults: Vec<(CommandMatch, IoQueueFaultBehavior)>,
    pub fault_active: Cell<bool>,
}Expand description
A fault configuration to inject faults into the io completions.
This struct maintains a mapping from CommandMatch to IoQueueFaultBehavior for
completions. When a command match is found, (and fault_active == true)
the associated fault is applied.
If there is more than one match for a given command, the
match defined first is prioritized. Faults are added via the
with_completion_queue_fault method and calls
can be chained. IoQueueFaultConfig::new() creates an empty fault.
§Panics
Panics if a duplicate CommandMatch is added
§Example
Panic when RESERVATION_REPORT command is seen.
use mesh::CellUpdater;
use nvme_resources::fault::IoQueueFaultConfig;
use nvme_resources::fault::CommandMatch;
use nvme_resources::fault::FaultConfiguration;
use nvme_resources::fault::IoQueueFaultBehavior;
use nvme_spec::Command;
use nvme_spec::nvm;
use zerocopy::FromZeros;
use zerocopy::IntoBytes;
pub fn build_admin_queue_fault() -> FaultConfiguration {
    let mut fault_start_updater = CellUpdater::new(false);
    // Setup command matches
    let mut command_io_queue = Command::new_zeroed();
    let mut command_log_page = Command::new_zeroed();
    let mut mask = Command::new_zeroed();
    command_io_queue.cdw0 = command_io_queue.cdw0.with_opcode(nvm::NvmOpcode::RESERVATION_REPORT.0);
    mask.cdw0 = mask.cdw0.with_opcode(u8::MAX);
    return FaultConfiguration::new(fault_start_updater.cell())
        .with_io_queue_fault(
            IoQueueFaultConfig::new(fault_start_updater.cell()).with_completion_queue_fault(
                CommandMatch {
                    command: command_io_queue,
                    mask: mask.as_bytes().try_into().expect("mask should be 64 bytes"),
                },
                IoQueueFaultBehavior::Panic("Received a RESERVATION_REPORT command".to_string()),
            )
        );
}Fields§
§io_completion_queue_faults: Vec<(CommandMatch, IoQueueFaultBehavior)>A map of NVME opcodes to the completion fault behavior for each.
fault_active: Cell<bool>Fault active state. (Repeated here because FaultConfiguration is not Cloneable).
Implementations§
Source§impl IoQueueFaultConfig
 
impl IoQueueFaultConfig
Sourcepub fn with_completion_queue_fault(
    self,
    pattern: CommandMatch,
    behaviour: IoQueueFaultBehavior,
) -> Self
 
pub fn with_completion_queue_fault( self, pattern: CommandMatch, behaviour: IoQueueFaultBehavior, ) -> Self
Add a CommandMatch -> IoQueueFaultBehavior mapping for the completion queue.
§Panics
Panics if an identical CommandMatch has already been configured.
Trait Implementations§
Source§impl Clone for IoQueueFaultConfig
 
impl Clone for IoQueueFaultConfig
Source§fn clone(&self) -> IoQueueFaultConfig
 
fn clone(&self) -> IoQueueFaultConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
 
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl DefaultEncoding for IoQueueFaultConfig
 
impl DefaultEncoding for IoQueueFaultConfig
Source§impl<'encoding> StructDecodeMetadata<'encoding, Resource> for IoQueueFaultConfig
 
impl<'encoding> StructDecodeMetadata<'encoding, Resource> for IoQueueFaultConfig
Source§impl StructEncodeMetadata<Resource> for IoQueueFaultConfig
 
impl StructEncodeMetadata<Resource> for IoQueueFaultConfig
Auto Trait Implementations§
impl Freeze for IoQueueFaultConfig
impl !RefUnwindSafe for IoQueueFaultConfig
impl Send for IoQueueFaultConfig
impl Sync for IoQueueFaultConfig
impl Unpin for IoQueueFaultConfig
impl !UnwindSafe for IoQueueFaultConfig
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> CloneToUninit for Twhere
    T: Clone,
 
impl<T> CloneToUninit for Twhere
    T: Clone,
§impl<T> Instrument for T
 
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
 
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
 
fn in_current_span(self) -> Instrumented<Self>
§impl<T> MeshField for T
 
impl<T> MeshField for T
§impl<T> MeshPayload for T
 
impl<T> MeshPayload for T
§impl<T> SerializeMessage for Twhere
    T: 'static + MeshPayload + Send,
 
impl<T> SerializeMessage for Twhere
    T: 'static + MeshPayload + Send,
§fn compute_message_size(&mut self, sizer: MessageSizer<'_>)
 
fn compute_message_size(&mut self, sizer: MessageSizer<'_>)
MessageEncode::compute_message_size].§fn write_message(self, writer: MessageWriter<'_, '_, Resource>)
 
fn write_message(self, writer: MessageWriter<'_, '_, Resource>)
MessageEncode::write_message].