From 27b19135847d1641488edc0e00818c7f3b97c85c Mon Sep 17 00:00:00 2001 From: Pavel Mores Date: Wed, 2 Nov 2022 15:01:25 +0100 Subject: [PATCH] runtime-rs: blanks filled & fixes made to virtiofsd launch The 'config' argument to ShareVirtioFsStandalone::new() is now actually used, taking care of an explicit TODO. If a shared path doesn't exist in ShareVirtioFsStandalone::virtiofsd_args() it is now created instead of returning an error, thus following ShareVirtioFsInline's suit. The '-o vhost_user_socket=...' command line argument doesn't seem to be supported by newer versions of virtiofsd so we replace it with '--socket-path' which should be functionally equivalent according to docs. Fixes #5572 Signed-off-by: Pavel Mores --- .../share_fs/share_virtio_fs_standalone.rs | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/runtime-rs/crates/resource/src/share_fs/share_virtio_fs_standalone.rs b/src/runtime-rs/crates/resource/src/share_fs/share_virtio_fs_standalone.rs index b0c9149735..a9ef41ee72 100644 --- a/src/runtime-rs/crates/resource/src/share_fs/share_virtio_fs_standalone.rs +++ b/src/runtime-rs/crates/resource/src/share_fs/share_virtio_fs_standalone.rs @@ -21,7 +21,7 @@ use tokio::{ }; use super::{ - share_virtio_fs::generate_sock_path, utils::get_host_ro_shared_path, + share_virtio_fs::generate_sock_path, utils::ensure_dir_exist, utils::get_host_ro_shared_path, virtio_fs_share_mount::VirtiofsShareMount, ShareFs, ShareFsMount, }; @@ -49,16 +49,15 @@ pub(crate) struct ShareVirtioFsStandalone { } impl ShareVirtioFsStandalone { - pub(crate) fn new(id: &str, _config: &SharedFsInfo) -> Result { + pub(crate) fn new(id: &str, config: &SharedFsInfo) -> Result { Ok(Self { inner: Arc::new(RwLock::new(ShareVirtioFsStandaloneInner::default())), - // TODO: update with config config: ShareVirtioFsStandaloneConfig { id: id.to_string(), jail_root: "".to_string(), - virtio_fs_daemon: "".to_string(), - virtio_fs_cache: "".to_string(), - virtio_fs_extra_args: vec![], + virtio_fs_daemon: config.virtio_fs_daemon.clone(), + virtio_fs_cache: config.virtio_fs_cache.clone(), + virtio_fs_extra_args: config.virtio_fs_extra_args.clone(), }, share_fs_mount: Arc::new(VirtiofsShareMount::new(id)), }) @@ -66,17 +65,11 @@ impl ShareVirtioFsStandalone { fn virtiofsd_args(&self, sock_path: &str) -> Result> { let source_path = get_host_ro_shared_path(&self.config.id); - if !source_path.exists() { - return Err(anyhow!( - "The virtiofs shared path({:?}) didn't exist", - source_path - )); - } + ensure_dir_exist(&source_path)?; let mut args: Vec = vec![ String::from("-f"), - String::from("-o"), - format!("vhost_user_socket={}", sock_path), + format!("--socket-path={}", sock_path), String::from("-o"), format!("source={}", source_path.to_str().unwrap()), String::from("-o"),