mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
block: Add support for user specified ID_SERIAL
Signed-off-by: Thomas Barrett <tbarrett@crusoeenergy.com>
This commit is contained in:
committed by
Rob Bradford
parent
49e342314d
commit
c4e8e653ac
@@ -820,6 +820,8 @@ components:
|
||||
format: int16
|
||||
id:
|
||||
type: string
|
||||
serial:
|
||||
type: string
|
||||
|
||||
NetConfig:
|
||||
type: object
|
||||
|
||||
@@ -779,7 +779,8 @@ impl DiskConfig {
|
||||
.add("ops_refill_time")
|
||||
.add("id")
|
||||
.add("_disable_io_uring")
|
||||
.add("pci_segment");
|
||||
.add("pci_segment")
|
||||
.add("serial");
|
||||
parser.parse(disk).map_err(Error::ParseDisk)?;
|
||||
|
||||
let path = parser.get("path").map(PathBuf::from);
|
||||
@@ -846,6 +847,7 @@ impl DiskConfig {
|
||||
.convert("ops_refill_time")
|
||||
.map_err(Error::ParseDisk)?
|
||||
.unwrap_or_default();
|
||||
let serial = parser.get("serial");
|
||||
let bw_tb_config = if bw_size != 0 && bw_refill_time != 0 {
|
||||
Some(TokenBucketConfig {
|
||||
size: bw_size,
|
||||
@@ -886,6 +888,7 @@ impl DiskConfig {
|
||||
id,
|
||||
disable_io_uring,
|
||||
pci_segment,
|
||||
serial,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -2462,7 +2465,14 @@ mod tests {
|
||||
..Default::default()
|
||||
}
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
DiskConfig::parse("path=/path/to_file,serial=test")?,
|
||||
DiskConfig {
|
||||
path: Some(PathBuf::from("/path/to_file")),
|
||||
serial: Some(String::from("test")),
|
||||
..Default::default()
|
||||
}
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -2315,6 +2315,7 @@ impl DeviceManager {
|
||||
self.force_iommu | disk_cfg.iommu,
|
||||
disk_cfg.num_queues,
|
||||
disk_cfg.queue_size,
|
||||
disk_cfg.serial.clone(),
|
||||
self.seccomp_action.clone(),
|
||||
disk_cfg.rate_limiter_config,
|
||||
self.exit_evt
|
||||
|
||||
@@ -220,6 +220,8 @@ pub struct DiskConfig {
|
||||
pub disable_io_uring: bool,
|
||||
#[serde(default)]
|
||||
pub pci_segment: u16,
|
||||
#[serde(default)]
|
||||
pub serial: Option<String>,
|
||||
}
|
||||
|
||||
pub const DEFAULT_DISK_NUM_QUEUES: usize = 1;
|
||||
@@ -249,6 +251,7 @@ impl Default for DiskConfig {
|
||||
disable_io_uring: false,
|
||||
rate_limiter_config: None,
|
||||
pci_segment: 0,
|
||||
serial: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user