Skip to content

Commit 9a232c4

Browse files
committed
Fix errors
1 parent f83a23d commit 9a232c4

File tree

6 files changed

+13
-19
lines changed

6 files changed

+13
-19
lines changed

src/daemon.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,6 @@ pub async fn daemon_start(
510510
pub async fn start_feos(
511511
ipv6_address: Ipv6Addr,
512512
prefix_length: u8,
513-
test_mode: bool,
514513
) -> Result<(), String> {
515514
println!(
516515
"

src/isolated_container/mod.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use crate::{network, vm};
77
use hyper_util::rt::TokioIo;
88
use isolated_container_service::isolated_container_service_server::IsolatedContainerService;
99
use log::info;
10-
use std::io::Write;
1110
use std::sync::Arc;
1211
use std::{collections::HashMap, sync::Mutex};
1312
use std::{fmt::Debug, io, path::PathBuf, time};
@@ -72,7 +71,7 @@ fn handle_error(e: vm::Error) -> tonic::Status {
7271
async fn get_channel(path: String) -> Result<Channel, Error> {
7372
async fn get_channel(path: String) -> Result<Channel, Error> {
7473
let channel = Endpoint::try_from("http://[::]:50051")
75-
.map_err(|e| Error::Failed)?
74+
.map_err(|_| Error::Failed)?
7675
.connect_with_connector(service_fn(move |_: Uri| {
7776
let path = path.clone();
7877
async move {
@@ -108,7 +107,7 @@ async fn get_channel(path: String) -> Result<Channel, Error> {
108107
}
109108
}))
110109
.await
111-
.map_err(|e| Error::Failed)?;
110+
.map_err(|_| Error::Failed)?;
112111
Ok(channel)
113112
}
114113

@@ -223,7 +222,7 @@ impl IsolatedContainerService for IsolatedContainerAPI {
223222
let request = tonic::Request::new(RunContainerRequest {
224223
uuid: container_id.to_string(),
225224
});
226-
let response = client.run_container(request).await?;
225+
client.run_container(request).await?;
227226

228227
Ok(Response::new(
229228
isolated_container_service::RunContainerResponse {},
@@ -261,8 +260,6 @@ impl IsolatedContainerService for IsolatedContainerAPI {
261260
) -> Result<Response<isolated_container_service::StateContainerResponse>, Status> {
262261
info!("Got state_container request");
263262

264-
let container_id: String = request.get_ref().uuid.clone();
265-
266263
let vm_id: String = request.get_ref().uuid.clone();
267264
let vm_id = Uuid::parse_str(&vm_id)
268265
.map_err(|_| Status::invalid_argument("failed to parse uuid"))?;

src/main.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ async fn main() -> Result<(), String> {
2929
(ipv6_address, prefix_length) = parse_command_line()?;
3030
}
3131

32-
let test_mode = env::var("RUN_MODE").map_or(false, |v| v == "test");
33-
34-
start_feos(ipv6_address, prefix_length, test_mode).await?;
32+
start_feos(ipv6_address, prefix_length).await?;
3533
Err("FeOS exited".to_string())
3634
}
3735

src/network/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ use tokio::task::JoinHandle;
99
use uuid::Uuid;
1010

1111
pub mod dhcpv6;
12-
mod network;
12+
mod utils;
1313

1414
use crate::network::dhcpv6::{
1515
add_ipv6_route, add_to_ipv6, adjust_base_ip, run_dhcpv6_server, IpRange,
1616
};
1717
use crate::radv::start_radv_server;
18-
pub use network::configure_network_devices;
19-
pub use network::configure_sriov;
18+
pub use utils::configure_network_devices;
19+
pub use utils::configure_sriov;
2020

2121
#[derive(Debug)]
2222
pub enum Error {

src/vm/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub enum NetworkMode {
5959

6060
#[derive(Debug)]
6161
struct VmInfo {
62-
pub child: Child,
62+
child: Child,
6363
}
6464

6565
#[derive(Debug)]
@@ -369,10 +369,6 @@ impl Manager {
369369

370370
pub fn kill_vm(&self, id: Uuid) -> Result<String, Error> {
371371
let mut vms = self.vms.lock().unwrap();
372-
let vm_info = match vms.get_mut(&id) {
373-
Some(info) => info,
374-
None => return Err(Error::NotFound),
375-
};
376372

377373
let mut socket = UnixStream::connect(id.to_string()).map_err(Error::SocketFailure)?;
378374
let response = api_client::simple_api_full_command_and_response(
@@ -399,7 +395,11 @@ impl Manager {
399395
info!("shutdown vmm: id {}, response: {}", id, x);
400396
}
401397

402-
vms.remove(&id);
398+
if let Some(mut info) = vms.remove(&id) {
399+
if let Err(e) = info.child.kill() {
400+
info!("failed to kill vm process {}: {}", id, e);
401+
}
402+
}
403403

404404
Ok(String::new())
405405
}

0 commit comments

Comments
 (0)