Add a seatbelt for the amount of memory on the host machine available for VM guests
Bhyve doesn't deal well with zfs ARC and all its variable, it is necessary to add some seat belts or otherwise guest machines can crash or be in malfunction.
Seat belt for vm memory. (#445)
- feat(middlewared/vm): Add get_memory_in_use() that returns the amount of memory used by all running guests. Add get_provisioned_memory() that returns the memory necessary to be provisioned in next boot.
- feat(middlewared/vm): Rename memory to virtual memory, just to be more clear.
- feat(middlewared/vm): Simplify how to get memory in use and provisioned memory.
- feat(middlewared/vm): feat(middlewared/vm): Seat belt on guests that has been given more virtual resources than are physically available. Also it is necessary resize ZFS arc_max to avoid ZFS uses all memory and make guests using swap that can lead a guest to crash.
We keep at least 35% of memory from initial arc_max value, every time we start a guest, we check if we have enough memory on usermem and also if it is possible to shrink arc_max subtracting the amount of memory requested by the guest; if we have enough resources, the guest is initialized and the method start() will return True, otherwise it will return False.
When we stop a guest, we give back that amount of memory to arc_max.
- feat(middleared/vm): Do not get the arc_max so earlier, also fix the comparison of resize_arc and ZFS_ARC_MAX.
- feat(middlewared/vm): Make the ARC resize calculation be bit more precise.
- feat(middlewared/vm): Show the vm ID on error output.
- feat(middlewared/vm): It must be less or equal.
- feat(middlewared/vm): Move teardown_guest_vmemory under VMSupervisor class, now it gives memory back to arc_max in case VM crash, same applies when 'halt' or 'shutdown' is performed inside the guest.
#2 Updated by Dru Lavigne over 1 year ago
- Subject changed from Seat belt for the amount of memory on the host machine available for guests. to Add a seatbelt for the amount of memory on the host machine available for VM guests
- Status changed from Ready For Release to Done
- Needs Merging changed from Yes to No
#4 Updated by Dru Lavigne over 1 year ago
- Severity set to New
- Needs Doc changed from Yes to No