-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
albatross_daemon: discover root policy and insert this
Previously, there was no such thing. Now, to be able to avoid overcommitment, we discover the available cpus, memory, block device size, and bridges at startup. This results in some changed semantics: - if a bridge used by some policy is not configured, we bail early - if the policies lead to overcommitment, we bail early We discover the root policy at startup each time (and also compare to the previous one), since we want to discover the data of the current system. It may be different from the previous one (network bridges, available memory, ...).
- Loading branch information
Showing
5 changed files
with
94 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// (c) 2017, 2018 Hannes Mehnert, all rights reserved | ||
|
||
#include <caml/mlvalues.h> | ||
#include <caml/alloc.h> | ||
#include <caml/memory.h> | ||
#include <caml/fail.h> | ||
#include <caml/unixsupport.h> | ||
|
||
#include <unistd.h> | ||
|
||
CAMLprim value vmm_cpu_count (value unit) { | ||
CAMLparam1(unit); | ||
int r; | ||
r = (int)sysconf(_SC_NPROCESSORS_CONF); | ||
CAMLreturn(Val_int(r)); | ||
} | ||
|
||
CAMLprim value vmm_memory (value unit) { | ||
CAMLparam1(unit); | ||
long pages = sysconf(_SC_PHYS_PAGES); | ||
long page_size = sysconf(_SC_PAGE_SIZE); | ||
CAMLreturn(Val_int(pages * (page_size / 1024) / 1024)); | ||
} | ||
|
||
#include <sys/param.h> | ||
#include <sys/mount.h> | ||
|
||
CAMLprim value vmm_disk_space (value path) { | ||
CAMLparam1(path); | ||
struct statfs s; | ||
const char *p = String_val(path); | ||
if (statfs(p, &s) < 0) | ||
uerror("statfs", Nothing); | ||
CAMLreturn(Val_int(s.f_blocks * s.f_bsize / 1024 / 1024)); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters