mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-20 00:48:04 +00:00
runtime-rs: remove vhost_fd from VsockConfig and make it cloneable.
Currently encounters difficulty in utilizing the clone operation on VsockConfig due to the implicit management of the vhost fd within the runtime-rs. This responsibility should be delegated to the VMM(especially QEMU) child process, as it's not runtime-rs core responsibilities. We'll remove the member vhost_fd from VsockConfig and make the VsockConfig/VsockDevice Cloneable. Fixes: #8474 Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
This commit is contained in:
parent
eb90962b27
commit
e31dbc94a5
@ -84,16 +84,13 @@ impl Device for HybridVsockDevice {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct VsockConfig {
|
pub struct VsockConfig {
|
||||||
/// A 32-bit Context Identifier (CID) used to identify the guest.
|
/// A 32-bit Context Identifier (CID) used to identify the guest.
|
||||||
pub guest_cid: u32,
|
pub guest_cid: u32,
|
||||||
|
|
||||||
/// Vhost vsock fd. Hold to ensure CID is not used by other VM.
|
|
||||||
pub vhost_fd: File,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct VsockDevice {
|
pub struct VsockDevice {
|
||||||
/// Unique identifier of the device
|
/// Unique identifier of the device
|
||||||
pub id: String,
|
pub id: String,
|
||||||
@ -121,16 +118,13 @@ const CID_RETRY_COUNT: u32 = 50;
|
|||||||
|
|
||||||
impl VsockDevice {
|
impl VsockDevice {
|
||||||
pub async fn new(id: String) -> Result<Self> {
|
pub async fn new(id: String) -> Result<Self> {
|
||||||
let (guest_cid, vhost_fd) = generate_vhost_vsock_cid()
|
let (guest_cid, _vhost_fd) = generate_vhost_vsock_cid()
|
||||||
.await
|
.await
|
||||||
.context("generate vhost vsock cid failed")?;
|
.context("generate vhost vsock cid failed")?;
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
id,
|
id,
|
||||||
config: VsockConfig {
|
config: VsockConfig { guest_cid },
|
||||||
guest_cid,
|
|
||||||
vhost_fd,
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user