Skip to content

Commit

Permalink
virtme-ng-init: handle command line option nr_open
Browse files Browse the repository at this point in the history
Handle kernel boot option `nr_open`, used to set the maximum amount of
open files (/proc/sys/fs/nr_open) in the virtme-ng guest.

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
  • Loading branch information
Andrea Righi committed Feb 22, 2024
1 parent f75260d commit b4a404d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,15 @@ fn get_active_console() -> Option<String> {
}
}

fn configure_limits() {
if let Ok(nr_open) = env::var("nr_open") {
if let Ok(mut file) = OpenOptions::new().write(true).open("/proc/sys/fs/nr_open") {
file.write_all(nr_open.as_bytes())
.expect("Failed to write nr_open");
}
}
}

fn configure_hostname() {
if let Ok(hostname) = env::var("virtme_hostname") {
if let Err(err) = sethostname(hostname) {
Expand Down Expand Up @@ -966,6 +975,7 @@ fn main() {

// Basic system initialization (order is important here).
configure_environment();
configure_limits();
configure_hostname();
mount_kernel_filesystems();
mount_virtme_overlays();
Expand Down

0 comments on commit b4a404d

Please sign in to comment.