main, vmm: seccomp: Use SeccompAction instead of SeccompLevel

This patch replaces the usage of 'SeccompLevel' with 'SeccompAction',
which is the first step to support the 'log' action over system
calls that are not on the allowed list of seccomp filters.

Signed-off-by: Bo Chen <chen.bo@intel.com>
This commit is contained in:
Bo Chen
2020-07-30 14:21:58 -07:00
committed by Sebastien Boeuf
parent bfc37bc8d3
commit b41884a406
4 changed files with 18 additions and 20 deletions

View File

@@ -12,7 +12,7 @@ extern crate clap;
use clap::{App, Arg, ArgGroup, ArgMatches};
use libc::EFD_NONBLOCK;
use log::LevelFilter;
use seccomp::SeccompLevel;
use seccomp::SeccompAction;
use std::sync::mpsc::channel;
use std::sync::{Arc, Mutex};
use std::{env, process};
@@ -288,18 +288,17 @@ fn start_vmm(cmd_arguments: ArgMatches) {
let api_evt = EventFd::new(EFD_NONBLOCK).expect("Cannot create API EventFd");
let http_sender = api_request_sender.clone();
let seccomp_level = if let Some(seccomp_value) = cmd_arguments.value_of("seccomp") {
let seccomp_action = if let Some(seccomp_value) = cmd_arguments.value_of("seccomp") {
match seccomp_value {
"true" => SeccompLevel::Advanced,
"false" => SeccompLevel::None,
"true" => SeccompAction::Trap,
"false" => SeccompAction::Allow,
_ => {
eprintln!("Invalid parameter {} for \"--seccomp\" flag", seccomp_value);
process::exit(1);
}
}
} else {
SeccompLevel::Advanced
SeccompAction::Trap
};
let hypervisor = hypervisor::new().unwrap();
let vmm_thread = match vmm::start_vmm_thread(
@@ -308,7 +307,7 @@ fn start_vmm(cmd_arguments: ArgMatches) {
api_evt.try_clone().unwrap(),
http_sender,
api_request_receiver,
&seccomp_level,
&seccomp_action,
hypervisor,
) {
Ok(t) => t,