vmm: trim qualified paths

Import the modules used in the crate instead of spelling the full paths
at every use site, and drop the now-unnecessary crate-level

Signed-off-by: Henry Hrvoje Tonkovac <htonkovac@gmail.com>
Assisted-by: Claude:Opus-4.8
This commit is contained in:
Henry Hrvoje Tonkovac
2026-06-22 14:43:08 +02:00
committed by Sebastien Boeuf
parent 0caa3ee73f
commit 025e782e50
27 changed files with 484 additions and 483 deletions

View File

@@ -35,11 +35,13 @@
//! [special HTTP library]: https://github.com/firecracker-microvm/micro-http
use std::fs::File;
use std::result;
use std::sync::mpsc::Sender;
use micro_http::{Body, Method, Request, Response, StatusCode, Version};
use vmm_sys_util::eventfd::EventFd;
use crate::api;
#[cfg(all(target_arch = "x86_64", feature = "guest_debug"))]
use crate::api::VmCoredump;
use crate::api::http::http_endpoint::fds_helper::{attach_fds_to_cfg, attach_fds_to_cfgs};
@@ -327,7 +329,7 @@ impl EndpointHandler for VmCreate {
}
}
match crate::api::VmCreate
match api::VmCreate
.send(api_notifier, api_sender, vm_config)
.map_err(HttpError::ApiError)
{
@@ -350,7 +352,7 @@ pub trait GetHandler {
&'static self,
_api_notifier: EventFd,
_api_sender: Sender<ApiRequest>,
) -> std::result::Result<Option<Body>, HttpError> {
) -> result::Result<Option<Body>, HttpError> {
Err(HttpError::BadRequest)
}
}
@@ -362,7 +364,7 @@ pub trait PutHandler {
_api_sender: Sender<ApiRequest>,
_body: &Option<Body>,
_files: Vec<File>,
) -> std::result::Result<Option<Body>, HttpError> {
) -> result::Result<Option<Body>, HttpError> {
Err(HttpError::BadRequest)
}
}
@@ -503,7 +505,7 @@ impl PutHandler for VmAddNet {
api_sender: Sender<ApiRequest>,
body: &Option<Body>,
files: Vec<File>,
) -> std::result::Result<Option<Body>, HttpError> {
) -> result::Result<Option<Body>, HttpError> {
if let Some(body) = body {
let mut net_cfg: NetConfig = serde_json::from_slice(body.raw())?;
attach_fds_to_cfg(files, &mut net_cfg)?;
@@ -525,7 +527,7 @@ impl PutHandler for VmResize {
api_sender: Sender<ApiRequest>,
body: &Option<Body>,
_files: Vec<File>,
) -> std::result::Result<Option<Body>, HttpError> {
) -> result::Result<Option<Body>, HttpError> {
if let Some(body) = body {
self.send(
api_notifier,
@@ -555,7 +557,7 @@ impl PutHandler for VmRestore {
api_sender: Sender<ApiRequest>,
body: &Option<Body>,
files: Vec<File>,
) -> std::result::Result<Option<Body>, HttpError> {
) -> result::Result<Option<Body>, HttpError> {
if let Some(body) = body {
let mut restore_cfg: RestoreConfig = serde_json::from_slice(body.raw())?;
@@ -593,7 +595,7 @@ impl EndpointHandler for VmActionHandler {
api_sender: Sender<ApiRequest>,
body: &Option<Body>,
files: Vec<File>,
) -> std::result::Result<Option<Body>, HttpError> {
) -> result::Result<Option<Body>, HttpError> {
PutHandler::handle_request(self.action, api_notifier, api_sender, body, files)
}
@@ -602,7 +604,7 @@ impl EndpointHandler for VmActionHandler {
api_notifier: EventFd,
api_sender: Sender<ApiRequest>,
_body: &Option<Body>,
) -> std::result::Result<Option<Body>, HttpError> {
) -> result::Result<Option<Body>, HttpError> {
GetHandler::handle_request(self.action, api_notifier, api_sender)
}
}
@@ -618,7 +620,7 @@ impl EndpointHandler for VmInfo {
api_sender: Sender<ApiRequest>,
) -> Response {
match req.method() {
Method::Get => match crate::api::VmInfo
Method::Get => match api::VmInfo
.send(api_notifier, api_sender, ())
.map_err(HttpError::ApiError)
{
@@ -647,7 +649,7 @@ impl EndpointHandler for VmmPing {
api_sender: Sender<ApiRequest>,
) -> Response {
match req.method() {
Method::Get => match crate::api::VmmPing
Method::Get => match api::VmmPing
.send(api_notifier, api_sender, ())
.map_err(HttpError::ApiError)
{
@@ -678,7 +680,7 @@ impl EndpointHandler for VmmShutdown {
) -> Response {
match req.method() {
Method::Put => {
match crate::api::VmmShutdown
match api::VmmShutdown
.send(api_notifier, api_sender, ())
.map_err(HttpError::ApiError)
{

View File

@@ -12,7 +12,7 @@ use std::panic::AssertUnwindSafe;
use std::path::{Path, PathBuf};
use std::sync::LazyLock;
use std::sync::mpsc::Sender;
use std::thread;
use std::{fs, iter, panic, result, thread};
use block::fcntl::{LockError, LockGranularity, LockType, try_acquire_lock};
use log::{error, info};
@@ -104,7 +104,7 @@ pub fn error_response(error: HttpError) -> Response {
let error: &dyn Error = &error;
// Write the Display::display() output all errors (from top to root).
let error_messages = std::iter::successors(Some(error), |sub_error| {
let error_messages = iter::successors(Some(error), |sub_error| {
// Dereference necessary to mitigate rustc compiler bug.
// See <https://github.com/rust-lang/rust/issues/141673>
(*sub_error).source()
@@ -167,7 +167,7 @@ pub trait EndpointHandler {
_api_sender: Sender<ApiRequest>,
_body: &Option<Body>,
_files: Vec<File>,
) -> std::result::Result<Option<Body>, HttpError> {
) -> result::Result<Option<Body>, HttpError> {
Err(HttpError::BadRequest)
}
@@ -176,7 +176,7 @@ pub trait EndpointHandler {
_api_notifier: EventFd,
_api_sender: Sender<ApiRequest>,
_body: &Option<Body>,
) -> std::result::Result<Option<Body>, HttpError> {
) -> result::Result<Option<Body>, HttpError> {
Err(HttpError::BadRequest)
}
}
@@ -385,7 +385,7 @@ fn start_http_thread(
})?;
}
std::panic::catch_unwind(AssertUnwindSafe(move || {
panic::catch_unwind(AssertUnwindSafe(move || {
server.start_server().unwrap();
loop {
match server.requests() {
@@ -456,7 +456,7 @@ pub fn start_http_path_thread(
let lock = acquire_api_socket_lock(&socket_path)?;
// We hold the lock, so any socket at this path is stale from a crashed
// run: remove it before bind. Ignore errors (it is usually not present).
let _ = std::fs::remove_file(&socket_path);
let _ = fs::remove_file(&socket_path);
let socket_fd = UnixListener::bind(socket_path).map_err(VmmError::CreateApiServerSocket)?;
// SAFETY: Valid FD just opened