diff --git a/tools/hermit_proxy/src/hermit/qemu.rs b/tools/hermit_proxy/src/hermit/qemu.rs index 1be6511be..59d0ec9fc 100644 --- a/tools/hermit_proxy/src/hermit/qemu.rs +++ b/tools/hermit_proxy/src/hermit/qemu.rs @@ -101,10 +101,9 @@ impl QEmu { } if hermit_env::verbose() != "0" { - println!("{:#?}", args); + debug!("Execute {} with args {:#?}", hermit_env::qemu_binary(), args); } - debug!("Execute {} with args {:#?}", hermit_env::qemu_binary(), args); let mut cmd = Command::new(hermit_env::qemu_binary()); diff --git a/tools/hermit_proxy/src/main.rs b/tools/hermit_proxy/src/main.rs index b5495ae48..28e6bd4a0 100644 --- a/tools/hermit_proxy/src/main.rs +++ b/tools/hermit_proxy/src/main.rs @@ -23,7 +23,8 @@ extern crate nix; mod hermit; use nix::sys::signal; -use std::{env, process}; +use std::env; + use hermit::error; extern fn exit(_:i32) { @@ -31,8 +32,6 @@ extern fn exit(_:i32) { } fn main() { - env_logger::init().unwrap(); - // register a signal let sig_action = signal::SigAction::new(signal::SigHandler::Handler(exit), signal::SaFlags::empty(), signal::SigSet::empty()); unsafe { @@ -40,21 +39,62 @@ fn main() { signal::sigaction(signal::SIGTERM, &sig_action).unwrap(); } -/* let matches = clap_app!(proxy => + let matches = clap_app!(HermitProxy => (version: "0.0.1") (author: "Lorenz Schmidt ") (about: "Allows you to start and manage HermitCore isles") - (@arg debug: -d ... "Sets the level of debugging information") + (@subcommand run => + (about: "Executes an HermitCore application") + (@arg file: +required "The binary to be executed") + (@arg isle: --isle +takes_value "Choose the hypervisor [uhyve/qemu/multi]") + (@arg debug: -d --debug "Enables debugging information") + (@arg cpus: --num_cpus +takes_value "Sets the number of cpus") + (@arg mem_size: --mem_size +takes_value "Sets the memory size") + (@arg qemu_binary: --qemu_binary +takes_value "Overrides the default qemu binary") + (@arg port: --port +takes_value "Overrides the default port [qemu only]") + (@arg app_port: --app_port +takes_value "Overrides the default app port [qemu only]") + ) ).get_matches(); -*/ // create the isle, wait to be available and start it - env::args().skip(1).next().ok_or(error::Error::MissingBinary) - .and_then(|path| hermit::new_isle(&path)) - .and_then(|mut isle| { - isle.wait_until_available()?; - isle.run()?; + if let Some(matches) = matches.subcommand_matches("run") { + if let Some(isle) = matches.value_of("isle") { + env::set_var("HERMIT_ISLE", isle); + } - Ok(()) - }).unwrap(); + if matches.is_present("debug") { + env::set_var("RUST_LOG", "trace"); + env::set_var("HERMIT_VERBOSE", "1"); + } + + if let Some(num_cpus) = matches.value_of("cpus") { + env::set_var("HERMIT_CPUS",num_cpus); + } + + if let Some(mem_size) = matches.value_of("mem_size") { + env::set_var("HERMIT_MEM", mem_size); + } + + if let Some(qemu_binary) = matches.value_of("qemu_binary") { + env::set_var("HERMIT_QEMU", qemu_binary); + } + + if let Some(port) = matches.value_of("port") { + env::set_var("HERMIT_PORT",port); + } + + if let Some(app_port) = matches.value_of("app_port") { + env::set_var("HERMIT_APP_PORT",app_port); + } + + env_logger::init().unwrap(); + + hermit::new_isle(&matches.value_of("file").unwrap()) + .and_then(|mut isle| { + isle.wait_until_available()?; + isle.run()?; + + Ok(()) + }).unwrap(); + } }