mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: simplify seccomp code
Only Thread::Vmm and Thread::Vcpu need to know the hypervisor type. Make the type optional, and then simplify the users. Assisted-by: Pi-agent:Claude-Opus-4.7 Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
@@ -9,7 +9,6 @@ use std::thread;
|
||||
|
||||
use futures::channel::oneshot;
|
||||
use futures::{FutureExt, executor};
|
||||
use hypervisor::HypervisorType;
|
||||
use log::{error, warn};
|
||||
use seccompiler::{SeccompAction, apply_filter};
|
||||
use vmm_sys_util::eventfd::EventFd;
|
||||
@@ -326,7 +325,6 @@ pub fn start_dbus_thread(
|
||||
api_sender: Sender<ApiRequest>,
|
||||
seccomp_action: &SeccompAction,
|
||||
exit_evt: EventFd,
|
||||
hypervisor_type: HypervisorType,
|
||||
) -> VmmResult<(thread::JoinHandle<VmmResult<()>>, DBusApiShutdownChannels)> {
|
||||
let dbus_iface = DBusApi::new(api_notifier, api_sender);
|
||||
let (connection, iface_ref) = executor::block_on(async move {
|
||||
@@ -356,7 +354,7 @@ pub fn start_dbus_thread(
|
||||
let (send_done, recv_done) = oneshot::channel::<()>();
|
||||
|
||||
// Retrieve seccomp filter for API thread
|
||||
let api_seccomp_filter = get_seccomp_filter(seccomp_action, Thread::DBusApi, hypervisor_type)
|
||||
let api_seccomp_filter = get_seccomp_filter(seccomp_action, Thread::DBusApi, None)
|
||||
.map_err(VmmError::CreateSeccompFilter)?;
|
||||
|
||||
let thread_join_handle = thread::Builder::new()
|
||||
|
||||
@@ -14,7 +14,6 @@ use std::sync::LazyLock;
|
||||
use std::sync::mpsc::Sender;
|
||||
use std::thread;
|
||||
|
||||
use hypervisor::HypervisorType;
|
||||
use log::{error, info};
|
||||
use micro_http::{
|
||||
Body, HttpServer, MediaType, Method, Request, Response, ServerError, StatusCode, Version,
|
||||
@@ -328,11 +327,10 @@ fn start_http_thread(
|
||||
api_sender: Sender<ApiRequest>,
|
||||
seccomp_action: &SeccompAction,
|
||||
exit_evt: EventFd,
|
||||
hypervisor_type: HypervisorType,
|
||||
landlock_enable: bool,
|
||||
) -> Result<HttpApiHandle> {
|
||||
// Retrieve seccomp filter for API thread
|
||||
let api_seccomp_filter = get_seccomp_filter(seccomp_action, Thread::HttpApi, hypervisor_type)
|
||||
let api_seccomp_filter = get_seccomp_filter(seccomp_action, Thread::HttpApi, None)
|
||||
.map_err(VmmError::CreateSeccompFilter)?;
|
||||
|
||||
let api_shutdown_fd = EventFd::new(libc::EFD_NONBLOCK).map_err(VmmError::EventFdCreate)?;
|
||||
@@ -410,7 +408,6 @@ pub fn start_http_path_thread(
|
||||
api_sender: Sender<ApiRequest>,
|
||||
seccomp_action: &SeccompAction,
|
||||
exit_evt: EventFd,
|
||||
hypervisor_type: HypervisorType,
|
||||
landlock_enable: bool,
|
||||
) -> Result<HttpApiHandle> {
|
||||
let socket_path = PathBuf::from(path);
|
||||
@@ -425,7 +422,6 @@ pub fn start_http_path_thread(
|
||||
api_sender,
|
||||
seccomp_action,
|
||||
exit_evt,
|
||||
hypervisor_type,
|
||||
landlock_enable,
|
||||
)
|
||||
}
|
||||
@@ -436,7 +432,6 @@ pub fn start_http_fd_thread(
|
||||
api_sender: Sender<ApiRequest>,
|
||||
seccomp_action: &SeccompAction,
|
||||
exit_evt: EventFd,
|
||||
hypervisor_type: HypervisorType,
|
||||
landlock_enable: bool,
|
||||
) -> Result<HttpApiHandle> {
|
||||
// SAFETY: Valid FD
|
||||
@@ -447,7 +442,6 @@ pub fn start_http_fd_thread(
|
||||
api_sender,
|
||||
seccomp_action,
|
||||
exit_evt,
|
||||
hypervisor_type,
|
||||
landlock_enable,
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user