mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-10-22 12:29:49 +00:00
Merge pull request #8672 from BbolroC/introduce-vsock-device-init
runtime-rs: Separate init_config() from new() for struct VsockDevice
This commit is contained in:
@@ -330,9 +330,11 @@ impl DeviceManager {
|
||||
// No need to do find device for hybrid vsock device.
|
||||
Arc::new(Mutex::new(HybridVsockDevice::new(&device_id, hvconfig)))
|
||||
}
|
||||
DeviceConfig::VsockCfg(_vconfig) => {
|
||||
DeviceConfig::VsockCfg(vconfig) => {
|
||||
// No need to do find device for vsock device.
|
||||
Arc::new(Mutex::new(VsockDevice::new(device_id.clone()).await?))
|
||||
Arc::new(Mutex::new(
|
||||
VsockDevice::new(device_id.clone(), vconfig).await?,
|
||||
))
|
||||
}
|
||||
DeviceConfig::ShareFsCfg(config) => {
|
||||
// Try to find the sharefs device. If found, just return matched device id.
|
||||
|
@@ -117,16 +117,20 @@ nix::ioctl_write_ptr!(
|
||||
const CID_RETRY_COUNT: u32 = 50;
|
||||
|
||||
impl VsockDevice {
|
||||
pub async fn new(id: String) -> Result<Self> {
|
||||
let (guest_cid, _vhost_fd) = generate_vhost_vsock_cid()
|
||||
.await
|
||||
.context("generate vhost vsock cid failed")?;
|
||||
|
||||
pub async fn new(id: String, config: &VsockConfig) -> Result<Self> {
|
||||
Ok(Self {
|
||||
id,
|
||||
config: VsockConfig { guest_cid },
|
||||
config: config.clone(),
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn init_config(&mut self) -> Result<File> {
|
||||
let (guest_cid, vhost_fd) = generate_vhost_vsock_cid()
|
||||
.await
|
||||
.context("generate vhost vsock cid failed")?;
|
||||
self.config.guest_cid = guest_cid;
|
||||
Ok(vhost_fd)
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
|
Reference in New Issue
Block a user