mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-19 01:39:48 +00:00
runtime-rs: Add devno to DeviceVirtioBlk
A new attribute named `devno` is added to DeviceVirtioBlk. It will be used to specify a device number for a CCW bus type. Signed-off-by: Hyounggyu Choi <Hyounggyu.Choi@ibm.com>
This commit is contained in:
parent
30a64092a7
commit
516daecc50
@ -917,15 +917,17 @@ struct DeviceVirtioBlk {
|
|||||||
id: String,
|
id: String,
|
||||||
config_wce: bool,
|
config_wce: bool,
|
||||||
share_rw: bool,
|
share_rw: bool,
|
||||||
|
devno: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DeviceVirtioBlk {
|
impl DeviceVirtioBlk {
|
||||||
fn new(id: &str, bus_type: VirtioBusType) -> DeviceVirtioBlk {
|
fn new(id: &str, bus_type: VirtioBusType, devno: Option<String>) -> DeviceVirtioBlk {
|
||||||
DeviceVirtioBlk {
|
DeviceVirtioBlk {
|
||||||
bus_type,
|
bus_type,
|
||||||
id: id.to_owned(),
|
id: id.to_owned(),
|
||||||
config_wce: false,
|
config_wce: false,
|
||||||
share_rw: true,
|
share_rw: true,
|
||||||
|
devno,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -959,7 +961,9 @@ impl ToQemuParams for DeviceVirtioBlk {
|
|||||||
params.push("share-rw=off".to_owned());
|
params.push("share-rw=off".to_owned());
|
||||||
}
|
}
|
||||||
params.push(format!("serial=image-{}", self.id));
|
params.push(format!("serial=image-{}", self.id));
|
||||||
|
if let Some(devno) = &self.devno {
|
||||||
|
params.push(format!("devno={}", devno));
|
||||||
|
}
|
||||||
Ok(vec!["-device".to_owned(), params.join(",")])
|
Ok(vec!["-device".to_owned(), params.join(",")])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1897,9 +1901,23 @@ impl<'a> QemuCmdLine<'a> {
|
|||||||
pub fn add_block_device(&mut self, device_id: &str, path: &str) -> Result<()> {
|
pub fn add_block_device(&mut self, device_id: &str, path: &str) -> Result<()> {
|
||||||
self.devices
|
self.devices
|
||||||
.push(Box::new(BlockBackend::new(device_id, path)));
|
.push(Box::new(BlockBackend::new(device_id, path)));
|
||||||
|
let devno = match &mut self.ccw_subchannel {
|
||||||
|
Some(subchannel) => match subchannel.add_device(device_id) {
|
||||||
|
Ok(slot) => {
|
||||||
|
let addr = subchannel.address_format_ccw(slot);
|
||||||
|
Some(addr)
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
info!(sl!(), "failed to add device to subchannel: {:?}", err);
|
||||||
|
None
|
||||||
|
}
|
||||||
|
},
|
||||||
|
None => None,
|
||||||
|
};
|
||||||
self.devices.push(Box::new(DeviceVirtioBlk::new(
|
self.devices.push(Box::new(DeviceVirtioBlk::new(
|
||||||
device_id,
|
device_id,
|
||||||
bus_type(self.config),
|
bus_type(self.config),
|
||||||
|
devno,
|
||||||
)));
|
)));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user