Skip to content

Commit bb15407

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

File tree

6 files changed

+45
-14
lines changed

6 files changed

+45
-14
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: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
// You may obtain a copy of the License at
66
//
77
// http://www.apache.org/licenses/LICENSE-2.0
8-
//
9-
// Unless required by applicable law or agreed to in writing, software
10-
// distributed under the License is distributed on an "AS IS" BASIS,
8+
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,
119
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1210
// See the License for the specific language governing permissions and
1311
// limitations under the License.
@@ -61,6 +59,8 @@ extern crate regex;
6159
extern crate simplelog;
6260
extern crate spin;
6361
extern crate tabwriter;
62+
#[macro_use]
63+
extern crate const_format;
6464

6565
#[macro_use]
6666
pub mod print;
@@ -169,8 +169,6 @@ lazy_static! {
169169
);
170170
}
171171

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

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)