Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vmm: fix clippy warning #142

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion vmm/common/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn main() {
.rust_protobuf()
.customize(Customize {
async_all: true,
..Default::default()
..Customize::default()
})
.rust_protobuf_customize(ProtobufCustomize::default().gen_mod_rs(false))
.run()
Expand Down
7 changes: 6 additions & 1 deletion vmm/sandbox/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
use std::process::exit;

fn main() {
built::write_built_file().expect("Failed to acquire build-time information");
if let Err(e) = built::write_built_file() {
eprint!("Failed to acquire build-time information: {:?}", e);
exit(-1)
}
}
4 changes: 2 additions & 2 deletions vmm/sandbox/src/cgroup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ use std::error::Error;

use anyhow::{anyhow, Ok, Result};
use cgroups_rs::{
cgroup_builder::*, cpu::CpuController, cpuset::CpuSetController, hugetlb::HugeTlbController,
memory::MemController, Cgroup,
cgroup_builder::CgroupBuilder, cpu::CpuController, cpuset::CpuSetController,
hugetlb::HugeTlbController, memory::MemController, Cgroup,
};
use containerd_sandbox::{cri::api::v1::LinuxContainerResources, data::SandboxData};
use serde::{Deserialize, Serialize};
Expand Down
5 changes: 4 additions & 1 deletion vmm/sandbox/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ use tokio::{
time::timeout,
};
use ttrpc::{context::with_timeout, r#async::Client};
use vmm_common::api::{sandbox::*, sandbox_ttrpc::SandboxServiceClient};
use vmm_common::api::{
sandbox::{CheckRequest, SyncClockPacket, UpdateInterfacesRequest, UpdateRoutesRequest},
sandbox_ttrpc::SandboxServiceClient,
};

use crate::network::{NetworkInterface, Route};

Expand Down
6 changes: 3 additions & 3 deletions vmm/sandbox/src/cloud_hypervisor/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ impl Default for CloudHypervisorVMConfig {
fn default() -> Self {
Self {
path: "/usr/local/bin/cloud-hypervisor".to_string(),
common: Default::default(),
common: HypervisorCommonConfig::default(),
hugepages: false,
entropy_source: "/dev/urandom".to_string(),
task: Default::default(),
virtiofsd: Default::default(),
task: TaskConfig::default(),
virtiofsd: VirtiofsdConfig::default(),
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions vmm/sandbox/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ impl Default for Bus {
fn default() -> Bus {
Bus {
r#type: BusType::PCI,
id: Default::default(),
bus_addr: Default::default(),
slots: Default::default(),
id: String::default(),
bus_addr: String::default(),
slots: Vec::default(),
}
}
}
Expand Down
1 change: 1 addition & 0 deletions vmm/sandbox/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#![warn(clippy::expect_fun_call, clippy::expect_used)]

#[macro_use]
mod device;
Expand Down
6 changes: 3 additions & 3 deletions vmm/sandbox/src/network/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

use protobuf::EnumOrUnknown;
use protobuf::{EnumOrUnknown, SpecialFields};
use vmm_common::api::sandbox::{IPAddress, IPFamily, Interface, Route};

use crate::network::{IpNet, NetworkInterface};
Expand All @@ -34,7 +34,7 @@ impl From<&NetworkInterface> for Interface {
hwAddr: interface.mac_address.to_string(),
raw_flags: interface.flags,
type_: "".to_string(),
special_fields: Default::default(),
special_fields: SpecialFields::default(),
}
}
}
Expand All @@ -49,7 +49,7 @@ impl From<&IpNet> for IPAddress {
}),
address: ip.addr_string(),
mask: ip.prefix_len.to_string(),
special_fields: Default::default(),
special_fields: SpecialFields::default(),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion vmm/sandbox/src/network/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ impl NetworkInterface {
let mut intf = NetworkInterface {
flags: msg.header.flags,
index: msg.header.index,
..Default::default()
..NetworkInterface::default()
};
for nla in msg.nlas.into_iter() {
use netlink_packet_route::nlas::link::Nla;
Expand Down
2 changes: 1 addition & 1 deletion vmm/sandbox/src/network/route.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl Route {
}
let mut route = Route {
scope: msg.header.scope as u32,
..Default::default()
..Route::default()
};
use netlink_packet_route::nlas::route::Nla;
for nla in msg.nlas.into_iter() {
Expand Down
2 changes: 1 addition & 1 deletion vmm/sandbox/src/qemu/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ pub struct QemuVMConfig {
impl Default for QemuVMConfig {
fn default() -> Self {
Self {
common: Default::default(),
common: HypervisorCommonConfig::default(),
machine_accelerators: "".to_string(),
firmware_path: "".to_string(),
cpu_features: "".to_string(),
Expand Down
2 changes: 1 addition & 1 deletion vmm/sandbox/src/qemu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ impl QemuVM {
agent_socket: "".to_string(),
netns: netns.to_string(),
pids: Pids::default(),
block_driver: Default::default(),
block_driver: BlockDriver::default(),
wait_chan: None,
client: None,
}
Expand Down
2 changes: 0 additions & 2 deletions vmm/scripts/image/build_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

set -e

[ -n "${DEBUG}" ] && set -x

DOCKER_RUNTIME=${DOCKER_RUNTIME:-runc}

readonly script_name="${0##*/}"
Expand Down
2 changes: 0 additions & 2 deletions vmm/scripts/image/centos/build_rootfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

set -e

[ -n "${DEBUG}" ] && set -x

golang_version="1.20.5"
cert_file_path="/kuasar/proxy.crt"
ARCH=$(uname -m)
Expand Down
64 changes: 64 additions & 0 deletions vmm/task/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vmm/task/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ rtnetlink = "0.12"
netlink-packet-route = "0.15"
netlink-packet-core = "0.5.0"
ipnetwork = "0.20"
anyhow = { version = "1.0.66", default-features = false, features = ["std", "backtrace"] }

# Async dependencies
async-trait = { version = "0.1.51"}
Expand Down
14 changes: 9 additions & 5 deletions vmm/task/src/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ impl ProcessLifecycle<InitProcess> for KuasarInitLifecycle {
.iter()
.map(|&x| ProcessInfo {
pid: x as u32,
..Default::default()
..ProcessInfo::default()
})
.collect())
}
Expand Down Expand Up @@ -679,9 +679,13 @@ mod tests {
let test_dir = "/tmp/kuasar-test_runtime_error_with_logfile";
let _ = mkdir(test_dir, 0o711).await;
let test_log_file = Path::new(test_dir).join("log.json");
write_str_to_file(test_log_file.as_path(), log_json)
.await
.expect("write log json should not be error");

assert!(
write_str_to_file(test_log_file.as_path(), log_json)
.await
.is_ok(),
"write log json should not be error"
);

let expected_msg = "panic";
let actual_err = runtime_error(
Expand All @@ -690,7 +694,7 @@ mod tests {
"test_runtime_error_with_logfile failed",
)
.await;
remove_dir_all(test_dir).await.expect("remove test dir");
assert!(remove_dir_all(test_dir).await.is_ok(), "remove test dir");
assert!(
actual_err.to_string().contains(expected_msg),
"actual error \"{}\" should contains \"{}\"",
Expand Down
Loading
Loading