Skip to content

Conversation

@alandau
Copy link
Contributor

@alandau alandau commented Jan 30, 2026

The command shows the current VTL2 settings and allows modifying them to add/remove SCSI disks exposed to VTL0 that are backed by NVMe namespaces or SCSI LUNs in VTL2.

Examples:

 # Run OpenVMM providing an NVMe namespace to VTL2, which exposes it as
 # a SCSI disk to VTL0. Use `--disk mem:1024,uh` instead to provide a SCSI LUN.
C:\openvmm>openvmm.exe -m 4GB -p 4 --vmbus-com1-serial term --hv --vtl2 --igvm "openhcl-x64-test-linux-direct.bin" --vtl2-vsock-path "C:\openvmm\uhdiag.sock" --com3 term --no-alias-map --vmbus-redirect --disk mem:1024,uh-nvme

 # Show current VTL2 settings
openvmm> vtl2-settings show
Vtl2Settings {
    namespace_settings: [],
    version: V1,
    fixed: Some(
        Vtl2SettingsFixed {
            scsi_sub_channels: None,
            io_ring_size: None,
            max_bounce_buffer_pages: None,
        },
    ),
    dynamic: Some(
        Vtl2SettingsDynamic {
            storage_controllers: [
                StorageController {
                    instance_id: "e1c5bd94-d0d6-41d4-a2b0-88095a16ded7",
                    protocol: Scsi,
                    luns: [
                        Lun {
                            channel: None,
                            location: 0,
                            device_id: "7acac475-b4f2-4631-926c-3978ab3429fc",
                            vendor_id: "OpenVMM",
                            product_id: "Disk",
                            product_revision_level: "1.0",
                            serial_number: "0",
                            model_number: "1",
                            medium_rotation_rate: None,
                            physical_sector_size: None,
                            fua: None,
                            write_cache: None,
                            odx: None,
                            disable_thin_provisioning: None,
                            max_transfer_length: None,
                            physical_devices: Some(
                                PhysicalDevices {
                                    r#type: Single,
                                    device: Some(
                                        PhysicalDevice {
                                            device_type: Nvme,
                                            device_path: "f9b90f6f-b129-4596-8171-a23481b8f718",
                                            sub_device_path: 1,
                                        },
                                    ),
                                    devices: [],
                                },
                            ),
                            is_dvd: false,
                            chunk_size_in_kb: 0,
                            scsi_disk_size_in_bytes: None,
                            ntfs_guid: None,
                            total_logic_size_in_kb: 0,
                            device_type: None,
                            device_path: None,
                            sub_device_path: None,
                        },
                    ],
                    io_queue_depth: None,
                },
            ],
            nic_devices: [],
        },
    ),
}

 # Remove disk from the guest
openvmm> vtl2-settings rm-scsi-disk --lun 0
Removed VTL0 SCSI disk: controller=e1c5bd94-d0d6-41d4-a2b0-88095a16ded7, lun=0

 # Add it back. Or use --backing-scsi-lun if the backing is SCSI.
openvmm> vtl2-settings add-scsi-disk --lun 0 --backing-nvme-nsid 1
Added VTL0 SCSI disk: controller=e1c5bd94-d0d6-41d4-a2b0-88095a16ded7, lun=0, backing=nvme_nsid=1

@alandau alandau marked this pull request as ready for review January 30, 2026 01:36
@alandau alandau requested review from a team as code owners January 30, 2026 01:36
Copilot AI review requested due to automatic review settings January 30, 2026 01:36
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an interactive console command (vtl2-settings) to inspect and modify OpenHCL VTL2 settings at runtime, enabling adding/removing VTL0-exposed SCSI disks backed by VTL2 NVMe namespaces or VTL2 SCSI LUNs.

Changes:

  • Add vtl2-settings interactive console command with show, add-scsi-disk, and rm-scsi-disk subcommands.
  • Cache VTL2 settings in VmResources and implement a helper to send updated settings via the GED RPC.
  • Fix NVMe admin worker behavior by no longer canceling namespace-change polling immediately after adding a namespace.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
vm/devices/storage/nvme/src/workers/admin.rs Stops prematurely canceling namespace-change polling after a namespace is added.
openvmm/openvmm_entry/src/storage_builder.rs Exposes VTL2 controller instance IDs for reuse when building VTL2 settings updates from the console.
openvmm/openvmm_entry/src/lib.rs Implements VTL2 settings caching + GED update helper, and adds the vtl2-settings interactive console command flow.

…settings

The command shows the current VTL2 settings and allows modifying them to add/remove SCSI disks
exposed to VTL0 that are backed by NVMe namespaces or SCSI LUNs in VTL2.

Examples:
```
 # Run OpenVMM providing an NVMe namespace to VTL2, which exposes it as
 # a SCSI disk to VTL0. Use `--disk mem:1024,uh` instead to provide a SCSI LUN.
C:\openvmm>openvmm.exe -m 4GB -p 4 --vmbus-com1-serial term --hv --vtl2 --igvm "openhcl-x64-test-linux-direct.bin" --vtl2-vsock-path "C:\openvmm\uhdiag.sock" --com3 term --no-alias-map --vmbus-redirect --disk mem:1024,uh-nvme

 # Show current VTL2 settings
openvmm> vtl2-settings show
Vtl2Settings {
    namespace_settings: [],
    version: V1,
    fixed: Some(
        Vtl2SettingsFixed {
            scsi_sub_channels: None,
            io_ring_size: None,
            max_bounce_buffer_pages: None,
        },
    ),
    dynamic: Some(
        Vtl2SettingsDynamic {
            storage_controllers: [
                StorageController {
                    instance_id: "e1c5bd94-d0d6-41d4-a2b0-88095a16ded7",
                    protocol: Scsi,
                    luns: [
                        Lun {
                            channel: None,
                            location: 0,
                            device_id: "7acac475-b4f2-4631-926c-3978ab3429fc",
                            vendor_id: "OpenVMM",
                            product_id: "Disk",
                            product_revision_level: "1.0",
                            serial_number: "0",
                            model_number: "1",
                            medium_rotation_rate: None,
                            physical_sector_size: None,
                            fua: None,
                            write_cache: None,
                            odx: None,
                            disable_thin_provisioning: None,
                            max_transfer_length: None,
                            physical_devices: Some(
                                PhysicalDevices {
                                    r#type: Single,
                                    device: Some(
                                        PhysicalDevice {
                                            device_type: Nvme,
                                            device_path: "f9b90f6f-b129-4596-8171-a23481b8f718",
                                            sub_device_path: 1,
                                        },
                                    ),
                                    devices: [],
                                },
                            ),
                            is_dvd: false,
                            chunk_size_in_kb: 0,
                            scsi_disk_size_in_bytes: None,
                            ntfs_guid: None,
                            total_logic_size_in_kb: 0,
                            device_type: None,
                            device_path: None,
                            sub_device_path: None,
                        },
                    ],
                    io_queue_depth: None,
                },
            ],
            nic_devices: [],
        },
    ),
}

 # Remove to disk from the guest
openvmm> vtl2-settings rm-scsi-disk --lun 0
Removed VTL0 SCSI disk: controller=e1c5bd94-d0d6-41d4-a2b0-88095a16ded7, lun=0

 # Add it back. Or use --backing-scsi-lun if the backing is SCSI.
openvmm> vtl2-settings add-scsi-disk --lun 0 --backing-nvme-nsid 1
Added VTL0 SCSI disk: controller=e1c5bd94-d0d6-41d4-a2b0-88095a16ded7, lun=0,backing=nvme_nsid=1
```
Copy link
Contributor

@mattkur mattkur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this! Just the output needs to be changed (I think?), but otherwise looks good to me.

}
InteractiveCommand::Vtl2Settings(cmd) => {
if resources.vtl2_settings.is_none() {
eprintln!("error: no VTL2 settings (not running with VTL2?)");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We generally prefer to use the tracing crate here, e.g. tracing::error!.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have an interactive CLI here, the user is issuing commands, and IMO should get the result on stdout/stderr. Tracing is dev-internal output that is issued during command execution. IOW, I deliberately made this eprintln instead of tracing. Let me know if you still believe tracing fits better here and I'll change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, existing commands follow the same logic. E.g. inspect prints to stdout and restart-vnc prints errors to stderr.

} else {
format!("scsi_lun={}", sub_device_path)
};
println!(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto on the tracing comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants