Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,33 @@ pub struct PassThroughDeviceConfig {
pub irq_id: usize,
}

/// A part of `AxVMConfig`, which represents the configuration of a VirtIO block device for a virtual machine.
#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
pub struct VirtioBlkMmioDeviceConfig {
/// The device ID.
pub device_id: String,
/// The MMIO base address.
pub mmio_base: String,
/// The MMIO size.
pub mmio_size: String,
/// The interrupt type.
pub interrupt_type: String,
/// The interrupt number.
pub interrupt_number: usize,
/// The guest device path.
pub guest_device_path: String,
/// The backend type.
pub backend_type: String,
/// The backend path.
pub backend_path: String,
/// The image size.
pub size: String,
/// Whether the device is readonly.
pub readonly: bool,
/// The serial number.
pub serial: String,
}

/// The configuration structure for the guest VM base info.
#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
pub struct VMBaseConfig {
Expand Down Expand Up @@ -175,6 +202,8 @@ pub struct VMDevicesConfig {
pub emu_devices: Vec<EmulatedDeviceConfig>,
/// Passthrough device Information
pub passthrough_devices: Vec<PassThroughDeviceConfig>,
/// VirtIO block device Information
pub virtio_blk_mmio: Option<Vec<VirtioBlkMmioDeviceConfig>>,
}

/// The configuration structure for the guest VM serialized from a toml file provided by user,
Expand Down
1 change: 1 addition & 0 deletions src/templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub fn get_vm_config_template(
devices: VMDevicesConfig {
emu_devices: vec![],
passthrough_devices: vec![],
virtio_blk_mmio: None,
},
}
}