1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//! Partial port of `FreeBSDMachine.c` — the FreeBSD per-host `Machine`.
//!
//! Ported here (operate on the base [`Machine`], so no unported substrate
//! is needed):
//! - `Machine_isCPUonline` (`FreeBSDMachine.c:397`)
//! - `Machine_getCPUPhysicalCoreID` (`FreeBSDMachine.c:406`)
//! - `Machine_getCPUThreadIndex` (`FreeBSDMachine.c:412`)
//!
//! Still `todo!()` and blocked on unported substrate:
//! - the `FreeBSDMachine` struct plus `FreeBSDMachine_scanCPU` /
//! `_scanMemoryInfo` need the per-CPU / VM `sysctl` scan modeled and the
//! embedded `ZfsArcStats` / `kvm_t` handle.
//! - `Machine_scan` / `Machine_new` / `Machine_delete` additionally need
//! `Machine_init` / `Machine_done` (still stubs in `machine.rs`),
//! `kvm_open`/`kvm_close` and `openzfs_sysctl_*` FFI.
use crateMachine;
/// TODO: port of `Machine* Machine_new(UsersTable* usersTable, uid_t userId)`
/// from `FreeBSDMachine.c:53`. Blocked: needs `Machine_init` (stub in
/// `machine.rs`), the `FreeBSDMachine` struct, `kvm_open` and
/// `openzfs_sysctl_init` FFI.
/// TODO: port of `void Machine_delete(Machine* super)` from
/// `FreeBSDMachine.c:147`. Blocked: needs `Machine_done` (stub in
/// `machine.rs`), the `FreeBSDMachine` struct and `kvm_close` FFI.
/// TODO: port of `static void FreeBSDMachine_scanCPU(Machine* super)` from
/// `FreeBSDMachine.c:165`. Blocked: needs the `FreeBSDMachine` struct and the
/// per-CPU `kern.cp_times` sysctl scan.
/// TODO: port of `static void FreeBSDMachine_scanMemoryInfo(Machine* super)`
/// from `FreeBSDMachine.c:305`. Blocked: needs the `FreeBSDMachine` struct and
/// the `vm.stats` / `vfs.bufspace` sysctl scan.
/// TODO: port of `void Machine_scan(Machine* super)` from
/// `FreeBSDMachine.c:389`. Blocked: needs the `FreeBSDMachine` scan helpers
/// above and `openzfs_sysctl_updateArcStats` (`generic/openzfs_sysctl.c`,
/// unported).
/// Port of `bool Machine_isCPUonline(const Machine* host, unsigned int id)`
/// (`FreeBSDMachine.c:397`). FreeBSD does not yet support offline CPUs or hot
/// swapping, so every existing CPU reports online.
/// Port of `int Machine_getCPUPhysicalCoreID(const Machine* host, unsigned int
/// id)` (`FreeBSDMachine.c:406`).
/// Port of `int Machine_getCPUThreadIndex(const Machine* host, unsigned int
/// id)` (`FreeBSDMachine.c:412`).