mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vm-virtio: vsock: Expect an identifier upon device creation
This identifier is chosen from the DeviceManager so that it will manage all identifiers across the VM, which will ensure uniqueness. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
committed by
Rob Bradford
parent
9b53044aae
commit
ec5ff395cf
@@ -376,6 +376,7 @@ where
|
||||
|
||||
/// Virtio device exposing virtual socket to the guest.
|
||||
pub struct Vsock<B: VsockBackend> {
|
||||
id: String,
|
||||
cid: u64,
|
||||
backend: Arc<RwLock<B>>,
|
||||
kill_evt: Option<EventFd>,
|
||||
@@ -394,7 +395,7 @@ where
|
||||
{
|
||||
/// Create a new virtio-vsock device with the given VM CID and vsock
|
||||
/// backend.
|
||||
pub fn new(cid: u64, backend: B, iommu: bool) -> io::Result<Vsock<B>> {
|
||||
pub fn new(id: String, cid: u64, backend: B, iommu: bool) -> io::Result<Vsock<B>> {
|
||||
let mut avail_features = 1u64 << VIRTIO_F_VERSION_1 | 1u64 << VIRTIO_F_IN_ORDER;
|
||||
|
||||
if iommu {
|
||||
@@ -402,6 +403,7 @@ where
|
||||
}
|
||||
|
||||
Ok(Vsock {
|
||||
id,
|
||||
cid,
|
||||
backend: Arc::new(RwLock::new(backend)),
|
||||
kill_evt: None,
|
||||
@@ -574,7 +576,14 @@ where
|
||||
|
||||
virtio_pausable!(Vsock, T: 'static + VsockBackend + Sync);
|
||||
|
||||
impl<B> Snapshottable for Vsock<B> where B: VsockBackend + Sync + 'static {}
|
||||
impl<B> Snapshottable for Vsock<B>
|
||||
where
|
||||
B: VsockBackend + Sync + 'static,
|
||||
{
|
||||
fn id(&self) -> String {
|
||||
self.id.clone()
|
||||
}
|
||||
}
|
||||
impl<B> Transportable for Vsock<B> where B: VsockBackend + Sync + 'static {}
|
||||
impl<B> Migratable for Vsock<B> where B: VsockBackend + Sync + 'static {}
|
||||
|
||||
|
||||
@@ -265,7 +265,7 @@ mod tests {
|
||||
cid: CID,
|
||||
mem: GuestMemoryMmap::from_ranges(&[(GuestAddress(0), MEM_SIZE)]).unwrap(),
|
||||
mem_size: MEM_SIZE,
|
||||
device: Vsock::new(CID, TestBackend::new(), false).unwrap(),
|
||||
device: Vsock::new(String::from("vsock"), CID, TestBackend::new(), false).unwrap(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user