Skip to content

VTL2 Settings: Divide by zero panic when chunk_size_in_kb is missing from LUN configuration #1796

@mattkur

Description

@mattkur

Bug Summary

The VTL2 settings processing code crashes with a divide-by-zero panic when the chunk_size_in_kb field is missing from LUN configurations in the protobuf schema.

Error Details

Panic Location: oss/vm/devices/storage/disk_striped/src/lib.rs:281:17
Error: attempt to divide by zero
Thread: worker-UnderhillWorker

Root Cause

The disk striping code attempts to divide by the chunk size value, but when chunk_size_in_kb is not provided in the VTL2 settings protobuf message, it defaults to 0, causing a divide-by-zero panic.

Reproduction Steps

  1. Create a VTL2 settings configuration with a LUN that omits the chunk_size_in_kb field
  2. Apply the settings to a VM that uses OpenHCL.
  3. Start the VM with OpenHCL
  4. Observe the panic during VTL2 settings processing

Expected Behavior

The system should either:

  1. Provide a sensible default when chunk_size_in_kb is missing (e.g., 64KB)
  2. Validate the field and return a proper error message instead of panicking
  3. Make the field required in the protobuf schema if it's mandatory

Impact

  • Complete VM startup failure when using striped storage configurations
  • Poor error reporting (cryptic divide-by-zero panic vs. clear validation error)
  • Affects any tooling that generates VTL2 settings programmatically

Suggested Fix

In disk_striped/src/lib.rs around line 281, add validation:

let chunk_size = if config.chunk_size_in_kb == 0 {
    64 // Default to 64KB chunks
} else {
    config.chunk_size_in_kb
};

Or add proper validation earlier in the settings processing pipeline.

Additional Context

This issue was discovered while developing PowerShell tooling for NVMe device configuration. The workaround is to explicitly set chunk_size_in_kb = 64 in all LUN configurations, but the system should handle missing values gracefully.

OpenHCL Version: 1.7.158.0
Commit: c6a30e1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstorage

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions