mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-15 06:34:03 +00:00
runtime-rs: Add block_device_cache_direct config to ch and qemu
Add block_device_cache_direct config to ch and qemu in runtime-rs. Fixes: #10849 Signed-off-by: Hui Zhu <teawater@antgroup.com>
This commit is contained in:
parent
e4cbc6abce
commit
db04c7ec93
@ -315,7 +315,8 @@ impl CloudHypervisorInner {
|
||||
.ok_or("missing socket")
|
||||
.map_err(|e| anyhow!(e))?;
|
||||
|
||||
let disk_config = DiskConfig::try_from(device.config)?;
|
||||
let mut disk_config = DiskConfig::try_from(device.config.clone())?;
|
||||
disk_config.direct = self.config.blockdev_info.block_device_cache_direct;
|
||||
|
||||
let response = cloud_hypervisor_vm_blockdev_add(
|
||||
socket.try_clone().context("failed to clone socket")?,
|
||||
|
@ -852,13 +852,13 @@ struct BlockBackend {
|
||||
}
|
||||
|
||||
impl BlockBackend {
|
||||
fn new(id: &str, path: &str) -> BlockBackend {
|
||||
fn new(id: &str, path: &str, cache_direct: bool) -> BlockBackend {
|
||||
BlockBackend {
|
||||
driver: "file".to_owned(),
|
||||
id: id.to_owned(),
|
||||
path: path.to_owned(),
|
||||
aio: "threads".to_owned(),
|
||||
cache_direct: true,
|
||||
cache_direct,
|
||||
cache_no_flush: false,
|
||||
read_only: true,
|
||||
}
|
||||
@ -1959,9 +1959,9 @@ impl<'a> QemuCmdLine<'a> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
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, is_direct: bool) -> Result<()> {
|
||||
self.devices
|
||||
.push(Box::new(BlockBackend::new(device_id, path)));
|
||||
.push(Box::new(BlockBackend::new(device_id, path, is_direct)));
|
||||
let devno = get_devno_ccw(&mut self.ccw_subchannel, device_id);
|
||||
self.devices.push(Box::new(DeviceVirtioBlk::new(
|
||||
device_id,
|
||||
|
@ -109,6 +109,7 @@ impl QemuInner {
|
||||
"ccw" => cmdline.add_block_device(
|
||||
block_dev.device_id.as_str(),
|
||||
&block_dev.config.path_on_host,
|
||||
self.config.blockdev_info.block_device_cache_direct,
|
||||
)?,
|
||||
unsupported => {
|
||||
info!(sl!(), "unsupported block device driver: {}", unsupported)
|
||||
|
Loading…
Reference in New Issue
Block a user