4. vmmls
• How
– Originally I tried to modify ls
– it was too rich, so finally I decided to write from scrach.
• What it does
– List the virtual machines
• no considerable difficulties here
– Show amount of available memory
• Oh my god...
4
5. Reporting available memory
• I wanted to show how much memory available.
• src/sys/amd64/vmm/vmm_mem.c has the avail
memory pool which manages memory regions
• vmm_mem_steal_memory()
– Add available memory on physical machine
to the memory pool
• vmm_mem_alloc(size_t size);
– Allocate memory to virtual machines
from the memory pool
• vmm_mem_free(vm_paddr_t start, size_t size);
– Return allocated memory
to the memory pool
5
6. Reporting available memory(cont.)
• BHyVe-sensei, I have a problem...
• The memory management is really minimum
• No one knows the amount of free memory!
• Calculated the amount of free memory
– Added new function in vmm_mem.c
– Calculates the sum of length of available memory
segments
6
8. Reporting available memory(cont.)
Host-Physical Memory
(not used by FreeBSD)
steal
vmm_mem_avail
allo ain
allo ain
allo ain
c
recl c
recl c
recl
Guest A
Guest B
Guest C
8
9. Reporting available memory(cont.)
• Added the function to estimate available memory
– vmm_mem.c (in vmm.ko)
• Added a new ioctl to allow access from userland
– VM_GET_FREEMEM
– vmm_dev.c … added a new ioctl implementation
– vmm_dev.h … added a new ioctl definition
• Added a new function to libvmmapi
– vmmapi.c … added a new function API to get available
memory amount
• Enhanced vmmls command by using the new API
9
11. Future work - 1
• Refactor the Ioctl() interface for
VM_GET_FREEMEM
– ioctl() access for vmm.ko is available only when one or
more VMs exist
– Ioctl(*, VM_GET_FREEMEM, ...) doesn t work
when no VMs exists!
• More fancy APIs
– sysctl
• Good for reporting integer value
• Is it possible to read-callback handler?
– ioctl using another special file ‒ such as /dev/bhyve
• sysctl can handle only one value
11
12. Future work - 2
• Review the fields shown by vmmls command
– Number of vCPUs
– Disk files the VM is opening
– Networks
– Time
• How much CPU time the VM consumed?
– Memory status
• I m sure what lowmem and highmem means...
– Event counters?
• Such as counter of VMEXIT...
• Another program, such as vmmstat should be more better
– etc etc
12