Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions alioth-cli/src/vu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use alioth::mem::mapped::RamBus;
use alioth::virtio::dev::blk::BlkFileParam;
use alioth::virtio::dev::fs::shared_dir::SharedDirParam;
use alioth::virtio::dev::net::tap::NetTapParam;
use alioth::virtio::dev::vsock::UdsVsockParam;
use alioth::virtio::dev::{DevParam, Virtio, VirtioDevice};
use alioth::virtio::vu::backend::{VuBackend, VuEventfd, VuIrqSender};
use clap::{Args, Subcommand};
Expand Down Expand Up @@ -88,6 +89,8 @@ pub enum DevType {
Blk(DevArgs<BlkFileParam>),
/// VirtIO filesystem device backed by a shared host directory.
Fs(DevArgs<SharedDirParam>),
/// VirtIO vsock device backed by a Unix domain socket.
Vsock(DevArgs<UdsVsockParam>),
}

#[derive(Args, Debug, Clone)]
Expand Down Expand Up @@ -138,6 +141,7 @@ pub fn start(args: VuArgs) -> Result<(), Error> {
DevType::Net(args) => create_dev(format!("net-{index}"), args, memory.clone()),
DevType::Blk(args) => create_dev(format!("blk-{index}"), args, memory.clone()),
DevType::Fs(args) => create_dev(format!("fs-{index}"), args, memory.clone()),
DevType::Vsock(args) => create_dev(format!("vsock-{index}"), args, memory.clone()),
}?;
let (conn, _) = listener.accept().context(error::Accept)?;
let backend = VuBackend::new(conn, dev, memory).context(error::CreateVu)?;
Expand Down
3 changes: 3 additions & 0 deletions alioth/src/virtio/dev/vsock/uds_vsock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,9 @@ impl VirtioMio for UdsVsock {
log::error!("{}: failed to deregister socket: {err}", self.name);
}
}
if let Err(err) = registry.deregister(&mut SourceFd(&self.listener.as_raw_fd())) {
log::error!("{}: failed to deregister listener: {err}", self.name);
}
self.host_ports.clear();
self.next_port = 1024;
}
Expand Down
6 changes: 5 additions & 1 deletion alioth/src/vm/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use crate::{
};

#[cfg(target_os = "linux")]
#[derive(Debug, PartialEq, Eq, Deserialize, Help)]
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Help)]
pub struct VuSocket {
pub socket: Box<Path>,
}
Expand Down Expand Up @@ -88,6 +88,10 @@ pub enum VsockParam {
/// Vsock device mapped to a Unix domain socket.
#[serde(alias = "uds")]
Uds(UdsVsockParam),
#[cfg(target_os = "linux")]
/// Vsock device backed by a vhost-user process.
#[serde(alias = "vu")]
Vu(VuSocket),
}

#[derive(Debug, Default, PartialEq, Eq, Deserialize)]
Expand Down
8 changes: 8 additions & 0 deletions alioth/src/vm/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,14 @@ where
#[cfg(target_os = "linux")]
VsockParam::Vhost(p) => vm.add_virtio_dev("vhost-vsock", p),
VsockParam::Uds(p) => vm.add_virtio_dev("uds-vsock", p),
#[cfg(target_os = "linux")]
VsockParam::Vu(s) => {
let p = VuFrontendParam {
id: DeviceId::Socket,
socket: s.socket,
};
vm.add_virtio_dev("vu-vsock", p)
}
}?;
}

Expand Down