Skip to content

Commit

Permalink
Merge pull request kata-containers#10683 from justxuewei/nxw/remove-mut
Browse files Browse the repository at this point in the history
  • Loading branch information
justxuewei authored Dec 28, 2024
2 parents 2068801 + ecf98e4 commit 6400295
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/runtime-rs/crates/hypervisor/src/ch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl CloudHypervisor {
}
}

pub async fn set_hypervisor_config(&mut self, config: HypervisorConfig) {
pub async fn set_hypervisor_config(&self, config: HypervisorConfig) {
let mut inner = self.inner.write().await;
inner.set_hypervisor_config(config)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ mod tests {
.get(hypervisor_name)
.ok_or_else(|| anyhow!("failed to get hypervisor for {}", &hypervisor_name))?;

let mut hypervisor = Qemu::new();
let hypervisor = Qemu::new();
hypervisor
.set_hypervisor_config(hypervisor_config.clone())
.await;
Expand Down
4 changes: 2 additions & 2 deletions src/runtime-rs/crates/hypervisor/src/dragonball/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ impl Dragonball {
}
}

pub async fn set_hypervisor_config(&mut self, config: HypervisorConfig) {
pub async fn set_hypervisor_config(&self, config: HypervisorConfig) {
let mut inner = self.inner.write().await;
inner.set_hypervisor_config(config)
}

pub async fn set_passfd_listener_port(&mut self, port: u32) {
pub async fn set_passfd_listener_port(&self, port: u32) {
let mut inner = self.inner.write().await;
inner.set_passfd_listener_port(port)
}
Expand Down
2 changes: 1 addition & 1 deletion src/runtime-rs/crates/hypervisor/src/firecracker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl Firecracker {
}
}

pub async fn set_hypervisor_config(&mut self, config: HypervisorConfig) {
pub async fn set_hypervisor_config(&self, config: HypervisorConfig) {
let mut inner = self.inner.write().await;
inner.set_hypervisor_config(config)
}
Expand Down
2 changes: 1 addition & 1 deletion src/runtime-rs/crates/hypervisor/src/qemu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl Qemu {
}
}

pub async fn set_hypervisor_config(&mut self, config: HypervisorConfig) {
pub async fn set_hypervisor_config(&self, config: HypervisorConfig) {
let mut inner = self.inner.write().await;
inner.set_hypervisor_config(config)
}
Expand Down
2 changes: 1 addition & 1 deletion src/runtime-rs/crates/hypervisor/src/remote/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl Remote {
}
}

pub async fn set_hypervisor_config(&mut self, config: HypervisorConfig) {
pub async fn set_hypervisor_config(&self, config: HypervisorConfig) {
let mut inner = self.inner.write().await;
inner.set_hypervisor_config(config)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ mod tests {
.get(hypervisor_name)
.ok_or_else(|| anyhow!("failed to get hypervisor for {}", &hypervisor_name))?;

let mut hypervisor = Qemu::new();
let hypervisor = Qemu::new();
hypervisor
.set_hypervisor_config(hypervisor_config.clone())
.await;
Expand Down
12 changes: 5 additions & 7 deletions src/runtime-rs/crates/runtimes/virt_container/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ async fn new_hypervisor(toml_config: &TomlConfig) -> Result<Arc<dyn Hypervisor>>
match hypervisor_name.as_str() {
#[cfg(all(feature = "dragonball", not(target_arch = "s390x")))]
HYPERVISOR_DRAGONBALL => {
let mut hypervisor = Dragonball::new();
let hypervisor = Dragonball::new();
hypervisor
.set_hypervisor_config(hypervisor_config.clone())
.await;
Expand All @@ -170,32 +170,30 @@ async fn new_hypervisor(toml_config: &TomlConfig) -> Result<Arc<dyn Hypervisor>>
Ok(Arc::new(hypervisor))
}
HYPERVISOR_QEMU => {
let mut hypervisor = Qemu::new();
let hypervisor = Qemu::new();
hypervisor
.set_hypervisor_config(hypervisor_config.clone())
.await;
Ok(Arc::new(hypervisor))
}
#[cfg(not(target_arch = "s390x"))]
HYPERVISOR_FIRECRACKER => {
let mut hypervisor = Firecracker::new();
let hypervisor = Firecracker::new();
hypervisor
.set_hypervisor_config(hypervisor_config.clone())
.await;
Ok(Arc::new(hypervisor))
}
#[cfg(all(feature = "cloud-hypervisor", not(target_arch = "s390x")))]
HYPERVISOR_NAME_CH => {
let mut hypervisor = CloudHypervisor::new();

let hypervisor = CloudHypervisor::new();
hypervisor
.set_hypervisor_config(hypervisor_config.clone())
.await;

Ok(Arc::new(hypervisor))
}
HYPERVISOR_REMOTE => {
let mut hypervisor = Remote::new();
let hypervisor = Remote::new();
hypervisor
.set_hypervisor_config(hypervisor_config.clone())
.await;
Expand Down

0 comments on commit 6400295

Please sign in to comment.