diff --git a/src/runtime-rs/Cargo.lock b/src/runtime-rs/Cargo.lock index 060f7a76f2..90129b4c5b 100644 --- a/src/runtime-rs/Cargo.lock +++ b/src/runtime-rs/Cargo.lock @@ -1223,6 +1223,7 @@ dependencies = [ "seccompiler", "serde", "serde_json", + "shim-interface", "slog", "slog-scope", "thiserror", @@ -1919,6 +1920,7 @@ dependencies = [ "safe-path", "serde", "serde_json", + "shim-interface", ] [[package]] @@ -2343,6 +2345,7 @@ dependencies = [ "logging", "oci", "persist", + "shim-interface", "slog", "slog-scope", "tokio", @@ -2474,6 +2477,7 @@ dependencies = [ "logging", "persist", "runtimes", + "shim-interface", "slog", "slog-scope", "tokio", @@ -2539,12 +2543,23 @@ dependencies = [ name = "shim-ctl" version = "0.1.0" dependencies = [ + "anyhow", "common", "logging", "runtimes", "tokio", ] +[[package]] +name = "shim-interface" +version = "0.1.0" +dependencies = [ + "anyhow", + "hyper", + "hyperlocal", + "tokio", +] + [[package]] name = "signal-hook-registry" version = "1.4.0" diff --git a/src/runtime-rs/crates/resource/src/network/utils/link/create.rs b/src/runtime-rs/crates/resource/src/network/utils/link/create.rs index 58b2016aa2..10c7c79427 100644 --- a/src/runtime-rs/crates/resource/src/network/utils/link/create.rs +++ b/src/runtime-rs/crates/resource/src/network/utils/link/create.rs @@ -119,7 +119,7 @@ pub fn create_link(name: &str, link_type: LinkType, queues: usize) -> Result<()> fn create_queue(name: &str, flags: libc::c_int) -> Result<(File, String)> { let path = Path::new(DEVICE_PATH); - let file = OpenOptions::new().read(true).write(true).open(&path)?; + let file = OpenOptions::new().read(true).write(true).open(path)?; let mut req = CreateLinkReq::from_name(name)?; unsafe { req.set_raw_flags(flags as libc::c_short); diff --git a/src/runtime-rs/crates/resource/src/network/utils/netns.rs b/src/runtime-rs/crates/resource/src/network/utils/netns.rs index c0d0306fef..07584c6419 100644 --- a/src/runtime-rs/crates/resource/src/network/utils/netns.rs +++ b/src/runtime-rs/crates/resource/src/network/utils/netns.rs @@ -20,7 +20,7 @@ impl NetnsGuard { let current_netns_path = format!("/proc/{}/task/{}/ns/{}", getpid(), gettid(), "net"); let old_netns = File::open(¤t_netns_path) .with_context(|| format!("open current netns path {}", ¤t_netns_path))?; - let new_netns = File::open(&new_netns_path) + let new_netns = File::open(new_netns_path) .with_context(|| format!("open new netns path {}", &new_netns_path))?; setns(new_netns.as_raw_fd(), CloneFlags::CLONE_NEWNET) .with_context(|| "set netns to new netns")?; diff --git a/src/runtime-rs/crates/resource/src/share_fs/utils.rs b/src/runtime-rs/crates/resource/src/share_fs/utils.rs index 115bdd1463..6288e860e0 100644 --- a/src/runtime-rs/crates/resource/src/share_fs/utils.rs +++ b/src/runtime-rs/crates/resource/src/share_fs/utils.rs @@ -38,7 +38,7 @@ pub(crate) fn share_to_guest( // to remount the read only dir mount point directly. if readonly { let dst = do_get_host_path(target, sid, cid, is_volume, true); - mount::bind_remount(&dst, readonly).context("bind remount readonly")?; + mount::bind_remount(dst, readonly).context("bind remount readonly")?; } Ok(do_get_guest_path(target, cid, is_volume, is_rafs)) diff --git a/src/runtime-rs/crates/resource/src/share_fs/virtio_fs_share_mount.rs b/src/runtime-rs/crates/resource/src/share_fs/virtio_fs_share_mount.rs index c1d999cfb0..22cbd65dd5 100644 --- a/src/runtime-rs/crates/resource/src/share_fs/virtio_fs_share_mount.rs +++ b/src/runtime-rs/crates/resource/src/share_fs/virtio_fs_share_mount.rs @@ -173,11 +173,11 @@ impl ShareFsMount for VirtiofsShareMount { async fn upgrade_to_rw(&self, file_name: &str) -> Result<()> { // Remount readonly directory with readwrite permission let host_dest = do_get_host_path(file_name, &self.id, "", true, true); - bind_remount(&host_dest, false) + bind_remount(host_dest, false) .context("remount readonly directory with readwrite permission")?; // Remount readwrite directory with readwrite permission let host_dest = do_get_host_path(file_name, &self.id, "", true, false); - bind_remount(&host_dest, false) + bind_remount(host_dest, false) .context("remount readwrite directory with readwrite permission")?; Ok(()) } @@ -185,18 +185,18 @@ impl ShareFsMount for VirtiofsShareMount { async fn downgrade_to_ro(&self, file_name: &str) -> Result<()> { // Remount readwrite directory with readonly permission let host_dest = do_get_host_path(file_name, &self.id, "", true, false); - bind_remount(&host_dest, true) + bind_remount(host_dest, true) .context("remount readwrite directory with readonly permission")?; // Remount readonly directory with readonly permission let host_dest = do_get_host_path(file_name, &self.id, "", true, true); - bind_remount(&host_dest, true) + bind_remount(host_dest, true) .context("remount readonly directory with readonly permission")?; Ok(()) } async fn umount(&self, file_name: &str) -> Result<()> { let host_dest = do_get_host_path(file_name, &self.id, "", true, true); - umount_timeout(&host_dest, 0).context("Umount readwrite host dest")?; + umount_timeout(host_dest, 0).context("Umount readwrite host dest")?; // Umount event will be propagated to ro directory Ok(()) } diff --git a/src/runtime-rs/crates/service/src/manager.rs b/src/runtime-rs/crates/service/src/manager.rs index a8ca80fa51..fe31c179b0 100644 --- a/src/runtime-rs/crates/service/src/manager.rs +++ b/src/runtime-rs/crates/service/src/manager.rs @@ -55,7 +55,7 @@ async fn send_event( .stdin(Stdio::piped()) .stdout(Stdio::piped()) .stderr(Stdio::piped()) - .args(&[ + .args([ "--address", &address, "publish", diff --git a/src/runtime-rs/crates/shim/src/shim_delete.rs b/src/runtime-rs/crates/shim/src/shim_delete.rs index 89d65b6101..e1053927f6 100644 --- a/src/runtime-rs/crates/shim/src/shim_delete.rs +++ b/src/runtime-rs/crates/shim/src/shim_delete.rs @@ -40,7 +40,7 @@ impl ShimExecutor { let trim_path = address.strip_prefix("unix://").context("trim path")?; let file_path = Path::new("/").join(trim_path); let file_path = file_path.as_path(); - if std::fs::metadata(&file_path).is_ok() { + if std::fs::metadata(file_path).is_ok() { info!(sl!(), "remote socket path: {:?}", &file_path); fs::remove_file(file_path).ok(); }