pub struct FaultConfiguration {
    pub fault_active: Cell<bool>,
    pub admin_fault: AdminQueueFaultConfig,
    pub pci_fault: PciFaultConfig,
    pub namespace_fault: NamespaceFaultConfig,
    pub io_fault: Arc<IoQueueFaultConfig>,
}Expand description
Fault configuration for the NVMe fault controller.
This struct defines behaviors that inject faults into the NVMe fault controller logic,
such as delaying or dropping commands, triggering namespace change notifications,
or customizing completion payloads. Fault injection is controlled by the
fault_active flag, unless specified otherwise in the fault description.
fault_active is managed by the test via [mesh::CellUpdater]. An
exception to the fault_active check is the NamespaceFaultConfig which
is processed regardless of fault_active state. (See nvme_test crate for
details on how the faults are applied.)
§Example
Panic when a command that matches CREATE_IO_COMPLETION_QUEUE is seen in the admin queue:
use mesh::CellUpdater;
use nvme_resources::fault::FaultConfiguration;
use nvme_resources::fault::AdminQueueFaultConfig;
use nvme_resources::fault::CommandMatch;
use nvme_spec::Command;
use nvme_resources::fault::AdminQueueFaultBehavior;
use nvme_resources::NvmeFaultControllerHandle;
use guid::Guid;
use zerocopy::FromZeros;
use zerocopy::IntoBytes;
pub fn example_fault() {
    let mut fault_start_updater = CellUpdater::new(false);
    // Setup command matches
    let mut command = Command::new_zeroed();
    let mut mask = Command::new_zeroed();
    command.cdw0 = command.cdw0.with_opcode(nvme_spec::AdminOpcode::CREATE_IO_COMPLETION_QUEUE.0);
    mask.cdw0 = mask.cdw0.with_opcode(u8::MAX);
    let fault_configuration = FaultConfiguration::new(fault_start_updater.cell())
        .with_admin_queue_fault(
            AdminQueueFaultConfig::new().with_submission_queue_fault(
                CommandMatch {
                    command: command,
                    mask: mask.as_bytes().try_into().expect("mask should be 64 bytes"),
                },
                AdminQueueFaultBehavior::Panic("Received a CREATE_IO_COMPLETION_QUEUE command".to_string()),
            )
        );
    let fault_controller_handle = NvmeFaultControllerHandle {
        subsystem_id: Guid::new_random(),
        msix_count: 10,
        max_io_queues: 10,
        namespaces: vec![
            // Define NamespaceDefinitions here
        ],
        fault_config: fault_configuration,
    };
    // Pass the controller handle in to the vm config to create and attach the fault controller. At this point the fault is inactive.
    fault_start_updater.set(true); // Activate the fault injection.
    // ... run test ...
    fault_start_updater.set(false); // Deactivate the fault injection.
}Fields§
§fault_active: Cell<bool>Fault active state
admin_fault: AdminQueueFaultConfigFault to apply to the admin queues
pci_fault: PciFaultConfigFault to apply to management layer of the controller
namespace_fault: NamespaceFaultConfigFault for test triggered namespace change notifications
io_fault: Arc<IoQueueFaultConfig>Fault to apply to all IO queues
Implementations§
Source§impl FaultConfiguration
 
impl FaultConfiguration
Sourcepub fn with_pci_fault(self, pci_fault: PciFaultConfig) -> Self
 
pub fn with_pci_fault(self, pci_fault: PciFaultConfig) -> Self
Add a PCI fault configuration to the fault configuration
Sourcepub fn with_admin_queue_fault(self, admin_fault: AdminQueueFaultConfig) -> Self
 
pub fn with_admin_queue_fault(self, admin_fault: AdminQueueFaultConfig) -> Self
Add an admin queue fault configuration to the fault configuration
Sourcepub fn with_io_queue_fault(self, io_fault: IoQueueFaultConfig) -> Self
 
pub fn with_io_queue_fault(self, io_fault: IoQueueFaultConfig) -> Self
Add an IO queue fault configuration to the fault configuration
Sourcepub fn with_namespace_fault(self, namespace_fault: NamespaceFaultConfig) -> Self
 
pub fn with_namespace_fault(self, namespace_fault: NamespaceFaultConfig) -> Self
Add a namespace fault configuration to the fault configuration
Trait Implementations§
Source§impl DefaultEncoding for FaultConfiguration
 
impl DefaultEncoding for FaultConfiguration
Source§impl<'encoding> StructDecodeMetadata<'encoding, Resource> for FaultConfiguration
 
impl<'encoding> StructDecodeMetadata<'encoding, Resource> for FaultConfiguration
Source§impl StructEncodeMetadata<Resource> for FaultConfiguration
 
impl StructEncodeMetadata<Resource> for FaultConfiguration
Auto Trait Implementations§
impl Freeze for FaultConfiguration
impl !RefUnwindSafe for FaultConfiguration
impl Send for FaultConfiguration
impl Sync for FaultConfiguration
impl Unpin for FaultConfiguration
impl !UnwindSafe for FaultConfiguration
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
§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].