1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//! Client definitions for describing IDE controller configuration.
//!
//! TODO: refactor to support `Resource`-based instantiation of IDE controllers,
//! at which point this crate name makes sense.
#![forbid(unsafe_code)]
#![warn(missing_docs)]
use inspect::Inspect;
use mesh::MeshPayload;
use vm_resource::kind::DiskHandleKind;
use vm_resource::kind::ScsiDeviceHandleKind;
use vm_resource::Resource;
/// The location of an IDE device on a controller.
#[derive(Debug, Default, Copy, Clone, Eq, PartialEq, Hash, MeshPayload, Inspect)]
#[inspect(display)]
pub struct IdePath {
/// The channel number. Must be zero or one.
pub channel: u8,
/// The device number on the channel. Must be zero or one.
pub drive: u8,
}
impl std::fmt::Display for IdePath {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}/{}", self.channel, self.drive)
}
}
/// Guest media for an IDE device.
#[derive(Debug, MeshPayload)]
pub enum GuestMedia {
/// An ATAPI drive, backed by a SCSI device.
Dvd(Resource<ScsiDeviceHandleKind>),
/// An ATA disk, backed by a simple disk.
Disk {
/// The backing disk.
disk_type: Resource<DiskHandleKind>,
/// Whether the disk is read-only.
read_only: bool,
/// The disk parameters, used for the vmbus SCSI interface.
disk_parameters: Option<scsidisk_resources::DiskParameters>,
},
}
/// IDE device configuration.
#[derive(Debug, MeshPayload)]
pub struct IdeDeviceConfig {
/// The location of the device on the controller.
pub path: IdePath,
/// The backing media for the device.
pub guest_media: GuestMedia,
}
/// IDE controller configuration.
#[derive(Debug, MeshPayload)]
pub struct IdeControllerConfig {
/// Disks on the primary channel.
pub primary_channel_disks: Vec<IdeDeviceConfig>,
/// Disks on the secondary channel.
pub secondary_channel_disks: Vec<IdeDeviceConfig>,
/// The maximum queue depth for the vmbus SCSI interface.
pub io_queue_depth: Option<u32>,
}