Skip to content

Commit d499f85

Browse files
committed
enable alternative log, config and bin path
Signed-off-by: Tianhao Wang <[email protected]>
1 parent 91c4a64 commit d499f85

File tree

6 files changed

+44
-11
lines changed

6 files changed

+44
-11
lines changed

qvisor/Cargo.lock

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

qvisor/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ rcublas-sys = { version = "0.5.0", optional = true }
5858
cuda11-cublasLt-sys = { version = "0.3.0", optional = true }
5959
libelf = { version = "0.1.0", optional = true }
6060
io-uring = "0.6.3"
61+
const_format = "0.2.32"
6162

6263
[features]
6364
cuda = ["cuda-driver-sys", "cuda-runtime-sys", "libelf", "rcublas-sys", "cuda11-cublasLt-sys"]

qvisor/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ extern crate regex;
6161
extern crate simplelog;
6262
extern crate spin;
6363
extern crate tabwriter;
64+
#[macro_use]
65+
extern crate const_format;
6466

6567
#[macro_use]
6668
pub mod print;
@@ -169,8 +171,6 @@ lazy_static! {
169171
);
170172
}
171173

172-
pub const LOG_FILE: &'static str = "/var/log/quark/quark.log";
173-
174174
pub fn InitSingleton() {
175175
self::qlib::InitSingleton();
176176
}

qvisor/src/print.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,14 @@ pub fn SetSyncPrint(syncPrint: bool) {
4343
LOG.SetSyncPrint(syncPrint);
4444
}
4545

46-
pub const LOG_FILE_DEFAULT: &str = "/var/log/quark/quark.log";
47-
pub const RAWLOG_FILE_DEFAULT: &str = "/var/log/quark/raw.log";
48-
pub const LOG_FILE_FORMAT: &str = "/var/log/quark/{}.log";
46+
47+
pub const LOG_DIR: &str = match option_env!("QLOG_DIR") {
48+
Some(s) => s,
49+
None => "/var/log/quark"
50+
};
51+
pub const LOG_FILE_DEFAULT: &str = concatcp!(LOG_DIR, "/quark.log");
52+
pub const RAWLOG_FILE_DEFAULT: &str = concatcp!(LOG_DIR, "/raw.log");
53+
pub const LOG_FILE_FORMAT: &str = concatcp!(LOG_DIR, "/{}.log");
4954
pub const TIME_FORMAT: &str = "%H:%M:%S%.3f";
5055

5156
pub const MEMORY_LEAK_LOG: bool = false;

qvisor/src/runc/cmd/cmd.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ impl CmdCmd {
7676
}
7777

7878
impl Config {
79-
pub const CONFIG_FILE: &'static str = "/etc/quark/config.json";
79+
pub const CONFIG_DIR: &'static str = match option_env!("QCONFIG_DIR") {
80+
Some(s) => s,
81+
None => "/etc/quark"
82+
};
83+
pub const CONFIG_FILE: &'static str = concatcp!(Config::CONFIG_DIR, "/config.json");
8084

8185
// if the config file exist, load file and return true; otherwise return false
8286
pub fn Load(&mut self) -> bool {

qvisor/src/runc/runtime/vm.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,15 @@ impl VirtualMachine {
166166
);
167167
}
168168

169+
pub const QUARK_BIN_DIR: &'static str = match option_env!("QBIN_DIR") {
170+
Some(s) => s,
171+
None => "/usr/local/bin"
172+
};
173+
pub const VDSO_PATH: &'static str = concatcp!(VirtualMachine::QUARK_BIN_DIR, "/vdso.so");
169174
#[cfg(debug_assertions)]
170-
pub const KERNEL_IMAGE: &'static str = "/usr/local/bin/qkernel_d.bin";
171-
175+
pub const KERNEL_IMAGE: &'static str = concatcp!(VirtualMachine::QUARK_BIN_DIR, "/qkernel_d.bin");
172176
#[cfg(not(debug_assertions))]
173-
pub const KERNEL_IMAGE: &'static str = "/usr/local/bin/qkernel.bin";
174-
175-
pub const VDSO_PATH: &'static str = "/usr/local/bin/vdso.so";
177+
pub const KERNEL_IMAGE: &'static str = concatcp!(VirtualMachine::QUARK_BIN_DIR, "/qkernel.bin");
176178

177179
pub fn InitShareSpace(
178180
cpuCount: usize,

0 commit comments

Comments
 (0)