mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-08 21:06:48 +00:00
Make vsock device optional
This commit is contained in:
parent
be45f0ee72
commit
83a7937334
10
Makefile
10
Makefile
@ -68,6 +68,16 @@ ifeq ($(ENABLE_KVM), 1)
|
||||
CARGO_OSDK_ARGS += --qemu-args="--enable-kvm"
|
||||
endif
|
||||
|
||||
ifeq ($(VSOCK),1)
|
||||
ifeq ($(QEMU_MACHINE), microvm)
|
||||
CARGO_OSDK_ARGS += --qumu.args="-device vhost-vsock-pci,id=vhost-vsock-pci0,guest-cid=3"
|
||||
else ifeq ($(EMULATE_IOMMU), 1)
|
||||
CARGO_OSDK_ARGS += --qemu.args="-device vhost-vsock-pci,id=vhost-vsock-pci0,guest-cid=3,disable-legacy=on,disable-modern=off,iommu_platform=on,ats=on"
|
||||
else
|
||||
CARGO_OSDK_ARGS += --qemu.args="-device vhost-vsock-pci,id=vhost-vsock-pci0,guest-cid=3,disable-legacy=on,disable-modern=off"
|
||||
endif
|
||||
endif
|
||||
|
||||
# Pass make variables to all subdirectory makes
|
||||
export
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use alloc::{boxed::Box, sync::Arc, vec, vec::Vec};
|
||||
use core::{cmp::min, hint::spin_loop};
|
||||
|
||||
@ -14,30 +15,6 @@ use crate::device::socket::error::SocketError;
|
||||
|
||||
const PER_CONNECTION_BUFFER_CAPACITY: usize = 1024;
|
||||
|
||||
/// TODO: A higher level interface for VirtIO socket (vsock) devices.
|
||||
///
|
||||
/// This keeps track of multiple vsock connections.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
///
|
||||
/// let mut socket = VsockConnectionManager::new(SocketDevice);
|
||||
///
|
||||
/// // Start a thread to call `socket.poll()` and handle events.
|
||||
///
|
||||
/// let remote_address = VsockAddr { cid: 2, port: 4321 };
|
||||
/// let local_port = 1234;
|
||||
/// socket.connect(remote_address, local_port)?;
|
||||
///
|
||||
/// // Wait until `socket.poll()` returns an event indicating that the socket is connected.
|
||||
///
|
||||
/// socket.send(remote_address, local_port, "Hello world".as_bytes())?;
|
||||
///
|
||||
/// socket.shutdown(remote_address, local_port)?;
|
||||
/// # Ok(())
|
||||
/// # }
|
||||
/// ``
|
||||
pub struct VsockConnectionManager {
|
||||
driver: Arc<SpinLock<SocketDevice>>,
|
||||
connections: Vec<Connection>,
|
||||
|
Loading…
x
Reference in New Issue
Block a user