diff --git a/src/runtime-rs/crates/hypervisor/src/device/vfio.rs b/src/runtime-rs/crates/hypervisor/src/device/vfio.rs index db1a99fb3f..5e62d4549c 100644 --- a/src/runtime-rs/crates/hypervisor/src/device/vfio.rs +++ b/src/runtime-rs/crates/hypervisor/src/device/vfio.rs @@ -11,7 +11,7 @@ use anyhow::{anyhow, Context, Result}; fn override_driver(bdf: &str, driver: &str) -> Result<()> { let driver_override = format!("/sys/bus/pci/devices/{}/driver_override", bdf); fs::write(&driver_override, driver) - .context(format!("echo {} > {}", driver, &driver_override))?; + .with_context(|| format!("echo {} > {}", driver, &driver_override))?; info!(sl!(), "echo {} > {}", driver, driver_override); Ok(()) } @@ -138,7 +138,7 @@ pub fn bind_device_to_host(bdf: &str, host_driver: &str, _vendor_device_id: &str // echo bdf > /sys/bus/pci/drivers_probe std::fs::write(PCI_DRIVER_PROBE, bdf) - .context(format!("echo {} > {}", bdf, PCI_DRIVER_PROBE))?; + .with_context(|| format!("echo {} > {}", bdf, PCI_DRIVER_PROBE))?; info!(sl!(), "echo {} > {}", bdf, PCI_DRIVER_PROBE); Ok(()) diff --git a/src/runtime-rs/crates/resource/src/network/endpoint/physical_endpoint.rs b/src/runtime-rs/crates/resource/src/network/endpoint/physical_endpoint.rs index 78387a5ce4..ffdfb5848b 100644 --- a/src/runtime-rs/crates/resource/src/network/endpoint/physical_endpoint.rs +++ b/src/runtime-rs/crates/resource/src/network/endpoint/physical_endpoint.rs @@ -65,11 +65,11 @@ impl PhysicalEndpoint { // get vendor and device id from pci space (sys/bus/pci/devices/$bdf) let iface_device_path = sys_pci_devices_path.join(&bdf).join("device"); let device_id = std::fs::read_to_string(&iface_device_path) - .context(format!("read device path {:?}", &iface_device_path))?; + .with_context(|| format!("read device path {:?}", &iface_device_path))?; let iface_vendor_path = sys_pci_devices_path.join(&bdf).join("vendor"); let vendor_id = std::fs::read_to_string(&iface_vendor_path) - .context(format!("read vendor path {:?}", &iface_vendor_path))?; + .with_context(|| format!("read vendor path {:?}", &iface_vendor_path))?; Ok(Self { iface_name: name.to_string(), @@ -99,10 +99,7 @@ impl Endpoint for PhysicalEndpoint { &self.driver, &self.vendor_device_id.vendor_device_id(), ) - .context(format!( - "bind physical endpoint from {} to vfio", - &self.driver - ))?; + .with_context(|| format!("bind physical endpoint from {} to vfio", &self.driver))?; // set vfio's bus type, pci or mmio. Mostly use pci by default. let mode = match self.driver.as_str() { @@ -116,7 +113,7 @@ impl Endpoint for PhysicalEndpoint { sysfs_path: "".to_string(), bus_slot_func: self.bdf.clone(), mode: device::VfioBusMode::new(mode) - .context(format!("new vfio bus mode {:?}", mode))?, + .with_context(|| format!("new vfio bus mode {:?}", mode))?, }); hypervisor.add_device(d).await.context("add device")?; Ok(()) @@ -136,10 +133,12 @@ impl Endpoint for PhysicalEndpoint { &self.driver, &self.vendor_device_id.vendor_device_id(), ) - .context(format!( - "bind physical endpoint device from vfio to {}", - &self.driver - ))?; + .with_context(|| { + format!( + "bind physical endpoint device from vfio to {}", + &self.driver + ) + })?; Ok(()) } } diff --git a/src/runtime-rs/crates/resource/src/network/network_model/route_model.rs b/src/runtime-rs/crates/resource/src/network/network_model/route_model.rs index 64b1da2e74..5955af0ff4 100644 --- a/src/runtime-rs/crates/resource/src/network/network_model/route_model.rs +++ b/src/runtime-rs/crates/resource/src/network/network_model/route_model.rs @@ -56,7 +56,7 @@ impl NetworkModel for RouteModel { .args(&ca) .output() .await - .context(format!("run command ip args {:?}", &ca))?; + .with_context(|| format!("run command ip args {:?}", &ca))?; if !output.status.success() { return Err(anyhow!( "run command ip args {:?} error {}", 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 1377a78594..a2a29dc971 100644 --- a/src/runtime-rs/crates/resource/src/network/utils/netns.rs +++ b/src/runtime-rs/crates/resource/src/network/utils/netns.rs @@ -19,11 +19,11 @@ impl NetnsGuard { let old_netns = if !new_netns_path.is_empty() { let current_netns_path = format!("/proc/{}/task/{}/ns/{}", getpid(), gettid(), "net"); let old_netns = File::open(¤t_netns_path) - .context(format!("open current netns path {}", ¤t_netns_path))?; + .with_context(|| format!("open current netns path {}", ¤t_netns_path))?; let new_netns = File::open(&new_netns_path) - .context(format!("open new netns path {}", &new_netns_path))?; + .with_context(|| format!("open new netns path {}", &new_netns_path))?; setns(new_netns.as_raw_fd(), CloneFlags::CLONE_NEWNET) - .context("set netns to new netns")?; + .with_context(|| "set netns to new netns")?; info!( sl!(), "set netns from old {:?} to new {:?} tid {}", 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 3a4b0c7439..bd90d6bd9b 100644 --- a/src/runtime-rs/crates/resource/src/share_fs/utils.rs +++ b/src/runtime-rs/crates/resource/src/share_fs/utils.rs @@ -30,7 +30,7 @@ pub(crate) fn share_to_guest( ) -> Result { let host_dest = do_get_host_path(target, sid, cid, is_volume, false); mount::bind_mount_unchecked(source, &host_dest, readonly) - .context(format!("failed to bind mount {} to {}", source, &host_dest))?; + .with_context(|| format!("failed to bind mount {} to {}", source, &host_dest))?; // bind mount remount event is not propagated to mount subtrees, so we have // to remount the read only dir mount point directly. diff --git a/src/runtime-rs/crates/resource/src/volume/mod.rs b/src/runtime-rs/crates/resource/src/volume/mod.rs index 2ad12f1196..53c737c79c 100644 --- a/src/runtime-rs/crates/resource/src/volume/mod.rs +++ b/src/runtime-rs/crates/resource/src/volume/mod.rs @@ -49,18 +49,18 @@ impl VolumeResource { let shm_size = shm_volume::DEFAULT_SHM_SIZE; Arc::new( shm_volume::ShmVolume::new(m, shm_size) - .context(format!("new shm volume {:?}", m))?, + .with_context(|| format!("new shm volume {:?}", m))?, ) } else if share_fs_volume::is_share_fs_volume(m) { Arc::new( share_fs_volume::ShareFsVolume::new(share_fs, m, cid) .await - .context(format!("new share fs volume {:?}", m))?, + .with_context(|| format!("new share fs volume {:?}", m))?, ) } else if block_volume::is_block_volume(m) { Arc::new( block_volume::BlockVolume::new(m) - .context(format!("new block volume {:?}", m))?, + .with_context(|| format!("new block volume {:?}", m))?, ) } else if is_skip_volume(m) { info!(sl!(), "skip volume {:?}", m); @@ -68,7 +68,7 @@ impl VolumeResource { } else { Arc::new( default_volume::DefaultVolume::new(m) - .context(format!("new default volume {:?}", m))?, + .with_context(|| format!("new default volume {:?}", m))?, ) }; diff --git a/versions.yaml b/versions.yaml index 34723fd857..07f1bcce57 100644 --- a/versions.yaml +++ b/versions.yaml @@ -282,6 +282,16 @@ languages: building Kata newest-version: "1.58.1" + golangci-lint: + description: "golangci-lint" + notes: "'version' is the default minimum version used by this project." + version: "1.41.1" + meta: + description: | + 'newest-version' is the latest version known to work when + building Kata + newest-version: "1.46.2" + specs: description: "Details of important specifications"